-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tree implementation for podman images
Signed-off-by: Kunal Kushwaha <[email protected]>
- Loading branch information
1 parent
2c4f3d6
commit 6bb59b5
Showing
6 changed files
with
150 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ var ( | |
rmImageCommand, | ||
saveCommand, | ||
tagCommand, | ||
treeCommand, | ||
} | ||
|
||
imageDescription = "Manage images" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/containers/libpod/cmd/podman/libpodruntime" | ||
"github.com/pkg/errors" | ||
"github.com/urfave/cli" | ||
) | ||
|
||
var ( | ||
treeDescription = "Displays the dependent layers of an image. The information is printed in tree format" | ||
|
||
treeCommand = cli.Command{ | ||
Name: "tree", | ||
Usage: "Show dependent layers of a specified image in tree format", | ||
Description: treeDescription, | ||
Action: treeCmd, | ||
ArgsUsage: "", | ||
UseShortOptionHandling: true, | ||
} | ||
) | ||
|
||
func treeCmd(c *cli.Context) error { | ||
|
||
runtime, err := libpodruntime.GetRuntime(c) | ||
if err != nil { | ||
return errors.Wrapf(err, "could not get runtime") | ||
} | ||
defer runtime.Shutdown(false) | ||
|
||
args := c.Args() | ||
if len(args) == 0 { | ||
return errors.Errorf("an image name must be specified") | ||
} | ||
if len(args) > 1 { | ||
return errors.Errorf("podman tree takes at most 1 argument") | ||
} | ||
|
||
image, err := runtime.ImageRuntime().NewFromLocal(args[0]) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
out, err := image.Tree(context.Background()) | ||
if err != nil { | ||
return errors.Wrapf(err, "error getting dependencies of image %q", image.InputName) | ||
} | ||
fmt.Println(out) | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
% podman-tree "1" | ||
|
||
## NAME | ||
podman\-tree - Show dependent layers of a specified image in tree format | ||
|
||
## SYNOPSIS | ||
**podman tree** [*image*:*tag*]**|**[*image-id*] | ||
[**--help**|**-h**] | ||
|
||
## DESCRIPTION | ||
Displays the dependent layers of an image. The information is printed in tree format. | ||
If you do not provide *tag*, podman will default to `latest` for the *image*. | ||
|
||
## OPTIONS | ||
|
||
**--help**, **-h** | ||
|
||
Print usage statement | ||
|
||
## EXAMPLES | ||
|
||
``` | ||
$ podman tree fedora:latest | ||
$ podman tree 243d869d10ea | ||
``` | ||
|
||
|
||
## SEE ALSO | ||
podman(1), crio(8) | ||
|
||
## HISTORY | ||
Oct 2018, Originally compiled by Kunal Kushwaha <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters