mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
improve semantics of utility function in cli/command/service
Signed-off-by: Gaetan de Villele <gdevillele@gmail.com>
This commit is contained in:
parent
595ea2f120
commit
1526a99672
3 changed files with 4 additions and 6 deletions
|
@ -29,7 +29,7 @@ func newCreateCommand(dockerCli *command.DockerCli) *cobra.Command {
|
||||||
flags.StringVar(&opts.mode, flagMode, "replicated", "Service mode (replicated or global)")
|
flags.StringVar(&opts.mode, flagMode, "replicated", "Service mode (replicated or global)")
|
||||||
flags.StringVar(&opts.name, flagName, "", "Service name")
|
flags.StringVar(&opts.name, flagName, "", "Service name")
|
||||||
|
|
||||||
addServiceFlags(cmd, opts)
|
addServiceFlags(flags, opts)
|
||||||
|
|
||||||
flags.VarP(&opts.labels, flagLabel, "l", "Service labels")
|
flags.VarP(&opts.labels, flagLabel, "l", "Service labels")
|
||||||
flags.Var(&opts.containerLabels, flagContainerLabel, "Container labels")
|
flags.Var(&opts.containerLabels, flagContainerLabel, "Container labels")
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/docker/docker/opts"
|
"github.com/docker/docker/opts"
|
||||||
runconfigopts "github.com/docker/docker/runconfig/opts"
|
runconfigopts "github.com/docker/docker/runconfig/opts"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/pflag"
|
||||||
)
|
)
|
||||||
|
|
||||||
type int64Value interface {
|
type int64Value interface {
|
||||||
|
@ -468,9 +468,7 @@ func (opts *serviceOptions) ToService() (swarm.ServiceSpec, error) {
|
||||||
|
|
||||||
// addServiceFlags adds all flags that are common to both `create` and `update`.
|
// addServiceFlags adds all flags that are common to both `create` and `update`.
|
||||||
// Any flags that are not common are added separately in the individual command
|
// Any flags that are not common are added separately in the individual command
|
||||||
func addServiceFlags(cmd *cobra.Command, opts *serviceOptions) {
|
func addServiceFlags(flags *pflag.FlagSet, opts *serviceOptions) {
|
||||||
flags := cmd.Flags()
|
|
||||||
|
|
||||||
flags.StringVarP(&opts.workdir, flagWorkdir, "w", "", "Working directory inside the container")
|
flags.StringVarP(&opts.workdir, flagWorkdir, "w", "", "Working directory inside the container")
|
||||||
flags.StringVarP(&opts.user, flagUser, "u", "", "Username or UID (format: <name|uid>[:<group|gid>])")
|
flags.StringVarP(&opts.user, flagUser, "u", "", "Username or UID (format: <name|uid>[:<group|gid>])")
|
||||||
flags.StringVar(&opts.hostname, flagHostname, "", "Container hostname")
|
flags.StringVar(&opts.hostname, flagHostname, "", "Container hostname")
|
||||||
|
|
|
@ -43,7 +43,7 @@ func newUpdateCommand(dockerCli *command.DockerCli) *cobra.Command {
|
||||||
flags.SetAnnotation("rollback", "version", []string{"1.25"})
|
flags.SetAnnotation("rollback", "version", []string{"1.25"})
|
||||||
flags.Bool("force", false, "Force update even if no changes require it")
|
flags.Bool("force", false, "Force update even if no changes require it")
|
||||||
flags.SetAnnotation("force", "version", []string{"1.25"})
|
flags.SetAnnotation("force", "version", []string{"1.25"})
|
||||||
addServiceFlags(cmd, serviceOpts)
|
addServiceFlags(flags, serviceOpts)
|
||||||
|
|
||||||
flags.Var(newListOptsVar(), flagEnvRemove, "Remove an environment variable")
|
flags.Var(newListOptsVar(), flagEnvRemove, "Remove an environment variable")
|
||||||
flags.Var(newListOptsVar(), flagGroupRemove, "Remove a previously added supplementary user group from the container")
|
flags.Var(newListOptsVar(), flagGroupRemove, "Remove a previously added supplementary user group from the container")
|
||||||
|
|
Loading…
Reference in a new issue