summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-04-20 16:37:38 -0400
committerGitHub <noreply@github.com>2020-04-20 16:37:38 -0400
commit1e9b3e7500a14ae066f5790fad6c3dfa9f94b688 (patch)
tree915e35f9821c61486ed4f6a22959d2e6abbad9d3 /cmd
parent37365b166d30d7da108d4ce79a76bbae787e4219 (diff)
parent9cd6bba5d57e7e23a92ab27e6c37f8623662d9b3 (diff)
downloadpodman-1e9b3e7500a14ae066f5790fad6c3dfa9f94b688.tar.gz
podman-1e9b3e7500a14ae066f5790fad6c3dfa9f94b688.tar.bz2
podman-1e9b3e7500a14ae066f5790fad6c3dfa9f94b688.zip
Merge pull request #5899 from jwhonce/wip/tree
V2 podman image tree
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/images/tree.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/cmd/podman/images/tree.go b/cmd/podman/images/tree.go
new file mode 100644
index 000000000..5e82e9dea
--- /dev/null
+++ b/cmd/podman/images/tree.go
@@ -0,0 +1,40 @@
+package images
+
+import (
+ "fmt"
+
+ "github.com/containers/libpod/cmd/podman/registry"
+ "github.com/containers/libpod/pkg/domain/entities"
+ "github.com/spf13/cobra"
+)
+
+var (
+ treeDescription = "Prints layer hierarchy of an image in a tree format"
+ treeCmd = &cobra.Command{
+ Use: "tree [flags] IMAGE",
+ Args: cobra.ExactArgs(1),
+ Short: treeDescription,
+ Long: treeDescription,
+ RunE: tree,
+ Example: "podman image tree alpine:latest",
+ }
+ treeOpts entities.ImageTreeOptions
+)
+
+func init() {
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
+ Command: treeCmd,
+ Parent: imageCmd,
+ })
+ treeCmd.Flags().BoolVar(&treeOpts.WhatRequires, "whatrequires", false, "Show all child images and layers of the specified image")
+}
+
+func tree(_ *cobra.Command, args []string) error {
+ results, err := registry.ImageEngine().Tree(registry.Context(), args[0], treeOpts)
+ if err != nil {
+ return err
+ }
+ fmt.Println(results.Tree)
+ return nil
+}