summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorJhon Honce <jhonce@redhat.com>2020-04-20 10:02:35 -0700
committerJhon Honce <jhonce@redhat.com>2020-04-20 10:10:24 -0700
commit9cd6bba5d57e7e23a92ab27e6c37f8623662d9b3 (patch)
tree4ab14b11f1bb0cf26287a5f4cc2acf94dda34a1d /cmd
parente5e625b2a6481dd49d1d6303df1157c8a51dd7c2 (diff)
downloadpodman-9cd6bba5d57e7e23a92ab27e6c37f8623662d9b3.tar.gz
podman-9cd6bba5d57e7e23a92ab27e6c37f8623662d9b3.tar.bz2
podman-9cd6bba5d57e7e23a92ab27e6c37f8623662d9b3.zip
V2 podman image tree
* Basic port of V1 podman image tree ID TODO: Refactor to return tree from service and format in presentation layer TODO: Support tunneling mode Signed-off-by: Jhon Honce <jhonce@redhat.com>
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
+}