diff --git a/.golangci.yml b/.golangci.yml index 03c1a22b8..b32b091f7 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -36,9 +36,13 @@ linters-settings: deny: - pkg: io/ioutil desc: 'io/ioutil package has been deprecated' + - pkg: gopkg.in/yaml.v2 + desc: 'compose-go uses yaml.v3' gomodguard: blocked: versions: + - github.com/distribution/distribution: + reason: "use distribution/reference" - gotest.tools: version: "< 3.0.0" reason: "deprecated, pre-modules version" @@ -61,5 +65,3 @@ issues: # golangci hides some golint warnings (the warning about exported things # withtout documentation for example), this will make it show them anyway. exclude-use-default: false - exclude: - - should not use dot imports diff --git a/go.mod b/go.mod index 9990d559d..f4be904b1 100644 --- a/go.mod +++ b/go.mod @@ -48,7 +48,6 @@ require ( go.uber.org/goleak v1.2.1 golang.org/x/sync v0.3.0 google.golang.org/grpc v1.58.0 - gopkg.in/yaml.v2 v2.4.0 gotest.tools/v3 v3.5.0 ) @@ -172,6 +171,7 @@ require ( google.golang.org/protobuf v1.31.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/api v0.26.2 // indirect k8s.io/apimachinery v0.26.2 // indirect diff --git a/pkg/compose/compose.go b/pkg/compose/compose.go index b8a98ddf3..688a48454 100644 --- a/pkg/compose/compose.go +++ b/pkg/compose/compose.go @@ -18,7 +18,6 @@ package compose import ( "context" - "encoding/json" "fmt" "io" "os" @@ -36,15 +35,13 @@ import ( "github.com/docker/cli/cli/config/configfile" "github.com/docker/cli/cli/flags" "github.com/docker/cli/cli/streams" + "github.com/docker/compose/v2/pkg/api" moby "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/client" "github.com/opencontainers/go-digest" "github.com/pkg/errors" - "gopkg.in/yaml.v2" - - "github.com/docker/compose/v2/pkg/api" ) var stdioToStdout bool @@ -169,9 +166,9 @@ func (s *composeService) Config(ctx context.Context, project *types.Project, opt switch options.Format { case "json": - return json.MarshalIndent(project, "", " ") + return project.MarshalJSON() case "yaml": - return yaml.Marshal(project) + return project.MarshalYAML() default: return nil, fmt.Errorf("unsupported format %q", options.Format) }