summaryrefslogtreecommitdiff
path: root/cmd/podman/images/untag.go
blob: 50941e4961753189a5b692720eab4f519171ced5 (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
package images

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

var (
	untagCmd = &cobra.Command{
		Use:               "untag IMAGE [IMAGE...]",
		Short:             "Remove a name from a local image",
		Long:              "Removes one or more names from a locally-stored image.",
		RunE:              untag,
		Args:              cobra.MinimumNArgs(1),
		ValidArgsFunction: common.AutocompleteImages,
		Example: `podman untag 0e3bbc2
  podman untag imageID:latest otherImageName:latest
  podman untag httpd myregistryhost:5000/fedora/httpd:v2`,
	}

	imageUntagCmd = &cobra.Command{
		Args:              untagCmd.Args,
		Use:               untagCmd.Use,
		Short:             untagCmd.Short,
		Long:              untagCmd.Long,
		RunE:              untagCmd.RunE,
		ValidArgsFunction: untagCmd.ValidArgsFunction,
		Example: `podman image untag 0e3bbc2
  podman image untag imageID:latest otherImageName:latest
  podman image untag httpd myregistryhost:5000/fedora/httpd:v2`,
	}
)

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

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