Skip to content

Commit

Permalink
go ahead and wire up sig-proxy and no-stdin for consistency with unde…
Browse files Browse the repository at this point in the history
…rlying docker container attach

Signed-off-by: Wes Higbee <wes.mcclure@gmail.com>
  • Loading branch information
g0t4 committed Dec 11, 2023
1 parent 5ed936b commit 44e653d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
11 changes: 6 additions & 5 deletions cmd/compose/attach.go
Expand Up @@ -31,11 +31,8 @@ type attachOpts struct {
index int

detachKeys string

// todo docker container attach also has:
// --no-stdin // whole point of attach is for STDIN (can already attach to STDOUT and STDERR via docker compose up)
// --sig-proxy

noStdin bool
proxy bool
}

func attachCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
Expand All @@ -61,6 +58,8 @@ func attachCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service
runCmd.Flags().IntVar(&opts.index, "index", 0, "index of the container if service has multiple replicas.")
runCmd.Flags().StringVarP(&opts.detachKeys, "detach-keys", "", "", "Override the key sequence for detaching from a container.")

runCmd.Flags().BoolVar(&opts.noStdin, "no-stdin", false, "Do not attach STDIN")
runCmd.Flags().BoolVar(&opts.proxy, "sig-proxy", true, "Proxy all received signals to the process")
return runCmd
}

Expand All @@ -74,6 +73,8 @@ func runAttach(ctx context.Context, dockerCli command.Cli, backend api.Service,
Service: opts.service,
Index: opts.index,
DetachKeys: opts.detachKeys,
NoStdin: opts.noStdin,
Proxy: opts.proxy,
}
return backend.Attach(ctx, projectName, attachOpts)
}
2 changes: 2 additions & 0 deletions pkg/api/api.go
Expand Up @@ -348,6 +348,8 @@ type AttachOptions struct {
Service string
Index int
DetachKeys string
NoStdin bool
Proxy bool
}

// EventsOptions group options of the Events API
Expand Down
2 changes: 2 additions & 0 deletions pkg/compose/attach_service.go
Expand Up @@ -33,5 +33,7 @@ func (s *composeService) Attach(ctx context.Context, projectName string, options

var attach container.AttachOptions
attach.DetachKeys = options.DetachKeys
attach.NoStdin = options.NoStdin
attach.Proxy = options.Proxy
return container.RunAttach(ctx, s.dockerCli, target.ID, &attach)
}

0 comments on commit 44e653d

Please sign in to comment.