mirror of https://github.com/docker/compose.git
ci: tweak restricted imports in linter (#10992)
* Eliminate direct dependency on gopkg.in/yaml.v2 * Add gopkg.in/yaml.v2 as a restricted import * Add github.com/distribution/distribution as a restricted dependency in favor of distribution/reference which is the subset of functionality that Compose needs * Remove an unused exclusion NOTE: This does change the `compose config` output slightly but does NOT change the semantics: * YAML indentation is slightly different for lists (this is a `v2` / `v3` thing) * JSON is now "minified" instead of pretty-printed (I think this generally desirable and more consistent with other JSON command outputs) Signed-off-by: Milas Bowman <milas.bowman@docker.com>
This commit is contained in:
parent
7a13457853
commit
19bbb12fac
|
@ -36,9 +36,13 @@ linters-settings:
|
||||||
deny:
|
deny:
|
||||||
- pkg: io/ioutil
|
- pkg: io/ioutil
|
||||||
desc: 'io/ioutil package has been deprecated'
|
desc: 'io/ioutil package has been deprecated'
|
||||||
|
- pkg: gopkg.in/yaml.v2
|
||||||
|
desc: 'compose-go uses yaml.v3'
|
||||||
gomodguard:
|
gomodguard:
|
||||||
blocked:
|
blocked:
|
||||||
versions:
|
versions:
|
||||||
|
- github.com/distribution/distribution:
|
||||||
|
reason: "use distribution/reference"
|
||||||
- gotest.tools:
|
- gotest.tools:
|
||||||
version: "< 3.0.0"
|
version: "< 3.0.0"
|
||||||
reason: "deprecated, pre-modules version"
|
reason: "deprecated, pre-modules version"
|
||||||
|
@ -61,5 +65,3 @@ issues:
|
||||||
# golangci hides some golint warnings (the warning about exported things
|
# golangci hides some golint warnings (the warning about exported things
|
||||||
# withtout documentation for example), this will make it show them anyway.
|
# withtout documentation for example), this will make it show them anyway.
|
||||||
exclude-use-default: false
|
exclude-use-default: false
|
||||||
exclude:
|
|
||||||
- should not use dot imports
|
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -48,7 +48,6 @@ require (
|
||||||
go.uber.org/goleak v1.2.1
|
go.uber.org/goleak v1.2.1
|
||||||
golang.org/x/sync v0.3.0
|
golang.org/x/sync v0.3.0
|
||||||
google.golang.org/grpc v1.58.0
|
google.golang.org/grpc v1.58.0
|
||||||
gopkg.in/yaml.v2 v2.4.0
|
|
||||||
gotest.tools/v3 v3.5.0
|
gotest.tools/v3 v3.5.0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -172,6 +171,7 @@ require (
|
||||||
google.golang.org/protobuf v1.31.0 // indirect
|
google.golang.org/protobuf v1.31.0 // indirect
|
||||||
gopkg.in/inf.v0 v0.9.1 // indirect
|
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||||
gopkg.in/ini.v1 v1.67.0 // 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
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
k8s.io/api v0.26.2 // indirect
|
k8s.io/api v0.26.2 // indirect
|
||||||
k8s.io/apimachinery v0.26.2 // indirect
|
k8s.io/apimachinery v0.26.2 // indirect
|
||||||
|
|
|
@ -18,7 +18,6 @@ package compose
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
@ -36,15 +35,13 @@ import (
|
||||||
"github.com/docker/cli/cli/config/configfile"
|
"github.com/docker/cli/cli/config/configfile"
|
||||||
"github.com/docker/cli/cli/flags"
|
"github.com/docker/cli/cli/flags"
|
||||||
"github.com/docker/cli/cli/streams"
|
"github.com/docker/cli/cli/streams"
|
||||||
|
"github.com/docker/compose/v2/pkg/api"
|
||||||
moby "github.com/docker/docker/api/types"
|
moby "github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
"github.com/opencontainers/go-digest"
|
"github.com/opencontainers/go-digest"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"gopkg.in/yaml.v2"
|
|
||||||
|
|
||||||
"github.com/docker/compose/v2/pkg/api"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var stdioToStdout bool
|
var stdioToStdout bool
|
||||||
|
@ -169,9 +166,9 @@ func (s *composeService) Config(ctx context.Context, project *types.Project, opt
|
||||||
|
|
||||||
switch options.Format {
|
switch options.Format {
|
||||||
case "json":
|
case "json":
|
||||||
return json.MarshalIndent(project, "", " ")
|
return project.MarshalJSON()
|
||||||
case "yaml":
|
case "yaml":
|
||||||
return yaml.Marshal(project)
|
return project.MarshalYAML()
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("unsupported format %q", options.Format)
|
return nil, fmt.Errorf("unsupported format %q", options.Format)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue