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

Function newServicesCommand

cli/command/stack/services.go:27–49  ·  view source on GitHub ↗
(dockerCLI command.Cli)

Source from the content-addressed store, hash-verified

25}
26
27func newServicesCommand(dockerCLI command.Cli) *cobra.Command {
28 opts := serviceListOptions{filter: cliopts.NewFilterOpt()}
29
30 cmd := &cobra.Command{
31 Use: "services [OPTIONS] STACK",
32 Short: "List the services in the stack",
33 Args: cli.ExactArgs(1),
34 RunE: func(cmd *cobra.Command, args []string) error {
35 opts.namespace = args[0]
36 if err := validateStackName(opts.namespace); err != nil {
37 return err
38 }
39 return runServices(cmd.Context(), dockerCLI, opts)
40 },
41 ValidArgsFunction: completeNames(dockerCLI),
42 DisableFlagsInUseLine: true,
43 }
44 flags := cmd.Flags()
45 flags.BoolVarP(&opts.quiet, "quiet", "q", false, "Only display IDs")
46 flags.StringVar(&opts.format, "format", "", flagsHelper.FormatHelp)
47 flags.VarP(&opts.filter, "filter", "f", "Filter output based on conditions provided")
48 return cmd
49}
50
51// runServices performs a stack services against the specified swarm cluster
52func runServices(ctx context.Context, dockerCLI command.Cli, opts serviceListOptions) error {

Calls 3

validateStackNameFunction · 0.85
runServicesFunction · 0.85
completeNamesFunction · 0.70

Used in the wild real call sites across dependent graphs

searching dependent graphs…