From 3baa727ed100a46c27f159a4430508b0a4a1b02c Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Fri, 4 Nov 2016 11:31:44 -0700 Subject: [PATCH] Add `--tty` to `docker service create/update` This fix tries to add `--tty` to `docker service create/update`. As was specified in 25644, `TTY` flag has been added to SwarmKit and is already vendored. This fix add `--tty` to `docker service create/update`. Related document has been updated. Additional integration tests has been added. This fix fixes 25644. Signed-off-by: Yong Tang --- command/service/opts.go | 5 +++++ command/service/update.go | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/command/service/opts.go b/command/service/opts.go index 2199e9f363..989fd18b8f 100644 --- a/command/service/opts.go +++ b/command/service/opts.go @@ -294,6 +294,7 @@ type serviceOptions struct { workdir string user string groups []string + tty bool mounts opts.MountOpt resources resourceOptions @@ -365,6 +366,7 @@ func (opts *serviceOptions) ToService() (swarm.ServiceSpec, error) { Dir: opts.workdir, User: opts.user, Groups: opts.groups, + TTY: opts.tty, Mounts: opts.mounts.Value(), StopGracePeriod: opts.stopGrace.Value(), }, @@ -450,6 +452,8 @@ func addServiceFlags(cmd *cobra.Command, opts *serviceOptions) { flags.Var(&opts.healthcheck.timeout, flagHealthTimeout, "Maximum time to allow one check to run") flags.IntVar(&opts.healthcheck.retries, flagHealthRetries, 0, "Consecutive failures needed to report unhealthy") flags.BoolVar(&opts.healthcheck.noHealthcheck, flagNoHealthcheck, false, "Disable any container-specified HEALTHCHECK") + + flags.BoolVarP(&opts.tty, flagTTY, "t", false, "Allocate a pseudo-TTY") } const ( @@ -490,6 +494,7 @@ const ( flagRestartMaxAttempts = "restart-max-attempts" flagRestartWindow = "restart-window" flagStopGracePeriod = "stop-grace-period" + flagTTY = "tty" flagUpdateDelay = "update-delay" flagUpdateFailureAction = "update-failure-action" flagUpdateMaxFailureRatio = "update-max-failure-ratio" diff --git a/command/service/update.go b/command/service/update.go index 34cc9bc3d8..c278ac1ba4 100644 --- a/command/service/update.go +++ b/command/service/update.go @@ -274,6 +274,14 @@ func updateService(flags *pflag.FlagSet, spec *swarm.ServiceSpec) error { return err } + if flags.Changed(flagTTY) { + tty, err := flags.GetBool(flagTTY) + if err != nil { + return err + } + cspec.TTY = tty + } + return nil }