MCPcopy
hub / github.com/docker/compose / exportCommand

Function exportCommand

cmd/compose/export.go:37–60  ·  cmd/compose/export.go::exportCommand
(p *ProjectOptions, dockerCli command.Cli, backendOptions *BackendOptions)

Source from the content-addressed store, hash-verified

35}
36
37func exportCommand(p *ProjectOptions, dockerCli command.Cli, backendOptions *BackendOptions) *cobra.Command {
38 options := exportOptions{
39 ProjectOptions: p,
40 }
41 cmd := &cobra.Command{
42 Use: "export [OPTIONS] SERVICE",
43 Short: "Export a service container's filesystem as a tar archive",
44 Args: cobra.MinimumNArgs(1),
45 PreRunE: Adapt(func(ctx context.Context, args []string) error {
46 options.service = args[0]
47 return nil
48 }),
49 RunE: Adapt(func(ctx context.Context, args []string) error {
50 return runExport(ctx, dockerCli, backendOptions, options)
51 }),
52 ValidArgsFunction: completeServiceNames(dockerCli, p),
53 }
54
55 flags := cmd.Flags()
56 flags.IntVar(&options.index, "index", 0, "index of the container if service has multiple replicas.")
57 flags.StringVarP(&options.output, "output", "o", "", "Write to a file, instead of STDOUT")
58
59 return cmd
60}
61
62func runExport(ctx context.Context, dockerCli command.Cli, backendOptions *BackendOptions, options exportOptions) error {
63 projectName, err := options.toProjectName(ctx, dockerCli)

Callers 1

RootCommandFunction · 0.85

Calls 3

AdaptFunction · 0.85
runExportFunction · 0.85
completeServiceNamesFunction · 0.85

Tested by

no test coverage detected