diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-04-04 13:00:25 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-04 13:00:25 -0700 |
commit | bf3593ef8d57b2b6e187a5c1cccf7cb9770182ec (patch) | |
tree | 405377d36b50c6afdc9d829beffe7868f4641025 /libpod/image | |
parent | e320efe9ed158f48eefa7046d88f5c842e454f61 (diff) | |
parent | dc94dbd3c17c9011fc1e851694a2190dcf6c2b3c (diff) | |
download | podman-bf3593ef8d57b2b6e187a5c1cccf7cb9770182ec.tar.gz podman-bf3593ef8d57b2b6e187a5c1cccf7cb9770182ec.tar.bz2 podman-bf3593ef8d57b2b6e187a5c1cccf7cb9770182ec.zip |
Merge pull request #2831 from baude/remotetree
podman-remote image tree
Diffstat (limited to 'libpod/image')
-rw-r--r-- | libpod/image/image.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/libpod/image/image.go b/libpod/image/image.go index 4862bf1d6..cc056b816 100644 --- a/libpod/image/image.go +++ b/libpod/image/image.go @@ -68,6 +68,16 @@ type Runtime struct { EventsLogFilePath string } +// InfoImage keep information of Image along with all associated layers +type InfoImage struct { + // ID of image + ID string + // Tags of image + Tags []string + // Layers stores all layers of image. + Layers []LayerInfo +} + // ErrRepoTagNotFound is the error returned when the image id given doesn't match a rep tag in store var ErrRepoTagNotFound = errors.New("unable to match user input to any specific repotag") @@ -1277,3 +1287,21 @@ func GetLayersMapWithImageInfo(imageruntime *Runtime) (map[string]*LayerInfo, er } return layerInfoMap, nil } + +// BuildImageHierarchyMap stores hierarchy of images such that all parent layers using which image is built are stored in imageInfo +// Layers are added such that (Start)RootLayer->...intermediate Parent Layer(s)-> TopLayer(End) +func BuildImageHierarchyMap(imageInfo *InfoImage, layerMap map[string]*LayerInfo, layerID string) error { + if layerID == "" { + return nil + } + ll, ok := layerMap[layerID] + if !ok { + return fmt.Errorf("lookup error: layerid %s not found", layerID) + } + if err := BuildImageHierarchyMap(imageInfo, layerMap, ll.ParentID); err != nil { + return err + } + + imageInfo.Layers = append(imageInfo.Layers, *ll) + return nil +} |