go ahead and wire up sig-proxy and no-stdin for consistency with underlying docker container attach

Signed-off-by: Wes Higbee <wes.mcclure@gmail.com>
This commit is contained in:
Wes Higbee 2023-12-04 11:18:19 -06:00
parent 2c16e16db7
commit 80823b77ef
3 changed files with 10 additions and 5 deletions

View File

@ -31,11 +31,8 @@ type attachOpts struct {
index int index int
detachKeys string detachKeys string
noStdin bool
// todo docker container attach also has: proxy bool
// --no-stdin // whole point of attach is for STDIN (can already attach to STDOUT and STDERR via docker compose up)
// --sig-proxy
} }
func attachCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command { func attachCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
@ -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().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().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 return runCmd
} }
@ -74,6 +73,8 @@ func runAttach(ctx context.Context, dockerCli command.Cli, backend api.Service,
Service: opts.service, Service: opts.service,
Index: opts.index, Index: opts.index,
DetachKeys: opts.detachKeys, DetachKeys: opts.detachKeys,
NoStdin: opts.noStdin,
Proxy: opts.proxy,
} }
return backend.Attach(ctx, projectName, attachOpts) return backend.Attach(ctx, projectName, attachOpts)
} }

View File

@ -350,6 +350,8 @@ type AttachOptions struct {
Service string Service string
Index int Index int
DetachKeys string DetachKeys string
NoStdin bool
Proxy bool
} }
// EventsOptions group options of the Events API // EventsOptions group options of the Events API

View File

@ -33,5 +33,7 @@ func (s *composeService) Attach(ctx context.Context, projectName string, options
var attach container.AttachOptions var attach container.AttachOptions
attach.DetachKeys = options.DetachKeys attach.DetachKeys = options.DetachKeys
attach.NoStdin = options.NoStdin
attach.Proxy = options.Proxy
return container.RunAttach(ctx, s.dockerCli, target.ID, &attach) return container.RunAttach(ctx, s.dockerCli, target.ID, &attach)
} }