Compare commits
1 Commits
07cd760116
...
ef88b4b17a
Author | SHA1 | Date |
---|---|---|
|
ef88b4b17a |
3
go.mod
3
go.mod
|
@ -60,6 +60,7 @@ require (
|
|||
go.uber.org/automaxprocs v1.6.0 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
go.uber.org/zap v1.27.0 // indirect
|
||||
go.yaml.in/yaml/v2 v2.4.2 // indirect
|
||||
golang.org/x/net v0.40.0 // indirect
|
||||
golang.org/x/oauth2 v0.30.0 // indirect
|
||||
golang.org/x/sys v0.33.0 // indirect
|
||||
|
@ -76,7 +77,7 @@ require (
|
|||
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
|
||||
sigs.k8s.io/randfill v1.0.0 // indirect
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.7.0 // indirect
|
||||
sigs.k8s.io/yaml v1.4.0 // indirect
|
||||
sigs.k8s.io/yaml v1.5.0 // indirect
|
||||
)
|
||||
|
||||
replace k8s.io/api => k8s.io/api v0.33.0
|
||||
|
|
7
go.sum
7
go.sum
|
@ -137,6 +137,10 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
|||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
|
||||
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
|
||||
go.yaml.in/yaml/v2 v2.4.2 h1:DzmwEr2rDGHl7lsFgAHxmNz/1NlQ7xLIrlN2h5d1eGI=
|
||||
go.yaml.in/yaml/v2 v2.4.2/go.mod h1:081UH+NErpNdqlCXm3TtEran0rJZGxAYx9hb/ELlsPU=
|
||||
go.yaml.in/yaml/v3 v3.0.3 h1:bXOww4E/J3f66rav3pX3m8w6jDE4knZjGOw8b5Y6iNE=
|
||||
go.yaml.in/yaml/v3 v3.0.3/go.mod h1:tBHosrYAkRZjRAOREWbDnBXUf08JOwYq++0QNwQiWzI=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
|
@ -222,5 +226,6 @@ sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU=
|
|||
sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.7.0 h1:qPeWmscJcXP0snki5IYF79Z8xrl8ETFxgMd7wez1XkI=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.7.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps=
|
||||
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
|
||||
sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY=
|
||||
sigs.k8s.io/yaml v1.5.0 h1:M10b2U7aEUY6hRtU870n2VTPgR5RZiL/I6Lcc2F4NUQ=
|
||||
sigs.k8s.io/yaml v1.5.0/go.mod h1:wZs27Rbxoai4C0f8/9urLZtZtF3avA3gKvGyPdDqTO4=
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
language: go
|
||||
|
||||
go:
|
||||
- "1.4.x"
|
||||
- "1.5.x"
|
||||
- "1.6.x"
|
||||
- "1.7.x"
|
||||
- "1.8.x"
|
||||
- "1.9.x"
|
||||
- "1.10.x"
|
||||
- "1.11.x"
|
||||
- "1.12.x"
|
||||
- "1.13.x"
|
||||
- "1.14.x"
|
||||
- "tip"
|
||||
|
||||
go_import_path: gopkg.in/yaml.v2
|
|
@ -0,0 +1,131 @@
|
|||
# YAML support for the Go language
|
||||
|
||||
Introduction
|
||||
------------
|
||||
|
||||
The yaml package enables Go programs to comfortably encode and decode YAML
|
||||
values. It was developed within [Canonical](https://www.canonical.com) as
|
||||
part of the [juju](https://juju.ubuntu.com) project, and is based on a
|
||||
pure Go port of the well-known [libyaml](http://pyyaml.org/wiki/LibYAML)
|
||||
C library to parse and generate YAML data quickly and reliably.
|
||||
|
||||
Compatibility
|
||||
-------------
|
||||
|
||||
The yaml package supports most of YAML 1.1 and 1.2, including support for
|
||||
anchors, tags, map merging, etc. Multi-document unmarshalling is not yet
|
||||
implemented, and base-60 floats from YAML 1.1 are purposefully not
|
||||
supported since they're a poor design and are gone in YAML 1.2.
|
||||
|
||||
Installation and usage
|
||||
----------------------
|
||||
|
||||
The import path for the package is *go.yaml.in/yaml/v2*.
|
||||
|
||||
To install it, run:
|
||||
|
||||
go get go.yaml.in/yaml/v2
|
||||
|
||||
API documentation
|
||||
-----------------
|
||||
|
||||
See: <https://pkg.go.dev/go.yaml.in/yaml/v2>
|
||||
|
||||
API stability
|
||||
-------------
|
||||
|
||||
The package API for yaml v2 will remain stable as described in [gopkg.in](https://gopkg.in).
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
The yaml package is licensed under the Apache License 2.0. Please see the LICENSE file for details.
|
||||
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
```Go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"go.yaml.in/yaml/v2"
|
||||
)
|
||||
|
||||
var data = `
|
||||
a: Easy!
|
||||
b:
|
||||
c: 2
|
||||
d: [3, 4]
|
||||
`
|
||||
|
||||
// Note: struct fields must be public in order for unmarshal to
|
||||
// correctly populate the data.
|
||||
type T struct {
|
||||
A string
|
||||
B struct {
|
||||
RenamedC int `yaml:"c"`
|
||||
D []int `yaml:",flow"`
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
t := T{}
|
||||
|
||||
err := yaml.Unmarshal([]byte(data), &t)
|
||||
if err != nil {
|
||||
log.Fatalf("error: %v", err)
|
||||
}
|
||||
fmt.Printf("--- t:\n%v\n\n", t)
|
||||
|
||||
d, err := yaml.Marshal(&t)
|
||||
if err != nil {
|
||||
log.Fatalf("error: %v", err)
|
||||
}
|
||||
fmt.Printf("--- t dump:\n%s\n\n", string(d))
|
||||
|
||||
m := make(map[interface{}]interface{})
|
||||
|
||||
err = yaml.Unmarshal([]byte(data), &m)
|
||||
if err != nil {
|
||||
log.Fatalf("error: %v", err)
|
||||
}
|
||||
fmt.Printf("--- m:\n%v\n\n", m)
|
||||
|
||||
d, err = yaml.Marshal(&m)
|
||||
if err != nil {
|
||||
log.Fatalf("error: %v", err)
|
||||
}
|
||||
fmt.Printf("--- m dump:\n%s\n\n", string(d))
|
||||
}
|
||||
```
|
||||
|
||||
This example will generate the following output:
|
||||
|
||||
```
|
||||
--- t:
|
||||
{Easy! {2 [3 4]}}
|
||||
|
||||
--- t dump:
|
||||
a: Easy!
|
||||
b:
|
||||
c: 2
|
||||
d: [3, 4]
|
||||
|
||||
|
||||
--- m:
|
||||
map[a:Easy! b:map[c:2 d:[3 4]]]
|
||||
|
||||
--- m dump:
|
||||
a: Easy!
|
||||
b:
|
||||
c: 2
|
||||
d:
|
||||
- 3
|
||||
- 4
|
||||
```
|
||||
|
0
vendor/sigs.k8s.io/yaml/goyaml.v2/decode.go → vendor/go.yaml.in/yaml/v2/decode.go
generated
vendored
0
vendor/sigs.k8s.io/yaml/goyaml.v2/decode.go → vendor/go.yaml.in/yaml/v2/decode.go
generated
vendored
0
vendor/sigs.k8s.io/yaml/goyaml.v2/encode.go → vendor/go.yaml.in/yaml/v2/encode.go
generated
vendored
0
vendor/sigs.k8s.io/yaml/goyaml.v2/encode.go → vendor/go.yaml.in/yaml/v2/encode.go
generated
vendored
0
vendor/sigs.k8s.io/yaml/goyaml.v2/parserc.go → vendor/go.yaml.in/yaml/v2/parserc.go
generated
vendored
0
vendor/sigs.k8s.io/yaml/goyaml.v2/parserc.go → vendor/go.yaml.in/yaml/v2/parserc.go
generated
vendored
0
vendor/sigs.k8s.io/yaml/goyaml.v2/readerc.go → vendor/go.yaml.in/yaml/v2/readerc.go
generated
vendored
0
vendor/sigs.k8s.io/yaml/goyaml.v2/readerc.go → vendor/go.yaml.in/yaml/v2/readerc.go
generated
vendored
0
vendor/sigs.k8s.io/yaml/goyaml.v2/resolve.go → vendor/go.yaml.in/yaml/v2/resolve.go
generated
vendored
0
vendor/sigs.k8s.io/yaml/goyaml.v2/resolve.go → vendor/go.yaml.in/yaml/v2/resolve.go
generated
vendored
0
vendor/sigs.k8s.io/yaml/goyaml.v2/sorter.go → vendor/go.yaml.in/yaml/v2/sorter.go
generated
vendored
0
vendor/sigs.k8s.io/yaml/goyaml.v2/sorter.go → vendor/go.yaml.in/yaml/v2/sorter.go
generated
vendored
0
vendor/sigs.k8s.io/yaml/goyaml.v2/writerc.go → vendor/go.yaml.in/yaml/v2/writerc.go
generated
vendored
0
vendor/sigs.k8s.io/yaml/goyaml.v2/writerc.go → vendor/go.yaml.in/yaml/v2/writerc.go
generated
vendored
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
// Source code and other details for the project are available at GitHub:
|
||||
//
|
||||
// https://github.com/go-yaml/yaml
|
||||
// https://github.com/yaml/go-yaml
|
||||
//
|
||||
package yaml
|
||||
|
0
vendor/sigs.k8s.io/yaml/goyaml.v2/yamlh.go → vendor/go.yaml.in/yaml/v2/yamlh.go
generated
vendored
0
vendor/sigs.k8s.io/yaml/goyaml.v2/yamlh.go → vendor/go.yaml.in/yaml/v2/yamlh.go
generated
vendored
|
@ -192,6 +192,9 @@ go.uber.org/zap/internal/exit
|
|||
go.uber.org/zap/internal/pool
|
||||
go.uber.org/zap/internal/stacktrace
|
||||
go.uber.org/zap/zapcore
|
||||
# go.yaml.in/yaml/v2 v2.4.2
|
||||
## explicit; go 1.15
|
||||
go.yaml.in/yaml/v2
|
||||
# golang.org/x/net v0.40.0
|
||||
## explicit; go 1.23.0
|
||||
golang.org/x/net/http/httpguts
|
||||
|
@ -860,8 +863,8 @@ sigs.k8s.io/structured-merge-diff/v4/merge
|
|||
sigs.k8s.io/structured-merge-diff/v4/schema
|
||||
sigs.k8s.io/structured-merge-diff/v4/typed
|
||||
sigs.k8s.io/structured-merge-diff/v4/value
|
||||
# sigs.k8s.io/yaml v1.4.0
|
||||
## explicit; go 1.12
|
||||
# sigs.k8s.io/yaml v1.5.0
|
||||
## explicit; go 1.22
|
||||
sigs.k8s.io/yaml
|
||||
sigs.k8s.io/yaml/goyaml.v2
|
||||
# k8s.io/api => k8s.io/api v0.33.0
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
language: go
|
||||
arch: arm64
|
||||
dist: focal
|
||||
go: 1.15.x
|
||||
script:
|
||||
- diff -u <(echo -n) <(gofmt -d *.go)
|
||||
- diff -u <(echo -n) <(golint $(go list -e ./...) | grep -v YAMLToJSON)
|
||||
- GO111MODULE=on go vet .
|
||||
- GO111MODULE=on go test -v -race ./...
|
||||
- git diff --exit-code
|
||||
install:
|
||||
- GO111MODULE=off go get golang.org/x/lint/golint
|
|
@ -1,24 +0,0 @@
|
|||
# See the OWNERS docs at https://go.k8s.io/owners
|
||||
|
||||
approvers:
|
||||
- dims
|
||||
- jpbetz
|
||||
- smarterclayton
|
||||
- deads2k
|
||||
- sttts
|
||||
- liggitt
|
||||
- natasha41575
|
||||
- knverey
|
||||
reviewers:
|
||||
- dims
|
||||
- thockin
|
||||
- jpbetz
|
||||
- smarterclayton
|
||||
- deads2k
|
||||
- derekwaynecarr
|
||||
- mikedanese
|
||||
- liggitt
|
||||
- sttts
|
||||
- tallclair
|
||||
labels:
|
||||
- sig/api-machinery
|
|
@ -1,143 +1,71 @@
|
|||
# go-yaml fork
|
||||
# goyaml.v2
|
||||
|
||||
This package is a fork of the go-yaml library and is intended solely for consumption
|
||||
by kubernetes projects. In this fork, we plan to support only critical changes required for
|
||||
kubernetes, such as small bug fixes and regressions. Larger, general-purpose feature requests
|
||||
should be made in the upstream go-yaml library, and we will reject such changes in this fork
|
||||
unless we are pulling them from upstream.
|
||||
This package provides type and function aliases for the `go.yaml.in/yaml/v2` package (which is compatible with `gopkg.in/yaml.v2`).
|
||||
|
||||
This fork is based on v2.4.0: https://github.com/go-yaml/yaml/releases/tag/v2.4.0
|
||||
## Purpose
|
||||
|
||||
# YAML support for the Go language
|
||||
The purpose of this package is to:
|
||||
|
||||
Introduction
|
||||
------------
|
||||
1. Provide a transition path for users migrating from the sigs.k8s.io/yaml package to direct usage of go.yaml.in/yaml/v2
|
||||
2. Maintain compatibility with existing code while encouraging migration to the upstream package
|
||||
3. Reduce maintenance overhead by delegating to the upstream implementation
|
||||
|
||||
The yaml package enables Go programs to comfortably encode and decode YAML
|
||||
values. It was developed within [Canonical](https://www.canonical.com) as
|
||||
part of the [juju](https://juju.ubuntu.com) project, and is based on a
|
||||
pure Go port of the well-known [libyaml](http://pyyaml.org/wiki/LibYAML)
|
||||
C library to parse and generate YAML data quickly and reliably.
|
||||
## Usage
|
||||
|
||||
Compatibility
|
||||
-------------
|
||||
Instead of importing this package directly, you should migrate to using `go.yaml.in/yaml/v2` directly:
|
||||
|
||||
The yaml package supports most of YAML 1.1 and 1.2, including support for
|
||||
anchors, tags, map merging, etc. Multi-document unmarshalling is not yet
|
||||
implemented, and base-60 floats from YAML 1.1 are purposefully not
|
||||
supported since they're a poor design and are gone in YAML 1.2.
|
||||
```go
|
||||
// Old way
|
||||
import "sigs.k8s.io/yaml/goyaml.v2"
|
||||
|
||||
Installation and usage
|
||||
----------------------
|
||||
|
||||
The import path for the package is *gopkg.in/yaml.v2*.
|
||||
|
||||
To install it, run:
|
||||
|
||||
go get gopkg.in/yaml.v2
|
||||
|
||||
API documentation
|
||||
-----------------
|
||||
|
||||
If opened in a browser, the import path itself leads to the API documentation:
|
||||
|
||||
* [https://gopkg.in/yaml.v2](https://gopkg.in/yaml.v2)
|
||||
|
||||
API stability
|
||||
-------------
|
||||
|
||||
The package API for yaml v2 will remain stable as described in [gopkg.in](https://gopkg.in).
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
The yaml package is licensed under the Apache License 2.0. Please see the LICENSE file for details.
|
||||
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
```Go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
var data = `
|
||||
a: Easy!
|
||||
b:
|
||||
c: 2
|
||||
d: [3, 4]
|
||||
`
|
||||
|
||||
// Note: struct fields must be public in order for unmarshal to
|
||||
// correctly populate the data.
|
||||
type T struct {
|
||||
A string
|
||||
B struct {
|
||||
RenamedC int `yaml:"c"`
|
||||
D []int `yaml:",flow"`
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
t := T{}
|
||||
|
||||
err := yaml.Unmarshal([]byte(data), &t)
|
||||
if err != nil {
|
||||
log.Fatalf("error: %v", err)
|
||||
}
|
||||
fmt.Printf("--- t:\n%v\n\n", t)
|
||||
|
||||
d, err := yaml.Marshal(&t)
|
||||
if err != nil {
|
||||
log.Fatalf("error: %v", err)
|
||||
}
|
||||
fmt.Printf("--- t dump:\n%s\n\n", string(d))
|
||||
|
||||
m := make(map[interface{}]interface{})
|
||||
|
||||
err = yaml.Unmarshal([]byte(data), &m)
|
||||
if err != nil {
|
||||
log.Fatalf("error: %v", err)
|
||||
}
|
||||
fmt.Printf("--- m:\n%v\n\n", m)
|
||||
|
||||
d, err = yaml.Marshal(&m)
|
||||
if err != nil {
|
||||
log.Fatalf("error: %v", err)
|
||||
}
|
||||
fmt.Printf("--- m dump:\n%s\n\n", string(d))
|
||||
}
|
||||
// Recommended way
|
||||
import "go.yaml.in/yaml/v2"
|
||||
```
|
||||
|
||||
This example will generate the following output:
|
||||
## Available Types and Functions
|
||||
|
||||
```
|
||||
--- t:
|
||||
{Easy! {2 [3 4]}}
|
||||
All public types and functions from `go.yaml.in/yaml/v2` are available through this package:
|
||||
|
||||
--- t dump:
|
||||
a: Easy!
|
||||
b:
|
||||
c: 2
|
||||
d: [3, 4]
|
||||
### Types
|
||||
|
||||
- `MapSlice` - Encodes and decodes as a YAML map with preserved key order
|
||||
- `MapItem` - An item in a MapSlice
|
||||
- `Unmarshaler` - Interface for custom unmarshaling behavior
|
||||
- `Marshaler` - Interface for custom marshaling behavior
|
||||
- `IsZeroer` - Interface to check if an object is zero
|
||||
- `Decoder` - Reads and decodes YAML values from an input stream
|
||||
- `Encoder` - Writes YAML values to an output stream
|
||||
- `TypeError` - Error returned by Unmarshal for decoding issues
|
||||
|
||||
--- m:
|
||||
map[a:Easy! b:map[c:2 d:[3 4]]]
|
||||
### Functions
|
||||
|
||||
--- m dump:
|
||||
a: Easy!
|
||||
b:
|
||||
c: 2
|
||||
d:
|
||||
- 3
|
||||
- 4
|
||||
```
|
||||
- `Unmarshal` - Decodes YAML data into a Go value
|
||||
- `UnmarshalStrict` - Like Unmarshal but errors on unknown fields
|
||||
- `Marshal` - Serializes a Go value into YAML
|
||||
- `NewDecoder` - Creates a new Decoder
|
||||
- `NewEncoder` - Creates a new Encoder
|
||||
- `FutureLineWrap` - Controls line wrapping behavior
|
||||
|
||||
## Migration Guide
|
||||
|
||||
To migrate from this package to `go.yaml.in/yaml/v2`:
|
||||
|
||||
1. Update your import statements:
|
||||
```go
|
||||
// From
|
||||
import "sigs.k8s.io/yaml/goyaml.v2"
|
||||
|
||||
// To
|
||||
import "go.yaml.in/yaml/v2"
|
||||
```
|
||||
|
||||
2. No code changes should be necessary as the API is identical
|
||||
|
||||
3. Update your go.mod file to include the dependency:
|
||||
```
|
||||
require go.yaml.in/yaml/v2 v2.4.2
|
||||
```
|
||||
|
||||
## Deprecation Notice
|
||||
|
||||
All types and functions in this package are marked as deprecated. You should migrate to using `go.yaml.in/yaml/v2` directly.
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
Copyright 2025 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package yaml
|
||||
|
||||
import (
|
||||
gopkg_yaml "go.yaml.in/yaml/v2"
|
||||
)
|
||||
|
||||
// Type aliases for public types from go.yaml.in/yaml/v2
|
||||
type (
|
||||
// MapSlice encodes and decodes as a YAML map.
|
||||
// The order of keys is preserved when encoding and decoding.
|
||||
// Deprecated: Use go.yaml.in/yaml/v2.MapSlice directly.
|
||||
MapSlice = gopkg_yaml.MapSlice
|
||||
|
||||
// MapItem is an item in a MapSlice.
|
||||
// Deprecated: Use go.yaml.in/yaml/v2.MapItem directly.
|
||||
MapItem = gopkg_yaml.MapItem
|
||||
|
||||
// Unmarshaler is implemented by types to customize their behavior when being unmarshaled from a YAML document.
|
||||
// Deprecated: Use go.yaml.in/yaml/v2.Unmarshaler directly.
|
||||
Unmarshaler = gopkg_yaml.Unmarshaler
|
||||
|
||||
// Marshaler is implemented by types to customize their behavior when being marshaled into a YAML document.
|
||||
// Deprecated: Use go.yaml.in/yaml/v2.Marshaler directly.
|
||||
Marshaler = gopkg_yaml.Marshaler
|
||||
|
||||
// IsZeroer is used to check whether an object is zero to determine whether it should be omitted when
|
||||
// marshaling with the omitempty flag. One notable implementation is time.Time.
|
||||
// Deprecated: Use go.yaml.in/yaml/v2.IsZeroer directly.
|
||||
IsZeroer = gopkg_yaml.IsZeroer
|
||||
|
||||
// Decoder reads and decodes YAML values from an input stream.
|
||||
// Deprecated: Use go.yaml.in/yaml/v2.Decoder directly.
|
||||
Decoder = gopkg_yaml.Decoder
|
||||
|
||||
// Encoder writes YAML values to an output stream.
|
||||
// Deprecated: Use go.yaml.in/yaml/v2.Encoder directly.
|
||||
Encoder = gopkg_yaml.Encoder
|
||||
|
||||
// TypeError is returned by Unmarshal when one or more fields in the YAML document cannot be properly decoded.
|
||||
// Deprecated: Use go.yaml.in/yaml/v2.TypeError directly.
|
||||
TypeError = gopkg_yaml.TypeError
|
||||
)
|
||||
|
||||
// Function aliases for public functions from go.yaml.in/yaml/v2
|
||||
var (
|
||||
// Unmarshal decodes the first document found within the in byte slice and assigns decoded values into the out value.
|
||||
// Deprecated: Use go.yaml.in/yaml/v2.Unmarshal directly.
|
||||
Unmarshal = gopkg_yaml.Unmarshal
|
||||
|
||||
// UnmarshalStrict is like Unmarshal except that any fields that are found in the data that do not have corresponding struct members will result in an error.
|
||||
// Deprecated: Use go.yaml.in/yaml/v2.UnmarshalStrict directly.
|
||||
UnmarshalStrict = gopkg_yaml.UnmarshalStrict
|
||||
|
||||
// Marshal serializes the value provided into a YAML document.
|
||||
// Deprecated: Use go.yaml.in/yaml/v2.Marshal directly.
|
||||
Marshal = gopkg_yaml.Marshal
|
||||
|
||||
// NewDecoder returns a new decoder that reads from r.
|
||||
// Deprecated: Use go.yaml.in/yaml/v2.NewDecoder directly.
|
||||
NewDecoder = gopkg_yaml.NewDecoder
|
||||
|
||||
// NewEncoder returns a new encoder that writes to w.
|
||||
// Deprecated: Use go.yaml.in/yaml/v2.NewEncoder directly.
|
||||
NewEncoder = gopkg_yaml.NewEncoder
|
||||
|
||||
// FutureLineWrap globally disables line wrapping when encoding long strings.
|
||||
// Deprecated: Use go.yaml.in/yaml/v2.FutureLineWrap directly.
|
||||
FutureLineWrap = gopkg_yaml.FutureLineWrap
|
||||
)
|
|
@ -24,7 +24,7 @@ import (
|
|||
"reflect"
|
||||
"strconv"
|
||||
|
||||
"sigs.k8s.io/yaml/goyaml.v2"
|
||||
"go.yaml.in/yaml/v2"
|
||||
)
|
||||
|
||||
// Marshal marshals obj into JSON using stdlib json.Marshal, and then converts JSON to YAML using JSONToYAML (see that method for more reference)
|
||||
|
@ -92,7 +92,7 @@ func jsonUnmarshal(reader io.Reader, obj interface{}, opts ...JSONOpt) error {
|
|||
d = opt(d)
|
||||
}
|
||||
if err := d.Decode(&obj); err != nil {
|
||||
return fmt.Errorf("while decoding JSON: %v", err)
|
||||
return fmt.Errorf("while decoding JSON: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -417,3 +417,10 @@ func jsonToYAMLValue(j interface{}) interface{} {
|
|||
}
|
||||
return j
|
||||
}
|
||||
|
||||
// DisallowUnknownFields configures the JSON decoder to error out if unknown
|
||||
// fields come along, instead of dropping them by default.
|
||||
func DisallowUnknownFields(d *json.Decoder) *json.Decoder {
|
||||
d.DisallowUnknownFields()
|
||||
return d
|
||||
}
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
// This file contains changes that are only compatible with go 1.10 and onwards.
|
||||
|
||||
//go:build go1.10
|
||||
// +build go1.10
|
||||
|
||||
/*
|
||||
Copyright 2021 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package yaml
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
// DisallowUnknownFields configures the JSON decoder to error out if unknown
|
||||
// fields come along, instead of dropping them by default.
|
||||
func DisallowUnknownFields(d *json.Decoder) *json.Decoder {
|
||||
d.DisallowUnknownFields()
|
||||
return d
|
||||
}
|
Loading…
Reference in New Issue