mirror of
https://github.com/containers/podman.git
synced 2025-12-10 07:42:12 +08:00
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>
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user