From 44e653d666ef8da60b20c3549674314c6f905e56 Mon Sep 17 00:00:00 2001 From: Wes Higbee Date: Mon, 4 Dec 2023 11:18:19 -0600 Subject: [PATCH] go ahead and wire up sig-proxy and no-stdin for consistency with underlying docker container attach Signed-off-by: Wes Higbee --- cmd/compose/attach.go | 11 ++++++----- pkg/api/api.go | 2 ++ pkg/compose/attach_service.go | 2 ++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/cmd/compose/attach.go b/cmd/compose/attach.go index 79ef12b93e2..1899edef117 100644 --- a/cmd/compose/attach.go +++ b/cmd/compose/attach.go @@ -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 { @@ -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 } @@ -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) } diff --git a/pkg/api/api.go b/pkg/api/api.go index e21afccb00c..1ff1ef458f4 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -348,6 +348,8 @@ type AttachOptions struct { Service string Index int DetachKeys string + NoStdin bool + Proxy bool } // EventsOptions group options of the Events API diff --git a/pkg/compose/attach_service.go b/pkg/compose/attach_service.go index 68bf8597234..3dbf37c7e14 100644 --- a/pkg/compose/attach_service.go +++ b/pkg/compose/attach_service.go @@ -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) }