Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ linters:
desc: compose-go uses yaml.v3
gocritic:
disabled-checks:
- paramTypeCombine
- unnamedResult
- whyNoLint
enabled-tags:
Expand Down Expand Up @@ -81,6 +80,9 @@ formatters:
enable:
- gofumpt
- goimports
settings:
gofumpt:
extra-rules: true
exclusions:
generated: lax
paths:
Expand Down
2 changes: 1 addition & 1 deletion cmd/formatter/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const (
)

// NewContainerFormat returns a Format for rendering using a Context
func NewContainerFormat(source string, quiet bool, size bool) formatter.Format {
func NewContainerFormat(source string, quiet, size bool) formatter.Format {
switch source {
case formatter.TableFormatKey, "": // table formatting is the default if none is set.
if quiet {
Expand Down
2 changes: 1 addition & 1 deletion cmd/formatter/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func ToStandardJSON(i interface{}) (string, error) {
}

// ToJSON return a string with the JSON representation of the interface{}
func ToJSON(i interface{}, prefix string, indentation string) (string, error) {
func ToJSON(i interface{}, prefix, indentation string) (string, error) {
buffer := &bytes.Buffer{}
encoder := json.NewEncoder(buffer)
encoder.SetEscapeHTML(false)
Expand Down
2 changes: 1 addition & 1 deletion internal/paths/paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"strings"
)

func IsChild(dir string, file string) bool {
func IsChild(dir, file string) bool {
if dir == "" {
return false
}
Expand Down
2 changes: 1 addition & 1 deletion internal/sync/tar.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type archiveEntry struct {
}

type LowLevelClient interface {
ContainersForService(ctx context.Context, projectName string, serviceName string) ([]container.Summary, error)
ContainersForService(ctx context.Context, projectName, serviceName string) ([]container.Summary, error)

Exec(ctx context.Context, containerID string, cmd []string, in io.Reader) error
Untar(ctx context.Context, id string, reader io.ReadCloser) error
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ type Service interface {
// Events executes the equivalent to a `compose events`
Events(ctx context.Context, projectName string, options EventsOptions) error
// Port executes the equivalent to a `compose port`
Port(ctx context.Context, projectName string, service string, port uint16, options PortOptions) (string, int, error)
Port(ctx context.Context, projectName, service string, port uint16, options PortOptions) (string, int, error)
// Publish executes the equivalent to a `compose publish`
Publish(ctx context.Context, project *types.Project, repository string, options PublishOptions) error
// Images executes the equivalent of a `compose images`
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/dryrunclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ func (d *DryRunClient) PluginUpgrade(ctx context.Context, name string, options m
return d.apiClient.PluginUpgrade(ctx, name, options)
}

func (d *DryRunClient) PluginPush(ctx context.Context, name string, registryAuth string) (io.ReadCloser, error) {
func (d *DryRunClient) PluginPush(ctx context.Context, name, registryAuth string) (io.ReadCloser, error) {
return d.apiClient.PluginPush(ctx, name, registryAuth)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/compose/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ func (s *composeService) toBuildOptions(project *types.Project, service types.Se
}, nil
}

func attestation(attest string, val string) *string {
func attestation(attest, val string) *string {
if b, err := strconv.ParseBool(val); err == nil {
s := fmt.Sprintf("type=%s,disabled=%t", attest, b)
return &s
Expand Down
4 changes: 2 additions & 2 deletions pkg/compose/build_bake.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ func toBakeSecrets(project *types.Project, secrets []types.ServiceSecretConfig)
return s
}

func dockerFilePath(ctxName string, dockerfile string) string {
func dockerFilePath(ctxName, dockerfile string) string {
if dockerfile == "" {
return ""
}
Expand Down Expand Up @@ -490,7 +490,7 @@ func dryRunBake(ctx context.Context, cfg bakeConfig) map[string]string {
return bakeResponse
}

func displayDryRunBuildEvent(w progress.Writer, name string, dryRunUUID, tag string) {
func displayDryRunBuildEvent(w progress.Writer, name, dryRunUUID, tag string) {
w.Event(progress.Event{
ID: name + " ==>",
Status: progress.Done,
Expand Down
2 changes: 1 addition & 1 deletion pkg/compose/convergence.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (c *convergence) setObservedState(serviceName string, containers Containers
c.services[serviceName] = containers
}

func newConvergence(services []string, state Containers, networks map[string]string, volumes map[string]string, s *composeService) *convergence {
func newConvergence(services []string, state Containers, networks, volumes map[string]string, s *composeService) *convergence {
observedState := map[string]Containers{}
for _, s := range services {
observedState[s] = Containers{}
Expand Down
4 changes: 2 additions & 2 deletions pkg/compose/cp.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (s *composeService) copy(ctx context.Context, projectName string, options a

var direction copyDirection
var serviceName string
var copyFunc func(ctx context.Context, containerID string, srcPath string, dstPath string, opts api.CopyOptions) error
var copyFunc func(ctx context.Context, containerID, srcPath, dstPath string, opts api.CopyOptions) error
if srcService != "" {
direction |= fromService
serviceName = srcService
Expand Down Expand Up @@ -143,7 +143,7 @@ func (s *composeService) listContainersTargetedForCopy(ctx context.Context, proj
}
}

func (s *composeService) copyToContainer(ctx context.Context, containerID string, srcPath string, dstPath string, opts api.CopyOptions) error {
func (s *composeService) copyToContainer(ctx context.Context, containerID, srcPath, dstPath string, opts api.CopyOptions) error {
var err error
if srcPath != "-" {
// Get an absolute source path.
Expand Down
8 changes: 4 additions & 4 deletions pkg/compose/dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ func NewGraph(project *types.Project, initialStatus ServiceStatus) (*Graph, erro
}

// NewVertex is the constructor function for the Vertex
func NewVertex(key string, service string, initialStatus ServiceStatus) *Vertex {
func NewVertex(key, service string, initialStatus ServiceStatus) *Vertex {
return &Vertex{
Key: key,
Service: service,
Expand All @@ -304,7 +304,7 @@ func NewVertex(key string, service string, initialStatus ServiceStatus) *Vertex
}

// AddVertex adds a vertex to the Graph
func (g *Graph) AddVertex(key string, service string, initialStatus ServiceStatus) {
func (g *Graph) AddVertex(key, service string, initialStatus ServiceStatus) {
g.lock.Lock()
defer g.lock.Unlock()

Expand All @@ -313,7 +313,7 @@ func (g *Graph) AddVertex(key string, service string, initialStatus ServiceStatu
}

// AddEdge adds a relationship of dependency between vertices `source` and `destination`
func (g *Graph) AddEdge(source string, destination string) error {
func (g *Graph) AddEdge(source, destination string) error {
g.lock.Lock()
defer g.lock.Unlock()

Expand Down Expand Up @@ -445,7 +445,7 @@ func (g *Graph) HasCycles() (bool, error) {
return false, nil
}

func (g *Graph) visit(key string, path []string, discovered []string, finished []string) ([]string, []string, error) {
func (g *Graph) visit(key string, path, discovered, finished []string) ([]string, []string, error) {
discovered = append(discovered, key)

for _, v := range g.Vertices[key].Children {
Expand Down
2 changes: 1 addition & 1 deletion pkg/compose/down.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func (s *composeService) ensureNetworksDown(ctx context.Context, project *types.
return ops
}

func (s *composeService) removeNetwork(ctx context.Context, composeNetworkName string, projectName string, name string, w progress.Writer) error {
func (s *composeService) removeNetwork(ctx context.Context, composeNetworkName, projectName, name string, w progress.Writer) error {
networks, err := s.apiClient().NetworkList(ctx, network.ListOptions{
Filters: filters.NewArgs(
projectFilter(projectName),
Expand Down
4 changes: 2 additions & 2 deletions pkg/compose/images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TestImages(t *testing.T) {
assert.DeepEqual(t, images, expected)
}

func imageInspect(id string, imageReference string, size int64) image.InspectResponse {
func imageInspect(id, imageReference string, size int64) image.InspectResponse {
return image.InspectResponse{
ID: id,
RepoTags: []string{
Expand All @@ -91,7 +91,7 @@ func imageInspect(id string, imageReference string, size int64) image.InspectRes
}
}

func containerDetail(service string, id string, status string, imageName string) container.Summary {
func containerDetail(service, id, status, imageName string) container.Summary {
return container.Summary{
ID: id,
Names: []string{"/" + id},
Expand Down
2 changes: 1 addition & 1 deletion pkg/compose/kill_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func TestKillSignal(t *testing.T) {
assert.NilError(t, err)
}

func testContainer(service string, id string, oneOff bool) container.Summary {
func testContainer(service, id string, oneOff bool) container.Summary {
// canonical docker names in the API start with a leading slash, some
// parts of Compose code will attempt to strip this off, so make sure
// it's consistently present
Expand Down
2 changes: 1 addition & 1 deletion pkg/compose/port.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/docker/docker/api/types/container"
)

func (s *composeService) Port(ctx context.Context, projectName string, service string, port uint16, options api.PortOptions) (string, int, error) {
func (s *composeService) Port(ctx context.Context, projectName, service string, port uint16, options api.PortOptions) (string, int, error) {
projectName = strings.ToLower(projectName)
ctr, err := s.getSpecifiedContainer(ctx, projectName, oneOffInclude, false, service, options.Index)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/compose/ps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func TestPs(t *testing.T) {
assert.DeepEqual(t, containers, expected)
}

func containerDetails(service string, id string, status string, health string, exitCode int) (containerType.Summary, containerType.InspectResponse) {
func containerDetails(service, id, status, health string, exitCode int) (containerType.Summary, containerType.InspectResponse) {
container := containerType.Summary{
ID: id,
Names: []string{"/" + id},
Expand Down
4 changes: 2 additions & 2 deletions pkg/compose/transform/replace.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
)

// ReplaceExtendsFile changes value for service.extends.file in input yaml stream, preserving formatting
func ReplaceExtendsFile(in []byte, service string, value string) ([]byte, error) {
func ReplaceExtendsFile(in []byte, service, value string) ([]byte, error) {
var doc yaml.Node
err := yaml.Unmarshal(in, &doc)
if err != nil {
Expand Down Expand Up @@ -78,7 +78,7 @@ func getMapping(root *yaml.Node, key string) (*yaml.Node, error) {
}

// replace changes yaml node value in stream at position, preserving content
func replace(in []byte, line int, column int, value string) []byte {
func replace(in []byte, line, column int, value string) []byte {
var out []byte
l := 1
pos := 0
Expand Down
2 changes: 1 addition & 1 deletion pkg/compose/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ type tarDockerClient struct {
s *composeService
}

func (t tarDockerClient) ContainersForService(ctx context.Context, projectName string, serviceName string) ([]container.Summary, error) {
func (t tarDockerClient) ContainersForService(ctx context.Context, projectName, serviceName string) ([]container.Summary, error) {
containers, err := t.s.getContainers(ctx, projectName, oneOffExclude, true, serviceName)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion pkg/e2e/assert.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (

// RequireServiceState ensures that the container is in the expected state
// (running or exited).
func RequireServiceState(t testing.TB, cli *CLI, service string, state string) {
func RequireServiceState(t testing.TB, cli *CLI, service, state string) {
t.Helper()
psRes := cli.RunDockerComposeCmd(t, "ps", "--all", "--format=json", service)
var svc map[string]interface{}
Expand Down
2 changes: 1 addition & 1 deletion pkg/e2e/cancel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func TestComposeCancel(t *testing.T) {
})
}

func StartWithNewGroupID(ctx context.Context, command icmd.Cmd, stdout *utils.SafeBuffer, stderr *utils.SafeBuffer) (*exec.Cmd, error) {
func StartWithNewGroupID(ctx context.Context, command icmd.Cmd, stdout, stderr *utils.SafeBuffer) (*exec.Cmd, error) {
cmd := exec.CommandContext(ctx, command.Command[0], command.Command[1:]...)
cmd.Env = command.Env
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
Expand Down
2 changes: 1 addition & 1 deletion pkg/e2e/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func findPluginExecutable(pluginExecutableName string) (string, error) {
}

// CopyFile copies a file from a sourceFile to a destinationFile setting permissions to 0755
func CopyFile(t testing.TB, sourceFile string, destinationFile string) {
func CopyFile(t testing.TB, sourceFile, destinationFile string) {
t.Helper()

src, err := os.Open(sourceFile)
Expand Down
2 changes: 1 addition & 1 deletion pkg/e2e/restart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"gotest.tools/v3/assert"
)

func assertServiceStatus(t *testing.T, projectName, service, status string, ps string) {
func assertServiceStatus(t *testing.T, projectName, service, status, ps string) {
// match output with random spaces like:
// e2e-start-stop-db-1 alpine:latest "echo hello" db 1 minutes ago Exited (0) 1 minutes ago
regx := fmt.Sprintf("%s-%s-1.+%s\\s+.+%s.+", projectName, service, service, status)
Expand Down
4 changes: 2 additions & 2 deletions pkg/e2e/watch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func doTest(t *testing.T, svcName string) {

require.NoError(t, os.Mkdir(dataDir, 0o700))

checkFileContents := func(path string, contents string) poll.Check {
checkFileContents := func(path, contents string) poll.Check {
return func(pollLog poll.LogT) poll.Result {
if r.Cmd.ProcessState != nil {
return poll.Error(fmt.Errorf("watch process exited early: %s", r.Cmd.ProcessState))
Expand Down Expand Up @@ -348,7 +348,7 @@ func TestWatchMultiServices(t *testing.T) {
return poll.Continue("%v", watch.Stdout())
})

waitRebuild := func(service string, expected string) {
waitRebuild := func(service, expected string) {
poll.WaitOn(t, func(l poll.LogT) poll.Result {
cat := c.RunDockerComposeCmdNoCheck(t, "-p", projectName, "exec", service, "cat", "/data/"+service)
if strings.Contains(cat.Stdout(), expected) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/progress/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type Event struct {
}

// ErrorMessageEvent creates a new Error Event with message
func ErrorMessageEvent(id string, msg string) Event {
func ErrorMessageEvent(id, msg string) Event {
return NewEvent(id, Error, msg)
}

Expand Down Expand Up @@ -164,7 +164,7 @@ func BuiltEvent(id string) Event {
}

// SkippedEvent creates a new Skipped Event
func SkippedEvent(id string, reason string) Event {
func SkippedEvent(id, reason string) Event {
return Event{
ID: id,
Status: Warning,
Expand Down
2 changes: 1 addition & 1 deletion pkg/watch/dockerignore.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func readDockerignorePatterns(r io.Reader) ([]string, error) {
return patterns, nil
}

func DockerIgnoreTesterFromContents(repoRoot string, contents string) (*dockerPathMatcher, error) {
func DockerIgnoreTesterFromContents(repoRoot, contents string) (*dockerPathMatcher, error) {
patterns, err := ignorefile.ReadAll(strings.NewReader(contents))
if err != nil {
return nil, fmt.Errorf("error reading .dockerignore: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/watch/temp_dir_fixture.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (f *TempDirFixture) JoinPaths(paths []string) []string {
}

// Returns the full path to the file written.
func (f *TempDirFixture) WriteFile(path string, contents string) string {
func (f *TempDirFixture) WriteFile(path, contents string) string {
fullPath := f.JoinPath(path)
base := filepath.Dir(fullPath)
err := os.MkdirAll(base, os.FileMode(0o777))
Expand Down