summaryrefslogtreecommitdiff
path: root/cmd/podman/images/tag.go
blob: 633368f50bbe2c0757796a0758afc955775829b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package images

import (
	"github.com/containers/podman/v3/cmd/podman/common"
	"github.com/containers/podman/v3/cmd/podman/registry"
	"github.com/containers/podman/v3/pkg/domain/entities"
	"github.com/spf13/cobra"
)

var (
	tagDescription = "Adds one or more additional names to locally-stored image."
	tagCommand     = &cobra.Command{
		Use:               "tag IMAGE TARGET_NAME [TARGET_NAME...]",
		Short:             "Add an additional name to a local image",
		Long:              tagDescription,
		RunE:              tag,
		Args:              cobra.MinimumNArgs(2),
		ValidArgsFunction: common.AutocompleteImages,
		Example: `podman tag 0e3bbc2 fedora:latest
  podman tag imageID:latest myNewImage:newTag
  podman tag httpd myregistryhost:5000/fedora/httpd:v2`,
	}

	imageTagCommand = &cobra.Command{
		Args:              tagCommand.Args,
		Use:               tagCommand.Use,
		Short:             tagCommand.Short,
		Long:              tagCommand.Long,
		RunE:              tagCommand.RunE,
		ValidArgsFunction: tagCommand.ValidArgsFunction,
		Example: `podman image tag 0e3bbc2 fedora:latest
  podman image tag imageID:latest myNewImage:newTag
  podman image tag httpd myregistryhost:5000/fedora/httpd:v2`,
	}
)

func init() {
	registry.Commands = append(registry.Commands, registry.CliCommand{
		Command: tagCommand,
	})
	registry.Commands = append(registry.Commands, registry.CliCommand{
		Command: imageTagCommand,
		Parent:  imageCmd,
	})
}

func tag(cmd *cobra.Command, args []string) error {
	return registry.ImageEngine().Tag(registry.GetContext(), args[0], args[1:], entities.ImageTagOptions{})
}