MCPcopy Create free account
hub / github.com/docker/cli / addServiceFlags

Function addServiceFlags

cli/command/service/opts.go:878–983  ·  view source on GitHub ↗

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

(flags *pflag.FlagSet, options *serviceOptions, defaultFlagValues flagDefaults)

Source from the content-addressed store, hash-verified

876// addServiceFlags adds all flags that are common to both `create` and `update`.
877// Any flags that are not common are added separately in the individual command
878func addServiceFlags(flags *pflag.FlagSet, options *serviceOptions, defaultFlagValues flagDefaults) {
879 flagDesc := func(flagName string, desc string) string {
880 if defaultValue, ok := defaultFlagValues[flagName]; ok {
881 return fmt.Sprintf("%s (default %v)", desc, defaultValue)
882 }
883 return desc
884 }
885
886 addDetachFlag(flags, &options.detach)
887 flags.BoolVarP(&options.quiet, flagQuiet, "q", false, "Suppress progress output")
888
889 flags.StringVarP(&options.workdir, flagWorkdir, "w", "", "Working directory inside the container")
890 flags.StringVarP(&options.user, flagUser, "u", "", "Username or UID (format: <name|uid>[:<group|gid>])")
891 flags.Var(&options.credentialSpec, flagCredentialSpec, "Credential spec for managed service account (Windows only)")
892 flags.SetAnnotation(flagCredentialSpec, "version", []string{"1.29"})
893 flags.StringVar(&options.hostname, flagHostname, "", "Container hostname")
894 flags.SetAnnotation(flagHostname, "version", []string{"1.25"})
895 flags.Var(&options.entrypoint, flagEntrypoint, "Overwrite the default ENTRYPOINT of the image")
896 flags.Var(&options.capAdd, flagCapAdd, "Add Linux capabilities")
897 flags.SetAnnotation(flagCapAdd, "version", []string{"1.41"})
898 flags.Var(&options.capDrop, flagCapDrop, "Drop Linux capabilities")
899 flags.SetAnnotation(flagCapDrop, "version", []string{"1.41"})
900
901 flags.Var(&options.resources.limitCPU, flagLimitCPU, "Limit CPUs")
902 flags.Var(&options.resources.limitMemBytes, flagLimitMemory, "Limit Memory")
903 flags.Var(&options.resources.resCPU, flagReserveCPU, "Reserve CPUs")
904 flags.Var(&options.resources.resMemBytes, flagReserveMemory, "Reserve Memory")
905 flags.Int64Var(&options.resources.limitPids, flagLimitPids, 0, "Limit maximum number of processes (default 0 = unlimited)")
906 flags.SetAnnotation(flagLimitPids, "version", []string{"1.41"})
907 flags.Var(&options.resources.swapBytes, flagSwapBytes, "Swap Bytes (-1 for unlimited)")
908 flags.SetAnnotation(flagSwapBytes, "version", []string{"1.52"})
909 flags.Int64Var(&options.resources.memSwappiness, flagMemSwappiness, -1, "Tune memory swappiness (0-100), -1 to reset to default")
910 flags.SetAnnotation(flagMemSwappiness, "version", []string{"1.52"})
911
912 flags.Var(&options.stopGrace, flagStopGracePeriod, flagDesc(flagStopGracePeriod, "Time to wait before force killing a container (ns|us|ms|s|m|h)"))
913 flags.Var(&options.replicas, flagReplicas, "Number of tasks")
914 flags.Var(&options.maxConcurrent, flagConcurrent, "Number of job tasks to run concurrently (default equal to --replicas)")
915 flags.SetAnnotation(flagConcurrent, "version", []string{"1.41"})
916 flags.Uint64Var(&options.maxReplicas, flagMaxReplicas, defaultFlagValues.getUint64(flagMaxReplicas), "Maximum number of tasks per node (default 0 = unlimited)")
917 flags.SetAnnotation(flagMaxReplicas, "version", []string{"1.40"})
918
919 flags.StringVar(&options.restartPolicy.condition, flagRestartCondition, "", flagDesc(flagRestartCondition, `Restart when condition is met ("none", "on-failure", "any")`))
920 flags.Var(&options.restartPolicy.delay, flagRestartDelay, flagDesc(flagRestartDelay, "Delay between restart attempts (ns|us|ms|s|m|h)"))
921 flags.Var(&options.restartPolicy.maxAttempts, flagRestartMaxAttempts, flagDesc(flagRestartMaxAttempts, "Maximum number of restarts before giving up"))
922
923 flags.Var(&options.restartPolicy.window, flagRestartWindow, flagDesc(flagRestartWindow, "Window used to evaluate the restart policy (ns|us|ms|s|m|h)"))
924
925 flags.Uint64Var(&options.update.parallelism, flagUpdateParallelism, defaultFlagValues.getUint64(flagUpdateParallelism), "Maximum number of tasks updated simultaneously (0 to update all at once)")
926 flags.DurationVar(&options.update.delay, flagUpdateDelay, 0, flagDesc(flagUpdateDelay, "Delay between updates (ns|us|ms|s|m|h)"))
927 flags.DurationVar(&options.update.monitor, flagUpdateMonitor, 0, flagDesc(flagUpdateMonitor, "Duration after each task update to monitor for failure (ns|us|ms|s|m|h)"))
928 flags.SetAnnotation(flagUpdateMonitor, "version", []string{"1.25"})
929 flags.StringVar(&options.update.onFailure, flagUpdateFailureAction, "", flagDesc(flagUpdateFailureAction, `Action on update failure ("pause", "continue", "rollback")`))
930 flags.Var(&options.update.maxFailureRatio, flagUpdateMaxFailureRatio, flagDesc(flagUpdateMaxFailureRatio, "Failure rate to tolerate during an update"))
931 flags.SetAnnotation(flagUpdateMaxFailureRatio, "version", []string{"1.25"})
932 flags.StringVar(&options.update.order, flagUpdateOrder, "", flagDesc(flagUpdateOrder, `Update order ("start-first", "stop-first")`))
933 flags.SetAnnotation(flagUpdateOrder, "version", []string{"1.29"})
934
935 flags.Uint64Var(&options.rollback.parallelism, flagRollbackParallelism, defaultFlagValues.getUint64(flagRollbackParallelism),

Callers 2

newUpdateCommandFunction · 0.85
newCreateCommandFunction · 0.85

Calls 3

addDetachFlagFunction · 0.85
getUint64Method · 0.80
getStringMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…