mirror of https://github.com/docker/cli.git
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 <yong.tang.github@outlook.com>
This commit is contained in:
parent
6780c318a3
commit
3baa727ed1
|
@ -294,6 +294,7 @@ type serviceOptions struct {
|
||||||
workdir string
|
workdir string
|
||||||
user string
|
user string
|
||||||
groups []string
|
groups []string
|
||||||
|
tty bool
|
||||||
mounts opts.MountOpt
|
mounts opts.MountOpt
|
||||||
|
|
||||||
resources resourceOptions
|
resources resourceOptions
|
||||||
|
@ -365,6 +366,7 @@ func (opts *serviceOptions) ToService() (swarm.ServiceSpec, error) {
|
||||||
Dir: opts.workdir,
|
Dir: opts.workdir,
|
||||||
User: opts.user,
|
User: opts.user,
|
||||||
Groups: opts.groups,
|
Groups: opts.groups,
|
||||||
|
TTY: opts.tty,
|
||||||
Mounts: opts.mounts.Value(),
|
Mounts: opts.mounts.Value(),
|
||||||
StopGracePeriod: opts.stopGrace.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.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.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.BoolVar(&opts.healthcheck.noHealthcheck, flagNoHealthcheck, false, "Disable any container-specified HEALTHCHECK")
|
||||||
|
|
||||||
|
flags.BoolVarP(&opts.tty, flagTTY, "t", false, "Allocate a pseudo-TTY")
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -490,6 +494,7 @@ const (
|
||||||
flagRestartMaxAttempts = "restart-max-attempts"
|
flagRestartMaxAttempts = "restart-max-attempts"
|
||||||
flagRestartWindow = "restart-window"
|
flagRestartWindow = "restart-window"
|
||||||
flagStopGracePeriod = "stop-grace-period"
|
flagStopGracePeriod = "stop-grace-period"
|
||||||
|
flagTTY = "tty"
|
||||||
flagUpdateDelay = "update-delay"
|
flagUpdateDelay = "update-delay"
|
||||||
flagUpdateFailureAction = "update-failure-action"
|
flagUpdateFailureAction = "update-failure-action"
|
||||||
flagUpdateMaxFailureRatio = "update-max-failure-ratio"
|
flagUpdateMaxFailureRatio = "update-max-failure-ratio"
|
||||||
|
|
|
@ -274,6 +274,14 @@ func updateService(flags *pflag.FlagSet, spec *swarm.ServiceSpec) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if flags.Changed(flagTTY) {
|
||||||
|
tty, err := flags.GetBool(flagTTY)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
cspec.TTY = tty
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue