diff --git a/go.mod b/go.mod index 7c0d7d561..c69c464f9 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.1 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.38.0 golang.org/x/sync v0.22.0 @@ -43,7 +44,6 @@ require ( google.golang.org/grpc v1.82.0 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/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 @@ -214,6 +213,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.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 diff --git a/pkg/lib/bundle/chartutil.go b/pkg/lib/bundle/chartutil.go index f7090446a..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.v2" + "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 7895126b6..d3d39f54c 100644 --- a/pkg/lib/bundle/generate.go +++ b/pkg/lib/bundle/generate.go @@ -1,6 +1,7 @@ package bundle import ( + "bytes" "fmt" "io" "os" @@ -8,7 +9,7 @@ import ( "strings" log "github.com/sirupsen/logrus" - "gopkg.in/yaml.v2" + "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" @@ -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/generate_test.go b/pkg/lib/bundle/generate_test.go index 3280d6e0a..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.v2" + "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 b1977068e..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.v2" + "go.yaml.in/yaml/v3" ) const ( diff --git a/pkg/lib/bundle/validate_test.go b/pkg/lib/bundle/validate_test.go index cb4a7283f..4b907efd3 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 diff --git a/pkg/lib/indexer/indexer.go b/pkg/lib/indexer/indexer.go index dd24289f2..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.v2" + "go.yaml.in/yaml/v3" utilerrors "k8s.io/apimachinery/pkg/util/errors" "github.com/operator-framework/operator-registry/pkg/containertools" 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 diff --git a/pkg/sqlite/directory_test.go b/pkg/sqlite/directory_test.go index 767d74334..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.v2" + "go.yaml.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)