newTagCommand creates a new "docker image tag" command.
(dockerCLI command.Cli)
| 10 | |
| 11 | // newTagCommand creates a new "docker image tag" command. |
| 12 | func newTagCommand(dockerCLI command.Cli) *cobra.Command { |
| 13 | cmd := &cobra.Command{ |
| 14 | Use: "tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]", |
| 15 | Short: "Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE", |
| 16 | Args: cli.ExactArgs(2), |
| 17 | RunE: func(cmd *cobra.Command, args []string) error { |
| 18 | _, err := dockerCLI.Client().ImageTag(cmd.Context(), client.ImageTagOptions{ |
| 19 | Source: args[0], |
| 20 | Target: args[1], |
| 21 | }) |
| 22 | return err |
| 23 | }, |
| 24 | Annotations: map[string]string{ |
| 25 | "aliases": "docker image tag, docker tag", |
| 26 | }, |
| 27 | ValidArgsFunction: completion.ImageNames(dockerCLI, 2), |
| 28 | DisableFlagsInUseLine: true, |
| 29 | } |
| 30 | |
| 31 | flags := cmd.Flags() |
| 32 | flags.SetInterspersed(false) |
| 33 | |
| 34 | return cmd |
| 35 | } |
searching dependent graphs…