diff options
author | baude <bbaude@redhat.com> | 2019-04-02 10:26:43 -0500 |
---|---|---|
committer | baude <bbaude@redhat.com> | 2019-04-04 14:41:50 -0500 |
commit | dc94dbd3c17c9011fc1e851694a2190dcf6c2b3c (patch) | |
tree | b887cd75144e555acfb4a346f43b89cdf5470d8c /pkg/adapter/images_remote.go | |
parent | 1759eb09e1c13bc8392d515d69ca93226d067c73 (diff) | |
download | podman-dc94dbd3c17c9011fc1e851694a2190dcf6c2b3c.tar.gz podman-dc94dbd3c17c9011fc1e851694a2190dcf6c2b3c.tar.bz2 podman-dc94dbd3c17c9011fc1e851694a2190dcf6c2b3c.zip |
podman-remote image tree
add the ability for the podman-remote client to be able to print an
image tree.
Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/adapter/images_remote.go')
-rw-r--r-- | pkg/adapter/images_remote.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/pkg/adapter/images_remote.go b/pkg/adapter/images_remote.go index e7b38dccc..722058d4a 100644 --- a/pkg/adapter/images_remote.go +++ b/pkg/adapter/images_remote.go @@ -6,8 +6,11 @@ import ( "context" "encoding/json" + "github.com/containers/libpod/cmd/podman/cliconfig" iopodman "github.com/containers/libpod/cmd/podman/varlink" + "github.com/containers/libpod/libpod/image" "github.com/containers/libpod/pkg/inspect" + "github.com/pkg/errors" ) // Inspect returns returns an ImageData struct from over a varlink connection @@ -22,3 +25,32 @@ func (i *ContainerImage) Inspect(ctx context.Context) (*inspect.ImageData, error } return &data, nil } + +// Tree ... +func (r *LocalRuntime) Tree(c *cliconfig.TreeValues) (*image.InfoImage, map[string]*image.LayerInfo, *ContainerImage, error) { + layerInfoMap := make(map[string]*image.LayerInfo) + imageInfo := &image.InfoImage{} + + img, err := r.NewImageFromLocal(c.InputArgs[0]) + if err != nil { + return nil, nil, nil, err + } + + reply, err := iopodman.GetLayersMapWithImageInfo().Call(r.Conn) + if err != nil { + return nil, nil, nil, errors.Wrap(err, "failed to obtain image layers") + } + if err := json.Unmarshal([]byte(reply), &layerInfoMap); err != nil { + return nil, nil, nil, errors.Wrap(err, "failed to unmarshal image layers") + } + + reply, err = iopodman.BuildImageHierarchyMap().Call(r.Conn, c.InputArgs[0]) + if err != nil { + return nil, nil, nil, errors.Wrap(err, "failed to get build image map") + } + if err := json.Unmarshal([]byte(reply), imageInfo); err != nil { + return nil, nil, nil, errors.Wrap(err, "failed to unmarshal build image map") + } + + return imageInfo, layerInfoMap, img, nil +} |