spiegel_podman/cmd/podman/images/tree.go
Valentin Rothberg bd09b7aa79 bump go module to version 4
Automated for .go files via gomove [1]:
`gomove github.com/containers/podman/v3 github.com/containers/podman/v4`

Remaining files via vgrep [2]:
`vgrep github.com/containers/podman/v3`

[1] https://github.com/KSubedi/gomove
[2] https://github.com/vrothberg/vgrep

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2022-01-18 12:47:07 +01:00

41 lines
1.1 KiB
Go

package images
import (
"fmt"
"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 (
treeDescription = "Prints layer hierarchy of an image in a tree format"
treeCmd = &cobra.Command{
Use: "tree [options] IMAGE",
Args: cobra.ExactArgs(1),
Short: treeDescription,
Long: treeDescription,
RunE: tree,
ValidArgsFunction: common.AutocompleteImages,
Example: "podman image tree alpine:latest",
}
treeOpts entities.ImageTreeOptions
)
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
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
}