newLoadCommand creates a new "docker image load" command.
(dockerCLI command.Cli)
| 25 | |
| 26 | // newLoadCommand creates a new "docker image load" command. |
| 27 | func newLoadCommand(dockerCLI command.Cli) *cobra.Command { |
| 28 | var opts loadOptions |
| 29 | |
| 30 | cmd := &cobra.Command{ |
| 31 | Use: "load [OPTIONS]", |
| 32 | Short: "Load an image from a tar archive or STDIN", |
| 33 | Args: cli.NoArgs, |
| 34 | RunE: func(cmd *cobra.Command, args []string) error { |
| 35 | return runLoad(cmd.Context(), dockerCLI, opts) |
| 36 | }, |
| 37 | Annotations: map[string]string{ |
| 38 | "aliases": "docker image load, docker load", |
| 39 | }, |
| 40 | ValidArgsFunction: cobra.NoFileCompletions, |
| 41 | DisableFlagsInUseLine: true, |
| 42 | } |
| 43 | |
| 44 | flags := cmd.Flags() |
| 45 | |
| 46 | flags.StringVarP(&opts.input, "input", "i", "", "Read from tar archive file, instead of STDIN") |
| 47 | flags.BoolVarP(&opts.quiet, "quiet", "q", false, "Suppress the load output") |
| 48 | flags.StringSliceVar(&opts.platform, "platform", []string{}, `Load only the given platform(s). Formatted as a comma-separated list of "os[/arch[/variant]]" (e.g., "linux/amd64,linux/arm64/v8").`) |
| 49 | _ = flags.SetAnnotation("platform", "version", []string{"1.48"}) |
| 50 | |
| 51 | _ = cmd.RegisterFlagCompletionFunc("platform", completion.Platforms()) |
| 52 | return cmd |
| 53 | } |
| 54 | |
| 55 | func runLoad(ctx context.Context, dockerCli command.Cli, opts loadOptions) error { |
| 56 | var input io.Reader = dockerCli.In() |
searching dependent graphs…