From 4b0c882b2c8b9039e9150ae4bc48e96dc08f0610 Mon Sep 17 00:00:00 2001 From: Chai Bot Date: Sun, 28 Jun 2026 22:12:12 +0000 Subject: [PATCH] Revert "Merge pull request #1330 from openshift-bot/synchronize-upstream" This reverts commit 0adff33f0e0251265c6574319131f6918e9f8993, reversing changes made to 32225496430f8607ece581277f56e254fed708be. --- go.mod | 30 +- go.sum | 60 +- pkg/manifests/csv.yaml | 8 - .../.github/workflows/e2e-tests.yml | 6 +- .../.github/workflows/go-verdiff.yaml | 2 +- .../.github/workflows/goreleaser.yaml | 2 +- .../.github/workflows/quickstart.yml | 2 +- .../.github/workflows/sanity.yaml | 6 +- .../.github/workflows/unit.yml | 2 +- .../_packageserver.clusterserviceversion.yaml | 8 - .../deploy/upstream/quickstart/olm.yaml | 8 - staging/operator-lifecycle-manager/go.mod | 30 +- staging/operator-lifecycle-manager/go.sum | 60 +- .../operators/decorators/operator.go | 2 +- .../pkg/lib/codec/mapstructure.go | 2 +- .../pkg/lib/comparison/equal.go | 6 +- .../pkg/package-server/server/server.go | 89 +- .../pkg/package-server/server/server_test.go | 132 --- .../containerd/containerd/labels/labels.go | 12 - .../containerd/containerd/labels/validate.go | 9 - .../containerd/containerd/version/version.go | 2 +- .../go-viper/mapstructure/v2/.editorconfig | 24 - .../go-viper/mapstructure/v2/.envrc | 7 - .../go-viper/mapstructure/v2/.gitignore | 10 - .../go-viper/mapstructure/v2/.golangci.yaml | 48 - .../go-viper/mapstructure/v2/README.md | 81 -- .../go-viper/mapstructure/v2/decode_hooks.go | 714 -------------- .../go-viper/mapstructure/v2/devenv.lock | 103 -- .../go-viper/mapstructure/v2/devenv.nix | 14 - .../go-viper/mapstructure/v2/devenv.yaml | 4 - .../go-viper/mapstructure/v2/errors.go | 244 ----- .../mapstructure/v2/internal/errors/errors.go | 11 - .../mapstructure/v2/internal/errors/join.go | 9 - .../v2/internal/errors/join_go1_19.go | 61 -- .../mapstructure/v2/reflect_go1_19.go | 44 - .../mapstructure/v2/reflect_go1_20.go | 10 - .../mitchellh/hashstructure/{v2 => }/LICENSE | 0 .../hashstructure/{v2 => }/README.md | 13 +- .../hashstructure/{v2 => }/hashstructure.go | 92 +- .../hashstructure/{v2 => }/include.go | 0 .../mitchellh/hashstructure/v2/errors.go | 22 - .../mapstructure}/CHANGELOG.md | 8 - .../v2 => mitchellh/mapstructure}/LICENSE | 0 .../mitchellh/mapstructure/README.md | 46 + .../mitchellh/mapstructure/decode_hooks.go | 279 ++++++ .../mitchellh/mapstructure/error.go | 50 + .../mapstructure}/mapstructure.go | 912 +++++------------- .../onsi/ginkgo/v2/ginkgo/run/run_command.go | 4 - .../ginkgo/v2/ginkgo/watch/watch_command.go | 4 - .../ginkgo/v2/reporters/default_reporter.go | 54 +- .../github.com/onsi/ginkgo/v2/types/config.go | 39 +- .../github.com/onsi/ginkgo/v2/types/errors.go | 17 +- .../onsi/ginkgo/v2/types/version.go | 2 +- .../operators/decorators/operator.go | 2 +- .../pkg/lib/codec/mapstructure.go | 2 +- .../pkg/lib/comparison/equal.go | 6 +- .../pkg/package-server/server/server.go | 89 +- .../prometheus/common/expfmt/expfmt.go | 4 +- .../prometheus/common/expfmt/text_create.go | 4 +- .../prometheus/common/expfmt/text_parse.go | 10 - .../prometheus/common/model/labels.go | 2 +- .../prometheus/common/model/labelset.go | 13 +- .../prometheus/common/model/metric.go | 5 +- .../prometheus/common/model/time.go | 44 +- .../prometheus/common/model/value.go | 8 +- .../prometheus/common/model/value_float.go | 2 +- .../common/model/value_histogram.go | 8 +- .../pkg/api/validation/objectmeta.go | 2 +- vendor/modules.txt | 37 +- 69 files changed, 848 insertions(+), 2794 deletions(-) delete mode 100644 staging/operator-lifecycle-manager/pkg/package-server/server/server_test.go delete mode 100644 vendor/github.com/go-viper/mapstructure/v2/.editorconfig delete mode 100644 vendor/github.com/go-viper/mapstructure/v2/.envrc delete mode 100644 vendor/github.com/go-viper/mapstructure/v2/.gitignore delete mode 100644 vendor/github.com/go-viper/mapstructure/v2/.golangci.yaml delete mode 100644 vendor/github.com/go-viper/mapstructure/v2/README.md delete mode 100644 vendor/github.com/go-viper/mapstructure/v2/decode_hooks.go delete mode 100644 vendor/github.com/go-viper/mapstructure/v2/devenv.lock delete mode 100644 vendor/github.com/go-viper/mapstructure/v2/devenv.nix delete mode 100644 vendor/github.com/go-viper/mapstructure/v2/devenv.yaml delete mode 100644 vendor/github.com/go-viper/mapstructure/v2/errors.go delete mode 100644 vendor/github.com/go-viper/mapstructure/v2/internal/errors/errors.go delete mode 100644 vendor/github.com/go-viper/mapstructure/v2/internal/errors/join.go delete mode 100644 vendor/github.com/go-viper/mapstructure/v2/internal/errors/join_go1_19.go delete mode 100644 vendor/github.com/go-viper/mapstructure/v2/reflect_go1_19.go delete mode 100644 vendor/github.com/go-viper/mapstructure/v2/reflect_go1_20.go rename vendor/github.com/mitchellh/hashstructure/{v2 => }/LICENSE (100%) rename vendor/github.com/mitchellh/hashstructure/{v2 => }/README.md (76%) rename vendor/github.com/mitchellh/hashstructure/{v2 => }/hashstructure.go (78%) rename vendor/github.com/mitchellh/hashstructure/{v2 => }/include.go (100%) delete mode 100644 vendor/github.com/mitchellh/hashstructure/v2/errors.go rename vendor/github.com/{go-viper/mapstructure/v2 => mitchellh/mapstructure}/CHANGELOG.md (92%) rename vendor/github.com/{go-viper/mapstructure/v2 => mitchellh/mapstructure}/LICENSE (100%) create mode 100644 vendor/github.com/mitchellh/mapstructure/README.md create mode 100644 vendor/github.com/mitchellh/mapstructure/decode_hooks.go create mode 100644 vendor/github.com/mitchellh/mapstructure/error.go rename vendor/github.com/{go-viper/mapstructure/v2 => mitchellh/mapstructure}/mapstructure.go (63%) diff --git a/go.mod b/go.mod index 470da2ed87..afd2f51979 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/grpc-ecosystem/grpc-health-probe v0.4.52 github.com/maxbrunsfeld/counterfeiter/v6 v6.12.2 github.com/mikefarah/yq/v3 v3.0.0-20201202084205-8846255d1c37 - github.com/onsi/ginkgo/v2 v2.32.0 + github.com/onsi/ginkgo/v2 v2.31.0 github.com/openshift/api v0.0.0-20260204104751-e09e5a4ebcd0 github.com/operator-framework/api v0.44.0 github.com/operator-framework/operator-lifecycle-manager v0.0.0-00010101000000-000000000000 @@ -22,10 +22,10 @@ require ( google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.6.2 google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af gopkg.in/yaml.v2 v2.4.0 - k8s.io/api v0.36.2 - k8s.io/apimachinery v0.36.2 - k8s.io/client-go v0.36.2 - k8s.io/code-generator v0.36.2 + k8s.io/api v0.36.1 + k8s.io/apimachinery v0.36.1 + k8s.io/client-go v0.36.1 + k8s.io/code-generator v0.36.1 k8s.io/kube-openapi v0.0.0-20260427204847-8949caaa1199 k8s.io/utils v0.0.0-20260319190234-28399d86e0b5 sigs.k8s.io/controller-runtime v0.24.1 @@ -51,7 +51,7 @@ require ( github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/clipperhouse/uax29/v2 v2.7.0 // indirect github.com/containerd/cgroups/v3 v3.1.2 // indirect - github.com/containerd/containerd v1.7.33 // indirect + github.com/containerd/containerd v1.7.32 // indirect github.com/containerd/containerd/api v1.10.0 // indirect github.com/containerd/continuity v0.4.5 // indirect github.com/containerd/errdefs v1.0.0 // indirect @@ -101,7 +101,6 @@ require ( github.com/go-openapi/swag/typeutils v0.26.0 // indirect github.com/go-openapi/swag/yamlutils v0.26.0 // indirect github.com/go-task/slim-sprig/v3 v3.0.0 // indirect - github.com/go-viper/mapstructure/v2 v2.5.0 // indirect github.com/gobuffalo/flect v1.0.3 // indirect github.com/goccy/go-yaml v1.18.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect @@ -137,7 +136,8 @@ require ( github.com/mattn/go-sqlite3 v1.14.45 // indirect github.com/miekg/pkcs11 v1.1.2 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect - github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect + github.com/mitchellh/hashstructure v1.1.0 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/moby/locker v1.0.1 // indirect github.com/moby/moby/client v0.4.1 // indirect github.com/moby/sys/capability v0.4.0 // indirect @@ -163,7 +163,7 @@ require ( github.com/proglottis/gpgme v0.1.6 // indirect github.com/prometheus/client_golang v1.23.2 // indirect github.com/prometheus/client_model v0.6.2 // indirect - github.com/prometheus/common v0.69.0 // indirect + github.com/prometheus/common v0.68.1 // indirect github.com/prometheus/procfs v0.20.1 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/secure-systems-lab/go-securesystemslib v0.11.0 // indirect @@ -224,16 +224,16 @@ require ( gopkg.in/op/go-logging.v1 v1.0.0-20160211212156-b2cb9fa56473 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/apiextensions-apiserver v0.36.2 // indirect - k8s.io/apiserver v0.36.2 // indirect + k8s.io/apiextensions-apiserver v0.36.1 // indirect + k8s.io/apiserver v0.36.1 // indirect k8s.io/cli-runtime v0.36.1 // indirect - k8s.io/component-base v0.36.2 // indirect + k8s.io/component-base v0.36.1 // indirect k8s.io/gengo/v2 v2.0.0-20250922181213-ec3ebc5fd46b // indirect k8s.io/klog/v2 v2.140.0 // indirect - k8s.io/kms v0.36.2 // indirect - k8s.io/kube-aggregator v0.36.2 // indirect + k8s.io/kms v0.36.1 // indirect + k8s.io/kube-aggregator v0.36.1 // indirect k8s.io/kubectl v0.36.1 // indirect - k8s.io/streaming v0.36.2 // indirect + k8s.io/streaming v0.36.1 // indirect oras.land/oras-go/v2 v2.6.1 // indirect sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.34.0 // indirect sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect diff --git a/go.sum b/go.sum index bea219d6c3..808d11ed8b 100644 --- a/go.sum +++ b/go.sum @@ -50,8 +50,8 @@ github.com/clipperhouse/uax29/v2 v2.7.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJ github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/containerd/cgroups/v3 v3.1.2 h1:OSosXMtkhI6Qove637tg1XgK4q+DhR0mX8Wi8EhrHa4= github.com/containerd/cgroups/v3 v3.1.2/go.mod h1:PKZ2AcWmSBsY/tJUVhtS/rluX0b1uq1GmPO1ElCmbOw= -github.com/containerd/containerd v1.7.33 h1:iAkYGC/ifR/V+0eR4iXWHNGYUF0DF2PmGV5iz4Irj5M= -github.com/containerd/containerd v1.7.33/go.mod h1:gSbSCVjPCdkfJCjyrzz7aRC+xFlqVbatNpfHfVCYGUM= +github.com/containerd/containerd v1.7.32 h1:S54xuVcPxeLaYgaRABtpJ2VyVUVsy0IGf7qHBs+sbY8= +github.com/containerd/containerd v1.7.32/go.mod h1:jdwD6s/BhV4XVJGrvtziNPVA+83n66TwptVaPKprq4E= github.com/containerd/containerd/api v1.10.0 h1:5n0oHYVBwN4VhoX9fFykCV9dF1/BvAXeg2F8W6UYq1o= github.com/containerd/containerd/api v1.10.0/go.mod h1:NBm1OAk8ZL+LG8R0ceObGxT5hbUYj7CzTmR3xh0DlMM= github.com/containerd/continuity v0.4.5 h1:ZRoN1sXq9u7V6QoHMcVWGhOwDFqZ4B9i5H6un1Wh0x4= @@ -207,8 +207,6 @@ github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+ github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= -github.com/go-viper/mapstructure/v2 v2.5.0 h1:vM5IJoUAy3d7zRSVtIwQgBj7BiWtMPfmPEgAXnvj1Ro= -github.com/go-viper/mapstructure/v2 v2.5.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/gobuffalo/flect v1.0.3 h1:xeWBM2nui+qnVvNM4S3foBhCAL2XgPU+a7FdpelbTq4= github.com/gobuffalo/flect v1.0.3/go.mod h1:A5msMlrHtLqh9umBSnvabjsMrCcCpAyzglnDvkbYKHs= github.com/goccy/go-yaml v1.8.1/go.mod h1:wS4gNoLalDSJxo/SpngzPQ2BN4uuZVLCmbM4S3vd4+Y= @@ -376,9 +374,11 @@ github.com/mikefarah/yq/v3 v3.0.0-20201202084205-8846255d1c37/go.mod h1:dYWq+UWo github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= -github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4= -github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE= +github.com/mitchellh/hashstructure v1.1.0 h1:P6P1hdjqAAknpY/M1CGipelZgp+4y9ja9kmUZPXP+H0= +github.com/mitchellh/hashstructure v1.1.0/go.mod h1:xUDAozZz0Wmdiufv0uyhnHkUTN6/6d8ulp4AwfLKrmA= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg= github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc= github.com/moby/moby/client v0.4.1 h1:DMQgisVoMkmMs7fp3ROSdiBnoAu8+vo3GggFl06M/wY= @@ -409,8 +409,8 @@ github.com/nxadm/tail v1.4.11/go.mod h1:OTaG3NK980DZzxbRq6lEuzgU+mug70nY11sMd4JX github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= -github.com/onsi/ginkgo/v2 v2.32.0 h1:Hw7s2pVrQo/8Yz5N77qdnpHaoc+c6cC9WIV1Jce+J6E= -github.com/onsi/ginkgo/v2 v2.32.0/go.mod h1:+aXOY+vzZ5mu2iI2HpTZUPmM//oQfsNFX6gU9kNcA44= +github.com/onsi/ginkgo/v2 v2.31.0 h1:GtuJos5DFUV9EerYJo8RhYxosYNGvOdDE5haKq6Grfs= +github.com/onsi/ginkgo/v2 v2.31.0/go.mod h1:+aXOY+vzZ5mu2iI2HpTZUPmM//oQfsNFX6gU9kNcA44= github.com/onsi/gomega v1.42.0 h1:CJby8u36xb7v34W78F8WKvqTQP7PCMIPB78IVDB73l4= github.com/onsi/gomega v1.42.0/go.mod h1:M/Uqpu/8qTjtzCLUA2zJHX9Iilrau25x1PdoSRbWh5A= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= @@ -449,8 +449,8 @@ github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNw github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE= github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.69.0 h1:OA85nJQS/T/MaYh/Q2CcgDKSGWqNIgrBDvDH85CuiNk= -github.com/prometheus/common v0.69.0/go.mod h1:ZzL3f6u94qUxh9p+tJTrF+FvBS1XXbbRAZCQkytAL0Y= +github.com/prometheus/common v0.68.1 h1:omjRRl4QP4komogpXuhfeOiisQg7xdy8VM1UY+pStaY= +github.com/prometheus/common v0.68.1/go.mod h1:ZzL3f6u94qUxh9p+tJTrF+FvBS1XXbbRAZCQkytAL0Y= github.com/prometheus/otlptranslator v1.0.0 h1:s0LJW/iN9dkIH+EnhiD3BlkkP5QVIUVEoIwkU+A6qos= github.com/prometheus/otlptranslator v1.0.0/go.mod h1:vRYWnXvI6aWGpsdY/mOT/cbeVRBlPWtBNDb7kGR3uKM= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= @@ -869,36 +869,36 @@ gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q= gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -k8s.io/api v0.36.2 h1:TF6YDLIzKfccK7cq9YpTcGX8TJmEkHVRv78DM51fRYY= -k8s.io/api v0.36.2/go.mod h1:F4LbMO4brjZYh7yFkXWhynSvtB7YauxV4c+HHkNRGNg= -k8s.io/apiextensions-apiserver v0.36.2 h1:3O5gqOj/dt2XWWbpMe+TXWpE9yU6pjM/tXxtHHJT/K4= -k8s.io/apiextensions-apiserver v0.36.2/go.mod h1:cL1tBWe8XSaP1H30iWKGo7hf6iAUUUJPEU70dskmAnA= -k8s.io/apimachinery v0.36.2 h1:0PE/W/WNy1UX61NLbXY5TMbJ6UwLL6E6lAPkYrKFxbQ= -k8s.io/apimachinery v0.36.2/go.mod h1:fvf/HOLXq9RId0rnDIbN1OEBvHXdQbLMM8nu0LcBUf4= -k8s.io/apiserver v0.36.2 h1:6vMnkmHZPeBloNkHUhmZYq7Ylv8WIB8xjyEl+eSt26E= -k8s.io/apiserver v0.36.2/go.mod h1:9PoQ2ikCytrZyZg11mGhLEF5m8Rgsb5FJmYJ4Wvnl1k= +k8s.io/api v0.36.1 h1:XbL/EMj8K2aJpJtePmqUyQMsM0D4QI2pvl7YKJ20FTY= +k8s.io/api v0.36.1/go.mod h1:KOWo4ey3TINlXjeHVuwB3i+tXXnu+UcwFBHlI/9dvEo= +k8s.io/apiextensions-apiserver v0.36.1 h1:6JfYmPUsuUIHuN+3QxutXYWj492RqF5fBSx67GYK5Ks= +k8s.io/apiextensions-apiserver v0.36.1/go.mod h1:pLzZin90riwisdzKwv/GoTwENooytoIx5zWJb4Hkby8= +k8s.io/apimachinery v0.36.1 h1:G63Gjx2W+q0YD+72Vo8oY0nDnePVwnuzTmmy5ENrVSA= +k8s.io/apimachinery v0.36.1/go.mod h1:ibYOR00vW/I1kzvi5SF0dRuJ52BvKtfvRdOn35GPQ+8= +k8s.io/apiserver v0.36.1 h1:iMS5V+rPUertv5P9RaqJgmHHTuh4quWpoxchvMUY+JY= +k8s.io/apiserver v0.36.1/go.mod h1:Cby1PbLWztu0GDOxoO6iFOyyqIsziHNEW+w9zVQ22Kw= k8s.io/cli-runtime v0.36.1 h1:yuC/BGnnj1YYPh6D1P+pZnzinCs6DvMq86yAeNqoqzM= k8s.io/cli-runtime v0.36.1/go.mod h1:ZQWHGt8xAF7KnviB79vX0lYNyUUqKIpU+LQg7exuFAw= -k8s.io/client-go v0.36.2 h1:bfgxmFKc9CgqsgX4xKLAAdmTQlWee7Ob/HlDOrJ5TBI= -k8s.io/client-go v0.36.2/go.mod h1:1vgO4OAlfPnoLcb+Rze2GF5rAr14w8qjrYMoyXJzQj0= -k8s.io/code-generator v0.36.2 h1:iBNFYhClojQaVrF99Z3iTAad7LztQh3yCtwR8L8Ocpg= -k8s.io/code-generator v0.36.2/go.mod h1:IfnsRW1IAq9iPxqs/FfOnVnWWONxS2mPDvWNR4fPlzI= -k8s.io/component-base v0.36.2 h1:Z0VH80O7Ng0HDZnZj3WRR3urEGa0kTwmO8CwEwjVK1w= -k8s.io/component-base v0.36.2/go.mod h1:mGfFOA7Gwpdm1VW2cwSQYbiDIlz8GD2WGwH88QSeCyA= +k8s.io/client-go v0.36.1 h1:FN/K8QIT2CEDt+2WB2HnWrUANZ50AP5GII43/SP2JR0= +k8s.io/client-go v0.36.1/go.mod h1:s6rAnCtTGYDQnpNjEhSaISV+2O8jwruZ6m3QOYBFbtU= +k8s.io/code-generator v0.36.1 h1:5bHQ7NbBcFFLHcoyo/hgU3m2tQV5RLz2nv4QNDlsbXc= +k8s.io/code-generator v0.36.1/go.mod h1:oCv8WmrW2RGdcMyvSk1aYbBfSs51ggtSFQr1YNeuAuo= +k8s.io/component-base v0.36.1 h1:iG6GsELftXqTNG9HG6kiVjatSgAw1sf5pJ6R5a6N0kA= +k8s.io/component-base v0.36.1/go.mod h1:nf9XPlntRdqO6WMeEWAA5F93Y4ICZQdeT9GeqLDB3JI= k8s.io/gengo/v2 v2.0.0-20250922181213-ec3ebc5fd46b h1:gMplByicHV/TJBizHd9aVEsTYoJBnnUAT5MHlTkbjhQ= k8s.io/gengo/v2 v2.0.0-20250922181213-ec3ebc5fd46b/go.mod h1:CgujABENc3KuTrcsdpGmrrASjtQsWCT7R99mEV4U/fM= k8s.io/klog/v2 v2.140.0 h1:Tf+J3AH7xnUzZyVVXhTgGhEKnFqye14aadWv7bzXdzc= k8s.io/klog/v2 v2.140.0/go.mod h1:o+/RWfJ6PwpnFn7OyAG3QnO47BFsymfEfrz6XyYSSp0= -k8s.io/kms v0.36.2 h1:o0l8zMRecm38k5NyRnO/3+2YA/MR6TMGcc3KQZA76hI= -k8s.io/kms v0.36.2/go.mod h1:g91diTD9h0oJCCHkTb00krlF+Qm5HTnkWLi9Q/TpRoc= -k8s.io/kube-aggregator v0.36.2 h1:zfeH9Fs16oDquNfBZef3M27dGG3QtJ9/TwkWfBlw1lo= -k8s.io/kube-aggregator v0.36.2/go.mod h1:UMrB5DfEhznFTf0bqYW2SV26GDy8HNaxoYakvKVWZ8M= +k8s.io/kms v0.36.1 h1:XdvKpywoW4k7YUHDh5uYP4mahJXECswHGfCddBBYLZs= +k8s.io/kms v0.36.1/go.mod h1:g91diTD9h0oJCCHkTb00krlF+Qm5HTnkWLi9Q/TpRoc= +k8s.io/kube-aggregator v0.36.1 h1:IzNeRsJcTtgsiCyTgCR1pSwWCrXC1QZQWMTcBw18cFQ= +k8s.io/kube-aggregator v0.36.1/go.mod h1:ROrIm5irUhVUJsKVCgBAAcXpK5IiqpdCn0Ka7LYMGs4= k8s.io/kube-openapi v0.0.0-20260427204847-8949caaa1199 h1:sWu4Td5mgJlwunsUydnhKEAfNUHM7hm1wfKEQmD7G5c= k8s.io/kube-openapi v0.0.0-20260427204847-8949caaa1199/go.mod h1:uGBT7iTA6c6MvqUvSXIaYZo9ukscABYi2btjhvgKGZ0= k8s.io/kubectl v0.36.1 h1:96HqS9twIdHM0MlJLTwbo14b9kUKPkOzZ4tlRDLv4qI= k8s.io/kubectl v0.36.1/go.mod h1:/DGPAIewKsFWF9VFgGvkPhao2Ev4SNuE3BioZo8yPbk= -k8s.io/streaming v0.36.2 h1:NSKthPPg9UFSKsRauVJUVGH2Dvn8fhKmY4qrMkw/p98= -k8s.io/streaming v0.36.2/go.mod h1:z6fV3D+NVkoeqRMtWwlUZK6U17SY/LqNzOxWL6GyR/s= +k8s.io/streaming v0.36.1 h1:L+K68n4Gg940BGNNYtUBvL1WTLL0YnKT3s+P1MNAmR4= +k8s.io/streaming v0.36.1/go.mod h1:z6fV3D+NVkoeqRMtWwlUZK6U17SY/LqNzOxWL6GyR/s= k8s.io/utils v0.0.0-20260319190234-28399d86e0b5 h1:kBawHLSnx/mYHmRnNUf9d4CpjREbeZuxoSGOX/J+aYM= k8s.io/utils v0.0.0-20260319190234-28399d86e0b5/go.mod h1:xDxuJ0whA3d0I4mf/C4ppKHxXynQ+fxnkmQH0vTHnuk= oras.land/oras-go/v2 v2.6.1 h1:bonOEkjLfp8tt6qXWRRWP6p1F+9octchOf2EqnWB4Zs= diff --git a/pkg/manifests/csv.yaml b/pkg/manifests/csv.yaml index 08416908f0..c077a62ae0 100644 --- a/pkg/manifests/csv.yaml +++ b/pkg/manifests/csv.yaml @@ -69,14 +69,6 @@ spec: verbs: - get - list - - apiGroups: - - "config.openshift.io" - resources: - - apiservers - resourceNames: - - cluster - verbs: - - get deployments: - name: packageserver spec: diff --git a/staging/operator-lifecycle-manager/.github/workflows/e2e-tests.yml b/staging/operator-lifecycle-manager/.github/workflows/e2e-tests.yml index f5c127dbe0..5b054bb1c2 100644 --- a/staging/operator-lifecycle-manager/.github/workflows/e2e-tests.yml +++ b/staging/operator-lifecycle-manager/.github/workflows/e2e-tests.yml @@ -17,7 +17,7 @@ jobs: sha: ${{ steps.vars.outputs.sha }} steps: # checkout code and setup go - - uses: actions/checkout@v7 + - uses: actions/checkout@v6 - uses: actions/setup-go@v6 with: go-version-file: "go.mod" @@ -49,7 +49,7 @@ jobs: E2E_KUBECONFIG_ROOT: ${{ github.workspace }}/kubeconfigs steps: # checkout code and setup go - - uses: actions/checkout@v7 + - uses: actions/checkout@v6 - uses: actions/setup-go@v6 with: go-version-file: "go.mod" @@ -136,7 +136,7 @@ jobs: E2E_KUBECONFIG_ROOT: ${{ github.workspace }}/kubeconfigs steps: # checkout code and setup go - - uses: actions/checkout@v7 + - uses: actions/checkout@v6 - uses: actions/setup-go@v6 with: go-version-file: "go.mod" diff --git a/staging/operator-lifecycle-manager/.github/workflows/go-verdiff.yaml b/staging/operator-lifecycle-manager/.github/workflows/go-verdiff.yaml index e6702117b4..0eff680626 100644 --- a/staging/operator-lifecycle-manager/.github/workflows/go-verdiff.yaml +++ b/staging/operator-lifecycle-manager/.github/workflows/go-verdiff.yaml @@ -10,7 +10,7 @@ jobs: go-verdiff: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v7 + - uses: actions/checkout@v6 with: fetch-depth: 0 - name: Check golang version diff --git a/staging/operator-lifecycle-manager/.github/workflows/goreleaser.yaml b/staging/operator-lifecycle-manager/.github/workflows/goreleaser.yaml index d21e49ae1a..445a21de55 100644 --- a/staging/operator-lifecycle-manager/.github/workflows/goreleaser.yaml +++ b/staging/operator-lifecycle-manager/.github/workflows/goreleaser.yaml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v7 + uses: actions/checkout@v6 with: fetch-depth: 0 - name: Set up Go diff --git a/staging/operator-lifecycle-manager/.github/workflows/quickstart.yml b/staging/operator-lifecycle-manager/.github/workflows/quickstart.yml index fca72ba7b4..d02555e213 100644 --- a/staging/operator-lifecycle-manager/.github/workflows/quickstart.yml +++ b/staging/operator-lifecycle-manager/.github/workflows/quickstart.yml @@ -8,7 +8,7 @@ jobs: install-quickstart: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v7 + - uses: actions/checkout@v6 - run: | curl -sLo kind "$(curl -sL https://api.github.com/repos/kubernetes-sigs/kind/releases/latest | jq -r '[.assets[] | select(.name == "kind-linux-amd64")] | first | .browser_download_url')" chmod +x kind diff --git a/staging/operator-lifecycle-manager/.github/workflows/sanity.yaml b/staging/operator-lifecycle-manager/.github/workflows/sanity.yaml index fc919d1635..3ce0a3ece7 100644 --- a/staging/operator-lifecycle-manager/.github/workflows/sanity.yaml +++ b/staging/operator-lifecycle-manager/.github/workflows/sanity.yaml @@ -10,7 +10,7 @@ jobs: check-vendor: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v7 + - uses: actions/checkout@v6 - uses: actions/setup-go@v6 with: go-version-file: "go.mod" @@ -19,7 +19,7 @@ jobs: static-analysis: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v7 + - uses: actions/checkout@v6 - uses: actions/setup-go@v6 with: go-version-file: "go.mod" @@ -28,7 +28,7 @@ jobs: verify: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v7 + - uses: actions/checkout@v6 - uses: actions/setup-go@v6 with: go-version-file: "go.mod" diff --git a/staging/operator-lifecycle-manager/.github/workflows/unit.yml b/staging/operator-lifecycle-manager/.github/workflows/unit.yml index eec04ab2bf..11c1b67e9d 100644 --- a/staging/operator-lifecycle-manager/.github/workflows/unit.yml +++ b/staging/operator-lifecycle-manager/.github/workflows/unit.yml @@ -14,7 +14,7 @@ jobs: github.event_name != 'issue_comment' || startsWith(github.event.comment.body, '/retest unit') runs-on: ubuntu-latest steps: - - uses: actions/checkout@v7 + - uses: actions/checkout@v6 - uses: actions/setup-go@v6 with: go-version-file: "go.mod" diff --git a/staging/operator-lifecycle-manager/deploy/chart/templates/_packageserver.clusterserviceversion.yaml b/staging/operator-lifecycle-manager/deploy/chart/templates/_packageserver.clusterserviceversion.yaml index 38658adbb2..5739dff461 100644 --- a/staging/operator-lifecycle-manager/deploy/chart/templates/_packageserver.clusterserviceversion.yaml +++ b/staging/operator-lifecycle-manager/deploy/chart/templates/_packageserver.clusterserviceversion.yaml @@ -67,14 +67,6 @@ spec: verbs: - get - list - - apiGroups: - - "config.openshift.io" - resources: - - apiservers - resourceNames: - - cluster - verbs: - - get deployments: - name: packageserver {{- include "packageserver.deployment-spec" . | nindent 8 }} diff --git a/staging/operator-lifecycle-manager/deploy/upstream/quickstart/olm.yaml b/staging/operator-lifecycle-manager/deploy/upstream/quickstart/olm.yaml index 1b8c3d0970..718ff64d55 100644 --- a/staging/operator-lifecycle-manager/deploy/upstream/quickstart/olm.yaml +++ b/staging/operator-lifecycle-manager/deploy/upstream/quickstart/olm.yaml @@ -264,14 +264,6 @@ spec: verbs: - get - list - - apiGroups: - - "config.openshift.io" - resources: - - apiservers - resourceNames: - - cluster - verbs: - - get deployments: - name: packageserver spec: diff --git a/staging/operator-lifecycle-manager/go.mod b/staging/operator-lifecycle-manager/go.mod index e325ec4f9d..503bc06027 100644 --- a/staging/operator-lifecycle-manager/go.mod +++ b/staging/operator-lifecycle-manager/go.mod @@ -11,12 +11,12 @@ require ( github.com/ghodss/yaml v1.0.0 github.com/go-air/gini v1.0.4 github.com/go-logr/logr v1.4.3 - github.com/go-viper/mapstructure/v2 v2.5.0 github.com/google/go-cmp v0.7.0 github.com/itchyny/gojq v0.12.19 github.com/maxbrunsfeld/counterfeiter/v6 v6.12.2 - github.com/mitchellh/hashstructure/v2 v2.0.2 - github.com/onsi/ginkgo/v2 v2.32.0 + github.com/mitchellh/hashstructure v1.1.0 + github.com/mitchellh/mapstructure v1.5.0 + github.com/onsi/ginkgo/v2 v2.31.0 github.com/onsi/gomega v1.42.0 github.com/openshift/api v0.0.0-20260204104751-e09e5a4ebcd0 github.com/openshift/client-go v0.0.0-20260108185524-48f4ccfc4e13 @@ -27,7 +27,7 @@ require ( github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.23.2 github.com/prometheus/client_model v0.6.2 - github.com/prometheus/common v0.69.0 + github.com/prometheus/common v0.68.1 github.com/sirupsen/logrus v1.9.4 github.com/spf13/cobra v1.10.2 github.com/spf13/pflag v1.0.10 @@ -39,15 +39,15 @@ require ( golang.org/x/time v0.15.0 google.golang.org/grpc v1.81.1 gopkg.in/yaml.v3 v3.0.1 - k8s.io/api v0.36.2 - k8s.io/apiextensions-apiserver v0.36.2 - k8s.io/apimachinery v0.36.2 - k8s.io/apiserver v0.36.2 - k8s.io/client-go v0.36.2 - k8s.io/code-generator v0.36.2 - k8s.io/component-base v0.36.2 + k8s.io/api v0.36.1 + k8s.io/apiextensions-apiserver v0.36.1 + k8s.io/apimachinery v0.36.1 + k8s.io/apiserver v0.36.1 + k8s.io/client-go v0.36.1 + k8s.io/code-generator v0.36.1 + k8s.io/component-base v0.36.1 k8s.io/klog/v2 v2.140.0 - k8s.io/kube-aggregator v0.36.2 + k8s.io/kube-aggregator v0.36.1 k8s.io/kube-openapi v0.0.0-20260427204847-8949caaa1199 k8s.io/utils v0.0.0-20260319190234-28399d86e0b5 sigs.k8s.io/controller-runtime v0.24.1 @@ -68,7 +68,7 @@ require ( github.com/cenkalti/backoff/v5 v5.0.3 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/containerd/cgroups/v3 v3.1.2 // indirect - github.com/containerd/containerd v1.7.33 // indirect + github.com/containerd/containerd v1.7.32 // indirect github.com/containerd/containerd/api v1.10.0 // indirect github.com/containerd/continuity v0.4.5 // indirect github.com/containerd/errdefs v1.0.0 // indirect @@ -194,8 +194,8 @@ require ( gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect k8s.io/gengo/v2 v2.0.0-20250922181213-ec3ebc5fd46b // indirect - k8s.io/kms v0.36.2 // indirect - k8s.io/streaming v0.36.2 // indirect + k8s.io/kms v0.36.1 // indirect + k8s.io/streaming v0.36.1 // indirect sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.34.0 // indirect sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect sigs.k8s.io/randfill v1.0.0 // indirect diff --git a/staging/operator-lifecycle-manager/go.sum b/staging/operator-lifecycle-manager/go.sum index a3e59efcd0..f9cfc029fc 100644 --- a/staging/operator-lifecycle-manager/go.sum +++ b/staging/operator-lifecycle-manager/go.sum @@ -37,8 +37,8 @@ github.com/clipperhouse/uax29/v2 v2.7.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJ github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/containerd/cgroups/v3 v3.1.2 h1:OSosXMtkhI6Qove637tg1XgK4q+DhR0mX8Wi8EhrHa4= github.com/containerd/cgroups/v3 v3.1.2/go.mod h1:PKZ2AcWmSBsY/tJUVhtS/rluX0b1uq1GmPO1ElCmbOw= -github.com/containerd/containerd v1.7.33 h1:iAkYGC/ifR/V+0eR4iXWHNGYUF0DF2PmGV5iz4Irj5M= -github.com/containerd/containerd v1.7.33/go.mod h1:gSbSCVjPCdkfJCjyrzz7aRC+xFlqVbatNpfHfVCYGUM= +github.com/containerd/containerd v1.7.32 h1:S54xuVcPxeLaYgaRABtpJ2VyVUVsy0IGf7qHBs+sbY8= +github.com/containerd/containerd v1.7.32/go.mod h1:jdwD6s/BhV4XVJGrvtziNPVA+83n66TwptVaPKprq4E= github.com/containerd/containerd/api v1.10.0 h1:5n0oHYVBwN4VhoX9fFykCV9dF1/BvAXeg2F8W6UYq1o= github.com/containerd/containerd/api v1.10.0/go.mod h1:NBm1OAk8ZL+LG8R0ceObGxT5hbUYj7CzTmR3xh0DlMM= github.com/containerd/continuity v0.4.5 h1:ZRoN1sXq9u7V6QoHMcVWGhOwDFqZ4B9i5H6un1Wh0x4= @@ -171,8 +171,6 @@ github.com/go-openapi/testify/v2 v2.4.2 h1:tiByHpvE9uHrrKjOszax7ZvKB7QOgizBWGBLu github.com/go-openapi/testify/v2 v2.4.2/go.mod h1:SgsVHtfooshd0tublTtJ50FPKhujf47YRqauXXOUxfw= github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= -github.com/go-viper/mapstructure/v2 v2.5.0 h1:vM5IJoUAy3d7zRSVtIwQgBj7BiWtMPfmPEgAXnvj1Ro= -github.com/go-viper/mapstructure/v2 v2.5.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/gobuffalo/flect v1.0.3 h1:xeWBM2nui+qnVvNM4S3foBhCAL2XgPU+a7FdpelbTq4= github.com/gobuffalo/flect v1.0.3/go.mod h1:A5msMlrHtLqh9umBSnvabjsMrCcCpAyzglnDvkbYKHs= github.com/goccy/go-yaml v1.18.0 h1:8W7wMFS12Pcas7KU+VVkaiCng+kG8QiFeFwzFb+rwuw= @@ -292,8 +290,10 @@ github.com/mfridman/tparse v0.18.0 h1:wh6dzOKaIwkUGyKgOntDW4liXSo37qg5AXbIhkMV3v github.com/mfridman/tparse v0.18.0/go.mod h1:gEvqZTuCgEhPbYk/2lS3Kcxg1GmTxxU7kTC8DvP0i/A= github.com/miekg/pkcs11 v1.1.2 h1:/VxmeAX5qU6Q3EwafypogwWbYryHFmF2RpkJmw3m4MQ= github.com/miekg/pkcs11 v1.1.2/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= -github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4= -github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE= +github.com/mitchellh/hashstructure v1.1.0 h1:P6P1hdjqAAknpY/M1CGipelZgp+4y9ja9kmUZPXP+H0= +github.com/mitchellh/hashstructure v1.1.0/go.mod h1:xUDAozZz0Wmdiufv0uyhnHkUTN6/6d8ulp4AwfLKrmA= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg= github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc= github.com/moby/moby/client v0.4.1 h1:DMQgisVoMkmMs7fp3ROSdiBnoAu8+vo3GggFl06M/wY= @@ -320,8 +320,8 @@ github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= -github.com/onsi/ginkgo/v2 v2.32.0 h1:Hw7s2pVrQo/8Yz5N77qdnpHaoc+c6cC9WIV1Jce+J6E= -github.com/onsi/ginkgo/v2 v2.32.0/go.mod h1:+aXOY+vzZ5mu2iI2HpTZUPmM//oQfsNFX6gU9kNcA44= +github.com/onsi/ginkgo/v2 v2.31.0 h1:GtuJos5DFUV9EerYJo8RhYxosYNGvOdDE5haKq6Grfs= +github.com/onsi/ginkgo/v2 v2.31.0/go.mod h1:+aXOY+vzZ5mu2iI2HpTZUPmM//oQfsNFX6gU9kNcA44= github.com/onsi/gomega v1.42.0 h1:CJby8u36xb7v34W78F8WKvqTQP7PCMIPB78IVDB73l4= github.com/onsi/gomega v1.42.0/go.mod h1:M/Uqpu/8qTjtzCLUA2zJHX9Iilrau25x1PdoSRbWh5A= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= @@ -356,8 +356,8 @@ github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UH github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk= github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE= -github.com/prometheus/common v0.69.0 h1:OA85nJQS/T/MaYh/Q2CcgDKSGWqNIgrBDvDH85CuiNk= -github.com/prometheus/common v0.69.0/go.mod h1:ZzL3f6u94qUxh9p+tJTrF+FvBS1XXbbRAZCQkytAL0Y= +github.com/prometheus/common v0.68.1 h1:omjRRl4QP4komogpXuhfeOiisQg7xdy8VM1UY+pStaY= +github.com/prometheus/common v0.68.1/go.mod h1:ZzL3f6u94qUxh9p+tJTrF+FvBS1XXbbRAZCQkytAL0Y= github.com/prometheus/otlptranslator v1.0.0 h1:s0LJW/iN9dkIH+EnhiD3BlkkP5QVIUVEoIwkU+A6qos= github.com/prometheus/otlptranslator v1.0.0/go.mod h1:vRYWnXvI6aWGpsdY/mOT/cbeVRBlPWtBNDb7kGR3uKM= github.com/prometheus/procfs v0.20.1 h1:XwbrGOIplXW/AU3YhIhLODXMJYyC1isLFfYCsTEycfc= @@ -635,32 +635,32 @@ gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q= gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -k8s.io/api v0.36.2 h1:TF6YDLIzKfccK7cq9YpTcGX8TJmEkHVRv78DM51fRYY= -k8s.io/api v0.36.2/go.mod h1:F4LbMO4brjZYh7yFkXWhynSvtB7YauxV4c+HHkNRGNg= -k8s.io/apiextensions-apiserver v0.36.2 h1:3O5gqOj/dt2XWWbpMe+TXWpE9yU6pjM/tXxtHHJT/K4= -k8s.io/apiextensions-apiserver v0.36.2/go.mod h1:cL1tBWe8XSaP1H30iWKGo7hf6iAUUUJPEU70dskmAnA= -k8s.io/apimachinery v0.36.2 h1:0PE/W/WNy1UX61NLbXY5TMbJ6UwLL6E6lAPkYrKFxbQ= -k8s.io/apimachinery v0.36.2/go.mod h1:fvf/HOLXq9RId0rnDIbN1OEBvHXdQbLMM8nu0LcBUf4= -k8s.io/apiserver v0.36.2 h1:6vMnkmHZPeBloNkHUhmZYq7Ylv8WIB8xjyEl+eSt26E= -k8s.io/apiserver v0.36.2/go.mod h1:9PoQ2ikCytrZyZg11mGhLEF5m8Rgsb5FJmYJ4Wvnl1k= -k8s.io/client-go v0.36.2 h1:bfgxmFKc9CgqsgX4xKLAAdmTQlWee7Ob/HlDOrJ5TBI= -k8s.io/client-go v0.36.2/go.mod h1:1vgO4OAlfPnoLcb+Rze2GF5rAr14w8qjrYMoyXJzQj0= -k8s.io/code-generator v0.36.2 h1:iBNFYhClojQaVrF99Z3iTAad7LztQh3yCtwR8L8Ocpg= -k8s.io/code-generator v0.36.2/go.mod h1:IfnsRW1IAq9iPxqs/FfOnVnWWONxS2mPDvWNR4fPlzI= -k8s.io/component-base v0.36.2 h1:Z0VH80O7Ng0HDZnZj3WRR3urEGa0kTwmO8CwEwjVK1w= -k8s.io/component-base v0.36.2/go.mod h1:mGfFOA7Gwpdm1VW2cwSQYbiDIlz8GD2WGwH88QSeCyA= +k8s.io/api v0.36.1 h1:XbL/EMj8K2aJpJtePmqUyQMsM0D4QI2pvl7YKJ20FTY= +k8s.io/api v0.36.1/go.mod h1:KOWo4ey3TINlXjeHVuwB3i+tXXnu+UcwFBHlI/9dvEo= +k8s.io/apiextensions-apiserver v0.36.1 h1:6JfYmPUsuUIHuN+3QxutXYWj492RqF5fBSx67GYK5Ks= +k8s.io/apiextensions-apiserver v0.36.1/go.mod h1:pLzZin90riwisdzKwv/GoTwENooytoIx5zWJb4Hkby8= +k8s.io/apimachinery v0.36.1 h1:G63Gjx2W+q0YD+72Vo8oY0nDnePVwnuzTmmy5ENrVSA= +k8s.io/apimachinery v0.36.1/go.mod h1:ibYOR00vW/I1kzvi5SF0dRuJ52BvKtfvRdOn35GPQ+8= +k8s.io/apiserver v0.36.1 h1:iMS5V+rPUertv5P9RaqJgmHHTuh4quWpoxchvMUY+JY= +k8s.io/apiserver v0.36.1/go.mod h1:Cby1PbLWztu0GDOxoO6iFOyyqIsziHNEW+w9zVQ22Kw= +k8s.io/client-go v0.36.1 h1:FN/K8QIT2CEDt+2WB2HnWrUANZ50AP5GII43/SP2JR0= +k8s.io/client-go v0.36.1/go.mod h1:s6rAnCtTGYDQnpNjEhSaISV+2O8jwruZ6m3QOYBFbtU= +k8s.io/code-generator v0.36.1 h1:5bHQ7NbBcFFLHcoyo/hgU3m2tQV5RLz2nv4QNDlsbXc= +k8s.io/code-generator v0.36.1/go.mod h1:oCv8WmrW2RGdcMyvSk1aYbBfSs51ggtSFQr1YNeuAuo= +k8s.io/component-base v0.36.1 h1:iG6GsELftXqTNG9HG6kiVjatSgAw1sf5pJ6R5a6N0kA= +k8s.io/component-base v0.36.1/go.mod h1:nf9XPlntRdqO6WMeEWAA5F93Y4ICZQdeT9GeqLDB3JI= k8s.io/gengo/v2 v2.0.0-20250922181213-ec3ebc5fd46b h1:gMplByicHV/TJBizHd9aVEsTYoJBnnUAT5MHlTkbjhQ= k8s.io/gengo/v2 v2.0.0-20250922181213-ec3ebc5fd46b/go.mod h1:CgujABENc3KuTrcsdpGmrrASjtQsWCT7R99mEV4U/fM= k8s.io/klog/v2 v2.140.0 h1:Tf+J3AH7xnUzZyVVXhTgGhEKnFqye14aadWv7bzXdzc= k8s.io/klog/v2 v2.140.0/go.mod h1:o+/RWfJ6PwpnFn7OyAG3QnO47BFsymfEfrz6XyYSSp0= -k8s.io/kms v0.36.2 h1:o0l8zMRecm38k5NyRnO/3+2YA/MR6TMGcc3KQZA76hI= -k8s.io/kms v0.36.2/go.mod h1:g91diTD9h0oJCCHkTb00krlF+Qm5HTnkWLi9Q/TpRoc= -k8s.io/kube-aggregator v0.36.2 h1:zfeH9Fs16oDquNfBZef3M27dGG3QtJ9/TwkWfBlw1lo= -k8s.io/kube-aggregator v0.36.2/go.mod h1:UMrB5DfEhznFTf0bqYW2SV26GDy8HNaxoYakvKVWZ8M= +k8s.io/kms v0.36.1 h1:XdvKpywoW4k7YUHDh5uYP4mahJXECswHGfCddBBYLZs= +k8s.io/kms v0.36.1/go.mod h1:g91diTD9h0oJCCHkTb00krlF+Qm5HTnkWLi9Q/TpRoc= +k8s.io/kube-aggregator v0.36.1 h1:IzNeRsJcTtgsiCyTgCR1pSwWCrXC1QZQWMTcBw18cFQ= +k8s.io/kube-aggregator v0.36.1/go.mod h1:ROrIm5irUhVUJsKVCgBAAcXpK5IiqpdCn0Ka7LYMGs4= k8s.io/kube-openapi v0.0.0-20260427204847-8949caaa1199 h1:sWu4Td5mgJlwunsUydnhKEAfNUHM7hm1wfKEQmD7G5c= k8s.io/kube-openapi v0.0.0-20260427204847-8949caaa1199/go.mod h1:uGBT7iTA6c6MvqUvSXIaYZo9ukscABYi2btjhvgKGZ0= -k8s.io/streaming v0.36.2 h1:NSKthPPg9UFSKsRauVJUVGH2Dvn8fhKmY4qrMkw/p98= -k8s.io/streaming v0.36.2/go.mod h1:z6fV3D+NVkoeqRMtWwlUZK6U17SY/LqNzOxWL6GyR/s= +k8s.io/streaming v0.36.1 h1:L+K68n4Gg940BGNNYtUBvL1WTLL0YnKT3s+P1MNAmR4= +k8s.io/streaming v0.36.1/go.mod h1:z6fV3D+NVkoeqRMtWwlUZK6U17SY/LqNzOxWL6GyR/s= k8s.io/utils v0.0.0-20260319190234-28399d86e0b5 h1:kBawHLSnx/mYHmRnNUf9d4CpjREbeZuxoSGOX/J+aYM= k8s.io/utils v0.0.0-20260319190234-28399d86e0b5/go.mod h1:xDxuJ0whA3d0I4mf/C4ppKHxXynQ+fxnkmQH0vTHnuk= oras.land/oras-go/v2 v2.6.1 h1:bonOEkjLfp8tt6qXWRRWP6p1F+9octchOf2EqnWB4Zs= diff --git a/staging/operator-lifecycle-manager/pkg/controller/operators/decorators/operator.go b/staging/operator-lifecycle-manager/pkg/controller/operators/decorators/operator.go index 5a21320e6f..56b9c92b67 100644 --- a/staging/operator-lifecycle-manager/pkg/controller/operators/decorators/operator.go +++ b/staging/operator-lifecycle-manager/pkg/controller/operators/decorators/operator.go @@ -5,8 +5,8 @@ import ( "sort" "strings" - "github.com/go-viper/mapstructure/v2" "github.com/itchyny/gojq" + "github.com/mitchellh/mapstructure" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/staging/operator-lifecycle-manager/pkg/lib/codec/mapstructure.go b/staging/operator-lifecycle-manager/pkg/lib/codec/mapstructure.go index 341f7eea47..c021b143bc 100644 --- a/staging/operator-lifecycle-manager/pkg/lib/codec/mapstructure.go +++ b/staging/operator-lifecycle-manager/pkg/lib/codec/mapstructure.go @@ -4,7 +4,7 @@ import ( "reflect" "time" - "github.com/go-viper/mapstructure/v2" + "github.com/mitchellh/mapstructure" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) diff --git a/staging/operator-lifecycle-manager/pkg/lib/comparison/equal.go b/staging/operator-lifecycle-manager/pkg/lib/comparison/equal.go index d1d7f84bc7..bccbaaa8a3 100644 --- a/staging/operator-lifecycle-manager/pkg/lib/comparison/equal.go +++ b/staging/operator-lifecycle-manager/pkg/lib/comparison/equal.go @@ -3,7 +3,7 @@ package comparison import ( // "fmt" - "github.com/mitchellh/hashstructure/v2" + "github.com/mitchellh/hashstructure" ) // Equalitor describes an algorithm for equivalence between two data structures. @@ -25,12 +25,12 @@ func (e EqualFunc) Equal(a, b interface{}) bool { // This function panics if an error is encountered generating a hash for either argument. func NewHashEqualitor() EqualFunc { return func(a, b interface{}) bool { - hashA, err := hashstructure.Hash(a, hashstructure.FormatV2, nil) + hashA, err := hashstructure.Hash(a, nil) if err != nil { panic(err.Error()) } - hashB, err := hashstructure.Hash(b, hashstructure.FormatV2, nil) + hashB, err := hashstructure.Hash(b, nil) if err != nil { panic(err.Error()) } diff --git a/staging/operator-lifecycle-manager/pkg/package-server/server/server.go b/staging/operator-lifecycle-manager/pkg/package-server/server/server.go index a6e8a3216c..81ea882c78 100644 --- a/staging/operator-lifecycle-manager/pkg/package-server/server/server.go +++ b/staging/operator-lifecycle-manager/pkg/package-server/server/server.go @@ -23,18 +23,13 @@ import ( "k8s.io/client-go/tools/clientcmd" "k8s.io/client-go/util/workqueue" - configv1client "github.com/openshift/client-go/config/clientset/versioned" - libcrypto "github.com/openshift/library-go/pkg/crypto" operatorsv1 "github.com/operator-framework/api/pkg/operators/v1" "github.com/operator-framework/operator-lifecycle-manager/pkg/api/client" olminformers "github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/informers/externalversions" - olmapiserver "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/apiserver" - "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/openshiftconfig" "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/queueinformer" "github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apiserver" genericpackageserver "github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apiserver/generic" "github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/provider" - apidiscovery "k8s.io/client-go/discovery" ) const DefaultWakeupInterval = 12 * time.Hour @@ -207,13 +202,19 @@ func (o *PackageServerOptions) Run(ctx context.Context) error { string(genericfeatures.UnauthenticatedHTTP2DOSMitigation): true, }) - // Set up the client config before calling Config() so it can be used to - // apply the cluster TLS security profile to the serving options. + // Grab the config for the API server + config, err := o.Config(ctx) + if err != nil { + return err + } + config.GenericConfig.EnableMetrics = true + + // Set up the client config var clientConfig *rest.Config - var err error if len(o.Kubeconfig) > 0 { loadingRules := &clientcmd.ClientConfigLoadingRules{ExplicitPath: o.Kubeconfig} loader := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loadingRules, &clientcmd.ConfigOverrides{}) + clientConfig, err = loader.ClientConfig() } else { clientConfig, err = rest.InClusterConfig() @@ -222,23 +223,6 @@ func (o *PackageServerOptions) Run(ctx context.Context) error { return fmt.Errorf("unable to construct lister client config: %v", err) } - // If --tls-min-version was not supplied (e.g. no PSM-injected flags yet), fall - // back to a direct GET of the cluster APIServer CR so the packageserver still - // honours the cluster TLS security profile on first boot or during upgrades. - if o.SecureServing.MinTLSVersion == "" { - if err := applyClusterTLSProfile(ctx, clientConfig, o.SecureServing); err != nil { - return fmt.Errorf("failed to apply cluster TLS profile to serving options: %w", err) - } - } - - // Grab the config for the API server - var config *apiserver.Config - config, err = o.Config(ctx) - if err != nil { - return err - } - config.GenericConfig.EnableMetrics = true - kubeClient, err := kubernetes.NewForConfig(clientConfig) if err != nil { return fmt.Errorf("unable to construct lister client: %v", err) @@ -342,58 +326,3 @@ func (op *Operator) syncOLMConfig(obj interface{}) error { return nil } - -// applyClusterTLSProfile fetches the cluster-wide APIServer TLS security profile -// and applies it to the SecureServingOptions. It is a no-op on non-OpenShift clusters. -// This is the fallback path used when --tls-min-version is not provided via flags -// (i.e. before the PSM has had a chance to inject them). -func applyClusterTLSProfile(ctx context.Context, config *rest.Config, serving *genericoptions.SecureServingOptionsWithLoopback) error { - const lookupTimeout = 30 * time.Second - profileCtx, cancel := context.WithTimeout(ctx, lookupTimeout) - defer cancel() - - profileConfig := rest.CopyConfig(config) - if profileConfig.Timeout == 0 || profileConfig.Timeout > lookupTimeout { - profileConfig.Timeout = lookupTimeout - } - - kubeClient, err := kubernetes.NewForConfig(profileConfig) - if err != nil { - return fmt.Errorf("failed to create kubernetes client: %w", err) - } - cfgClient, err := configv1client.NewForConfig(profileConfig) - if err != nil { - return fmt.Errorf("failed to create config client: %w", err) - } - return applyClusterTLSProfileWithClients(profileCtx, kubeClient.Discovery(), cfgClient, serving) -} - -// applyClusterTLSProfileWithClients is the testable core of applyClusterTLSProfile. -// It applies the cluster-wide APIServer TLS security profile to the SecureServingOptions, -// but only for fields not already set by explicit flags (--tls-min-version / --tls-cipher-suites). -// It is a no-op on non-OpenShift clusters. -func applyClusterTLSProfileWithClients(ctx context.Context, discovery apidiscovery.DiscoveryInterface, cfgClient configv1client.Interface, serving *genericoptions.SecureServingOptionsWithLoopback) error { - available, err := openshiftconfig.IsAPIAvailable(discovery) - if err != nil { - return fmt.Errorf("failed to check OpenShift config API: %w", err) - } - if !available { - return nil - } - - apiServer, err := cfgClient.ConfigV1().APIServers().Get(ctx, "cluster", metav1.GetOptions{}) - if err != nil { - return fmt.Errorf("failed to get APIServer config: %w", err) - } - - minVersion, cipherSuites := olmapiserver.GetSecurityProfileConfig(apiServer.Spec.TLSSecurityProfile) - // Only override fields not already set by explicit flags. - if serving.MinTLSVersion == "" { - serving.MinTLSVersion = libcrypto.TLSVersionToNameOrDie(minVersion) - } - if len(serving.CipherSuites) == 0 { - serving.CipherSuites = libcrypto.CipherSuitesToNamesOrDie(cipherSuites) - } - log.Infof("Applying cluster TLS security profile: minVersion=%s cipherSuites=%v", serving.MinTLSVersion, serving.CipherSuites) - return nil -} diff --git a/staging/operator-lifecycle-manager/pkg/package-server/server/server_test.go b/staging/operator-lifecycle-manager/pkg/package-server/server/server_test.go deleted file mode 100644 index 27a7e1fefb..0000000000 --- a/staging/operator-lifecycle-manager/pkg/package-server/server/server_test.go +++ /dev/null @@ -1,132 +0,0 @@ -package server - -import ( - "context" - "testing" - - apiconfigv1 "github.com/openshift/api/config/v1" - configfake "github.com/openshift/client-go/config/clientset/versioned/fake" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - genericoptions "k8s.io/apiserver/pkg/server/options" - fakediscovery "k8s.io/client-go/discovery/fake" - k8sfake "k8s.io/client-go/kubernetes/fake" -) - -// clusterAPIServer returns a minimal APIServer singleton with the given TLS profile. -func clusterAPIServer(profile *apiconfigv1.TLSSecurityProfile) *apiconfigv1.APIServer { - return &apiconfigv1.APIServer{ - ObjectMeta: metav1.ObjectMeta{Name: "cluster"}, - Spec: apiconfigv1.APIServerSpec{TLSSecurityProfile: profile}, - } -} - -func newServing() *genericoptions.SecureServingOptionsWithLoopback { - return genericoptions.NewSecureServingOptions().WithLoopback() -} - -// nonOpenShiftDiscovery returns a fake discovery that advertises only core k8s -// groups — no config.openshift.io — simulating a vanilla Kubernetes cluster. -func nonOpenShiftDiscovery() *fakediscovery.FakeDiscovery { - k8sClient := k8sfake.NewSimpleClientset() - disc := k8sClient.Discovery().(*fakediscovery.FakeDiscovery) - // Set a non-empty resource list so ServerGroups doesn't return an empty - // list (which ServerSupportsVersion treats as "all supported"). - disc.Resources = []*metav1.APIResourceList{ - {GroupVersion: "v1"}, - } - return disc -} - -// TestApplyClusterTLSProfileWithClients_NonOpenShift verifies that the function -// is a no-op when the OpenShift config API is not present (vanilla Kubernetes). -func TestApplyClusterTLSProfileWithClients_NonOpenShift(t *testing.T) { - cfgClient := configfake.NewSimpleClientset() - serving := newServing() - - err := applyClusterTLSProfileWithClients(context.Background(), nonOpenShiftDiscovery(), cfgClient, serving) - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - if serving.MinTLSVersion != "" { - t.Errorf("expected MinTLSVersion to be unset, got %q", serving.MinTLSVersion) - } - if len(serving.CipherSuites) != 0 { - t.Errorf("expected CipherSuites to be unset, got %v", serving.CipherSuites) - } -} - -// TestApplyClusterTLSProfileWithClients_IntermediateProfile verifies that the -// Intermediate TLS profile populates MinTLSVersion and CipherSuites. -func TestApplyClusterTLSProfileWithClients_IntermediateProfile(t *testing.T) { - apiServer := clusterAPIServer(&apiconfigv1.TLSSecurityProfile{ - Type: apiconfigv1.TLSProfileIntermediateType, - }) - cfgClient := configfake.NewSimpleClientset(apiServer) - serving := newServing() - - err := applyClusterTLSProfileWithClients(context.Background(), cfgClient.Discovery(), cfgClient, serving) - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - if serving.MinTLSVersion == "" { - t.Error("expected MinTLSVersion to be set for Intermediate profile") - } - if len(serving.CipherSuites) == 0 { - t.Error("expected CipherSuites to be set for Intermediate profile") - } -} - -// TestApplyClusterTLSProfileWithClients_ModernProfile verifies that the Modern -// profile sets MinTLSVersion to VersionTLS13. -func TestApplyClusterTLSProfileWithClients_ModernProfile(t *testing.T) { - apiServer := clusterAPIServer(&apiconfigv1.TLSSecurityProfile{ - Type: apiconfigv1.TLSProfileModernType, - }) - cfgClient := configfake.NewSimpleClientset(apiServer) - serving := newServing() - - err := applyClusterTLSProfileWithClients(context.Background(), cfgClient.Discovery(), cfgClient, serving) - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - if serving.MinTLSVersion != "VersionTLS13" { - t.Errorf("expected MinTLSVersion=VersionTLS13 for Modern profile, got %q", serving.MinTLSVersion) - } -} - -// TestApplyClusterTLSProfileWithClients_FlagsTakePrecedence verifies that -// explicitly set flags are not overwritten by the cluster profile. -func TestApplyClusterTLSProfileWithClients_FlagsTakePrecedence(t *testing.T) { - apiServer := clusterAPIServer(&apiconfigv1.TLSSecurityProfile{ - Type: apiconfigv1.TLSProfileModernType, - }) - cfgClient := configfake.NewSimpleClientset(apiServer) - serving := newServing() - // Simulate user-supplied flags. - serving.MinTLSVersion = "VersionTLS12" - serving.CipherSuites = []string{"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"} - - err := applyClusterTLSProfileWithClients(context.Background(), cfgClient.Discovery(), cfgClient, serving) - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - if serving.MinTLSVersion != "VersionTLS12" { - t.Errorf("user-supplied MinTLSVersion should not be overwritten, got %q", serving.MinTLSVersion) - } - if len(serving.CipherSuites) != 1 || serving.CipherSuites[0] != "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" { - t.Errorf("user-supplied CipherSuites should not be overwritten, got %v", serving.CipherSuites) - } -} - -// TestApplyClusterTLSProfileWithClients_MissingAPIServerCR verifies that a -// missing singleton APIServer CR propagates as an error (fail-closed). -func TestApplyClusterTLSProfileWithClients_MissingAPIServerCR(t *testing.T) { - // config client advertises the API group but has no APIServer object - cfgClient := configfake.NewSimpleClientset() - serving := newServing() - - err := applyClusterTLSProfileWithClients(context.Background(), cfgClient.Discovery(), cfgClient, serving) - if err == nil { - t.Fatal("expected an error when the APIServer CR is missing, got nil") - } -} diff --git a/vendor/github.com/containerd/containerd/labels/labels.go b/vendor/github.com/containerd/containerd/labels/labels.go index ba4c245e45..0f9bab5c5d 100644 --- a/vendor/github.com/containerd/containerd/labels/labels.go +++ b/vendor/github.com/containerd/containerd/labels/labels.go @@ -16,18 +16,6 @@ package labels -// ReservedPrefix is the prefix of the label namespace reserved for labels -// defined and consumed by containerd itself. Labels in this namespace must -// not be copied from untrusted sources such as image config labels. Use -// IsReserved to check for such labels. -const ReservedPrefix = "containerd.io/" - -// CRIContainerdPrefix is the prefix of the label namespace reserved for -// labels defined and consumed by containerd's CRI plugin. Labels in this -// namespace must not be copied from untrusted sources such as image config -// labels. Use IsReserved to check for such labels. -const CRIContainerdPrefix = "io.cri-containerd" - // LabelUncompressed is added to compressed layer contents. // The value is digest of the uncompressed content. const LabelUncompressed = "containerd.io/uncompressed" diff --git a/vendor/github.com/containerd/containerd/labels/validate.go b/vendor/github.com/containerd/containerd/labels/validate.go index 18c2857392..f83b5dde29 100644 --- a/vendor/github.com/containerd/containerd/labels/validate.go +++ b/vendor/github.com/containerd/containerd/labels/validate.go @@ -18,7 +18,6 @@ package labels import ( "fmt" - "strings" "github.com/containerd/containerd/errdefs" ) @@ -40,11 +39,3 @@ func Validate(k, v string) error { } return nil } - -// IsReserved returns true if the label key is in a namespace reserved for -// containerd (ReservedPrefix) or its CRI plugin (CRIContainerdPrefix). -// Reserved labels are interpreted by containerd and must not be copied from -// untrusted sources such as image config labels. -func IsReserved(k string) bool { - return strings.HasPrefix(k, ReservedPrefix) || strings.HasPrefix(k, CRIContainerdPrefix) -} diff --git a/vendor/github.com/containerd/containerd/version/version.go b/vendor/github.com/containerd/containerd/version/version.go index ab00acab9d..9957bbc3ce 100644 --- a/vendor/github.com/containerd/containerd/version/version.go +++ b/vendor/github.com/containerd/containerd/version/version.go @@ -23,7 +23,7 @@ var ( Package = "github.com/containerd/containerd" // Version holds the complete version number. Filled in at linking time. - Version = "1.7.33+unknown" + Version = "1.7.32+unknown" // Revision is filled with the VCS (e.g. git) revision being used to build // the program at linking time. diff --git a/vendor/github.com/go-viper/mapstructure/v2/.editorconfig b/vendor/github.com/go-viper/mapstructure/v2/.editorconfig deleted file mode 100644 index c37602a02d..0000000000 --- a/vendor/github.com/go-viper/mapstructure/v2/.editorconfig +++ /dev/null @@ -1,24 +0,0 @@ -root = true - -[*] -charset = utf-8 -end_of_line = lf -indent_size = 4 -indent_style = space -insert_final_newline = true -trim_trailing_whitespace = true - -[*.go] -indent_style = tab - -[{Makefile,*.mk}] -indent_style = tab - -[*.nix] -indent_size = 2 - -[.golangci.yaml] -indent_size = 2 - -[devenv.yaml] -indent_size = 2 diff --git a/vendor/github.com/go-viper/mapstructure/v2/.envrc b/vendor/github.com/go-viper/mapstructure/v2/.envrc deleted file mode 100644 index e2be8891cb..0000000000 --- a/vendor/github.com/go-viper/mapstructure/v2/.envrc +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -export DIRENV_WARN_TIMEOUT=20s - -eval "$(devenv direnvrc)" - -use devenv diff --git a/vendor/github.com/go-viper/mapstructure/v2/.gitignore b/vendor/github.com/go-viper/mapstructure/v2/.gitignore deleted file mode 100644 index 71caea19ff..0000000000 --- a/vendor/github.com/go-viper/mapstructure/v2/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/bin/ -/build/ -/var/ - -# Devenv -.devenv* -devenv.local.nix -devenv.local.yaml -.direnv -.pre-commit-config.yaml diff --git a/vendor/github.com/go-viper/mapstructure/v2/.golangci.yaml b/vendor/github.com/go-viper/mapstructure/v2/.golangci.yaml deleted file mode 100644 index bda9625668..0000000000 --- a/vendor/github.com/go-viper/mapstructure/v2/.golangci.yaml +++ /dev/null @@ -1,48 +0,0 @@ -version: "2" - -run: - timeout: 10m - -linters: - enable: - - govet - - ineffassign - # - misspell - - nolintlint - # - revive - - disable: - - errcheck - - staticcheck - - unused - - settings: - misspell: - locale: US - nolintlint: - allow-unused: false # report any unused nolint directives - require-specific: false # don't require nolint directives to be specific about which linter is being skipped - -formatters: - enable: - - gci - - gofmt - - gofumpt - - goimports - # - golines - - settings: - gci: - sections: - - standard - - default - - localmodule - gofmt: - simplify: true - rewrite-rules: - - pattern: interface{} - replacement: any - - exclusions: - paths: - - internal/ diff --git a/vendor/github.com/go-viper/mapstructure/v2/README.md b/vendor/github.com/go-viper/mapstructure/v2/README.md deleted file mode 100644 index 45db719755..0000000000 --- a/vendor/github.com/go-viper/mapstructure/v2/README.md +++ /dev/null @@ -1,81 +0,0 @@ -# mapstructure - -[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/go-viper/mapstructure/ci.yaml?style=flat-square)](https://github.com/go-viper/mapstructure/actions/workflows/ci.yaml) -[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=flat-square)](https://pkg.go.dev/mod/github.com/go-viper/mapstructure/v2) -![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/go-viper/mapstructure?style=flat-square&color=61CFDD) -[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/go-viper/mapstructure/badge?style=flat-square)](https://deps.dev/go/github.com%252Fgo-viper%252Fmapstructure%252Fv2) - -mapstructure is a Go library for decoding generic map values to structures -and vice versa, while providing helpful error handling. - -This library is most useful when decoding values from some data stream (JSON, -Gob, etc.) where you don't _quite_ know the structure of the underlying data -until you read a part of it. You can therefore read a `map[string]interface{}` -and use this library to decode it into the proper underlying native Go -structure. - -## Installation - -```shell -go get github.com/go-viper/mapstructure/v2 -``` - -## Migrating from `github.com/mitchellh/mapstructure` - -[@mitchehllh](https://github.com/mitchellh) announced his intent to archive some of his unmaintained projects (see [here](https://gist.github.com/mitchellh/90029601268e59a29e64e55bab1c5bdc) and [here](https://github.com/mitchellh/mapstructure/issues/349)). This is a repository achieved the "blessed fork" status. - -You can migrate to this package by changing your import paths in your Go files to `github.com/go-viper/mapstructure/v2`. -The API is the same, so you don't need to change anything else. - -Here is a script that can help you with the migration: - -```shell -sed -i 's|github.com/mitchellh/mapstructure|github.com/go-viper/mapstructure/v2|g' $(find . -type f -name '*.go') -``` - -If you need more time to migrate your code, that is absolutely fine. - -Some of the latest fixes are backported to the v1 release branch of this package, so you can use the Go modules `replace` feature until you are ready to migrate: - -```shell -replace github.com/mitchellh/mapstructure => github.com/go-viper/mapstructure v1.6.0 -``` - -## Usage & Example - -For usage and examples see the [documentation](https://pkg.go.dev/mod/github.com/go-viper/mapstructure/v2). - -The `Decode` function has examples associated with it there. - -## But Why?! - -Go offers fantastic standard libraries for decoding formats such as JSON. -The standard method is to have a struct pre-created, and populate that struct -from the bytes of the encoded format. This is great, but the problem is if -you have configuration or an encoding that changes slightly depending on -specific fields. For example, consider this JSON: - -```json -{ - "type": "person", - "name": "Mitchell" -} -``` - -Perhaps we can't populate a specific structure without first reading -the "type" field from the JSON. We could always do two passes over the -decoding of the JSON (reading the "type" first, and the rest later). -However, it is much simpler to just decode this into a `map[string]interface{}` -structure, read the "type" key, then use something like this library -to decode it into the proper structure. - -## Credits - -Mapstructure was originally created by [@mitchellh](https://github.com/mitchellh). -This is a maintained fork of the original library. - -Read more about the reasons for the fork [here](https://github.com/mitchellh/mapstructure/issues/349). - -## License - -The project is licensed under the [MIT License](LICENSE). diff --git a/vendor/github.com/go-viper/mapstructure/v2/decode_hooks.go b/vendor/github.com/go-viper/mapstructure/v2/decode_hooks.go deleted file mode 100644 index a852a0a04c..0000000000 --- a/vendor/github.com/go-viper/mapstructure/v2/decode_hooks.go +++ /dev/null @@ -1,714 +0,0 @@ -package mapstructure - -import ( - "encoding" - "errors" - "fmt" - "net" - "net/netip" - "net/url" - "reflect" - "strconv" - "strings" - "time" -) - -// typedDecodeHook takes a raw DecodeHookFunc (an any) and turns -// it into the proper DecodeHookFunc type, such as DecodeHookFuncType. -func typedDecodeHook(h DecodeHookFunc) DecodeHookFunc { - // Create variables here so we can reference them with the reflect pkg - var f1 DecodeHookFuncType - var f2 DecodeHookFuncKind - var f3 DecodeHookFuncValue - - // Fill in the variables into this interface and the rest is done - // automatically using the reflect package. - potential := []any{f1, f2, f3} - - v := reflect.ValueOf(h) - vt := v.Type() - for _, raw := range potential { - pt := reflect.ValueOf(raw).Type() - if vt.ConvertibleTo(pt) { - return v.Convert(pt).Interface() - } - } - - return nil -} - -// cachedDecodeHook takes a raw DecodeHookFunc (an any) and turns -// it into a closure to be used directly -// if the type fails to convert we return a closure always erroring to keep the previous behaviour -func cachedDecodeHook(raw DecodeHookFunc) func(from reflect.Value, to reflect.Value) (any, error) { - switch f := typedDecodeHook(raw).(type) { - case DecodeHookFuncType: - return func(from reflect.Value, to reflect.Value) (any, error) { - return f(from.Type(), to.Type(), from.Interface()) - } - case DecodeHookFuncKind: - return func(from reflect.Value, to reflect.Value) (any, error) { - return f(from.Kind(), to.Kind(), from.Interface()) - } - case DecodeHookFuncValue: - return func(from reflect.Value, to reflect.Value) (any, error) { - return f(from, to) - } - default: - return func(from reflect.Value, to reflect.Value) (any, error) { - return nil, errors.New("invalid decode hook signature") - } - } -} - -// DecodeHookExec executes the given decode hook. This should be used -// since it'll naturally degrade to the older backwards compatible DecodeHookFunc -// that took reflect.Kind instead of reflect.Type. -func DecodeHookExec( - raw DecodeHookFunc, - from reflect.Value, to reflect.Value, -) (any, error) { - switch f := typedDecodeHook(raw).(type) { - case DecodeHookFuncType: - return f(from.Type(), to.Type(), from.Interface()) - case DecodeHookFuncKind: - return f(from.Kind(), to.Kind(), from.Interface()) - case DecodeHookFuncValue: - return f(from, to) - default: - return nil, errors.New("invalid decode hook signature") - } -} - -// ComposeDecodeHookFunc creates a single DecodeHookFunc that -// automatically composes multiple DecodeHookFuncs. -// -// The composed funcs are called in order, with the result of the -// previous transformation. -func ComposeDecodeHookFunc(fs ...DecodeHookFunc) DecodeHookFunc { - cached := make([]func(from reflect.Value, to reflect.Value) (any, error), 0, len(fs)) - for _, f := range fs { - cached = append(cached, cachedDecodeHook(f)) - } - return func(f reflect.Value, t reflect.Value) (any, error) { - var err error - data := f.Interface() - - newFrom := f - for _, c := range cached { - data, err = c(newFrom, t) - if err != nil { - return nil, err - } - if v, ok := data.(reflect.Value); ok { - newFrom = v - } else { - newFrom = reflect.ValueOf(data) - } - } - - return data, nil - } -} - -// OrComposeDecodeHookFunc executes all input hook functions until one of them returns no error. In that case its value is returned. -// If all hooks return an error, OrComposeDecodeHookFunc returns an error concatenating all error messages. -func OrComposeDecodeHookFunc(ff ...DecodeHookFunc) DecodeHookFunc { - cached := make([]func(from reflect.Value, to reflect.Value) (any, error), 0, len(ff)) - for _, f := range ff { - cached = append(cached, cachedDecodeHook(f)) - } - return func(a, b reflect.Value) (any, error) { - var allErrs string - var out any - var err error - - for _, c := range cached { - out, err = c(a, b) - if err != nil { - allErrs += err.Error() + "\n" - continue - } - - return out, nil - } - - return nil, errors.New(allErrs) - } -} - -// StringToSliceHookFunc returns a DecodeHookFunc that converts -// string to []string by splitting on the given sep. -func StringToSliceHookFunc(sep string) DecodeHookFunc { - return func( - f reflect.Type, - t reflect.Type, - data any, - ) (any, error) { - if f.Kind() != reflect.String { - return data, nil - } - if t != reflect.SliceOf(f) { - return data, nil - } - - raw := data.(string) - if raw == "" { - return []string{}, nil - } - - return strings.Split(raw, sep), nil - } -} - -// StringToWeakSliceHookFunc brings back the old (pre-v2) behavior of [StringToSliceHookFunc]. -// -// As of mapstructure v2.0.0 [StringToSliceHookFunc] checks if the return type is a string slice. -// This function removes that check. -func StringToWeakSliceHookFunc(sep string) DecodeHookFunc { - return func( - f reflect.Type, - t reflect.Type, - data any, - ) (any, error) { - if f.Kind() != reflect.String || t.Kind() != reflect.Slice { - return data, nil - } - - raw := data.(string) - if raw == "" { - return []string{}, nil - } - - return strings.Split(raw, sep), nil - } -} - -// StringToTimeDurationHookFunc returns a DecodeHookFunc that converts -// strings to time.Duration. -func StringToTimeDurationHookFunc() DecodeHookFunc { - return func( - f reflect.Type, - t reflect.Type, - data any, - ) (any, error) { - if f.Kind() != reflect.String { - return data, nil - } - if t != reflect.TypeOf(time.Duration(5)) { - return data, nil - } - - // Convert it by parsing - d, err := time.ParseDuration(data.(string)) - - return d, wrapTimeParseDurationError(err) - } -} - -// StringToTimeLocationHookFunc returns a DecodeHookFunc that converts -// strings to *time.Location. -func StringToTimeLocationHookFunc() DecodeHookFunc { - return func( - f reflect.Type, - t reflect.Type, - data any, - ) (any, error) { - if f.Kind() != reflect.String { - return data, nil - } - if t != reflect.TypeOf(time.Local) { - return data, nil - } - d, err := time.LoadLocation(data.(string)) - - return d, wrapTimeParseLocationError(err) - } -} - -// StringToURLHookFunc returns a DecodeHookFunc that converts -// strings to *url.URL. -func StringToURLHookFunc() DecodeHookFunc { - return func( - f reflect.Type, - t reflect.Type, - data any, - ) (any, error) { - if f.Kind() != reflect.String { - return data, nil - } - if t != reflect.TypeOf(&url.URL{}) { - return data, nil - } - - // Convert it by parsing - u, err := url.Parse(data.(string)) - - return u, wrapUrlError(err) - } -} - -// StringToIPHookFunc returns a DecodeHookFunc that converts -// strings to net.IP -func StringToIPHookFunc() DecodeHookFunc { - return func( - f reflect.Type, - t reflect.Type, - data any, - ) (any, error) { - if f.Kind() != reflect.String { - return data, nil - } - if t != reflect.TypeOf(net.IP{}) { - return data, nil - } - - // Convert it by parsing - ip := net.ParseIP(data.(string)) - if ip == nil { - return net.IP{}, fmt.Errorf("failed parsing ip") - } - - return ip, nil - } -} - -// StringToIPNetHookFunc returns a DecodeHookFunc that converts -// strings to net.IPNet -func StringToIPNetHookFunc() DecodeHookFunc { - return func( - f reflect.Type, - t reflect.Type, - data any, - ) (any, error) { - if f.Kind() != reflect.String { - return data, nil - } - if t != reflect.TypeOf(net.IPNet{}) { - return data, nil - } - - // Convert it by parsing - _, net, err := net.ParseCIDR(data.(string)) - return net, wrapNetParseError(err) - } -} - -// StringToTimeHookFunc returns a DecodeHookFunc that converts -// strings to time.Time. -func StringToTimeHookFunc(layout string) DecodeHookFunc { - return func( - f reflect.Type, - t reflect.Type, - data any, - ) (any, error) { - if f.Kind() != reflect.String { - return data, nil - } - if t != reflect.TypeOf(time.Time{}) { - return data, nil - } - - // Convert it by parsing - ti, err := time.Parse(layout, data.(string)) - - return ti, wrapTimeParseError(err) - } -} - -// WeaklyTypedHook is a DecodeHookFunc which adds support for weak typing to -// the decoder. -// -// Note that this is significantly different from the WeaklyTypedInput option -// of the DecoderConfig. -func WeaklyTypedHook( - f reflect.Kind, - t reflect.Kind, - data any, -) (any, error) { - dataVal := reflect.ValueOf(data) - switch t { - case reflect.String: - switch f { - case reflect.Bool: - if dataVal.Bool() { - return "1", nil - } - return "0", nil - case reflect.Float32: - return strconv.FormatFloat(dataVal.Float(), 'f', -1, 64), nil - case reflect.Int: - return strconv.FormatInt(dataVal.Int(), 10), nil - case reflect.Slice: - dataType := dataVal.Type() - elemKind := dataType.Elem().Kind() - if elemKind == reflect.Uint8 { - return string(dataVal.Interface().([]uint8)), nil - } - case reflect.Uint: - return strconv.FormatUint(dataVal.Uint(), 10), nil - } - } - - return data, nil -} - -func RecursiveStructToMapHookFunc() DecodeHookFunc { - return func(f reflect.Value, t reflect.Value) (any, error) { - if f.Kind() != reflect.Struct { - return f.Interface(), nil - } - - var i any = struct{}{} - if t.Type() != reflect.TypeOf(&i).Elem() { - return f.Interface(), nil - } - - m := make(map[string]any) - t.Set(reflect.ValueOf(m)) - - return f.Interface(), nil - } -} - -// TextUnmarshallerHookFunc returns a DecodeHookFunc that applies -// strings to the UnmarshalText function, when the target type -// implements the encoding.TextUnmarshaler interface -func TextUnmarshallerHookFunc() DecodeHookFuncType { - return func( - f reflect.Type, - t reflect.Type, - data any, - ) (any, error) { - if f.Kind() != reflect.String { - return data, nil - } - result := reflect.New(t).Interface() - unmarshaller, ok := result.(encoding.TextUnmarshaler) - if !ok { - return data, nil - } - str, ok := data.(string) - if !ok { - str = reflect.Indirect(reflect.ValueOf(&data)).Elem().String() - } - if err := unmarshaller.UnmarshalText([]byte(str)); err != nil { - return nil, err - } - return result, nil - } -} - -// StringToNetIPAddrHookFunc returns a DecodeHookFunc that converts -// strings to netip.Addr. -func StringToNetIPAddrHookFunc() DecodeHookFunc { - return func( - f reflect.Type, - t reflect.Type, - data any, - ) (any, error) { - if f.Kind() != reflect.String { - return data, nil - } - if t != reflect.TypeOf(netip.Addr{}) { - return data, nil - } - - // Convert it by parsing - addr, err := netip.ParseAddr(data.(string)) - - return addr, wrapNetIPParseAddrError(err) - } -} - -// StringToNetIPAddrPortHookFunc returns a DecodeHookFunc that converts -// strings to netip.AddrPort. -func StringToNetIPAddrPortHookFunc() DecodeHookFunc { - return func( - f reflect.Type, - t reflect.Type, - data any, - ) (any, error) { - if f.Kind() != reflect.String { - return data, nil - } - if t != reflect.TypeOf(netip.AddrPort{}) { - return data, nil - } - - // Convert it by parsing - addrPort, err := netip.ParseAddrPort(data.(string)) - - return addrPort, wrapNetIPParseAddrPortError(err) - } -} - -// StringToNetIPPrefixHookFunc returns a DecodeHookFunc that converts -// strings to netip.Prefix. -func StringToNetIPPrefixHookFunc() DecodeHookFunc { - return func( - f reflect.Type, - t reflect.Type, - data any, - ) (any, error) { - if f.Kind() != reflect.String { - return data, nil - } - if t != reflect.TypeOf(netip.Prefix{}) { - return data, nil - } - - // Convert it by parsing - prefix, err := netip.ParsePrefix(data.(string)) - - return prefix, wrapNetIPParsePrefixError(err) - } -} - -// StringToBasicTypeHookFunc returns a DecodeHookFunc that converts -// strings to basic types. -// int8, uint8, int16, uint16, int32, uint32, int64, uint64, int, uint, float32, float64, bool, byte, rune, complex64, complex128 -func StringToBasicTypeHookFunc() DecodeHookFunc { - return ComposeDecodeHookFunc( - StringToInt8HookFunc(), - StringToUint8HookFunc(), - StringToInt16HookFunc(), - StringToUint16HookFunc(), - StringToInt32HookFunc(), - StringToUint32HookFunc(), - StringToInt64HookFunc(), - StringToUint64HookFunc(), - StringToIntHookFunc(), - StringToUintHookFunc(), - StringToFloat32HookFunc(), - StringToFloat64HookFunc(), - StringToBoolHookFunc(), - // byte and rune are aliases for uint8 and int32 respectively - // StringToByteHookFunc(), - // StringToRuneHookFunc(), - StringToComplex64HookFunc(), - StringToComplex128HookFunc(), - ) -} - -// StringToInt8HookFunc returns a DecodeHookFunc that converts -// strings to int8. -func StringToInt8HookFunc() DecodeHookFunc { - return func(f reflect.Type, t reflect.Type, data any) (any, error) { - if f.Kind() != reflect.String || t.Kind() != reflect.Int8 { - return data, nil - } - - // Convert it by parsing - i64, err := strconv.ParseInt(data.(string), 0, 8) - return int8(i64), wrapStrconvNumError(err) - } -} - -// StringToUint8HookFunc returns a DecodeHookFunc that converts -// strings to uint8. -func StringToUint8HookFunc() DecodeHookFunc { - return func(f reflect.Type, t reflect.Type, data any) (any, error) { - if f.Kind() != reflect.String || t.Kind() != reflect.Uint8 { - return data, nil - } - - // Convert it by parsing - u64, err := strconv.ParseUint(data.(string), 0, 8) - return uint8(u64), wrapStrconvNumError(err) - } -} - -// StringToInt16HookFunc returns a DecodeHookFunc that converts -// strings to int16. -func StringToInt16HookFunc() DecodeHookFunc { - return func(f reflect.Type, t reflect.Type, data any) (any, error) { - if f.Kind() != reflect.String || t.Kind() != reflect.Int16 { - return data, nil - } - - // Convert it by parsing - i64, err := strconv.ParseInt(data.(string), 0, 16) - return int16(i64), wrapStrconvNumError(err) - } -} - -// StringToUint16HookFunc returns a DecodeHookFunc that converts -// strings to uint16. -func StringToUint16HookFunc() DecodeHookFunc { - return func(f reflect.Type, t reflect.Type, data any) (any, error) { - if f.Kind() != reflect.String || t.Kind() != reflect.Uint16 { - return data, nil - } - - // Convert it by parsing - u64, err := strconv.ParseUint(data.(string), 0, 16) - return uint16(u64), wrapStrconvNumError(err) - } -} - -// StringToInt32HookFunc returns a DecodeHookFunc that converts -// strings to int32. -func StringToInt32HookFunc() DecodeHookFunc { - return func(f reflect.Type, t reflect.Type, data any) (any, error) { - if f.Kind() != reflect.String || t.Kind() != reflect.Int32 { - return data, nil - } - - // Convert it by parsing - i64, err := strconv.ParseInt(data.(string), 0, 32) - return int32(i64), wrapStrconvNumError(err) - } -} - -// StringToUint32HookFunc returns a DecodeHookFunc that converts -// strings to uint32. -func StringToUint32HookFunc() DecodeHookFunc { - return func(f reflect.Type, t reflect.Type, data any) (any, error) { - if f.Kind() != reflect.String || t.Kind() != reflect.Uint32 { - return data, nil - } - - // Convert it by parsing - u64, err := strconv.ParseUint(data.(string), 0, 32) - return uint32(u64), wrapStrconvNumError(err) - } -} - -// StringToInt64HookFunc returns a DecodeHookFunc that converts -// strings to int64. -func StringToInt64HookFunc() DecodeHookFunc { - return func(f reflect.Type, t reflect.Type, data any) (any, error) { - if f.Kind() != reflect.String || t.Kind() != reflect.Int64 { - return data, nil - } - - // Convert it by parsing - i64, err := strconv.ParseInt(data.(string), 0, 64) - return int64(i64), wrapStrconvNumError(err) - } -} - -// StringToUint64HookFunc returns a DecodeHookFunc that converts -// strings to uint64. -func StringToUint64HookFunc() DecodeHookFunc { - return func(f reflect.Type, t reflect.Type, data any) (any, error) { - if f.Kind() != reflect.String || t.Kind() != reflect.Uint64 { - return data, nil - } - - // Convert it by parsing - u64, err := strconv.ParseUint(data.(string), 0, 64) - return uint64(u64), wrapStrconvNumError(err) - } -} - -// StringToIntHookFunc returns a DecodeHookFunc that converts -// strings to int. -func StringToIntHookFunc() DecodeHookFunc { - return func(f reflect.Type, t reflect.Type, data any) (any, error) { - if f.Kind() != reflect.String || t.Kind() != reflect.Int { - return data, nil - } - - // Convert it by parsing - i64, err := strconv.ParseInt(data.(string), 0, 0) - return int(i64), wrapStrconvNumError(err) - } -} - -// StringToUintHookFunc returns a DecodeHookFunc that converts -// strings to uint. -func StringToUintHookFunc() DecodeHookFunc { - return func(f reflect.Type, t reflect.Type, data any) (any, error) { - if f.Kind() != reflect.String || t.Kind() != reflect.Uint { - return data, nil - } - - // Convert it by parsing - u64, err := strconv.ParseUint(data.(string), 0, 0) - return uint(u64), wrapStrconvNumError(err) - } -} - -// StringToFloat32HookFunc returns a DecodeHookFunc that converts -// strings to float32. -func StringToFloat32HookFunc() DecodeHookFunc { - return func(f reflect.Type, t reflect.Type, data any) (any, error) { - if f.Kind() != reflect.String || t.Kind() != reflect.Float32 { - return data, nil - } - - // Convert it by parsing - f64, err := strconv.ParseFloat(data.(string), 32) - return float32(f64), wrapStrconvNumError(err) - } -} - -// StringToFloat64HookFunc returns a DecodeHookFunc that converts -// strings to float64. -func StringToFloat64HookFunc() DecodeHookFunc { - return func(f reflect.Type, t reflect.Type, data any) (any, error) { - if f.Kind() != reflect.String || t.Kind() != reflect.Float64 { - return data, nil - } - - // Convert it by parsing - f64, err := strconv.ParseFloat(data.(string), 64) - return f64, wrapStrconvNumError(err) - } -} - -// StringToBoolHookFunc returns a DecodeHookFunc that converts -// strings to bool. -func StringToBoolHookFunc() DecodeHookFunc { - return func(f reflect.Type, t reflect.Type, data any) (any, error) { - if f.Kind() != reflect.String || t.Kind() != reflect.Bool { - return data, nil - } - - // Convert it by parsing - b, err := strconv.ParseBool(data.(string)) - return b, wrapStrconvNumError(err) - } -} - -// StringToByteHookFunc returns a DecodeHookFunc that converts -// strings to byte. -func StringToByteHookFunc() DecodeHookFunc { - return StringToUint8HookFunc() -} - -// StringToRuneHookFunc returns a DecodeHookFunc that converts -// strings to rune. -func StringToRuneHookFunc() DecodeHookFunc { - return StringToInt32HookFunc() -} - -// StringToComplex64HookFunc returns a DecodeHookFunc that converts -// strings to complex64. -func StringToComplex64HookFunc() DecodeHookFunc { - return func(f reflect.Type, t reflect.Type, data any) (any, error) { - if f.Kind() != reflect.String || t.Kind() != reflect.Complex64 { - return data, nil - } - - // Convert it by parsing - c128, err := strconv.ParseComplex(data.(string), 64) - return complex64(c128), wrapStrconvNumError(err) - } -} - -// StringToComplex128HookFunc returns a DecodeHookFunc that converts -// strings to complex128. -func StringToComplex128HookFunc() DecodeHookFunc { - return func(f reflect.Type, t reflect.Type, data any) (any, error) { - if f.Kind() != reflect.String || t.Kind() != reflect.Complex128 { - return data, nil - } - - // Convert it by parsing - c128, err := strconv.ParseComplex(data.(string), 128) - return c128, wrapStrconvNumError(err) - } -} diff --git a/vendor/github.com/go-viper/mapstructure/v2/devenv.lock b/vendor/github.com/go-viper/mapstructure/v2/devenv.lock deleted file mode 100644 index 72c2c9b4db..0000000000 --- a/vendor/github.com/go-viper/mapstructure/v2/devenv.lock +++ /dev/null @@ -1,103 +0,0 @@ -{ - "nodes": { - "devenv": { - "locked": { - "dir": "src/modules", - "lastModified": 1765288076, - "owner": "cachix", - "repo": "devenv", - "rev": "93c055af1e8fcac49251f1b2e1c57f78620ad351", - "type": "github" - }, - "original": { - "dir": "src/modules", - "owner": "cachix", - "repo": "devenv", - "type": "github" - } - }, - "flake-compat": { - "flake": false, - "locked": { - "lastModified": 1765121682, - "owner": "edolstra", - "repo": "flake-compat", - "rev": "65f23138d8d09a92e30f1e5c87611b23ef451bf3", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, - "git-hooks": { - "inputs": { - "flake-compat": "flake-compat", - "gitignore": "gitignore", - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1765016596, - "owner": "cachix", - "repo": "git-hooks.nix", - "rev": "548fc44fca28a5e81c5d6b846e555e6b9c2a5a3c", - "type": "github" - }, - "original": { - "owner": "cachix", - "repo": "git-hooks.nix", - "type": "github" - } - }, - "gitignore": { - "inputs": { - "nixpkgs": [ - "git-hooks", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1762808025, - "owner": "hercules-ci", - "repo": "gitignore.nix", - "rev": "cb5e3fdca1de58ccbc3ef53de65bd372b48f567c", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "gitignore.nix", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1764580874, - "owner": "cachix", - "repo": "devenv-nixpkgs", - "rev": "dcf61356c3ab25f1362b4a4428a6d871e84f1d1d", - "type": "github" - }, - "original": { - "owner": "cachix", - "ref": "rolling", - "repo": "devenv-nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "devenv": "devenv", - "git-hooks": "git-hooks", - "nixpkgs": "nixpkgs", - "pre-commit-hooks": [ - "git-hooks" - ] - } - } - }, - "root": "root", - "version": 7 -} diff --git a/vendor/github.com/go-viper/mapstructure/v2/devenv.nix b/vendor/github.com/go-viper/mapstructure/v2/devenv.nix deleted file mode 100644 index b31ab7a1ff..0000000000 --- a/vendor/github.com/go-viper/mapstructure/v2/devenv.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ - pkgs, - ... -}: - -{ - languages = { - go.enable = true; - }; - - packages = with pkgs; [ - golangci-lint - ]; -} diff --git a/vendor/github.com/go-viper/mapstructure/v2/devenv.yaml b/vendor/github.com/go-viper/mapstructure/v2/devenv.yaml deleted file mode 100644 index 68616a49cd..0000000000 --- a/vendor/github.com/go-viper/mapstructure/v2/devenv.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# yaml-language-server: $schema=https://devenv.sh/devenv.schema.json -inputs: - nixpkgs: - url: github:cachix/devenv-nixpkgs/rolling diff --git a/vendor/github.com/go-viper/mapstructure/v2/errors.go b/vendor/github.com/go-viper/mapstructure/v2/errors.go deleted file mode 100644 index 07d31c22aa..0000000000 --- a/vendor/github.com/go-viper/mapstructure/v2/errors.go +++ /dev/null @@ -1,244 +0,0 @@ -package mapstructure - -import ( - "errors" - "fmt" - "net" - "net/url" - "reflect" - "strconv" - "strings" - "time" -) - -// Error interface is implemented by all errors emitted by mapstructure. -// -// Use [errors.As] to check if an error implements this interface. -type Error interface { - error - - mapstructure() -} - -// DecodeError is a generic error type that holds information about -// a decoding error together with the name of the field that caused the error. -type DecodeError struct { - name string - err error -} - -func newDecodeError(name string, err error) *DecodeError { - return &DecodeError{ - name: name, - err: err, - } -} - -func (e *DecodeError) Name() string { - return e.name -} - -func (e *DecodeError) Unwrap() error { - return e.err -} - -func (e *DecodeError) Error() string { - return fmt.Sprintf("'%s' %s", e.name, e.err) -} - -func (*DecodeError) mapstructure() {} - -// ParseError is an error type that indicates a value could not be parsed -// into the expected type. -type ParseError struct { - Expected reflect.Value - Value any - Err error -} - -func (e *ParseError) Error() string { - return fmt.Sprintf("cannot parse value as '%s': %s", e.Expected.Type(), e.Err) -} - -func (*ParseError) mapstructure() {} - -// UnconvertibleTypeError is an error type that indicates a value could not be -// converted to the expected type. -type UnconvertibleTypeError struct { - Expected reflect.Value - Value any -} - -func (e *UnconvertibleTypeError) Error() string { - return fmt.Sprintf( - "expected type '%s', got unconvertible type '%s'", - e.Expected.Type(), - reflect.TypeOf(e.Value), - ) -} - -func (*UnconvertibleTypeError) mapstructure() {} - -func wrapStrconvNumError(err error) error { - if err == nil { - return nil - } - - if err, ok := err.(*strconv.NumError); ok { - return &strconvNumError{Err: err} - } - - return err -} - -type strconvNumError struct { - Err *strconv.NumError -} - -func (e *strconvNumError) Error() string { - return "strconv." + e.Err.Func + ": " + e.Err.Err.Error() -} - -func (e *strconvNumError) Unwrap() error { return e.Err } - -func wrapUrlError(err error) error { - if err == nil { - return nil - } - - if err, ok := err.(*url.Error); ok { - return &urlError{Err: err} - } - - return err -} - -type urlError struct { - Err *url.Error -} - -func (e *urlError) Error() string { - return fmt.Sprintf("%s", e.Err.Err) -} - -func (e *urlError) Unwrap() error { return e.Err } - -func wrapNetParseError(err error) error { - if err == nil { - return nil - } - - if err, ok := err.(*net.ParseError); ok { - return &netParseError{Err: err} - } - - return err -} - -type netParseError struct { - Err *net.ParseError -} - -func (e *netParseError) Error() string { - return "invalid " + e.Err.Type -} - -func (e *netParseError) Unwrap() error { return e.Err } - -func wrapTimeParseError(err error) error { - if err == nil { - return nil - } - - if err, ok := err.(*time.ParseError); ok { - return &timeParseError{Err: err} - } - - return err -} - -type timeParseError struct { - Err *time.ParseError -} - -func (e *timeParseError) Error() string { - if e.Err.Message == "" { - return fmt.Sprintf("parsing time as %q: cannot parse as %q", e.Err.Layout, e.Err.LayoutElem) - } - - return "parsing time " + e.Err.Message -} - -func (e *timeParseError) Unwrap() error { return e.Err } - -func wrapNetIPParseAddrError(err error) error { - if err == nil { - return nil - } - - if errMsg := err.Error(); strings.HasPrefix(errMsg, "ParseAddr") { - errPieces := strings.Split(errMsg, ": ") - - return fmt.Errorf("ParseAddr: %s", errPieces[len(errPieces)-1]) - } - - return err -} - -func wrapNetIPParseAddrPortError(err error) error { - if err == nil { - return nil - } - - errMsg := err.Error() - if strings.HasPrefix(errMsg, "invalid port ") { - return errors.New("invalid port") - } else if strings.HasPrefix(errMsg, "invalid ip:port ") { - return errors.New("invalid ip:port") - } - - return err -} - -func wrapNetIPParsePrefixError(err error) error { - if err == nil { - return nil - } - - if errMsg := err.Error(); strings.HasPrefix(errMsg, "netip.ParsePrefix") { - errPieces := strings.Split(errMsg, ": ") - - return fmt.Errorf("netip.ParsePrefix: %s", errPieces[len(errPieces)-1]) - } - - return err -} - -func wrapTimeParseDurationError(err error) error { - if err == nil { - return nil - } - - errMsg := err.Error() - if strings.HasPrefix(errMsg, "time: unknown unit ") { - return errors.New("time: unknown unit") - } else if strings.HasPrefix(errMsg, "time: ") { - idx := strings.LastIndex(errMsg, " ") - - return errors.New(errMsg[:idx]) - } - - return err -} - -func wrapTimeParseLocationError(err error) error { - if err == nil { - return nil - } - errMsg := err.Error() - if strings.Contains(errMsg, "unknown time zone") || strings.HasPrefix(errMsg, "time: unknown format") { - return fmt.Errorf("invalid time zone format: %w", err) - } - - return err -} diff --git a/vendor/github.com/go-viper/mapstructure/v2/internal/errors/errors.go b/vendor/github.com/go-viper/mapstructure/v2/internal/errors/errors.go deleted file mode 100644 index d1c15e474f..0000000000 --- a/vendor/github.com/go-viper/mapstructure/v2/internal/errors/errors.go +++ /dev/null @@ -1,11 +0,0 @@ -package errors - -import "errors" - -func New(text string) error { - return errors.New(text) -} - -func As(err error, target interface{}) bool { - return errors.As(err, target) -} diff --git a/vendor/github.com/go-viper/mapstructure/v2/internal/errors/join.go b/vendor/github.com/go-viper/mapstructure/v2/internal/errors/join.go deleted file mode 100644 index d74e3a0b5a..0000000000 --- a/vendor/github.com/go-viper/mapstructure/v2/internal/errors/join.go +++ /dev/null @@ -1,9 +0,0 @@ -//go:build go1.20 - -package errors - -import "errors" - -func Join(errs ...error) error { - return errors.Join(errs...) -} diff --git a/vendor/github.com/go-viper/mapstructure/v2/internal/errors/join_go1_19.go b/vendor/github.com/go-viper/mapstructure/v2/internal/errors/join_go1_19.go deleted file mode 100644 index 700b40229c..0000000000 --- a/vendor/github.com/go-viper/mapstructure/v2/internal/errors/join_go1_19.go +++ /dev/null @@ -1,61 +0,0 @@ -//go:build !go1.20 - -// Copyright 2022 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package errors - -// Join returns an error that wraps the given errors. -// Any nil error values are discarded. -// Join returns nil if every value in errs is nil. -// The error formats as the concatenation of the strings obtained -// by calling the Error method of each element of errs, with a newline -// between each string. -// -// A non-nil error returned by Join implements the Unwrap() []error method. -func Join(errs ...error) error { - n := 0 - for _, err := range errs { - if err != nil { - n++ - } - } - if n == 0 { - return nil - } - e := &joinError{ - errs: make([]error, 0, n), - } - for _, err := range errs { - if err != nil { - e.errs = append(e.errs, err) - } - } - return e -} - -type joinError struct { - errs []error -} - -func (e *joinError) Error() string { - // Since Join returns nil if every value in errs is nil, - // e.errs cannot be empty. - if len(e.errs) == 1 { - return e.errs[0].Error() - } - - b := []byte(e.errs[0].Error()) - for _, err := range e.errs[1:] { - b = append(b, '\n') - b = append(b, err.Error()...) - } - // At this point, b has at least one byte '\n'. - // return unsafe.String(&b[0], len(b)) - return string(b) -} - -func (e *joinError) Unwrap() []error { - return e.errs -} diff --git a/vendor/github.com/go-viper/mapstructure/v2/reflect_go1_19.go b/vendor/github.com/go-viper/mapstructure/v2/reflect_go1_19.go deleted file mode 100644 index d0913fff6c..0000000000 --- a/vendor/github.com/go-viper/mapstructure/v2/reflect_go1_19.go +++ /dev/null @@ -1,44 +0,0 @@ -//go:build !go1.20 - -package mapstructure - -import "reflect" - -func isComparable(v reflect.Value) bool { - k := v.Kind() - switch k { - case reflect.Invalid: - return false - - case reflect.Array: - switch v.Type().Elem().Kind() { - case reflect.Interface, reflect.Array, reflect.Struct: - for i := 0; i < v.Type().Len(); i++ { - // if !v.Index(i).Comparable() { - if !isComparable(v.Index(i)) { - return false - } - } - return true - } - return v.Type().Comparable() - - case reflect.Interface: - // return v.Elem().Comparable() - return isComparable(v.Elem()) - - case reflect.Struct: - for i := 0; i < v.NumField(); i++ { - return false - - // if !v.Field(i).Comparable() { - if !isComparable(v.Field(i)) { - return false - } - } - return true - - default: - return v.Type().Comparable() - } -} diff --git a/vendor/github.com/go-viper/mapstructure/v2/reflect_go1_20.go b/vendor/github.com/go-viper/mapstructure/v2/reflect_go1_20.go deleted file mode 100644 index f8255a1b17..0000000000 --- a/vendor/github.com/go-viper/mapstructure/v2/reflect_go1_20.go +++ /dev/null @@ -1,10 +0,0 @@ -//go:build go1.20 - -package mapstructure - -import "reflect" - -// TODO: remove once we drop support for Go <1.20 -func isComparable(v reflect.Value) bool { - return v.Comparable() -} diff --git a/vendor/github.com/mitchellh/hashstructure/v2/LICENSE b/vendor/github.com/mitchellh/hashstructure/LICENSE similarity index 100% rename from vendor/github.com/mitchellh/hashstructure/v2/LICENSE rename to vendor/github.com/mitchellh/hashstructure/LICENSE diff --git a/vendor/github.com/mitchellh/hashstructure/v2/README.md b/vendor/github.com/mitchellh/hashstructure/README.md similarity index 76% rename from vendor/github.com/mitchellh/hashstructure/v2/README.md rename to vendor/github.com/mitchellh/hashstructure/README.md index 21f36be193..feb0c24962 100644 --- a/vendor/github.com/mitchellh/hashstructure/v2/README.md +++ b/vendor/github.com/mitchellh/hashstructure/README.md @@ -30,18 +30,9 @@ sending data across the network, caching values locally (de-dup), and so on. Standard `go get`: ``` -$ go get github.com/mitchellh/hashstructure/v2 +$ go get github.com/mitchellh/hashstructure ``` -**Note on v2:** It is highly recommended you use the "v2" release since this -fixes some significant hash collisions issues from v1. In practice, we used -v1 for many years in real projects at HashiCorp and never had issues, but it -is highly dependent on the shape of the data you're hashing and how you use -those hashes. - -When using v2+, you can still generate weaker v1 hashes by using the -`FormatV1` format when calling `Hash`. - ## Usage & Example For usage and examples see the [Godoc](http://godoc.org/github.com/mitchellh/hashstructure). @@ -65,7 +56,7 @@ v := ComplexStruct{ }, } -hash, err := hashstructure.Hash(v, hashstructure.FormatV2, nil) +hash, err := hashstructure.Hash(v, nil) if err != nil { panic(err) } diff --git a/vendor/github.com/mitchellh/hashstructure/v2/hashstructure.go b/vendor/github.com/mitchellh/hashstructure/hashstructure.go similarity index 78% rename from vendor/github.com/mitchellh/hashstructure/v2/hashstructure.go rename to vendor/github.com/mitchellh/hashstructure/hashstructure.go index 3dc0eb74e0..89dd4d3ea8 100644 --- a/vendor/github.com/mitchellh/hashstructure/v2/hashstructure.go +++ b/vendor/github.com/mitchellh/hashstructure/hashstructure.go @@ -9,6 +9,16 @@ import ( "time" ) +// ErrNotStringer is returned when there's an error with hash:"string" +type ErrNotStringer struct { + Field string +} + +// Error implements error for ErrNotStringer +func (ens *ErrNotStringer) Error() string { + return fmt.Sprintf("hashstructure: %s has hash:\"string\" set, but does not implement fmt.Stringer", ens.Field) +} + // HashOptions are options that are available for hashing. type HashOptions struct { // Hasher is the hash function to use. If this isn't set, it will @@ -31,33 +41,14 @@ type HashOptions struct { // Default is false (in which case the tag is used instead) SlicesAsSets bool - // UseStringer will attempt to use fmt.Stringer always. If the struct + // UseStringer will attempt to use fmt.Stringer aways. If the struct // doesn't implement fmt.Stringer, it'll fall back to trying usual tricks. // If this is true, and the "string" tag is also set, the tag takes - // precedence (meaning that if the type doesn't implement fmt.Stringer, we + // precedense (meaning that if the type doesn't implement fmt.Stringer, we // panic) UseStringer bool } -// Format specifies the hashing process used. Different formats typically -// generate different hashes for the same value and have different properties. -type Format uint - -const ( - // To disallow the zero value - formatInvalid Format = iota - - // FormatV1 is the format used in v1.x of this library. This has the - // downsides noted in issue #18 but allows simultaneous v1/v2 usage. - FormatV1 - - // FormatV2 is the current recommended format and fixes the issues - // noted in FormatV1. - FormatV2 - - formatMax // so we can easily find the end -) - // Hash returns the hash value of an arbitrary value. // // If opts is nil, then default options will be used. See HashOptions @@ -65,11 +56,6 @@ const ( // concurrently. None of the values within a *HashOptions struct are // safe to read/write while hashing is being done. // -// The "format" is required and must be one of the format values defined -// by this library. You should probably just use "FormatV2". This allows -// generated hashes uses alternate logic to maintain compatibility with -// older versions. -// // Notes on the value: // // * Unexported fields on structs are ignored and do not affect the @@ -95,12 +81,7 @@ const ( // * "string" - The field will be hashed as a string, only works when the // field implements fmt.Stringer // -func Hash(v interface{}, format Format, opts *HashOptions) (uint64, error) { - // Validate our format - if format <= formatInvalid || format >= formatMax { - return 0, &ErrFormat{} - } - +func Hash(v interface{}, opts *HashOptions) (uint64, error) { // Create default options if opts == nil { opts = &HashOptions{} @@ -117,7 +98,6 @@ func Hash(v interface{}, format Format, opts *HashOptions) (uint64, error) { // Create our walker and walk the structure w := &walker{ - format: format, h: opts.Hasher, tag: opts.TagName, zeronil: opts.ZeroNil, @@ -129,7 +109,6 @@ func Hash(v interface{}, format Format, opts *HashOptions) (uint64, error) { } type walker struct { - format Format h hash.Hash64 tag string zeronil bool @@ -268,11 +247,6 @@ func (w *walker) visit(v reflect.Value, opts *visitOpts) (uint64, error) { h = hashUpdateUnordered(h, fieldHash) } - if w.format != FormatV1 { - // Important: read the docs for hashFinishUnordered - h = hashFinishUnordered(w.h, h) - } - return h, nil case reflect.Struct: @@ -309,6 +283,7 @@ func (w *walker) visit(v reflect.Value, opts *visitOpts) (uint64, error) { l := v.NumField() for i := 0; i < l; i++ { if innerV := v.Field(i); v.CanSet() || t.Field(i).Name != "_" { + var f visitFlag fieldType := t.Field(i) if fieldType.PkgPath != "" { @@ -323,7 +298,8 @@ func (w *walker) visit(v reflect.Value, opts *visitOpts) (uint64, error) { } if w.ignorezerovalue { - if innerV.IsZero() { + zeroVal := reflect.Zero(reflect.TypeOf(innerV.Interface())).Interface() + if innerV.Interface() == zeroVal { continue } } @@ -374,11 +350,6 @@ func (w *walker) visit(v reflect.Value, opts *visitOpts) (uint64, error) { fieldHash := hashUpdateOrdered(w.h, kh, vh) h = hashUpdateUnordered(h, fieldHash) } - - if w.format != FormatV1 { - // Important: read the docs for hashFinishUnordered - h = hashFinishUnordered(w.h, h) - } } return h, nil @@ -406,11 +377,6 @@ func (w *walker) visit(v reflect.Value, opts *visitOpts) (uint64, error) { } } - if set && w.format != FormatV1 { - // Important: read the docs for hashFinishUnordered - h = hashFinishUnordered(w.h, h) - } - return h, nil case reflect.String: @@ -447,32 +413,6 @@ func hashUpdateUnordered(a, b uint64) uint64 { return a ^ b } -// After mixing a group of unique hashes with hashUpdateUnordered, it's always -// necessary to call hashFinishUnordered. Why? Because hashUpdateUnordered -// is a simple XOR, and calling hashUpdateUnordered on hashes produced by -// hashUpdateUnordered can effectively cancel out a previous change to the hash -// result if the same hash value appears later on. For example, consider: -// -// hashUpdateUnordered(hashUpdateUnordered("A", "B"), hashUpdateUnordered("A", "C")) = -// H("A") ^ H("B")) ^ (H("A") ^ H("C")) = -// (H("A") ^ H("A")) ^ (H("B") ^ H(C)) = -// H(B) ^ H(C) = -// hashUpdateUnordered(hashUpdateUnordered("Z", "B"), hashUpdateUnordered("Z", "C")) -// -// hashFinishUnordered "hardens" the result, so that encountering partially -// overlapping input data later on in a different context won't cancel out. -func hashFinishUnordered(h hash.Hash64, a uint64) uint64 { - h.Reset() - - // We just panic if the writes fail - e1 := binary.Write(h, binary.LittleEndian, a) - if e1 != nil { - panic(e1) - } - - return h.Sum64() -} - // visitFlag is used as a bitmask for affecting visit behavior type visitFlag uint diff --git a/vendor/github.com/mitchellh/hashstructure/v2/include.go b/vendor/github.com/mitchellh/hashstructure/include.go similarity index 100% rename from vendor/github.com/mitchellh/hashstructure/v2/include.go rename to vendor/github.com/mitchellh/hashstructure/include.go diff --git a/vendor/github.com/mitchellh/hashstructure/v2/errors.go b/vendor/github.com/mitchellh/hashstructure/v2/errors.go deleted file mode 100644 index 44b8951478..0000000000 --- a/vendor/github.com/mitchellh/hashstructure/v2/errors.go +++ /dev/null @@ -1,22 +0,0 @@ -package hashstructure - -import ( - "fmt" -) - -// ErrNotStringer is returned when there's an error with hash:"string" -type ErrNotStringer struct { - Field string -} - -// Error implements error for ErrNotStringer -func (ens *ErrNotStringer) Error() string { - return fmt.Sprintf("hashstructure: %s has hash:\"string\" set, but does not implement fmt.Stringer", ens.Field) -} - -// ErrFormat is returned when an invalid format is given to the Hash function. -type ErrFormat struct{} - -func (*ErrFormat) Error() string { - return "format must be one of the defined Format values in the hashstructure library" -} diff --git a/vendor/github.com/go-viper/mapstructure/v2/CHANGELOG.md b/vendor/github.com/mitchellh/mapstructure/CHANGELOG.md similarity index 92% rename from vendor/github.com/go-viper/mapstructure/v2/CHANGELOG.md rename to vendor/github.com/mitchellh/mapstructure/CHANGELOG.md index afd44e5f5f..c758234904 100644 --- a/vendor/github.com/go-viper/mapstructure/v2/CHANGELOG.md +++ b/vendor/github.com/mitchellh/mapstructure/CHANGELOG.md @@ -1,11 +1,3 @@ -> [!WARNING] -> As of v2 of this library, change log can be found in GitHub releases. - -## 1.5.1 - -* Wrap errors so they're compatible with `errors.Is` and `errors.As` [GH-282] -* Fix map of slices not decoding properly in certain cases. [GH-266] - ## 1.5.0 * New option `IgnoreUntaggedFields` to ignore decoding to any fields diff --git a/vendor/github.com/go-viper/mapstructure/v2/LICENSE b/vendor/github.com/mitchellh/mapstructure/LICENSE similarity index 100% rename from vendor/github.com/go-viper/mapstructure/v2/LICENSE rename to vendor/github.com/mitchellh/mapstructure/LICENSE diff --git a/vendor/github.com/mitchellh/mapstructure/README.md b/vendor/github.com/mitchellh/mapstructure/README.md new file mode 100644 index 0000000000..0018dc7d9f --- /dev/null +++ b/vendor/github.com/mitchellh/mapstructure/README.md @@ -0,0 +1,46 @@ +# mapstructure [![Godoc](https://godoc.org/github.com/mitchellh/mapstructure?status.svg)](https://godoc.org/github.com/mitchellh/mapstructure) + +mapstructure is a Go library for decoding generic map values to structures +and vice versa, while providing helpful error handling. + +This library is most useful when decoding values from some data stream (JSON, +Gob, etc.) where you don't _quite_ know the structure of the underlying data +until you read a part of it. You can therefore read a `map[string]interface{}` +and use this library to decode it into the proper underlying native Go +structure. + +## Installation + +Standard `go get`: + +``` +$ go get github.com/mitchellh/mapstructure +``` + +## Usage & Example + +For usage and examples see the [Godoc](http://godoc.org/github.com/mitchellh/mapstructure). + +The `Decode` function has examples associated with it there. + +## But Why?! + +Go offers fantastic standard libraries for decoding formats such as JSON. +The standard method is to have a struct pre-created, and populate that struct +from the bytes of the encoded format. This is great, but the problem is if +you have configuration or an encoding that changes slightly depending on +specific fields. For example, consider this JSON: + +```json +{ + "type": "person", + "name": "Mitchell" +} +``` + +Perhaps we can't populate a specific structure without first reading +the "type" field from the JSON. We could always do two passes over the +decoding of the JSON (reading the "type" first, and the rest later). +However, it is much simpler to just decode this into a `map[string]interface{}` +structure, read the "type" key, then use something like this library +to decode it into the proper structure. diff --git a/vendor/github.com/mitchellh/mapstructure/decode_hooks.go b/vendor/github.com/mitchellh/mapstructure/decode_hooks.go new file mode 100644 index 0000000000..3a754ca724 --- /dev/null +++ b/vendor/github.com/mitchellh/mapstructure/decode_hooks.go @@ -0,0 +1,279 @@ +package mapstructure + +import ( + "encoding" + "errors" + "fmt" + "net" + "reflect" + "strconv" + "strings" + "time" +) + +// typedDecodeHook takes a raw DecodeHookFunc (an interface{}) and turns +// it into the proper DecodeHookFunc type, such as DecodeHookFuncType. +func typedDecodeHook(h DecodeHookFunc) DecodeHookFunc { + // Create variables here so we can reference them with the reflect pkg + var f1 DecodeHookFuncType + var f2 DecodeHookFuncKind + var f3 DecodeHookFuncValue + + // Fill in the variables into this interface and the rest is done + // automatically using the reflect package. + potential := []interface{}{f1, f2, f3} + + v := reflect.ValueOf(h) + vt := v.Type() + for _, raw := range potential { + pt := reflect.ValueOf(raw).Type() + if vt.ConvertibleTo(pt) { + return v.Convert(pt).Interface() + } + } + + return nil +} + +// DecodeHookExec executes the given decode hook. This should be used +// since it'll naturally degrade to the older backwards compatible DecodeHookFunc +// that took reflect.Kind instead of reflect.Type. +func DecodeHookExec( + raw DecodeHookFunc, + from reflect.Value, to reflect.Value) (interface{}, error) { + + switch f := typedDecodeHook(raw).(type) { + case DecodeHookFuncType: + return f(from.Type(), to.Type(), from.Interface()) + case DecodeHookFuncKind: + return f(from.Kind(), to.Kind(), from.Interface()) + case DecodeHookFuncValue: + return f(from, to) + default: + return nil, errors.New("invalid decode hook signature") + } +} + +// ComposeDecodeHookFunc creates a single DecodeHookFunc that +// automatically composes multiple DecodeHookFuncs. +// +// The composed funcs are called in order, with the result of the +// previous transformation. +func ComposeDecodeHookFunc(fs ...DecodeHookFunc) DecodeHookFunc { + return func(f reflect.Value, t reflect.Value) (interface{}, error) { + var err error + data := f.Interface() + + newFrom := f + for _, f1 := range fs { + data, err = DecodeHookExec(f1, newFrom, t) + if err != nil { + return nil, err + } + newFrom = reflect.ValueOf(data) + } + + return data, nil + } +} + +// OrComposeDecodeHookFunc executes all input hook functions until one of them returns no error. In that case its value is returned. +// If all hooks return an error, OrComposeDecodeHookFunc returns an error concatenating all error messages. +func OrComposeDecodeHookFunc(ff ...DecodeHookFunc) DecodeHookFunc { + return func(a, b reflect.Value) (interface{}, error) { + var allErrs string + var out interface{} + var err error + + for _, f := range ff { + out, err = DecodeHookExec(f, a, b) + if err != nil { + allErrs += err.Error() + "\n" + continue + } + + return out, nil + } + + return nil, errors.New(allErrs) + } +} + +// StringToSliceHookFunc returns a DecodeHookFunc that converts +// string to []string by splitting on the given sep. +func StringToSliceHookFunc(sep string) DecodeHookFunc { + return func( + f reflect.Kind, + t reflect.Kind, + data interface{}) (interface{}, error) { + if f != reflect.String || t != reflect.Slice { + return data, nil + } + + raw := data.(string) + if raw == "" { + return []string{}, nil + } + + return strings.Split(raw, sep), nil + } +} + +// StringToTimeDurationHookFunc returns a DecodeHookFunc that converts +// strings to time.Duration. +func StringToTimeDurationHookFunc() DecodeHookFunc { + return func( + f reflect.Type, + t reflect.Type, + data interface{}) (interface{}, error) { + if f.Kind() != reflect.String { + return data, nil + } + if t != reflect.TypeOf(time.Duration(5)) { + return data, nil + } + + // Convert it by parsing + return time.ParseDuration(data.(string)) + } +} + +// StringToIPHookFunc returns a DecodeHookFunc that converts +// strings to net.IP +func StringToIPHookFunc() DecodeHookFunc { + return func( + f reflect.Type, + t reflect.Type, + data interface{}) (interface{}, error) { + if f.Kind() != reflect.String { + return data, nil + } + if t != reflect.TypeOf(net.IP{}) { + return data, nil + } + + // Convert it by parsing + ip := net.ParseIP(data.(string)) + if ip == nil { + return net.IP{}, fmt.Errorf("failed parsing ip %v", data) + } + + return ip, nil + } +} + +// StringToIPNetHookFunc returns a DecodeHookFunc that converts +// strings to net.IPNet +func StringToIPNetHookFunc() DecodeHookFunc { + return func( + f reflect.Type, + t reflect.Type, + data interface{}) (interface{}, error) { + if f.Kind() != reflect.String { + return data, nil + } + if t != reflect.TypeOf(net.IPNet{}) { + return data, nil + } + + // Convert it by parsing + _, net, err := net.ParseCIDR(data.(string)) + return net, err + } +} + +// StringToTimeHookFunc returns a DecodeHookFunc that converts +// strings to time.Time. +func StringToTimeHookFunc(layout string) DecodeHookFunc { + return func( + f reflect.Type, + t reflect.Type, + data interface{}) (interface{}, error) { + if f.Kind() != reflect.String { + return data, nil + } + if t != reflect.TypeOf(time.Time{}) { + return data, nil + } + + // Convert it by parsing + return time.Parse(layout, data.(string)) + } +} + +// WeaklyTypedHook is a DecodeHookFunc which adds support for weak typing to +// the decoder. +// +// Note that this is significantly different from the WeaklyTypedInput option +// of the DecoderConfig. +func WeaklyTypedHook( + f reflect.Kind, + t reflect.Kind, + data interface{}) (interface{}, error) { + dataVal := reflect.ValueOf(data) + switch t { + case reflect.String: + switch f { + case reflect.Bool: + if dataVal.Bool() { + return "1", nil + } + return "0", nil + case reflect.Float32: + return strconv.FormatFloat(dataVal.Float(), 'f', -1, 64), nil + case reflect.Int: + return strconv.FormatInt(dataVal.Int(), 10), nil + case reflect.Slice: + dataType := dataVal.Type() + elemKind := dataType.Elem().Kind() + if elemKind == reflect.Uint8 { + return string(dataVal.Interface().([]uint8)), nil + } + case reflect.Uint: + return strconv.FormatUint(dataVal.Uint(), 10), nil + } + } + + return data, nil +} + +func RecursiveStructToMapHookFunc() DecodeHookFunc { + return func(f reflect.Value, t reflect.Value) (interface{}, error) { + if f.Kind() != reflect.Struct { + return f.Interface(), nil + } + + var i interface{} = struct{}{} + if t.Type() != reflect.TypeOf(&i).Elem() { + return f.Interface(), nil + } + + m := make(map[string]interface{}) + t.Set(reflect.ValueOf(m)) + + return f.Interface(), nil + } +} + +// TextUnmarshallerHookFunc returns a DecodeHookFunc that applies +// strings to the UnmarshalText function, when the target type +// implements the encoding.TextUnmarshaler interface +func TextUnmarshallerHookFunc() DecodeHookFuncType { + return func( + f reflect.Type, + t reflect.Type, + data interface{}) (interface{}, error) { + if f.Kind() != reflect.String { + return data, nil + } + result := reflect.New(t).Interface() + unmarshaller, ok := result.(encoding.TextUnmarshaler) + if !ok { + return data, nil + } + if err := unmarshaller.UnmarshalText([]byte(data.(string))); err != nil { + return nil, err + } + return result, nil + } +} diff --git a/vendor/github.com/mitchellh/mapstructure/error.go b/vendor/github.com/mitchellh/mapstructure/error.go new file mode 100644 index 0000000000..47a99e5af3 --- /dev/null +++ b/vendor/github.com/mitchellh/mapstructure/error.go @@ -0,0 +1,50 @@ +package mapstructure + +import ( + "errors" + "fmt" + "sort" + "strings" +) + +// Error implements the error interface and can represents multiple +// errors that occur in the course of a single decode. +type Error struct { + Errors []string +} + +func (e *Error) Error() string { + points := make([]string, len(e.Errors)) + for i, err := range e.Errors { + points[i] = fmt.Sprintf("* %s", err) + } + + sort.Strings(points) + return fmt.Sprintf( + "%d error(s) decoding:\n\n%s", + len(e.Errors), strings.Join(points, "\n")) +} + +// WrappedErrors implements the errwrap.Wrapper interface to make this +// return value more useful with the errwrap and go-multierror libraries. +func (e *Error) WrappedErrors() []error { + if e == nil { + return nil + } + + result := make([]error, len(e.Errors)) + for i, e := range e.Errors { + result[i] = errors.New(e) + } + + return result +} + +func appendErrors(errors []string, err error) []string { + switch e := err.(type) { + case *Error: + return append(errors, e.Errors...) + default: + return append(errors, e.Error()) + } +} diff --git a/vendor/github.com/go-viper/mapstructure/v2/mapstructure.go b/vendor/github.com/mitchellh/mapstructure/mapstructure.go similarity index 63% rename from vendor/github.com/go-viper/mapstructure/v2/mapstructure.go rename to vendor/github.com/mitchellh/mapstructure/mapstructure.go index 9087fd96c7..1efb22ac36 100644 --- a/vendor/github.com/go-viper/mapstructure/v2/mapstructure.go +++ b/vendor/github.com/mitchellh/mapstructure/mapstructure.go @@ -1,5 +1,5 @@ // Package mapstructure exposes functionality to convert one arbitrary -// Go type into another, typically to convert a map[string]any +// Go type into another, typically to convert a map[string]interface{} // into a native Go structure. // // The Go structure can be arbitrarily complex, containing slices, @@ -9,84 +9,84 @@ // // The simplest function to start with is Decode. // -// # Field Tags +// Field Tags // // When decoding to a struct, mapstructure will use the field name by // default to perform the mapping. For example, if a struct has a field // "Username" then mapstructure will look for a key in the source value // of "username" (case insensitive). // -// type User struct { -// Username string -// } +// type User struct { +// Username string +// } // // You can change the behavior of mapstructure by using struct tags. // The default struct tag that mapstructure looks for is "mapstructure" // but you can customize it using DecoderConfig. // -// # Renaming Fields +// Renaming Fields // // To rename the key that mapstructure looks for, use the "mapstructure" // tag and set a value directly. For example, to change the "username" example // above to "user": // -// type User struct { -// Username string `mapstructure:"user"` -// } +// type User struct { +// Username string `mapstructure:"user"` +// } // -// # Embedded Structs and Squashing +// Embedded Structs and Squashing // // Embedded structs are treated as if they're another field with that name. // By default, the two structs below are equivalent when decoding with // mapstructure: // -// type Person struct { -// Name string -// } +// type Person struct { +// Name string +// } // -// type Friend struct { -// Person -// } +// type Friend struct { +// Person +// } // -// type Friend struct { -// Person Person -// } +// type Friend struct { +// Person Person +// } // // This would require an input that looks like below: // -// map[string]any{ -// "person": map[string]any{"name": "alice"}, -// } +// map[string]interface{}{ +// "person": map[string]interface{}{"name": "alice"}, +// } // // If your "person" value is NOT nested, then you can append ",squash" to // your tag value and mapstructure will treat it as if the embedded struct // were part of the struct directly. Example: // -// type Friend struct { -// Person `mapstructure:",squash"` -// } +// type Friend struct { +// Person `mapstructure:",squash"` +// } // // Now the following input would be accepted: // -// map[string]any{ -// "name": "alice", -// } +// map[string]interface{}{ +// "name": "alice", +// } // // When decoding from a struct to a map, the squash tag squashes the struct // fields into a single map. Using the example structs from above: // -// Friend{Person: Person{Name: "alice"}} +// Friend{Person: Person{Name: "alice"}} // // Will be decoded into a map: // -// map[string]any{ -// "name": "alice", -// } +// map[string]interface{}{ +// "name": "alice", +// } // // DecoderConfig has a field that changes the behavior of mapstructure // to always squash embedded structs. // -// # Remainder Values +// Remainder Values // // If there are any unmapped keys in the source value, mapstructure by // default will silently ignore them. You can error by setting ErrorUnused @@ -95,104 +95,64 @@ // // You can also use the ",remain" suffix on your tag to collect all unused // values in a map. The field with this tag MUST be a map type and should -// probably be a "map[string]any" or "map[any]any". +// probably be a "map[string]interface{}" or "map[interface{}]interface{}". // See example below: // -// type Friend struct { -// Name string -// Other map[string]any `mapstructure:",remain"` -// } +// type Friend struct { +// Name string +// Other map[string]interface{} `mapstructure:",remain"` +// } // // Given the input below, Other would be populated with the other // values that weren't used (everything but "name"): // -// map[string]any{ -// "name": "bob", -// "address": "123 Maple St.", -// } +// map[string]interface{}{ +// "name": "bob", +// "address": "123 Maple St.", +// } // -// # Omit Empty Values +// Omit Empty Values // // When decoding from a struct to any other value, you may use the // ",omitempty" suffix on your tag to omit that value if it equates to -// the zero value, or a zero-length element. The zero value of all types is -// specified in the Go specification. +// the zero value. The zero value of all types is specified in the Go +// specification. // // For example, the zero type of a numeric type is zero ("0"). If the struct // field value is zero and a numeric type, the field is empty, and it won't -// be encoded into the destination type. And likewise for the URLs field, if the -// slice is nil or empty, it won't be encoded into the destination type. +// be encoded into the destination type. // -// type Source struct { -// Age int `mapstructure:",omitempty"` -// URLs []string `mapstructure:",omitempty"` -// } +// type Source struct { +// Age int `mapstructure:",omitempty"` +// } // -// # Omit Zero Values -// -// When decoding from a struct to any other value, you may use the -// ",omitzero" suffix on your tag to omit that value if it equates to the zero -// value. The zero value of all types is specified in the Go specification. -// -// For example, the zero type of a numeric type is zero ("0"). If the struct -// field value is zero and a numeric type, the field is empty, and it won't -// be encoded into the destination type. And likewise for the URLs field, if the -// slice is nil, it won't be encoded into the destination type. -// -// Note that if the field is a slice, and it is empty but not nil, it will -// still be encoded into the destination type. -// -// type Source struct { -// Age int `mapstructure:",omitzero"` -// URLs []string `mapstructure:",omitzero"` -// } -// -// # Unexported fields +// Unexported fields // // Since unexported (private) struct fields cannot be set outside the package // where they are defined, the decoder will simply skip them. // // For this output type definition: // -// type Exported struct { -// private string // this unexported field will be skipped -// Public string -// } +// type Exported struct { +// private string // this unexported field will be skipped +// Public string +// } // // Using this map as input: // -// map[string]any{ -// "private": "I will be ignored", -// "Public": "I made it through!", -// } +// map[string]interface{}{ +// "private": "I will be ignored", +// "Public": "I made it through!", +// } // // The following struct will be decoded: // -// type Exported struct { -// private: "" // field is left with an empty string (zero value) -// Public: "I made it through!" -// } -// -// # Custom Decoding with Unmarshaler -// -// Types can implement the Unmarshaler interface to control their own decoding. The interface -// behaves similarly to how UnmarshalJSON does in the standard library. It can be used as an -// alternative or companion to a DecodeHook. -// -// type TrimmedString string -// -// func (t *TrimmedString) UnmarshalMapstructure(input any) error { -// str, ok := input.(string) -// if !ok { -// return fmt.Errorf("expected string, got %T", input) -// } -// *t = TrimmedString(strings.TrimSpace(str)) -// return nil -// } +// type Exported struct { +// private: "" // field is left with an empty string (zero value) +// Public: "I made it through!" +// } // -// See the Unmarshaler interface documentation for more details. -// -// # Other Configuration +// Other Configuration // // mapstructure is highly configurable. See the DecoderConfig struct // for other features and options that are supported. @@ -200,13 +160,12 @@ package mapstructure import ( "encoding/json" + "errors" "fmt" "reflect" "sort" "strconv" "strings" - - "github.com/go-viper/mapstructure/v2/internal/errors" ) // DecodeHookFunc is the callback function that can be used for @@ -223,30 +182,19 @@ import ( // we started with Kinds and then realized Types were the better solution, // but have a promise to not break backwards compat so we now support // both. -type DecodeHookFunc any +type DecodeHookFunc interface{} // DecodeHookFuncType is a DecodeHookFunc which has complete information about // the source and target types. -type DecodeHookFuncType func(reflect.Type, reflect.Type, any) (any, error) +type DecodeHookFuncType func(reflect.Type, reflect.Type, interface{}) (interface{}, error) // DecodeHookFuncKind is a DecodeHookFunc which knows only the Kinds of the // source and target types. -type DecodeHookFuncKind func(reflect.Kind, reflect.Kind, any) (any, error) +type DecodeHookFuncKind func(reflect.Kind, reflect.Kind, interface{}) (interface{}, error) // DecodeHookFuncValue is a DecodeHookFunc which has complete access to both the source and target // values. -type DecodeHookFuncValue func(from reflect.Value, to reflect.Value) (any, error) - -// Unmarshaler is the interface implemented by types that can unmarshal -// themselves. UnmarshalMapstructure receives the input data (potentially -// transformed by DecodeHook) and should populate the receiver with the -// decoded values. -// -// The Unmarshaler interface takes precedence over the default decoding -// logic for any type (structs, slices, maps, primitives, etc.). -type Unmarshaler interface { - UnmarshalMapstructure(any) error -} +type DecodeHookFuncValue func(from reflect.Value, to reflect.Value) (interface{}, error) // DecoderConfig is the configuration that is used to create a new decoder // and allows customization of various aspects of decoding. @@ -273,12 +221,6 @@ type DecoderConfig struct { // will affect all nested structs as well. ErrorUnset bool - // AllowUnsetPointer, if set to true, will prevent fields with pointer types - // from being reported as unset, even if ErrorUnset is true and the field was - // not present in the input data. This allows pointer fields to be optional - // without triggering an error when they are missing. - AllowUnsetPointer bool - // ZeroFields, if set to true, will zero fields before writing them. // For example, a map will be emptied before decoded values are put in // it. If this is false, a map will be merged. @@ -311,35 +253,18 @@ type DecoderConfig struct { // } Squash bool - // Deep will map structures in slices instead of copying them - // - // type Parent struct { - // Children []Child `mapstructure:",deep"` - // } - Deep bool - // Metadata is the struct that will contain extra metadata about // the decoding. If this is nil, then no metadata will be tracked. Metadata *Metadata // Result is a pointer to the struct that will contain the decoded // value. - Result any + Result interface{} // The tag name that mapstructure reads for field names. This - // defaults to "mapstructure". Multiple tag names can be specified - // as a comma-separated list (e.g., "yaml,json"), and the first - // matching non-empty tag will be used. + // defaults to "mapstructure" TagName string - // RootName specifies the name to use for the root element in error messages. For example: - // '' has unset fields: - RootName string - - // The option of the value in the tag that indicates a field should - // be squashed. This defaults to "squash". - SquashTagOption string - // IgnoreUntaggedFields ignores all struct fields without explicit // TagName, comparable to `mapstructure:"-"` as default behaviour. IgnoreUntaggedFields bool @@ -347,34 +272,7 @@ type DecoderConfig struct { // MatchName is the function used to match the map key to the struct // field name or tag. Defaults to `strings.EqualFold`. This can be used // to implement case-sensitive tag values, support snake casing, etc. - // - // MatchName is used as a fallback comparison when the direct key lookup fails. - // See also MapFieldName for transforming field names before lookup. MatchName func(mapKey, fieldName string) bool - - // DecodeNil, if set to true, will cause the DecodeHook (if present) to run - // even if the input is nil. This can be used to provide default values. - DecodeNil bool - - // MapFieldName is the function used to convert the struct field name to the map's key name. - // - // This is useful for automatically converting between naming conventions without - // explicitly tagging each field. For example, to convert Go's PascalCase field names - // to snake_case map keys: - // - // MapFieldName: func(s string) string { - // return strcase.ToSnake(s) - // } - // - // When decoding from a map to a struct, the transformed field name is used for - // the initial lookup. If not found, MatchName is used as a fallback comparison. - // Explicit struct tags always take precedence over MapFieldName. - MapFieldName func(string) string - - // DisableUnmarshaler, if set to true, disables the use of the Unmarshaler - // interface. Types implementing Unmarshaler will be decoded using the - // standard struct decoding logic instead. - DisableUnmarshaler bool } // A Decoder takes a raw interface value and turns it into structured @@ -384,8 +282,7 @@ type DecoderConfig struct { // structure. The top-level Decode method is just a convenience that sets // up the most basic Decoder. type Decoder struct { - config *DecoderConfig - cachedDecodeHook func(from reflect.Value, to reflect.Value) (any, error) + config *DecoderConfig } // Metadata contains information about decoding a structure that @@ -406,7 +303,7 @@ type Metadata struct { // Decode takes an input structure and uses reflection to translate it to // the output structure. output must be a pointer to a map or struct. -func Decode(input any, output any) error { +func Decode(input interface{}, output interface{}) error { config := &DecoderConfig{ Metadata: nil, Result: output, @@ -422,7 +319,7 @@ func Decode(input any, output any) error { // WeakDecode is the same as Decode but is shorthand to enable // WeaklyTypedInput. See DecoderConfig for more info. -func WeakDecode(input, output any) error { +func WeakDecode(input, output interface{}) error { config := &DecoderConfig{ Metadata: nil, Result: output, @@ -439,7 +336,7 @@ func WeakDecode(input, output any) error { // DecodeMetadata is the same as Decode, but is shorthand to // enable metadata collection. See DecoderConfig for more info. -func DecodeMetadata(input any, output any, metadata *Metadata) error { +func DecodeMetadata(input interface{}, output interface{}, metadata *Metadata) error { config := &DecoderConfig{ Metadata: metadata, Result: output, @@ -456,7 +353,7 @@ func DecodeMetadata(input any, output any, metadata *Metadata) error { // WeakDecodeMetadata is the same as Decode, but is shorthand to // enable both WeaklyTypedInput and metadata collection. See // DecoderConfig for more info. -func WeakDecodeMetadata(input any, output any, metadata *Metadata) error { +func WeakDecodeMetadata(input interface{}, output interface{}, metadata *Metadata) error { config := &DecoderConfig{ Metadata: metadata, Result: output, @@ -503,64 +400,36 @@ func NewDecoder(config *DecoderConfig) (*Decoder, error) { config.TagName = "mapstructure" } - if config.SquashTagOption == "" { - config.SquashTagOption = "squash" - } - if config.MatchName == nil { config.MatchName = strings.EqualFold } - if config.MapFieldName == nil { - config.MapFieldName = func(s string) string { - return s - } - } - result := &Decoder{ config: config, } - if config.DecodeHook != nil { - result.cachedDecodeHook = cachedDecodeHook(config.DecodeHook) - } return result, nil } // Decode decodes the given raw interface to the target pointer specified // by the configuration. -func (d *Decoder) Decode(input any) error { - err := d.decode(d.config.RootName, input, reflect.ValueOf(d.config.Result).Elem()) - - // Retain some of the original behavior when multiple errors ocurr - var joinedErr interface{ Unwrap() []error } - if errors.As(err, &joinedErr) { - return fmt.Errorf("decoding failed due to the following error(s):\n\n%w", err) - } - - return err -} - -// isNil returns true if the input is nil or a typed nil pointer. -func isNil(input any) bool { - if input == nil { - return true - } - val := reflect.ValueOf(input) - return val.Kind() == reflect.Ptr && val.IsNil() +func (d *Decoder) Decode(input interface{}) error { + return d.decode("", input, reflect.ValueOf(d.config.Result).Elem()) } // Decodes an unknown data type into a specific reflection value. -func (d *Decoder) decode(name string, input any, outVal reflect.Value) error { - var ( - inputVal = reflect.ValueOf(input) - outputKind = getKind(outVal) - decodeNil = d.config.DecodeNil && d.cachedDecodeHook != nil - ) - if isNil(input) { - // Typed nils won't match the "input == nil" below, so reset input. - input = nil +func (d *Decoder) decode(name string, input interface{}, outVal reflect.Value) error { + var inputVal reflect.Value + if input != nil { + inputVal = reflect.ValueOf(input) + + // We need to check here if input is a typed nil. Typed nils won't + // match the "input == nil" below so we check that here. + if inputVal.Kind() == reflect.Ptr && inputVal.IsNil() { + input = nil + } } + if input == nil { // If the data is nil, then we don't set anything, unless ZeroFields is set // to true. @@ -571,91 +440,59 @@ func (d *Decoder) decode(name string, input any, outVal reflect.Value) error { d.config.Metadata.Keys = append(d.config.Metadata.Keys, name) } } - if !decodeNil { - return nil - } + return nil } + if !inputVal.IsValid() { - if !decodeNil { - // If the input value is invalid, then we just set the value - // to be the zero value. - outVal.Set(reflect.Zero(outVal.Type())) - if d.config.Metadata != nil && name != "" { - d.config.Metadata.Keys = append(d.config.Metadata.Keys, name) - } - return nil - } - // Hooks need a valid inputVal, so reset it to zero value of outVal type. - switch outputKind { - case reflect.Struct, reflect.Map: - var mapVal map[string]any - inputVal = reflect.ValueOf(mapVal) // create nil map pointer - case reflect.Slice, reflect.Array: - var sliceVal []any - inputVal = reflect.ValueOf(sliceVal) // create nil slice pointer - default: - inputVal = reflect.Zero(outVal.Type()) + // If the input value is invalid, then we just set the value + // to be the zero value. + outVal.Set(reflect.Zero(outVal.Type())) + if d.config.Metadata != nil && name != "" { + d.config.Metadata.Keys = append(d.config.Metadata.Keys, name) } + return nil } - if d.cachedDecodeHook != nil { + if d.config.DecodeHook != nil { // We have a DecodeHook, so let's pre-process the input. var err error - input, err = d.cachedDecodeHook(inputVal, outVal) + input, err = DecodeHookExec(d.config.DecodeHook, inputVal, outVal) if err != nil { - return newDecodeError(name, err) + return fmt.Errorf("error decoding '%s': %s", name, err) } } - if isNil(input) { - return nil - } var err error + outputKind := getKind(outVal) addMetaKey := true - - // Check if the target implements Unmarshaler and use it if not disabled - unmarshaled := false - if !d.config.DisableUnmarshaler { - if unmarshaler, ok := getUnmarshaler(outVal); ok { - if err = unmarshaler.UnmarshalMapstructure(input); err != nil { - err = newDecodeError(name, err) - } - unmarshaled = true - } - } - - if !unmarshaled { - switch outputKind { - case reflect.Bool: - err = d.decodeBool(name, input, outVal) - case reflect.Interface: - err = d.decodeBasic(name, input, outVal) - case reflect.String: - err = d.decodeString(name, input, outVal) - case reflect.Int: - err = d.decodeInt(name, input, outVal) - case reflect.Uint: - err = d.decodeUint(name, input, outVal) - case reflect.Float32: - err = d.decodeFloat(name, input, outVal) - case reflect.Complex64: - err = d.decodeComplex(name, input, outVal) - case reflect.Struct: - err = d.decodeStruct(name, input, outVal) - case reflect.Map: - err = d.decodeMap(name, input, outVal) - case reflect.Ptr: - addMetaKey, err = d.decodePtr(name, input, outVal) - case reflect.Slice: - err = d.decodeSlice(name, input, outVal) - case reflect.Array: - err = d.decodeArray(name, input, outVal) - case reflect.Func: - err = d.decodeFunc(name, input, outVal) - default: - // If we reached this point then we weren't able to decode it - return newDecodeError(name, fmt.Errorf("unsupported type: %s", outputKind)) - } + switch outputKind { + case reflect.Bool: + err = d.decodeBool(name, input, outVal) + case reflect.Interface: + err = d.decodeBasic(name, input, outVal) + case reflect.String: + err = d.decodeString(name, input, outVal) + case reflect.Int: + err = d.decodeInt(name, input, outVal) + case reflect.Uint: + err = d.decodeUint(name, input, outVal) + case reflect.Float32: + err = d.decodeFloat(name, input, outVal) + case reflect.Struct: + err = d.decodeStruct(name, input, outVal) + case reflect.Map: + err = d.decodeMap(name, input, outVal) + case reflect.Ptr: + addMetaKey, err = d.decodePtr(name, input, outVal) + case reflect.Slice: + err = d.decodeSlice(name, input, outVal) + case reflect.Array: + err = d.decodeArray(name, input, outVal) + case reflect.Func: + err = d.decodeFunc(name, input, outVal) + default: + // If we reached this point then we weren't able to decode it + return fmt.Errorf("%s: unsupported type: %s", name, outputKind) } // If we reached here, then we successfully decoded SOMETHING, so @@ -669,7 +506,7 @@ func (d *Decoder) decode(name string, input any, outVal reflect.Value) error { // This decodes a basic type (bool, int, string, etc.) and sets the // value to "data" of that type. -func (d *Decoder) decodeBasic(name string, data any, val reflect.Value) error { +func (d *Decoder) decodeBasic(name string, data interface{}, val reflect.Value) error { if val.IsValid() && val.Elem().IsValid() { elem := val.Elem() @@ -716,17 +553,16 @@ func (d *Decoder) decodeBasic(name string, data any, val reflect.Value) error { dataValType := dataVal.Type() if !dataValType.AssignableTo(val.Type()) { - return newDecodeError(name, &UnconvertibleTypeError{ - Expected: val, - Value: data, - }) + return fmt.Errorf( + "'%s' expected type '%s', got '%s'", + name, val.Type(), dataValType) } val.Set(dataVal) return nil } -func (d *Decoder) decodeString(name string, data any, val reflect.Value) error { +func (d *Decoder) decodeString(name string, data interface{}, val reflect.Value) error { dataVal := reflect.Indirect(reflect.ValueOf(data)) dataKind := getKind(dataVal) @@ -754,7 +590,7 @@ func (d *Decoder) decodeString(name string, data any, val reflect.Value) error { case reflect.Uint8: var uints []uint8 if dataKind == reflect.Array { - uints = make([]uint8, dataVal.Len()) + uints = make([]uint8, dataVal.Len(), dataVal.Len()) for i := range uints { uints[i] = dataVal.Index(i).Interface().(uint8) } @@ -770,16 +606,15 @@ func (d *Decoder) decodeString(name string, data any, val reflect.Value) error { } if !converted { - return newDecodeError(name, &UnconvertibleTypeError{ - Expected: val, - Value: data, - }) + return fmt.Errorf( + "'%s' expected type '%s', got unconvertible type '%s', value: '%v'", + name, val.Type(), dataVal.Type(), data) } return nil } -func (d *Decoder) decodeInt(name string, data any, val reflect.Value) error { +func (d *Decoder) decodeInt(name string, data interface{}, val reflect.Value) error { dataVal := reflect.Indirect(reflect.ValueOf(data)) dataKind := getKind(dataVal) dataType := dataVal.Type() @@ -807,34 +642,26 @@ func (d *Decoder) decodeInt(name string, data any, val reflect.Value) error { if err == nil { val.SetInt(i) } else { - return newDecodeError(name, &ParseError{ - Expected: val, - Value: data, - Err: wrapStrconvNumError(err), - }) + return fmt.Errorf("cannot parse '%s' as int: %s", name, err) } case dataType.PkgPath() == "encoding/json" && dataType.Name() == "Number": jn := data.(json.Number) i, err := jn.Int64() if err != nil { - return newDecodeError(name, &ParseError{ - Expected: val, - Value: data, - Err: err, - }) + return fmt.Errorf( + "error decoding json.Number into %s: %s", name, err) } val.SetInt(i) default: - return newDecodeError(name, &UnconvertibleTypeError{ - Expected: val, - Value: data, - }) + return fmt.Errorf( + "'%s' expected type '%s', got unconvertible type '%s', value: '%v'", + name, val.Type(), dataVal.Type(), data) } return nil } -func (d *Decoder) decodeUint(name string, data any, val reflect.Value) error { +func (d *Decoder) decodeUint(name string, data interface{}, val reflect.Value) error { dataVal := reflect.Indirect(reflect.ValueOf(data)) dataKind := getKind(dataVal) dataType := dataVal.Type() @@ -843,11 +670,8 @@ func (d *Decoder) decodeUint(name string, data any, val reflect.Value) error { case dataKind == reflect.Int: i := dataVal.Int() if i < 0 && !d.config.WeaklyTypedInput { - return newDecodeError(name, &ParseError{ - Expected: val, - Value: data, - Err: fmt.Errorf("%d overflows uint", i), - }) + return fmt.Errorf("cannot parse '%s', %d overflows uint", + name, i) } val.SetUint(uint64(i)) case dataKind == reflect.Uint: @@ -855,11 +679,8 @@ func (d *Decoder) decodeUint(name string, data any, val reflect.Value) error { case dataKind == reflect.Float32: f := dataVal.Float() if f < 0 && !d.config.WeaklyTypedInput { - return newDecodeError(name, &ParseError{ - Expected: val, - Value: data, - Err: fmt.Errorf("%f overflows uint", f), - }) + return fmt.Errorf("cannot parse '%s', %f overflows uint", + name, f) } val.SetUint(uint64(f)) case dataKind == reflect.Bool && d.config.WeaklyTypedInput: @@ -878,34 +699,26 @@ func (d *Decoder) decodeUint(name string, data any, val reflect.Value) error { if err == nil { val.SetUint(i) } else { - return newDecodeError(name, &ParseError{ - Expected: val, - Value: data, - Err: wrapStrconvNumError(err), - }) + return fmt.Errorf("cannot parse '%s' as uint: %s", name, err) } case dataType.PkgPath() == "encoding/json" && dataType.Name() == "Number": jn := data.(json.Number) i, err := strconv.ParseUint(string(jn), 0, 64) if err != nil { - return newDecodeError(name, &ParseError{ - Expected: val, - Value: data, - Err: wrapStrconvNumError(err), - }) + return fmt.Errorf( + "error decoding json.Number into %s: %s", name, err) } val.SetUint(i) default: - return newDecodeError(name, &UnconvertibleTypeError{ - Expected: val, - Value: data, - }) + return fmt.Errorf( + "'%s' expected type '%s', got unconvertible type '%s', value: '%v'", + name, val.Type(), dataVal.Type(), data) } return nil } -func (d *Decoder) decodeBool(name string, data any, val reflect.Value) error { +func (d *Decoder) decodeBool(name string, data interface{}, val reflect.Value) error { dataVal := reflect.Indirect(reflect.ValueOf(data)) dataKind := getKind(dataVal) @@ -925,23 +738,18 @@ func (d *Decoder) decodeBool(name string, data any, val reflect.Value) error { } else if dataVal.String() == "" { val.SetBool(false) } else { - return newDecodeError(name, &ParseError{ - Expected: val, - Value: data, - Err: wrapStrconvNumError(err), - }) + return fmt.Errorf("cannot parse '%s' as bool: %s", name, err) } default: - return newDecodeError(name, &UnconvertibleTypeError{ - Expected: val, - Value: data, - }) + return fmt.Errorf( + "'%s' expected type '%s', got unconvertible type '%s', value: '%v'", + name, val.Type(), dataVal.Type(), data) } return nil } -func (d *Decoder) decodeFloat(name string, data any, val reflect.Value) error { +func (d *Decoder) decodeFloat(name string, data interface{}, val reflect.Value) error { dataVal := reflect.Indirect(reflect.ValueOf(data)) dataKind := getKind(dataVal) dataType := dataVal.Type() @@ -969,51 +777,26 @@ func (d *Decoder) decodeFloat(name string, data any, val reflect.Value) error { if err == nil { val.SetFloat(f) } else { - return newDecodeError(name, &ParseError{ - Expected: val, - Value: data, - Err: wrapStrconvNumError(err), - }) + return fmt.Errorf("cannot parse '%s' as float: %s", name, err) } case dataType.PkgPath() == "encoding/json" && dataType.Name() == "Number": jn := data.(json.Number) i, err := jn.Float64() if err != nil { - return newDecodeError(name, &ParseError{ - Expected: val, - Value: data, - Err: err, - }) + return fmt.Errorf( + "error decoding json.Number into %s: %s", name, err) } val.SetFloat(i) default: - return newDecodeError(name, &UnconvertibleTypeError{ - Expected: val, - Value: data, - }) - } - - return nil -} - -func (d *Decoder) decodeComplex(name string, data any, val reflect.Value) error { - dataVal := reflect.Indirect(reflect.ValueOf(data)) - dataKind := getKind(dataVal) - - switch { - case dataKind == reflect.Complex64: - val.SetComplex(dataVal.Complex()) - default: - return newDecodeError(name, &UnconvertibleTypeError{ - Expected: val, - Value: data, - }) + return fmt.Errorf( + "'%s' expected type '%s', got unconvertible type '%s', value: '%v'", + name, val.Type(), dataVal.Type(), data) } return nil } -func (d *Decoder) decodeMap(name string, data any, val reflect.Value) error { +func (d *Decoder) decodeMap(name string, data interface{}, val reflect.Value) error { valType := val.Type() valKeyType := valType.Key() valElemType := valType.Elem() @@ -1028,14 +811,8 @@ func (d *Decoder) decodeMap(name string, data any, val reflect.Value) error { valMap = reflect.MakeMap(mapType) } - dataVal := reflect.ValueOf(data) - - // Resolve any levels of indirection - for dataVal.Kind() == reflect.Pointer { - dataVal = reflect.Indirect(dataVal) - } - // Check input type and based on the input type jump to the proper func + dataVal := reflect.Indirect(reflect.ValueOf(data)) switch dataVal.Kind() { case reflect.Map: return d.decodeMapFromMap(name, dataVal, val, valMap) @@ -1051,10 +828,7 @@ func (d *Decoder) decodeMap(name string, data any, val reflect.Value) error { fallthrough default: - return newDecodeError(name, &UnconvertibleTypeError{ - Expected: val, - Value: data, - }) + return fmt.Errorf("'%s' expected a map, got '%s'", name, dataVal.Kind()) } } @@ -1083,7 +857,7 @@ func (d *Decoder) decodeMapFromMap(name string, dataVal reflect.Value, val refle valElemType := valType.Elem() // Accumulate errors - var errs []error + errors := make([]string, 0) // If the input data is empty, then we just match what the input data is. if dataVal.Len() == 0 { @@ -1105,7 +879,7 @@ func (d *Decoder) decodeMapFromMap(name string, dataVal reflect.Value, val refle // First decode the key into the proper type currentKey := reflect.Indirect(reflect.New(valKeyType)) if err := d.decode(fieldName, k.Interface(), currentKey); err != nil { - errs = append(errs, err) + errors = appendErrors(errors, err) continue } @@ -1113,7 +887,7 @@ func (d *Decoder) decodeMapFromMap(name string, dataVal reflect.Value, val refle v := dataVal.MapIndex(k).Interface() currentVal := reflect.Indirect(reflect.New(valElemType)) if err := d.decode(fieldName, v, currentVal); err != nil { - errs = append(errs, err) + errors = appendErrors(errors, err) continue } @@ -1123,7 +897,12 @@ func (d *Decoder) decodeMapFromMap(name string, dataVal reflect.Value, val refle // Set the built up map to the value val.Set(valMap) - return errors.Join(errs...) + // If we had errors, return those + if len(errors) > 0 { + return &Error{errors} + } + + return nil } func (d *Decoder) decodeMapFromStruct(name string, dataVal reflect.Value, val reflect.Value, valMap reflect.Value) error { @@ -1140,14 +919,11 @@ func (d *Decoder) decodeMapFromStruct(name string, dataVal reflect.Value, val re // to the map value. v := dataVal.Field(i) if !v.Type().AssignableTo(valMap.Type().Elem()) { - return newDecodeError( - name+"."+f.Name, - fmt.Errorf("cannot assign type %q to map value field of type %q", v.Type(), valMap.Type().Elem()), - ) + return fmt.Errorf("cannot assign type '%s' to map value field of type '%s'", v.Type(), valMap.Type().Elem()) } - tagValue, _ := getTagValue(f, d.config.TagName) - keyName := d.config.MapFieldName(f.Name) + tagValue := f.Tag.Get(d.config.TagName) + keyName := f.Name if tagValue == "" && d.config.IgnoreUntaggedFields { continue @@ -1156,9 +932,6 @@ func (d *Decoder) decodeMapFromStruct(name string, dataVal reflect.Value, val re // If Squash is set in the config, we squash the field down. squash := d.config.Squash && v.Kind() == reflect.Struct && f.Anonymous - // If Deep is set in the config, set as default value. - deep := d.config.Deep - v = dereferencePtrToStructIfNeeded(v, d.config.TagName) // Determine the name of the key in the map @@ -1167,17 +940,12 @@ func (d *Decoder) decodeMapFromStruct(name string, dataVal reflect.Value, val re continue } // If "omitempty" is specified in the tag, it ignores empty values. - if strings.Contains(tagValue[index+1:], "omitempty") && isEmptyValue(v) { - continue - } - - // If "omitzero" is specified in the tag, it ignores zero values. - if strings.Contains(tagValue[index+1:], "omitzero") && v.IsZero() { + if strings.Index(tagValue[index+1:], "omitempty") != -1 && isEmptyValue(v) { continue } // If "squash" is specified in the tag, we squash the field down. - squash = squash || strings.Contains(tagValue[index+1:], d.config.SquashTagOption) + squash = squash || strings.Index(tagValue[index+1:], "squash") != -1 if squash { // When squashing, the embedded type can be a pointer to a struct. if v.Kind() == reflect.Ptr && v.Elem().Kind() == reflect.Struct { @@ -1186,30 +954,9 @@ func (d *Decoder) decodeMapFromStruct(name string, dataVal reflect.Value, val re // The final type must be a struct if v.Kind() != reflect.Struct { - return newDecodeError( - name+"."+f.Name, - fmt.Errorf("cannot squash non-struct type %q", v.Type()), - ) - } - } else { - if strings.Contains(tagValue[index+1:], "remain") { - if v.Kind() != reflect.Map { - return newDecodeError( - name+"."+f.Name, - fmt.Errorf("error remain-tag field with invalid type: %q", v.Type()), - ) - } - - ptr := v.MapRange() - for ptr.Next() { - valMap.SetMapIndex(ptr.Key(), ptr.Value()) - } - continue + return fmt.Errorf("cannot squash non-struct type '%s'", v.Type()) } } - - deep = deep || strings.Contains(tagValue[index+1:], "deep") - if keyNameTagValue := tagValue[:index]; keyNameTagValue != "" { keyName = keyNameTagValue } @@ -1256,41 +1003,6 @@ func (d *Decoder) decodeMapFromStruct(name string, dataVal reflect.Value, val re valMap.SetMapIndex(reflect.ValueOf(keyName), vMap) } - case reflect.Slice: - if deep { - var childType reflect.Type - switch v.Type().Elem().Kind() { - case reflect.Struct: - childType = reflect.TypeOf(map[string]any{}) - default: - childType = v.Type().Elem() - } - - sType := reflect.SliceOf(childType) - - addrVal := reflect.New(sType) - - vSlice := reflect.MakeSlice(sType, v.Len(), v.Cap()) - - if v.Len() > 0 { - reflect.Indirect(addrVal).Set(vSlice) - - err := d.decode(keyName, v.Interface(), reflect.Indirect(addrVal)) - if err != nil { - return err - } - } - - vSlice = reflect.Indirect(addrVal) - - valMap.SetMapIndex(reflect.ValueOf(keyName), vSlice) - - break - } - - // When deep mapping is not needed, fallthrough to normal copy - fallthrough - default: valMap.SetMapIndex(reflect.ValueOf(keyName), v) } @@ -1303,7 +1015,7 @@ func (d *Decoder) decodeMapFromStruct(name string, dataVal reflect.Value, val re return nil } -func (d *Decoder) decodePtr(name string, data any, val reflect.Value) (bool, error) { +func (d *Decoder) decodePtr(name string, data interface{}, val reflect.Value) (bool, error) { // If the input data is nil, then we want to just set the output // pointer to be nil as well. isNil := data == nil @@ -1350,21 +1062,20 @@ func (d *Decoder) decodePtr(name string, data any, val reflect.Value) (bool, err return false, nil } -func (d *Decoder) decodeFunc(name string, data any, val reflect.Value) error { +func (d *Decoder) decodeFunc(name string, data interface{}, val reflect.Value) error { // Create an element of the concrete (non pointer) type and decode // into that. Then set the value of the pointer to this type. dataVal := reflect.Indirect(reflect.ValueOf(data)) if val.Type() != dataVal.Type() { - return newDecodeError(name, &UnconvertibleTypeError{ - Expected: val, - Value: data, - }) + return fmt.Errorf( + "'%s' expected type '%s', got unconvertible type '%s', value: '%v'", + name, val.Type(), dataVal.Type(), data) } val.Set(dataVal) return nil } -func (d *Decoder) decodeSlice(name string, data any, val reflect.Value) error { +func (d *Decoder) decodeSlice(name string, data interface{}, val reflect.Value) error { dataVal := reflect.Indirect(reflect.ValueOf(data)) dataValKind := dataVal.Kind() valType := val.Type() @@ -1386,7 +1097,7 @@ func (d *Decoder) decodeSlice(name string, data any, val reflect.Value) error { return nil } // Create slice of maps of other sizes - return d.decodeSlice(name, []any{data}, val) + return d.decodeSlice(name, []interface{}{data}, val) case dataValKind == reflect.String && valElemType.Kind() == reflect.Uint8: return d.decodeSlice(name, []byte(dataVal.String()), val) @@ -1395,12 +1106,12 @@ func (d *Decoder) decodeSlice(name string, data any, val reflect.Value) error { // and "lift" it into it. i.e. a string becomes a string slice. default: // Just re-try this function with data as a slice. - return d.decodeSlice(name, []any{data}, val) + return d.decodeSlice(name, []interface{}{data}, val) } } - return newDecodeError(name, - fmt.Errorf("source data must be an array or slice, got %s", dataValKind)) + return fmt.Errorf( + "'%s': source data must be an array or slice, got %s", name, dataValKind) } // If the input value is nil, then don't allocate since empty != nil @@ -1412,12 +1123,10 @@ func (d *Decoder) decodeSlice(name string, data any, val reflect.Value) error { if valSlice.IsNil() || d.config.ZeroFields { // Make a new slice to hold our result, same size as the original data. valSlice = reflect.MakeSlice(sliceType, dataVal.Len(), dataVal.Len()) - } else if valSlice.Len() > dataVal.Len() { - valSlice = valSlice.Slice(0, dataVal.Len()) } // Accumulate any errors - var errs []error + errors := make([]string, 0) for i := 0; i < dataVal.Len(); i++ { currentData := dataVal.Index(i).Interface() @@ -1428,17 +1137,22 @@ func (d *Decoder) decodeSlice(name string, data any, val reflect.Value) error { fieldName := name + "[" + strconv.Itoa(i) + "]" if err := d.decode(fieldName, currentData, currentField); err != nil { - errs = append(errs, err) + errors = appendErrors(errors, err) } } // Finally, set the value to the slice we built up val.Set(valSlice) - return errors.Join(errs...) + // If there were errors, we return those + if len(errors) > 0 { + return &Error{errors} + } + + return nil } -func (d *Decoder) decodeArray(name string, data any, val reflect.Value) error { +func (d *Decoder) decodeArray(name string, data interface{}, val reflect.Value) error { dataVal := reflect.Indirect(reflect.ValueOf(data)) dataValKind := dataVal.Kind() valType := val.Type() @@ -1447,7 +1161,7 @@ func (d *Decoder) decodeArray(name string, data any, val reflect.Value) error { valArray := val - if isComparable(valArray) && valArray.Interface() == reflect.Zero(valArray.Type()).Interface() || d.config.ZeroFields { + if valArray.Interface() == reflect.Zero(valArray.Type()).Interface() || d.config.ZeroFields { // Check input type if dataValKind != reflect.Array && dataValKind != reflect.Slice { if d.config.WeaklyTypedInput { @@ -1463,17 +1177,18 @@ func (d *Decoder) decodeArray(name string, data any, val reflect.Value) error { // and "lift" it into it. i.e. a string becomes a string array. default: // Just re-try this function with data as a slice. - return d.decodeArray(name, []any{data}, val) + return d.decodeArray(name, []interface{}{data}, val) } } - return newDecodeError(name, - fmt.Errorf("source data must be an array or slice, got %s", dataValKind)) + return fmt.Errorf( + "'%s': source data must be an array or slice, got %s", name, dataValKind) } if dataVal.Len() > arrayType.Len() { - return newDecodeError(name, - fmt.Errorf("expected source data to have length less or equal to %d, got %d", arrayType.Len(), dataVal.Len())) + return fmt.Errorf( + "'%s': expected source data to have length less or equal to %d, got %d", name, arrayType.Len(), dataVal.Len()) + } // Make a new array to hold our result, same size as the original data. @@ -1481,7 +1196,7 @@ func (d *Decoder) decodeArray(name string, data any, val reflect.Value) error { } // Accumulate any errors - var errs []error + errors := make([]string, 0) for i := 0; i < dataVal.Len(); i++ { currentData := dataVal.Index(i).Interface() @@ -1489,17 +1204,22 @@ func (d *Decoder) decodeArray(name string, data any, val reflect.Value) error { fieldName := name + "[" + strconv.Itoa(i) + "]" if err := d.decode(fieldName, currentData, currentField); err != nil { - errs = append(errs, err) + errors = appendErrors(errors, err) } } // Finally, set the value to the array we built up val.Set(valArray) - return errors.Join(errs...) + // If there were errors, we return those + if len(errors) > 0 { + return &Error{errors} + } + + return nil } -func (d *Decoder) decodeStruct(name string, data any, val reflect.Value) error { +func (d *Decoder) decodeStruct(name string, data interface{}, val reflect.Value) error { dataVal := reflect.Indirect(reflect.ValueOf(data)) // If the type of the value to write to and the data match directly, @@ -1520,7 +1240,7 @@ func (d *Decoder) decodeStruct(name string, data any, val reflect.Value) error { // as an intermediary. // Make a new map to hold our result - mapType := reflect.TypeOf((map[string]any)(nil)) + mapType := reflect.TypeOf((map[string]interface{})(nil)) mval := reflect.MakeMap(mapType) // Creating a pointer to a map so that other methods can completely @@ -1538,28 +1258,27 @@ func (d *Decoder) decodeStruct(name string, data any, val reflect.Value) error { return result default: - return newDecodeError(name, - fmt.Errorf("expected a map or struct, got %q", dataValKind)) + return fmt.Errorf("'%s' expected a map, got '%s'", name, dataVal.Kind()) } } func (d *Decoder) decodeStructFromMap(name string, dataVal, val reflect.Value) error { dataValType := dataVal.Type() if kind := dataValType.Key().Kind(); kind != reflect.String && kind != reflect.Interface { - return newDecodeError(name, - fmt.Errorf("needs a map with string keys, has %q keys", kind)) + return fmt.Errorf( + "'%s' needs a map with string keys, has '%s' keys", + name, dataValType.Key().Kind()) } dataValKeys := make(map[reflect.Value]struct{}) - dataValKeysUnused := make(map[any]struct{}) + dataValKeysUnused := make(map[interface{}]struct{}) for _, dataValKey := range dataVal.MapKeys() { dataValKeys[dataValKey] = struct{}{} dataValKeysUnused[dataValKey.Interface()] = struct{}{} } - targetValKeysUnused := make(map[any]struct{}) - - var errs []error + targetValKeysUnused := make(map[interface{}]struct{}) + errors := make([]string, 0) // This slice will keep track of all the structs we'll be decoding. // There can be more than one struct if there are embedded structs @@ -1598,12 +1317,9 @@ func (d *Decoder) decodeStructFromMap(name string, dataVal, val reflect.Value) e remain := false // We always parse the tags cause we're looking for other tags too - tagParts := getTagParts(fieldType, d.config.TagName) - if len(tagParts) == 0 { - tagParts = []string{""} - } + tagParts := strings.Split(fieldType.Tag.Get(d.config.TagName), ",") for _, tag := range tagParts[1:] { - if tag == d.config.SquashTagOption { + if tag == "squash" { squash = true break } @@ -1615,30 +1331,11 @@ func (d *Decoder) decodeStructFromMap(name string, dataVal, val reflect.Value) e } if squash { - switch fieldVal.Kind() { - case reflect.Struct: + if fieldVal.Kind() != reflect.Struct { + errors = appendErrors(errors, + fmt.Errorf("%s: unsupported type for squash: %s", fieldType.Name, fieldVal.Kind())) + } else { structs = append(structs, fieldVal) - case reflect.Interface: - if !fieldVal.IsNil() { - structs = append(structs, fieldVal.Elem().Elem()) - } - case reflect.Ptr: - if fieldVal.Type().Elem().Kind() == reflect.Struct { - if fieldVal.IsNil() { - fieldVal.Set(reflect.New(fieldVal.Type().Elem())) - } - structs = append(structs, fieldVal.Elem()) - } else { - errs = append(errs, newDecodeError( - name+"."+fieldType.Name, - fmt.Errorf("unsupported type for squashed pointer: %s", fieldVal.Type().Elem().Kind()), - )) - } - default: - errs = append(errs, newDecodeError( - name+"."+fieldType.Name, - fmt.Errorf("unsupported type for squash: %s", fieldVal.Kind()), - )) } continue } @@ -1658,15 +1355,10 @@ func (d *Decoder) decodeStructFromMap(name string, dataVal, val reflect.Value) e field, fieldValue := f.field, f.val fieldName := field.Name - tagValue, _ := getTagValue(field, d.config.TagName) - if tagValue == "" && d.config.IgnoreUntaggedFields { - continue - } + tagValue := field.Tag.Get(d.config.TagName) tagValue = strings.SplitN(tagValue, ",", 2)[0] if tagValue != "" { fieldName = tagValue - } else { - fieldName = d.config.MapFieldName(fieldName) } rawMapKey := reflect.ValueOf(fieldName) @@ -1691,9 +1383,7 @@ func (d *Decoder) decodeStructFromMap(name string, dataVal, val reflect.Value) e if !rawMapVal.IsValid() { // There was no matching key in the map for the value in // the struct. Remember it for potential errors and metadata. - if !(d.config.AllowUnsetPointer && fieldValue.Kind() == reflect.Ptr) { - targetValKeysUnused[fieldName] = struct{}{} - } + targetValKeysUnused[fieldName] = struct{}{} continue } } @@ -1719,7 +1409,7 @@ func (d *Decoder) decodeStructFromMap(name string, dataVal, val reflect.Value) e } if err := d.decode(fieldName, rawMapVal.Interface(), fieldValue); err != nil { - errs = append(errs, err) + errors = appendErrors(errors, err) } } @@ -1727,14 +1417,14 @@ func (d *Decoder) decodeStructFromMap(name string, dataVal, val reflect.Value) e // we put the unused keys directly into the remain field. if remainField != nil && len(dataValKeysUnused) > 0 { // Build a map of only the unused values - remain := map[any]any{} + remain := map[interface{}]interface{}{} for key := range dataValKeysUnused { remain[key] = dataVal.MapIndex(reflect.ValueOf(key)).Interface() } // Decode it as-if we were just decoding this map onto our map. if err := d.decodeMap(name, remain, remainField.val); err != nil { - errs = append(errs, err) + errors = appendErrors(errors, err) } // Set the map to nil so we have none so that the next check will @@ -1749,16 +1439,8 @@ func (d *Decoder) decodeStructFromMap(name string, dataVal, val reflect.Value) e } sort.Strings(keys) - // Improve error message when name is empty by showing the target struct type - // in the case where it is empty for embedded structs. - errorName := name - if errorName == "" { - errorName = val.Type().String() - } - errs = append(errs, newDecodeError( - errorName, - fmt.Errorf("has invalid keys: %s", strings.Join(keys, ", ")), - )) + err := fmt.Errorf("'%s' has invalid keys: %s", name, strings.Join(keys, ", ")) + errors = appendErrors(errors, err) } if d.config.ErrorUnset && len(targetValKeysUnused) > 0 { @@ -1768,14 +1450,12 @@ func (d *Decoder) decodeStructFromMap(name string, dataVal, val reflect.Value) e } sort.Strings(keys) - errs = append(errs, newDecodeError( - name, - fmt.Errorf("has unset fields: %s", strings.Join(keys, ", ")), - )) + err := fmt.Errorf("'%s' has unset fields: %s", name, strings.Join(keys, ", ")) + errors = appendErrors(errors, err) } - if err := errors.Join(errs...); err != nil { - return err + if len(errors) > 0 { + return &Error{errors} } // Add the unused keys to the list of unused keys if we're tracking metadata @@ -1829,8 +1509,6 @@ func getKind(val reflect.Value) reflect.Kind { return reflect.Uint case kind >= reflect.Float32 && kind <= reflect.Float64: return reflect.Float32 - case kind >= reflect.Complex64 && kind <= reflect.Complex128: - return reflect.Complex64 default: return kind } @@ -1842,7 +1520,7 @@ func isStructTypeConvertibleToMap(typ reflect.Type, checkMapstructureTags bool, if f.PkgPath == "" && !checkMapstructureTags { // check for unexported fields return true } - if checkMapstructureTags && hasAnyTag(f, tagName) { // check for mapstructure tags inside + if checkMapstructureTags && f.Tag.Get(tagName) != "" { // check for mapstructure tags inside return true } } @@ -1850,99 +1528,13 @@ func isStructTypeConvertibleToMap(typ reflect.Type, checkMapstructureTags bool, } func dereferencePtrToStructIfNeeded(v reflect.Value, tagName string) reflect.Value { - if v.Kind() != reflect.Ptr { - return v - } - - switch v.Elem().Kind() { - case reflect.Slice: - return v.Elem() - - case reflect.Struct: - deref := v.Elem() - derefT := deref.Type() - if isStructTypeConvertibleToMap(derefT, true, tagName) { - return deref - } - return v - - default: + if v.Kind() != reflect.Ptr || v.Elem().Kind() != reflect.Struct { return v } -} - -func hasAnyTag(field reflect.StructField, tagName string) bool { - _, ok := getTagValue(field, tagName) - return ok -} - -func getTagParts(field reflect.StructField, tagName string) []string { - tagValue, ok := getTagValue(field, tagName) - if !ok { - return nil - } - return strings.Split(tagValue, ",") -} - -func getTagValue(field reflect.StructField, tagName string) (string, bool) { - for _, name := range splitTagNames(tagName) { - if tag := field.Tag.Get(name); tag != "" { - return tag, true - } - } - return "", false -} - -func splitTagNames(tagName string) []string { - if tagName == "" { - return []string{"mapstructure"} - } - parts := strings.Split(tagName, ",") - result := make([]string, 0, len(parts)) - - for _, name := range parts { - name = strings.TrimSpace(name) - if name != "" { - result = append(result, name) - } - } - - return result -} - -// unmarshalerType is cached for performance -var unmarshalerType = reflect.TypeOf((*Unmarshaler)(nil)).Elem() - -// getUnmarshaler checks if the value implements Unmarshaler and returns -// the Unmarshaler and a boolean indicating if it was found. It handles both -// pointer and value receivers. -func getUnmarshaler(val reflect.Value) (Unmarshaler, bool) { - // Skip invalid or nil values - if !val.IsValid() { - return nil, false - } - - switch val.Kind() { - case reflect.Pointer, reflect.Interface: - if val.IsNil() { - return nil, false - } + deref := v.Elem() + derefT := deref.Type() + if isStructTypeConvertibleToMap(derefT, true, tagName) { + return deref } - - // Check pointer receiver first (most common case) - if val.CanAddr() { - ptrVal := val.Addr() - // Quick check: if no methods, can't implement any interface - if ptrVal.Type().NumMethod() > 0 && ptrVal.Type().Implements(unmarshalerType) { - return ptrVal.Interface().(Unmarshaler), true - } - } - - // Check value receiver - // Quick check: if no methods, can't implement any interface - if val.Type().NumMethod() > 0 && val.CanInterface() && val.Type().Implements(unmarshalerType) { - return val.Interface().(Unmarshaler), true - } - - return nil, false + return v } diff --git a/vendor/github.com/onsi/ginkgo/v2/ginkgo/run/run_command.go b/vendor/github.com/onsi/ginkgo/v2/ginkgo/run/run_command.go index 7b6c2cc226..c5091e6de8 100644 --- a/vendor/github.com/onsi/ginkgo/v2/ginkgo/run/run_command.go +++ b/vendor/github.com/onsi/ginkgo/v2/ginkgo/run/run_command.go @@ -39,10 +39,6 @@ func BuildRunCommand() command.Command { cliConfig, goFlagsConfig, errors = types.VetAndInitializeCLIAndGoConfig(cliConfig, goFlagsConfig) command.AbortIfErrors("Ginkgo detected configuration issues:", errors) - if types.ReconcileFdOutputConfiguration(reporterConfig, &suiteConfig, &cliConfig) { - fmt.Println("--fd is incompatible with parallel runs (-p/-procs) and -randomize-all; ignoring those flags and running specs in series, in declaration order.") - } - runner := &SpecRunner{ cliConfig: cliConfig, goFlagsConfig: goFlagsConfig, diff --git a/vendor/github.com/onsi/ginkgo/v2/ginkgo/watch/watch_command.go b/vendor/github.com/onsi/ginkgo/v2/ginkgo/watch/watch_command.go index c60d7115fa..fe1ca30519 100644 --- a/vendor/github.com/onsi/ginkgo/v2/ginkgo/watch/watch_command.go +++ b/vendor/github.com/onsi/ginkgo/v2/ginkgo/watch/watch_command.go @@ -37,10 +37,6 @@ func BuildWatchCommand() command.Command { cliConfig, goFlagsConfig, errors = types.VetAndInitializeCLIAndGoConfig(cliConfig, goFlagsConfig) command.AbortIfErrors("Ginkgo detected configuration issues:", errors) - if types.ReconcileFdOutputConfiguration(reporterConfig, &suiteConfig, &cliConfig) { - fmt.Println("--fd is incompatible with parallel runs (-p/-procs) and -randomize-all; ignoring those flags and running specs in series, in declaration order.") - } - watcher := &SpecWatcher{ cliConfig: cliConfig, goFlagsConfig: goFlagsConfig, diff --git a/vendor/github.com/onsi/ginkgo/v2/reporters/default_reporter.go b/vendor/github.com/onsi/ginkgo/v2/reporters/default_reporter.go index f3e15a913e..be5719a8ef 100644 --- a/vendor/github.com/onsi/ginkgo/v2/reporters/default_reporter.go +++ b/vendor/github.com/onsi/ginkgo/v2/reporters/default_reporter.go @@ -31,7 +31,6 @@ type DefaultReporter struct { specDenoter string retryDenoter string formatter formatter.Formatter - fdHierarchy []string runningInParallel bool lock *sync.Mutex @@ -83,8 +82,6 @@ func (r *DefaultReporter) SuiteWillBegin(report types.Report) { if report.SuiteConfig.ParallelTotal > 1 { r.emit(r.f("- %d procs ", report.SuiteConfig.ParallelTotal)) } - } else if r.conf.FdOutput { - return } else { banner := r.f("Running Suite: %s - %s", report.SuiteDescription, report.SuitePath) r.emitBlock(banner) @@ -127,7 +124,7 @@ func (r *DefaultReporter) SuiteWillBegin(report types.Report) { func (r *DefaultReporter) SuiteDidEnd(report types.Report) { failures := report.SpecReports.WithState(types.SpecStateFailureStates) - if !r.conf.FdOutput && len(failures) > 0 { + if len(failures) > 0 { r.emitBlock("\n") if len(failures) > 1 { r.emitBlock(r.f("{{red}}{{bold}}Summarizing %d Failures:{{/}}", len(failures))) @@ -230,10 +227,6 @@ func (r *DefaultReporter) DidRun(report types.SpecReport) { return } - if r.conf.FdOutput { - r.didRunFd(report) - return - } header := r.specDenoter if report.LeafNodeType.Is(types.NodeTypesForSuiteLevelNodes) { header = fmt.Sprintf("[%s]", report.LeafNodeType) @@ -365,51 +358,6 @@ func (r *DefaultReporter) DidRun(report types.SpecReport) { r.emitDelimiter(0) } -func (r *DefaultReporter) didRunFd(report types.SpecReport) { - r.lock.Lock() - defer r.lock.Unlock() - - if !report.LeafNodeType.Is(types.NodeTypeIt) { - return - } - - hierarchy := report.ContainerHierarchyTexts - - // blank line when top-level container changes - if len(r.fdHierarchy) > 0 && - (len(hierarchy) == 0 || hierarchy[0] != r.fdHierarchy[0]) { - fmt.Fprintln(r.writer) - } - - // emit newly-diverged container lines - divergeAt := 0 - for divergeAt < len(r.fdHierarchy) && divergeAt < len(hierarchy) && - r.fdHierarchy[divergeAt] == hierarchy[divergeAt] { - divergeAt++ - } - for i := divergeAt; i < len(hierarchy); i++ { - fmt.Fprintf(r.writer, "%s%s\n", strings.Repeat(" ", i), hierarchy[i]) - } - - // leaf label - depth := len(hierarchy) - indent := strings.Repeat(" ", depth) - label := report.LeafNodeText - - switch report.State { - case types.SpecStateFailed, types.SpecStatePanicked: - label = fmt.Sprintf("%s (FAILED)", label) - case types.SpecStatePending: - label = fmt.Sprintf("%s (PENDING)", label) - case types.SpecStateSkipped: - label = fmt.Sprintf("%s (SKIPPED)", label) - } - - color := r.highlightColorForState(report.State) - fmt.Fprintf(r.writer, "%s%s\n", indent, r.f(color+"%s{{/}}", label)) - r.fdHierarchy = hierarchy -} - func (r *DefaultReporter) highlightColorForState(state types.SpecState) string { switch state { case types.SpecStatePassed: diff --git a/vendor/github.com/onsi/ginkgo/v2/types/config.go b/vendor/github.com/onsi/ginkgo/v2/types/config.go index 854fec6a39..ca64acb27a 100644 --- a/vendor/github.com/onsi/ginkgo/v2/types/config.go +++ b/vendor/github.com/onsi/ginkgo/v2/types/config.go @@ -38,7 +38,6 @@ type SuiteConfig struct { OutputInterceptorMode string SourceRoots []string GracePeriod time.Duration - SleepOnFailure time.Duration ParallelProcess int ParallelTotal int @@ -95,7 +94,6 @@ type ReporterConfig struct { GithubOutput bool SilenceSkips bool ForceNewlines bool - FdOutput bool JSONReport string GoJSONReport string @@ -295,8 +293,6 @@ var SuiteConfigFlags = GinkgoFlags{ Usage: "Make up to this many attempts to run each spec. If any of the attempts succeed, the suite will not be failed."}, {KeyPath: "S.FailOnEmpty", Name: "fail-on-empty", SectionKey: "failure", Usage: "If set, ginkgo will mark the test suite as failed if no specs are run."}, - {KeyPath: "S.SleepOnFailure", Name: "sleep-on-failure", SectionKey: "failure", UsageDefaultValue: "0 - disabled", - Usage: "If set, ginkgo will pause for this duration after a spec fails - before its teardown (AfterEach/JustAfterEach/DeferCleanup) runs - so you can inspect the live system. Press ^C to end the pause early and proceed to cleanup. Serial only: cannot be combined with -p/--procs."}, {KeyPath: "S.DryRun", Name: "dry-run", SectionKey: "debug", DeprecatedName: "dryRun", DeprecatedDocLink: "changed-command-line-flags", Usage: "If set, ginkgo will walk the test hierarchy without actually running anything. Best paired with -v."}, @@ -362,8 +358,7 @@ var ReporterConfigFlags = GinkgoFlags{ Usage: "If set, default reporter will not print out skipped tests."}, {KeyPath: "R.ForceNewlines", Name: "force-newlines", SectionKey: "output", Usage: "If set, default reporter will ensure a newline appears after each test."}, - {KeyPath: "R.FdOutput", Name: "fd", SectionKey: "output", - Usage: "If set, emits RSpec-style 'format documentation' output instead of Ginkgo's default output. --fd is exclusive: it overrides -p/-procs and -randomize-all, forcing specs to run serially in declaration order, since fd's hierarchical output can't be rendered sensibly when specs are parallelized or randomized."}, + {KeyPath: "R.JSONReport", Name: "json-report", UsageArgument: "filename.json", SectionKey: "output", Usage: "If set, Ginkgo will generate a JSON-formatted test report at the specified location."}, {KeyPath: "R.GoJSONReport", Name: "gojson-report", UsageArgument: "filename.json", SectionKey: "output", @@ -434,14 +429,6 @@ func VetConfig(flagSet GinkgoFlagSet, suiteConfig SuiteConfig, reporterConfig Re errors = append(errors, GinkgoErrors.GracePeriodCannotBeZero()) } - if suiteConfig.SleepOnFailure < 0 { - errors = append(errors, GinkgoErrors.InvalidSleepOnFailureConfiguration()) - } - - if suiteConfig.SleepOnFailure > 0 && suiteConfig.ParallelTotal > 1 { - errors = append(errors, GinkgoErrors.SleepOnFailureInParallelConfiguration()) - } - if len(suiteConfig.FocusFiles) > 0 { _, err := ParseFileFilters(suiteConfig.FocusFiles) if err != nil { @@ -489,30 +476,6 @@ func VetConfig(flagSet GinkgoFlagSet, suiteConfig SuiteConfig, reporterConfig Re return errors } -// ReconcileFdOutputConfiguration forces serial, in-order execution when --fd is combined with -// -p, -procs (>1), or -randomize-all. fd's RSpec-style hierarchical output assumes specs run -// one at a time, in declaration order -- parallelism and randomization both break that assumption -// and produce fragmented, hard-to-read output. Rather than refusing to run, Ginkgo ignores those -// flags and runs in series instead. suiteConfig and cliConfig are mutated in place; the return -// value is true if anything was overridden, so callers can let the user know what was ignored. -func ReconcileFdOutputConfiguration(reporterConfig ReporterConfig, suiteConfig *SuiteConfig, cliConfig *CLIConfig) bool { - if !reporterConfig.FdOutput { - return false - } - - changed := false - if cliConfig.ComputedProcs() > 1 { - cliConfig.Procs = 1 - cliConfig.Parallel = false - changed = true - } - if suiteConfig.RandomizeAllSpecs { - suiteConfig.RandomizeAllSpecs = false - changed = true - } - return changed -} - // GinkgoCLISharedFlags provides flags shared by the Ginkgo CLI's build, watch, and run commands var GinkgoCLISharedFlags = GinkgoFlags{ {KeyPath: "C.Recurse", Name: "r", SectionKey: "multiple-suites", diff --git a/vendor/github.com/onsi/ginkgo/v2/types/errors.go b/vendor/github.com/onsi/ginkgo/v2/types/errors.go index 636070c124..623e54b66e 100644 --- a/vendor/github.com/onsi/ginkgo/v2/types/errors.go +++ b/vendor/github.com/onsi/ginkgo/v2/types/errors.go @@ -455,7 +455,7 @@ func (g ginkgoErrors) InvalidEmptyComponentForSemVerConstraint(cl CodeLocation) Heading: "Invalid Empty Component for ComponentSemVerConstraint", Message: "ComponentSemVerConstraint requires a non-empty component name", CodeLocation: cl, - DocLink: "spec-semantic-version-filtering", + DocLink: "spec-semantic-version-filtering", } } @@ -621,21 +621,6 @@ func (g ginkgoErrors) GracePeriodCannotBeZero() error { } } -func (g ginkgoErrors) InvalidSleepOnFailureConfiguration() error { - return GinkgoError{ - Heading: "Ginkgo requires a non-negative --sleep-on-failure.", - Message: "Please set --sleep-on-failure to a positive duration (e.g. 5m), or 0 to disable it.", - } -} - -func (g ginkgoErrors) SleepOnFailureInParallelConfiguration() error { - return GinkgoError{ - Heading: "Ginkgo only supports --sleep-on-failure in serial mode.", - Message: "--sleep-on-failure pauses a failed spec on a live system for inspection, which only makes sense when the suite runs serially. Please run again without -p or --procs, or unset --sleep-on-failure.", - DocLink: "spec-timeouts-and-interruptible-nodes", - } -} - func (g ginkgoErrors) ConflictingVerbosityConfiguration() error { return GinkgoError{ Heading: "Conflicting reporter verbosity settings.", diff --git a/vendor/github.com/onsi/ginkgo/v2/types/version.go b/vendor/github.com/onsi/ginkgo/v2/types/version.go index dc28324c1d..1b43092c22 100644 --- a/vendor/github.com/onsi/ginkgo/v2/types/version.go +++ b/vendor/github.com/onsi/ginkgo/v2/types/version.go @@ -1,3 +1,3 @@ package types -const VERSION = "2.32.0" +const VERSION = "2.31.0" diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/decorators/operator.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/decorators/operator.go index 5a21320e6f..56b9c92b67 100644 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/decorators/operator.go +++ b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/decorators/operator.go @@ -5,8 +5,8 @@ import ( "sort" "strings" - "github.com/go-viper/mapstructure/v2" "github.com/itchyny/gojq" + "github.com/mitchellh/mapstructure" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/lib/codec/mapstructure.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/lib/codec/mapstructure.go index 341f7eea47..c021b143bc 100644 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/lib/codec/mapstructure.go +++ b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/lib/codec/mapstructure.go @@ -4,7 +4,7 @@ import ( "reflect" "time" - "github.com/go-viper/mapstructure/v2" + "github.com/mitchellh/mapstructure" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/lib/comparison/equal.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/lib/comparison/equal.go index d1d7f84bc7..bccbaaa8a3 100644 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/lib/comparison/equal.go +++ b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/lib/comparison/equal.go @@ -3,7 +3,7 @@ package comparison import ( // "fmt" - "github.com/mitchellh/hashstructure/v2" + "github.com/mitchellh/hashstructure" ) // Equalitor describes an algorithm for equivalence between two data structures. @@ -25,12 +25,12 @@ func (e EqualFunc) Equal(a, b interface{}) bool { // This function panics if an error is encountered generating a hash for either argument. func NewHashEqualitor() EqualFunc { return func(a, b interface{}) bool { - hashA, err := hashstructure.Hash(a, hashstructure.FormatV2, nil) + hashA, err := hashstructure.Hash(a, nil) if err != nil { panic(err.Error()) } - hashB, err := hashstructure.Hash(b, hashstructure.FormatV2, nil) + hashB, err := hashstructure.Hash(b, nil) if err != nil { panic(err.Error()) } diff --git a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/server/server.go b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/server/server.go index a6e8a3216c..81ea882c78 100644 --- a/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/server/server.go +++ b/vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/server/server.go @@ -23,18 +23,13 @@ import ( "k8s.io/client-go/tools/clientcmd" "k8s.io/client-go/util/workqueue" - configv1client "github.com/openshift/client-go/config/clientset/versioned" - libcrypto "github.com/openshift/library-go/pkg/crypto" operatorsv1 "github.com/operator-framework/api/pkg/operators/v1" "github.com/operator-framework/operator-lifecycle-manager/pkg/api/client" olminformers "github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/informers/externalversions" - olmapiserver "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/apiserver" - "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/openshiftconfig" "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/queueinformer" "github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apiserver" genericpackageserver "github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/apiserver/generic" "github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/provider" - apidiscovery "k8s.io/client-go/discovery" ) const DefaultWakeupInterval = 12 * time.Hour @@ -207,13 +202,19 @@ func (o *PackageServerOptions) Run(ctx context.Context) error { string(genericfeatures.UnauthenticatedHTTP2DOSMitigation): true, }) - // Set up the client config before calling Config() so it can be used to - // apply the cluster TLS security profile to the serving options. + // Grab the config for the API server + config, err := o.Config(ctx) + if err != nil { + return err + } + config.GenericConfig.EnableMetrics = true + + // Set up the client config var clientConfig *rest.Config - var err error if len(o.Kubeconfig) > 0 { loadingRules := &clientcmd.ClientConfigLoadingRules{ExplicitPath: o.Kubeconfig} loader := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loadingRules, &clientcmd.ConfigOverrides{}) + clientConfig, err = loader.ClientConfig() } else { clientConfig, err = rest.InClusterConfig() @@ -222,23 +223,6 @@ func (o *PackageServerOptions) Run(ctx context.Context) error { return fmt.Errorf("unable to construct lister client config: %v", err) } - // If --tls-min-version was not supplied (e.g. no PSM-injected flags yet), fall - // back to a direct GET of the cluster APIServer CR so the packageserver still - // honours the cluster TLS security profile on first boot or during upgrades. - if o.SecureServing.MinTLSVersion == "" { - if err := applyClusterTLSProfile(ctx, clientConfig, o.SecureServing); err != nil { - return fmt.Errorf("failed to apply cluster TLS profile to serving options: %w", err) - } - } - - // Grab the config for the API server - var config *apiserver.Config - config, err = o.Config(ctx) - if err != nil { - return err - } - config.GenericConfig.EnableMetrics = true - kubeClient, err := kubernetes.NewForConfig(clientConfig) if err != nil { return fmt.Errorf("unable to construct lister client: %v", err) @@ -342,58 +326,3 @@ func (op *Operator) syncOLMConfig(obj interface{}) error { return nil } - -// applyClusterTLSProfile fetches the cluster-wide APIServer TLS security profile -// and applies it to the SecureServingOptions. It is a no-op on non-OpenShift clusters. -// This is the fallback path used when --tls-min-version is not provided via flags -// (i.e. before the PSM has had a chance to inject them). -func applyClusterTLSProfile(ctx context.Context, config *rest.Config, serving *genericoptions.SecureServingOptionsWithLoopback) error { - const lookupTimeout = 30 * time.Second - profileCtx, cancel := context.WithTimeout(ctx, lookupTimeout) - defer cancel() - - profileConfig := rest.CopyConfig(config) - if profileConfig.Timeout == 0 || profileConfig.Timeout > lookupTimeout { - profileConfig.Timeout = lookupTimeout - } - - kubeClient, err := kubernetes.NewForConfig(profileConfig) - if err != nil { - return fmt.Errorf("failed to create kubernetes client: %w", err) - } - cfgClient, err := configv1client.NewForConfig(profileConfig) - if err != nil { - return fmt.Errorf("failed to create config client: %w", err) - } - return applyClusterTLSProfileWithClients(profileCtx, kubeClient.Discovery(), cfgClient, serving) -} - -// applyClusterTLSProfileWithClients is the testable core of applyClusterTLSProfile. -// It applies the cluster-wide APIServer TLS security profile to the SecureServingOptions, -// but only for fields not already set by explicit flags (--tls-min-version / --tls-cipher-suites). -// It is a no-op on non-OpenShift clusters. -func applyClusterTLSProfileWithClients(ctx context.Context, discovery apidiscovery.DiscoveryInterface, cfgClient configv1client.Interface, serving *genericoptions.SecureServingOptionsWithLoopback) error { - available, err := openshiftconfig.IsAPIAvailable(discovery) - if err != nil { - return fmt.Errorf("failed to check OpenShift config API: %w", err) - } - if !available { - return nil - } - - apiServer, err := cfgClient.ConfigV1().APIServers().Get(ctx, "cluster", metav1.GetOptions{}) - if err != nil { - return fmt.Errorf("failed to get APIServer config: %w", err) - } - - minVersion, cipherSuites := olmapiserver.GetSecurityProfileConfig(apiServer.Spec.TLSSecurityProfile) - // Only override fields not already set by explicit flags. - if serving.MinTLSVersion == "" { - serving.MinTLSVersion = libcrypto.TLSVersionToNameOrDie(minVersion) - } - if len(serving.CipherSuites) == 0 { - serving.CipherSuites = libcrypto.CipherSuitesToNamesOrDie(cipherSuites) - } - log.Infof("Applying cluster TLS security profile: minVersion=%s cipherSuites=%v", serving.MinTLSVersion, serving.CipherSuites) - return nil -} diff --git a/vendor/github.com/prometheus/common/expfmt/expfmt.go b/vendor/github.com/prometheus/common/expfmt/expfmt.go index 10bf35708c..4e4c13e724 100644 --- a/vendor/github.com/prometheus/common/expfmt/expfmt.go +++ b/vendor/github.com/prometheus/common/expfmt/expfmt.go @@ -122,7 +122,7 @@ func NewOpenMetricsFormat(version string) (Format, error) { // removed. func (f Format) WithEscapingScheme(s model.EscapingScheme) Format { var terms []string - for p := range strings.SplitSeq(string(f), ";") { + for _, p := range strings.Split(string(f), ";") { toks := strings.Split(p, "=") if len(toks) != 2 { trimmed := strings.TrimSpace(p) @@ -194,7 +194,7 @@ func (f Format) FormatType() FormatType { // "escaping" term exists, that will be used. Otherwise, the global default will // be returned. func (f Format) ToEscapingScheme() model.EscapingScheme { - for p := range strings.SplitSeq(string(f), ";") { + for _, p := range strings.Split(string(f), ";") { toks := strings.Split(p, "=") if len(toks) != 2 { continue diff --git a/vendor/github.com/prometheus/common/expfmt/text_create.go b/vendor/github.com/prometheus/common/expfmt/text_create.go index f4074ae9a3..6b89781456 100644 --- a/vendor/github.com/prometheus/common/expfmt/text_create.go +++ b/vendor/github.com/prometheus/common/expfmt/text_create.go @@ -42,12 +42,12 @@ const ( var ( bufPool = sync.Pool{ - New: func() any { + New: func() interface{} { return bufio.NewWriter(io.Discard) }, } numBufPool = sync.Pool{ - New: func() any { + New: func() interface{} { b := make([]byte, 0, initialNumBufSize) return &b }, diff --git a/vendor/github.com/prometheus/common/expfmt/text_parse.go b/vendor/github.com/prometheus/common/expfmt/text_parse.go index 4ce1f40b81..00c8841a10 100644 --- a/vendor/github.com/prometheus/common/expfmt/text_parse.go +++ b/vendor/github.com/prometheus/common/expfmt/text_parse.go @@ -339,16 +339,6 @@ func (p *TextParser) startLabelName() stateFn { return nil // Unexpected end of input. } if p.currentByte == '}' { - if p.currentMF == nil { - // The closing brace was reached before any metric name was read, - // e.g. for the input "{}". There is no metric to attach labels to, - // so this is a malformed exposition. This mirrors the guard in - // startLabelValue. currentMF (not currentMetric) is checked because - // reset only clears currentMF between parses. - p.parseError("invalid metric name") - p.currentLabelPairs = nil - return nil - } p.currentMetric.Label = append(p.currentMetric.Label, p.currentLabelPairs...) p.currentLabelPairs = nil if p.skipBlankTab(); p.err != nil { diff --git a/vendor/github.com/prometheus/common/model/labels.go b/vendor/github.com/prometheus/common/model/labels.go index 29688a13c8..dfeb34be5f 100644 --- a/vendor/github.com/prometheus/common/model/labels.go +++ b/vendor/github.com/prometheus/common/model/labels.go @@ -124,7 +124,7 @@ func (ln LabelName) IsValidLegacy() bool { } // UnmarshalYAML implements the yaml.Unmarshaler interface. -func (ln *LabelName) UnmarshalYAML(unmarshal func(any) error) error { +func (ln *LabelName) UnmarshalYAML(unmarshal func(interface{}) error) error { var s string if err := unmarshal(&s); err != nil { return err diff --git a/vendor/github.com/prometheus/common/model/labelset.go b/vendor/github.com/prometheus/common/model/labelset.go index 6010b26a88..9de47b2568 100644 --- a/vendor/github.com/prometheus/common/model/labelset.go +++ b/vendor/github.com/prometheus/common/model/labelset.go @@ -16,7 +16,6 @@ package model import ( "encoding/json" "fmt" - "maps" "sort" ) @@ -108,7 +107,9 @@ func (ls LabelSet) Before(o LabelSet) bool { // Clone returns a copy of the label set. func (ls LabelSet) Clone() LabelSet { lsn := make(LabelSet, len(ls)) - maps.Copy(lsn, ls) + for ln, lv := range ls { + lsn[ln] = lv + } return lsn } @@ -116,9 +117,13 @@ func (ls LabelSet) Clone() LabelSet { func (ls LabelSet) Merge(other LabelSet) LabelSet { result := make(LabelSet, len(ls)) - maps.Copy(result, ls) + for k, v := range ls { + result[k] = v + } - maps.Copy(result, other) + for k, v := range other { + result[k] = v + } return result } diff --git a/vendor/github.com/prometheus/common/model/metric.go b/vendor/github.com/prometheus/common/model/metric.go index 2fe461511d..429a0dab1e 100644 --- a/vendor/github.com/prometheus/common/model/metric.go +++ b/vendor/github.com/prometheus/common/model/metric.go @@ -17,7 +17,6 @@ import ( "encoding/json" "errors" "fmt" - "maps" "regexp" "sort" "strconv" @@ -259,7 +258,9 @@ func (m Metric) Before(o Metric) bool { // Clone returns a copy of the Metric. func (m Metric) Clone() Metric { clone := make(Metric, len(m)) - maps.Copy(clone, m) + for k, v := range m { + clone[k] = v + } return clone } diff --git a/vendor/github.com/prometheus/common/model/time.go b/vendor/github.com/prometheus/common/model/time.go index 0854753f4a..1730b0fdc1 100644 --- a/vendor/github.com/prometheus/common/model/time.go +++ b/vendor/github.com/prometheus/common/model/time.go @@ -123,38 +123,44 @@ func (t Time) MarshalJSON() ([]byte, error) { // UnmarshalJSON implements the json.Unmarshaler interface. func (t *Time) UnmarshalJSON(b []byte) error { - base, frac, found := strings.Cut(string(b), ".") - if !found { - v, err := strconv.ParseInt(base, 10, 64) + p := strings.Split(string(b), ".") + switch len(p) { + case 1: + v, err := strconv.ParseInt(p[0], 10, 64) if err != nil { return err } *t = Time(v * second) - } else { - v, err := strconv.ParseInt(base, 10, 64) + + case 2: + v, err := strconv.ParseInt(p[0], 10, 64) if err != nil { return err } + v *= second - prec := dotPrecision - len(frac) + prec := dotPrecision - len(p[1]) if prec < 0 { - frac = frac[:dotPrecision] + p[1] = p[1][:dotPrecision] + } else if prec > 0 { + p[1] += strings.Repeat("0", prec) } - va, err := strconv.ParseInt(frac, 10, 32) + + va, err := strconv.ParseInt(p[1], 10, 32) if err != nil { return err } - switch prec { - case 1: - va *= 10 - case 2: - va *= 100 - } - if len(base) > 0 && base[0] == '-' { - va = -va + // If the value was something like -0.1 the negative is lost in the + // parsing because of the leading zero, this ensures that we capture it. + if len(p[0]) > 0 && p[0][0] == '-' && v+va > 0 { + *t = Time(v+va) * -1 + } else { + *t = Time(v + va) } - *t = Time(v*second + va) + + default: + return fmt.Errorf("invalid time %q", string(b)) } return nil } @@ -334,12 +340,12 @@ func (d *Duration) UnmarshalText(text []byte) error { } // MarshalYAML implements the yaml.Marshaler interface. -func (d Duration) MarshalYAML() (any, error) { +func (d Duration) MarshalYAML() (interface{}, error) { return d.String(), nil } // UnmarshalYAML implements the yaml.Unmarshaler interface. -func (d *Duration) UnmarshalYAML(unmarshal func(any) error) error { +func (d *Duration) UnmarshalYAML(unmarshal func(interface{}) error) error { var s string if err := unmarshal(&s); err != nil { return err diff --git a/vendor/github.com/prometheus/common/model/value.go b/vendor/github.com/prometheus/common/model/value.go index 8dffd9c4a5..a9995a37ee 100644 --- a/vendor/github.com/prometheus/common/model/value.go +++ b/vendor/github.com/prometheus/common/model/value.go @@ -259,13 +259,13 @@ func (s Scalar) String() string { // MarshalJSON implements json.Marshaler. func (s Scalar) MarshalJSON() ([]byte, error) { v := strconv.FormatFloat(float64(s.Value), 'f', -1, 64) - return json.Marshal([...]any{s.Timestamp, v}) + return json.Marshal([...]interface{}{s.Timestamp, v}) } // UnmarshalJSON implements json.Unmarshaler. func (s *Scalar) UnmarshalJSON(b []byte) error { var f string - v := [...]any{&s.Timestamp, &f} + v := [...]interface{}{&s.Timestamp, &f} if err := json.Unmarshal(b, &v); err != nil { return err @@ -291,12 +291,12 @@ func (s *String) String() string { // MarshalJSON implements json.Marshaler. func (s String) MarshalJSON() ([]byte, error) { - return json.Marshal([]any{s.Timestamp, s.Value}) + return json.Marshal([]interface{}{s.Timestamp, s.Value}) } // UnmarshalJSON implements json.Unmarshaler. func (s *String) UnmarshalJSON(b []byte) error { - v := [...]any{&s.Timestamp, &s.Value} + v := [...]interface{}{&s.Timestamp, &s.Value} return json.Unmarshal(b, &v) } diff --git a/vendor/github.com/prometheus/common/model/value_float.go b/vendor/github.com/prometheus/common/model/value_float.go index b7d93615e2..6bfc757d18 100644 --- a/vendor/github.com/prometheus/common/model/value_float.go +++ b/vendor/github.com/prometheus/common/model/value_float.go @@ -79,7 +79,7 @@ func (s SamplePair) MarshalJSON() ([]byte, error) { if err != nil { return nil, err } - return fmt.Appendf(nil, "[%s,%s]", t, v), nil + return []byte(fmt.Sprintf("[%s,%s]", t, v)), nil } // UnmarshalJSON implements json.Unmarshaler. diff --git a/vendor/github.com/prometheus/common/model/value_histogram.go b/vendor/github.com/prometheus/common/model/value_histogram.go index f27856ccc4..91ce5b7a45 100644 --- a/vendor/github.com/prometheus/common/model/value_histogram.go +++ b/vendor/github.com/prometheus/common/model/value_histogram.go @@ -67,11 +67,11 @@ func (s HistogramBucket) MarshalJSON() ([]byte, error) { if err != nil { return nil, err } - return fmt.Appendf(nil, "[%s,%s,%s,%s]", b, l, u, c), nil + return []byte(fmt.Sprintf("[%s,%s,%s,%s]", b, l, u, c)), nil } func (s *HistogramBucket) UnmarshalJSON(buf []byte) error { - tmp := []any{&s.Boundaries, &s.Lower, &s.Upper, &s.Count} + tmp := []interface{}{&s.Boundaries, &s.Lower, &s.Upper, &s.Count} wantLen := len(tmp) if err := json.Unmarshal(buf, &tmp); err != nil { return err @@ -152,11 +152,11 @@ func (s SampleHistogramPair) MarshalJSON() ([]byte, error) { if err != nil { return nil, err } - return fmt.Appendf(nil, "[%s,%s]", t, v), nil + return []byte(fmt.Sprintf("[%s,%s]", t, v)), nil } func (s *SampleHistogramPair) UnmarshalJSON(buf []byte) error { - tmp := []any{&s.Timestamp, &s.Histogram} + tmp := []interface{}{&s.Timestamp, &s.Histogram} wantLen := len(tmp) if err := json.Unmarshal(buf, &tmp); err != nil { return err diff --git a/vendor/k8s.io/apimachinery/pkg/api/validation/objectmeta.go b/vendor/k8s.io/apimachinery/pkg/api/validation/objectmeta.go index 9a4f378483..839fcbc2c1 100644 --- a/vendor/k8s.io/apimachinery/pkg/api/validation/objectmeta.go +++ b/vendor/k8s.io/apimachinery/pkg/api/validation/objectmeta.go @@ -46,7 +46,7 @@ func ValidateAnnotations(annotations map[string]string, fldPath *field.Path) fie for k := range annotations { // The rule is QualifiedName except that case doesn't matter, so convert to lowercase before checking. for _, msg := range validation.IsQualifiedName(strings.ToLower(k)) { - allErrs = append(allErrs, field.Invalid(fldPath, k, msg).WithOrigin("format=k8s-label-key")) + allErrs = append(allErrs, field.Invalid(fldPath, k, msg)).WithOrigin("format=k8s-label-key") } } if err := ValidateAnnotationsSize(annotations); err != nil { diff --git a/vendor/modules.txt b/vendor/modules.txt index 7a9ead4731..ac0bd1db68 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -92,7 +92,7 @@ github.com/clipperhouse/uax29/v2/graphemes # github.com/containerd/cgroups/v3 v3.1.2 ## explicit; go 1.22.0 github.com/containerd/cgroups/v3/cgroup1/stats -# github.com/containerd/containerd v1.7.33 +# github.com/containerd/containerd v1.7.32 ## explicit; go 1.24.0 github.com/containerd/containerd/archive github.com/containerd/containerd/archive/compression @@ -333,10 +333,6 @@ github.com/go-openapi/swag/yamlutils # github.com/go-task/slim-sprig/v3 v3.0.0 ## explicit; go 1.20 github.com/go-task/slim-sprig/v3 -# github.com/go-viper/mapstructure/v2 v2.5.0 -## explicit; go 1.18 -github.com/go-viper/mapstructure/v2 -github.com/go-viper/mapstructure/v2/internal/errors # github.com/gobuffalo/flect v1.0.3 ## explicit; go 1.16 github.com/gobuffalo/flect @@ -531,9 +527,12 @@ github.com/mikefarah/yq/v3/pkg/yqlib # github.com/mitchellh/go-wordwrap v1.0.1 ## explicit; go 1.14 github.com/mitchellh/go-wordwrap -# github.com/mitchellh/hashstructure/v2 v2.0.2 +# github.com/mitchellh/hashstructure v1.1.0 +## explicit; go 1.14 +github.com/mitchellh/hashstructure +# github.com/mitchellh/mapstructure v1.5.0 ## explicit; go 1.14 -github.com/mitchellh/hashstructure/v2 +github.com/mitchellh/mapstructure # github.com/moby/locker v1.0.1 ## explicit; go 1.13 github.com/moby/locker @@ -570,7 +569,7 @@ github.com/modern-go/reflect2 github.com/munnerz/goautoneg # github.com/nxadm/tail v1.4.11 ## explicit; go 1.13 -# github.com/onsi/ginkgo/v2 v2.32.0 +# github.com/onsi/ginkgo/v2 v2.31.0 ## explicit; go 1.25.0 github.com/onsi/ginkgo/v2/config github.com/onsi/ginkgo/v2/formatter @@ -841,7 +840,7 @@ github.com/prometheus/client_golang/prometheus/testutil/promlint/validations # github.com/prometheus/client_model v0.6.2 ## explicit; go 1.22.0 github.com/prometheus/client_model/go -# github.com/prometheus/common v0.69.0 +# github.com/prometheus/common v0.68.1 ## explicit; go 1.25.0 github.com/prometheus/common/expfmt github.com/prometheus/common/model @@ -1433,7 +1432,7 @@ gopkg.in/yaml.v2 # gopkg.in/yaml.v3 v3.0.1 ## explicit gopkg.in/yaml.v3 -# k8s.io/api v0.36.2 +# k8s.io/api v0.36.1 ## explicit; go 1.26.0 k8s.io/api/admission/v1 k8s.io/api/admission/v1beta1 @@ -1493,7 +1492,7 @@ k8s.io/api/storage/v1 k8s.io/api/storage/v1alpha1 k8s.io/api/storage/v1beta1 k8s.io/api/storagemigration/v1beta1 -# k8s.io/apiextensions-apiserver v0.36.2 +# k8s.io/apiextensions-apiserver v0.36.1 ## explicit; go 1.26.0 k8s.io/apiextensions-apiserver/pkg/apihelpers k8s.io/apiextensions-apiserver/pkg/apis/apiextensions @@ -1515,7 +1514,7 @@ k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/scheme k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1 k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1 k8s.io/apiextensions-apiserver/pkg/features -# k8s.io/apimachinery v0.36.2 +# k8s.io/apimachinery v0.36.1 ## explicit; go 1.26.0 k8s.io/apimachinery/pkg/api/equality k8s.io/apimachinery/pkg/api/errors @@ -1583,7 +1582,7 @@ k8s.io/apimachinery/pkg/version k8s.io/apimachinery/pkg/watch k8s.io/apimachinery/third_party/forked/golang/json k8s.io/apimachinery/third_party/forked/golang/reflect -# k8s.io/apiserver v0.36.2 +# k8s.io/apiserver v0.36.1 ## explicit; go 1.26.0 k8s.io/apiserver/pkg/admission k8s.io/apiserver/pkg/admission/configuration @@ -1769,7 +1768,7 @@ k8s.io/apiserver/plugin/pkg/authorizer/webhook/metrics # k8s.io/cli-runtime v0.36.1 ## explicit; go 1.26.0 k8s.io/cli-runtime/pkg/printers -# k8s.io/client-go v0.36.2 +# k8s.io/client-go v0.36.1 ## explicit; go 1.26.0 k8s.io/client-go/applyconfigurations k8s.io/client-go/applyconfigurations/admissionregistration/v1 @@ -2109,7 +2108,7 @@ k8s.io/client-go/util/keyutil k8s.io/client-go/util/retry k8s.io/client-go/util/watchlist k8s.io/client-go/util/workqueue -# k8s.io/code-generator v0.36.2 +# k8s.io/code-generator v0.36.1 ## explicit; go 1.26.0 k8s.io/code-generator k8s.io/code-generator/cmd/applyconfiguration-gen @@ -2145,7 +2144,7 @@ k8s.io/code-generator/cmd/register-gen/generators k8s.io/code-generator/pkg/namer k8s.io/code-generator/pkg/util k8s.io/code-generator/third_party/forked/golang/reflect -# k8s.io/component-base v0.36.2 +# k8s.io/component-base v0.36.1 ## explicit; go 1.26.0 k8s.io/component-base/cli/flag k8s.io/component-base/compatibility @@ -2188,13 +2187,13 @@ k8s.io/klog/v2/internal/severity k8s.io/klog/v2/internal/sloghandler k8s.io/klog/v2/internal/verbosity k8s.io/klog/v2/textlogger -# k8s.io/kms v0.36.2 +# k8s.io/kms v0.36.1 ## explicit; go 1.26.0 k8s.io/kms/apis/v1beta1 k8s.io/kms/apis/v2 k8s.io/kms/pkg/service k8s.io/kms/pkg/util -# k8s.io/kube-aggregator v0.36.2 +# k8s.io/kube-aggregator v0.36.1 ## explicit; go 1.26.0 k8s.io/kube-aggregator/pkg/apis/apiregistration k8s.io/kube-aggregator/pkg/apis/apiregistration/v1 @@ -2246,7 +2245,7 @@ k8s.io/kube-openapi/pkg/validation/validate k8s.io/kubectl/pkg/util/interrupt k8s.io/kubectl/pkg/util/templates k8s.io/kubectl/pkg/util/term -# k8s.io/streaming v0.36.2 +# k8s.io/streaming v0.36.1 ## explicit; go 1.26.0 k8s.io/streaming/pkg/httpstream k8s.io/streaming/pkg/httpstream/wsstream