From dccb724d26bd56327c0ec4b5b93698b42bbe74fe Mon Sep 17 00:00:00 2001 From: Chiman Jain Date: Wed, 24 Jun 2026 10:03:20 +0530 Subject: [PATCH 1/4] chore: upgrade gopkg.in/yaml from v2 to v3 Signed-off-by: Chiman Jain --- go.mod | 4 ++-- pkg/lib/bundle/chartutil.go | 2 +- pkg/lib/bundle/generate.go | 2 +- pkg/lib/bundle/generate_test.go | 2 +- pkg/lib/bundle/utils_test.go | 2 +- pkg/lib/indexer/indexer.go | 2 +- pkg/sqlite/directory_test.go | 11 +++++++---- 7 files changed, 14 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index 8960b4560..40d2c820b 100644 --- a/go.mod +++ b/go.mod @@ -43,7 +43,7 @@ require ( google.golang.org/grpc v1.81.1 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 + 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 @@ -214,7 +214,7 @@ require ( gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect k8s.io/apiserver v0.36.2 // indirect k8s.io/cli-runtime v0.36.1 // indirect k8s.io/component-base v0.36.2 // indirect diff --git a/pkg/lib/bundle/chartutil.go b/pkg/lib/bundle/chartutil.go index f7090446a..8c888afb8 100644 --- a/pkg/lib/bundle/chartutil.go +++ b/pkg/lib/bundle/chartutil.go @@ -23,7 +23,7 @@ import ( "path/filepath" "github.com/pkg/errors" - "gopkg.in/yaml.v2" + "gopkg.in/yaml.v3" ) // Maintainer describes a Chart maintainer. diff --git a/pkg/lib/bundle/generate.go b/pkg/lib/bundle/generate.go index 7895126b6..d59fcad3d 100644 --- a/pkg/lib/bundle/generate.go +++ b/pkg/lib/bundle/generate.go @@ -8,7 +8,7 @@ import ( "strings" log "github.com/sirupsen/logrus" - "gopkg.in/yaml.v2" + "gopkg.in/yaml.v3" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" utilerrors "k8s.io/apimachinery/pkg/util/errors" k8syaml "k8s.io/apimachinery/pkg/util/yaml" diff --git a/pkg/lib/bundle/generate_test.go b/pkg/lib/bundle/generate_test.go index 3280d6e0a..467a6b14a 100644 --- a/pkg/lib/bundle/generate_test.go +++ b/pkg/lib/bundle/generate_test.go @@ -7,7 +7,7 @@ import ( "testing" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v2" + "gopkg.in/yaml.v3" ) func TestGetMediaType(t *testing.T) { diff --git a/pkg/lib/bundle/utils_test.go b/pkg/lib/bundle/utils_test.go index b1977068e..476582cfb 100644 --- a/pkg/lib/bundle/utils_test.go +++ b/pkg/lib/bundle/utils_test.go @@ -4,7 +4,7 @@ import ( "os" "path/filepath" - "gopkg.in/yaml.v2" + "gopkg.in/yaml.v3" ) const ( diff --git a/pkg/lib/indexer/indexer.go b/pkg/lib/indexer/indexer.go index dd24289f2..9e010dcff 100644 --- a/pkg/lib/indexer/indexer.go +++ b/pkg/lib/indexer/indexer.go @@ -13,7 +13,7 @@ import ( "sync" "github.com/sirupsen/logrus" - "gopkg.in/yaml.v2" + "gopkg.in/yaml.v3" utilerrors "k8s.io/apimachinery/pkg/util/errors" "github.com/operator-framework/operator-registry/pkg/containertools" diff --git a/pkg/sqlite/directory_test.go b/pkg/sqlite/directory_test.go index 767d74334..69858716a 100644 --- a/pkg/sqlite/directory_test.go +++ b/pkg/sqlite/directory_test.go @@ -9,7 +9,7 @@ import ( "github.com/otiai10/copy" "github.com/sirupsen/logrus" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v2" + "gopkg.in/yaml.v3" "github.com/operator-framework/operator-registry/pkg/api" "github.com/operator-framework/operator-registry/pkg/registry" @@ -206,13 +206,16 @@ func TestQuerierForDirectory(t *testing.T) { {"etcd", "stable", "etcdoperator.v0.6.1", ""}, {"etcd", "stable", "etcdoperator.v0.9.0", "etcdoperator.v0.6.1"}, {"etcd", "stable", "etcdoperator.v0.9.2", "etcdoperator.v0.9.1"}, - {"etcd", "stable", "etcdoperator.v0.9.2", "etcdoperator.v0.9.0"}}, etcdChannelEntriesThatProvide) + {"etcd", "stable", "etcdoperator.v0.9.2", "etcdoperator.v0.9.0"}, + }, etcdChannelEntriesThatProvide) etcdLatestChannelEntriesThatProvide, err := store.GetLatestChannelEntriesThatProvide(context.TODO(), "etcd.database.coreos.com", "v1beta2", "EtcdCluster") require.NoError(t, err) - require.ElementsMatch(t, []*registry.ChannelEntry{{"etcd", "alpha", "etcdoperator.v0.9.2", "etcdoperator.v0.9.0"}, + require.ElementsMatch(t, []*registry.ChannelEntry{ + {"etcd", "alpha", "etcdoperator.v0.9.2", "etcdoperator.v0.9.0"}, {"etcd", "beta", "etcdoperator.v0.9.0", "etcdoperator.v0.6.1"}, - {"etcd", "stable", "etcdoperator.v0.9.2", "etcdoperator.v0.9.0"}}, etcdLatestChannelEntriesThatProvide) + {"etcd", "stable", "etcdoperator.v0.9.2", "etcdoperator.v0.9.0"}, + }, etcdLatestChannelEntriesThatProvide) etcdBundleByProvides, err := store.GetBundleThatProvides(context.TODO(), "etcd.database.coreos.com", "v1beta2", "EtcdCluster") require.NoError(t, err) From 4d7d83133cf94f561434b14e2c340ad9f55bc806 Mon Sep 17 00:00:00 2001 From: Chiman Jain Date: Wed, 24 Jun 2026 19:11:37 +0530 Subject: [PATCH 2/4] refactor: update indent to 2 with yaml.v3 and fix minor test inconsistencies Signed-off-by: Chiman Jain --- pkg/lib/bundle/generate.go | 12 +++++++++--- pkg/lib/bundle/validate_test.go | 6 +++--- pkg/prettyunmarshaler/prettyunmarshaler_test.go | 4 ++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/pkg/lib/bundle/generate.go b/pkg/lib/bundle/generate.go index d59fcad3d..e3e1cf17b 100644 --- a/pkg/lib/bundle/generate.go +++ b/pkg/lib/bundle/generate.go @@ -1,6 +1,7 @@ package bundle import ( + "bytes" "fmt" "io" "os" @@ -315,12 +316,17 @@ func GenerateAnnotations(mediaType, manifests, metadata, packageName, channels, annotations.Annotations[ChannelDefaultLabel] = channelDefault } - afile, err := yaml.Marshal(annotations) - if err != nil { + var buf bytes.Buffer + encoder := yaml.NewEncoder(&buf) + encoder.SetIndent(2) + if err := encoder.Encode(annotations); err != nil { + return nil, err + } + if err := encoder.Close(); err != nil { return nil, err } - return afile, nil + return buf.Bytes(), nil } // GenerateDockerfile builds Dockerfile with mediatype, manifests & diff --git a/pkg/lib/bundle/validate_test.go b/pkg/lib/bundle/validate_test.go index cb4a7283f..dc4344b4e 100644 --- a/pkg/lib/bundle/validate_test.go +++ b/pkg/lib/bundle/validate_test.go @@ -30,7 +30,7 @@ func TestValidateBundleDependencies(t *testing.T) { logger: logger, } - var table = []struct { + table := []struct { description string mediaType string directory string @@ -108,7 +108,7 @@ func TestValidateBundleContent(t *testing.T) { logger: logger, } - var table = []struct { + table := []struct { description string mediaType string directory string @@ -134,7 +134,7 @@ func TestValidateBundleContent(t *testing.T) { mediaType: RegistryV1Type, directory: "./testdata/validate/invalid_manifests_bundle/invalid_sa/", numErrors: 1, - errStrings: []string{"json: cannot unmarshal number into Go struct field ObjectMeta.metadata.namespace of type string"}, + errStrings: []string{"json: cannot unmarshal number into Go struct field Meta.metadata.namespace of type string"}, }, { description: "registryv1 bundle/invalid type", diff --git a/pkg/prettyunmarshaler/prettyunmarshaler_test.go b/pkg/prettyunmarshaler/prettyunmarshaler_test.go index a904cd34f..7a7181094 100644 --- a/pkg/prettyunmarshaler/prettyunmarshaler_test.go +++ b/pkg/prettyunmarshaler/prettyunmarshaler_test.go @@ -149,9 +149,9 @@ func TestJsonUnmarshalError(t *testing.T) { // // If the data does not cause a syntax error, this function will panic. func customOffsetSyntaxError(data []byte, offset int64) *json.SyntaxError { - var d *byte = nil + var d byte var se *json.SyntaxError - err := json.Unmarshal(data, d) + err := json.Unmarshal(data, &d) if errors.As(err, &se) { se.Offset = offset return se From 52ecb0c332f0b246f1f8b0d7884e84313aeffb7f Mon Sep 17 00:00:00 2001 From: Chiman Jain Date: Wed, 24 Jun 2026 23:53:54 +0530 Subject: [PATCH 3/4] chore: migrate gopkg.in.yaml.v3 dependency to go.yaml.in/yaml/v3 Signed-off-by: Chiman Jain --- pkg/lib/bundle/chartutil.go | 2 +- pkg/lib/bundle/generate.go | 2 +- pkg/lib/bundle/generate_test.go | 2 +- pkg/lib/bundle/utils_test.go | 2 +- pkg/lib/indexer/indexer.go | 2 +- pkg/sqlite/directory_test.go | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/lib/bundle/chartutil.go b/pkg/lib/bundle/chartutil.go index 8c888afb8..49fe3bf9b 100644 --- a/pkg/lib/bundle/chartutil.go +++ b/pkg/lib/bundle/chartutil.go @@ -23,7 +23,7 @@ import ( "path/filepath" "github.com/pkg/errors" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v3" ) // Maintainer describes a Chart maintainer. diff --git a/pkg/lib/bundle/generate.go b/pkg/lib/bundle/generate.go index e3e1cf17b..d3d39f54c 100644 --- a/pkg/lib/bundle/generate.go +++ b/pkg/lib/bundle/generate.go @@ -9,7 +9,7 @@ import ( "strings" log "github.com/sirupsen/logrus" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v3" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" utilerrors "k8s.io/apimachinery/pkg/util/errors" k8syaml "k8s.io/apimachinery/pkg/util/yaml" diff --git a/pkg/lib/bundle/generate_test.go b/pkg/lib/bundle/generate_test.go index 467a6b14a..0cdc9bb81 100644 --- a/pkg/lib/bundle/generate_test.go +++ b/pkg/lib/bundle/generate_test.go @@ -7,7 +7,7 @@ import ( "testing" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v3" ) func TestGetMediaType(t *testing.T) { diff --git a/pkg/lib/bundle/utils_test.go b/pkg/lib/bundle/utils_test.go index 476582cfb..65712312f 100644 --- a/pkg/lib/bundle/utils_test.go +++ b/pkg/lib/bundle/utils_test.go @@ -4,7 +4,7 @@ import ( "os" "path/filepath" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v3" ) const ( diff --git a/pkg/lib/indexer/indexer.go b/pkg/lib/indexer/indexer.go index 9e010dcff..97e9c3dfd 100644 --- a/pkg/lib/indexer/indexer.go +++ b/pkg/lib/indexer/indexer.go @@ -13,7 +13,7 @@ import ( "sync" "github.com/sirupsen/logrus" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v3" utilerrors "k8s.io/apimachinery/pkg/util/errors" "github.com/operator-framework/operator-registry/pkg/containertools" diff --git a/pkg/sqlite/directory_test.go b/pkg/sqlite/directory_test.go index 69858716a..c82018797 100644 --- a/pkg/sqlite/directory_test.go +++ b/pkg/sqlite/directory_test.go @@ -9,7 +9,7 @@ import ( "github.com/otiai10/copy" "github.com/sirupsen/logrus" "github.com/stretchr/testify/require" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v3" "github.com/operator-framework/operator-registry/pkg/api" "github.com/operator-framework/operator-registry/pkg/registry" From 1670818c953859141bdec96797c90ee1e113df9c Mon Sep 17 00:00:00 2001 From: Chiman Jain Date: Wed, 24 Jun 2026 23:57:34 +0530 Subject: [PATCH 4/4] chore: run go mod tidy after rebase Signed-off-by: Chiman Jain --- go.mod | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 40d2c820b..00971eca6 100644 --- a/go.mod +++ b/go.mod @@ -35,6 +35,7 @@ require ( go.etcd.io/bbolt v1.5.0 go.podman.io/common v0.68.0 go.podman.io/image/v5 v5.40.0 + go.yaml.in/yaml/v3 v3.0.4 golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f golang.org/x/mod v0.37.0 golang.org/x/sync v0.21.0 @@ -43,7 +44,6 @@ require ( google.golang.org/grpc v1.81.1 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.v3 v3.0.1 k8s.io/api v0.36.2 k8s.io/apiextensions-apiserver v0.36.2 k8s.io/apimachinery v0.36.2 @@ -201,7 +201,6 @@ require ( go.opentelemetry.io/proto/otlp v1.10.0 // indirect go.podman.io/storage v1.63.0 // indirect go.yaml.in/yaml/v2 v2.4.3 // indirect - go.yaml.in/yaml/v3 v3.0.4 // indirect golang.org/x/crypto v0.53.0 // indirect golang.org/x/net v0.56.0 // indirect golang.org/x/oauth2 v0.36.0 // indirect @@ -215,6 +214,7 @@ require ( gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/apiserver v0.36.2 // indirect k8s.io/cli-runtime v0.36.1 // indirect k8s.io/component-base v0.36.2 // indirect