mirror of https://github.com/knative/caching.git
upgrade to latest dependencies (#943)
bumping sigs.k8s.io/yaml c3772b5...0f318dc: > 0f318dc Merge pull request # 134 from kubernetes-sigs/forgot-to-add-redirects-for-constants > 8eaa802 Merge pull request # 133 from kubernetes-sigs/deprecate-code-in-goyaml.v3-goyaml.v2-and-redirect > b8fc0c0 Forgot to add redirects for v3 constants > 0fe7da3 Merge pull request # 125 from kragniz/go-1.24 > 69e45c1 Deprecate code in goyaml.v2/goyaml.v3 directories and redirect > c6ac2c9 Merge pull request # 126 from kragniz/remove-travis > 14cbb88 Test against go 1.24.x > b9a9b1c Merge pull request # 106 from ThatsMrTalbot/patch-1 > 203ded9 Remove old travisci config file > 56d6720 Merge pull request # 122 from liggitt/unhashable-key > 4c6913f fix: wrap errors returned by JSON unmarshal > 119290a Merge pull request # 118 from skitt/drop-go1.10-build > 63d028e Handle unhashable keys during merge > 50e7f43 Merge pull request # 119 from skitt/test-go-1.21 > ea138a0 Merge Go 1.10+ files > 9934139 Test with Go 1.21 and later bumping knative.dev/pkg 05e18ff...4ec554b: > 4ec554b Bump sigs.k8s.io/yaml from 1.4.0 to 1.5.0 (# 3194) > 0285e29 group otel updates (# 3193) > fe85a65 drop unused functions in webhook testing (# 3191) > fd105c6 refactor webhook testing (# 3186) > fe477b7 drop cert-manager from downstream tests (# 3187) Signed-off-by: Knative Automation <automation@knative.team>
This commit is contained in:
parent
911ea8102c
commit
fa78e60d38
5
go.mod
5
go.mod
|
@ -11,7 +11,7 @@ require (
|
|||
k8s.io/code-generator v0.33.1
|
||||
k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff
|
||||
knative.dev/hack v0.0.0-20250514121446-f525e187efdc
|
||||
knative.dev/pkg v0.0.0-20250612083447-05e18ffb29c7
|
||||
knative.dev/pkg v0.0.0-20250625154605-4ec554b5af30
|
||||
)
|
||||
|
||||
require (
|
||||
|
@ -55,6 +55,7 @@ require (
|
|||
github.com/x448/float16 v0.8.4 // indirect
|
||||
go.opencensus.io v0.24.0 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
go.yaml.in/yaml/v2 v2.4.2 // indirect
|
||||
golang.org/x/mod v0.25.0 // indirect
|
||||
golang.org/x/net v0.41.0 // indirect
|
||||
golang.org/x/oauth2 v0.28.0 // indirect
|
||||
|
@ -80,5 +81,5 @@ 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.6.0 // indirect
|
||||
sigs.k8s.io/yaml v1.4.0 // indirect
|
||||
sigs.k8s.io/yaml v1.5.0 // indirect
|
||||
)
|
||||
|
|
11
go.sum
11
go.sum
|
@ -331,6 +331,10 @@ go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN8
|
|||
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||
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-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
|
@ -676,8 +680,8 @@ k8s.io/utils v0.0.0-20241210054802-24370beab758 h1:sdbE21q2nlQtFh65saZY+rRM6x6aJ
|
|||
k8s.io/utils v0.0.0-20241210054802-24370beab758/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
|
||||
knative.dev/hack v0.0.0-20250514121446-f525e187efdc h1:8HmclJlA0zNE/G1SkgdC3/IFSSyhaSz2iIhihU6YbEo=
|
||||
knative.dev/hack v0.0.0-20250514121446-f525e187efdc/go.mod h1:R0ritgYtjLDO9527h5vb5X6gfvt5LCrJ55BNbVDsWiY=
|
||||
knative.dev/pkg v0.0.0-20250612083447-05e18ffb29c7 h1:034E/3HHcG7y533bMXa+d9vD5yjEow2thggnnsGlbTM=
|
||||
knative.dev/pkg v0.0.0-20250612083447-05e18ffb29c7/go.mod h1:nrao281iv0FJ5u/c0j3zmrinAlyOUZo9hJUxbrbsxWo=
|
||||
knative.dev/pkg v0.0.0-20250625154605-4ec554b5af30 h1:lVwS2tuUfP8cbfX9HDFK8YDZRyYEgz9ls0QdqgHDZsU=
|
||||
knative.dev/pkg v0.0.0-20250625154605-4ec554b5af30/go.mod h1:+iNu1QWqeID/fstavvUo7e5+oJKOhFWTAgy0xzwwd40=
|
||||
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
||||
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
|
||||
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
|
||||
|
@ -688,5 +692,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.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.6.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
|
@ -180,6 +180,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/mod v0.25.0
|
||||
## explicit; go 1.23.0
|
||||
golang.org/x/mod/internal/lazyregexp
|
||||
|
@ -852,7 +855,7 @@ k8s.io/utils/trace
|
|||
# knative.dev/hack v0.0.0-20250514121446-f525e187efdc
|
||||
## explicit; go 1.21
|
||||
knative.dev/hack
|
||||
# knative.dev/pkg v0.0.0-20250612083447-05e18ffb29c7
|
||||
# knative.dev/pkg v0.0.0-20250625154605-4ec554b5af30
|
||||
## explicit; go 1.24.0
|
||||
knative.dev/pkg/apis
|
||||
knative.dev/pkg/apis/duck
|
||||
|
@ -907,7 +910,7 @@ 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
|
||||
|
|
|
@ -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,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