MCPcopy Index your code
hub / github.com/docker/cli / newDeployCommand

Function newDeployCommand

cli/command/stack/deploy.go:29–69  ·  view source on GitHub ↗
(dockerCLI command.Cli)

Source from the content-addressed store, hash-verified

27}
28
29func newDeployCommand(dockerCLI command.Cli) *cobra.Command {
30 var opts deployOptions
31
32 cmd := &cobra.Command{
33 Use: "deploy [OPTIONS] STACK",
34 Aliases: []string{"up"},
35 Short: "Deploy a new stack or update an existing stack",
36 Args: cli.ExactArgs(1),
37 RunE: func(cmd *cobra.Command, args []string) error {
38 opts.namespace = args[0]
39 if err := validateStackName(opts.namespace); err != nil {
40 return err
41 }
42 config, err := loadComposeFile(dockerCLI, opts)
43 if err != nil {
44 return err
45 }
46 return runDeploy(cmd.Context(), dockerCLI, cmd.Flags(), &opts, config)
47 },
48 ValidArgsFunction: completeNames(dockerCLI),
49 DisableFlagsInUseLine: true,
50 }
51
52 flags := cmd.Flags()
53 flags.StringSliceVarP(&opts.composefiles, "compose-file", "c", []string{}, `Path to a Compose file, or "-" to read from stdin`)
54 _ = flags.SetAnnotation("compose-file", "version", []string{"1.25"})
55 // Provide tab-completion for filenames. On Bash, this is constrained to the
56 // ".yaml" and ".yml" file-extensions, but this doesn't appear to be supported
57 // by other shells.
58 _ = cmd.MarkFlagFilename("compose-file", "yaml", "yml")
59
60 flags.BoolVar(&opts.sendRegistryAuth, "with-registry-auth", false, "Send registry authentication details to Swarm agents")
61 flags.BoolVar(&opts.prune, "prune", false, "Prune services that are no longer referenced")
62 flags.SetAnnotation("prune", "version", []string{"1.27"})
63 flags.StringVar(&opts.resolveImage, "resolve-image", resolveImageAlways,
64 `Query the registry to resolve image digest and supported platforms ("`+resolveImageAlways+`", "`+resolveImageChanged+`", "`+resolveImageNever+`")`)
65 flags.SetAnnotation("resolve-image", "version", []string{"1.30"})
66 flags.BoolVarP(&opts.detach, "detach", "d", true, "Exit immediately instead of waiting for the stack services to converge")
67 flags.BoolVarP(&opts.quiet, "quiet", "q", false, "Suppress progress output")
68 return cmd
69}
70
71// Resolve image constants
72const (

Callers 2

newStackCommandFunction · 0.85
TestDeployWithEmptyNameFunction · 0.85

Calls 4

validateStackNameFunction · 0.85
loadComposeFileFunction · 0.85
runDeployFunction · 0.85
completeNamesFunction · 0.70

Tested by 1

TestDeployWithEmptyNameFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…