summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2021-05-05 16:38:32 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2021-05-19 17:32:02 -0400
commit2b89b241461c6baba777894f09a75df17dd05741 (patch)
treed2dfa80d41cd5bb7dac3c5bc51a1c7ddf28f02da /cmd
parent4c756268e6d0dbe90e61a59d9644e34a0f2d5f36 (diff)
downloadpodman-2b89b241461c6baba777894f09a75df17dd05741.tar.gz
podman-2b89b241461c6baba777894f09a75df17dd05741.tar.bz2
podman-2b89b241461c6baba777894f09a75df17dd05741.zip
Add support for podman manifest rm command
This is mainly to match command line of Docker. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/manifest/manifest.go3
-rw-r--r--cmd/podman/manifest/rm.go51
2 files changed, 53 insertions, 1 deletions
diff --git a/cmd/podman/manifest/manifest.go b/cmd/podman/manifest/manifest.go
index f67915481..c725078bf 100644
--- a/cmd/podman/manifest/manifest.go
+++ b/cmd/podman/manifest/manifest.go
@@ -19,7 +19,8 @@ var (
podman manifest inspect localhost/list
podman manifest annotate --annotation left=right mylist:v1.11 image:v1.11-amd64
podman manifest push mylist:v1.11 docker://quay.io/myuser/image:v1.11
- podman manifest remove mylist:v1.11 sha256:15352d97781ffdf357bf3459c037be3efac4133dc9070c2dce7eca7c05c3e736`,
+ podman manifest remove mylist:v1.11 sha256:15352d97781ffdf357bf3459c037be3efac4133dc9070c2dce7eca7c05c3e736
+ podman manifest rm mylist:v1.11`,
}
)
diff --git a/cmd/podman/manifest/rm.go b/cmd/podman/manifest/rm.go
new file mode 100644
index 000000000..58c0de886
--- /dev/null
+++ b/cmd/podman/manifest/rm.go
@@ -0,0 +1,51 @@
+package manifest
+
+import (
+ "context"
+ "fmt"
+
+ "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/containers/podman/v3/pkg/errorhandling"
+ "github.com/spf13/cobra"
+)
+
+var (
+ rmCmd = &cobra.Command{
+ Use: "rm LIST",
+ Short: "Remove manifest list or image index from local storage",
+ Long: "Remove manifest list or image index from local storage.",
+ RunE: rm,
+ ValidArgsFunction: common.AutocompleteImages,
+ Example: `podman manifest rm mylist:v1.11`,
+ Args: cobra.ExactArgs(1),
+ DisableFlagsInUseLine: true,
+ }
+)
+
+func init() {
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
+ Command: rmCmd,
+ Parent: manifestCmd,
+ })
+}
+
+func rm(cmd *cobra.Command, args []string) error {
+ report, rmErrors := registry.ImageEngine().ManifestRm(context.Background(), args)
+ if report != nil {
+ for _, u := range report.Untagged {
+ fmt.Println("Untagged: " + u)
+ }
+ for _, d := range report.Deleted {
+ // Make sure an image was deleted (and not just untagged); else print it
+ if len(d) > 0 {
+ fmt.Println("Deleted: " + d)
+ }
+ }
+ registry.SetExitCode(report.ExitCode)
+ }
+
+ return errorhandling.JoinErrors(rmErrors)
+}