add id + tar name to the layer details
This commit is contained in:
parent
9078b1dc81
commit
e779798478
@ -303,6 +303,7 @@ func InitializeData(imageID string) ([]*Layer, []*filetree.FileTree, float64, fi
|
||||
// note that the image config stores images in reverse chronological order, so iterate backwards through layers
|
||||
// as you iterate chronologically through history (ignoring history items that have no layer contents)
|
||||
layerIdx := len(trees) - 1
|
||||
tarPathIdx := 0
|
||||
for idx := 0; idx < len(config.History); idx++ {
|
||||
// ignore empty layers, we are only observing layers with content
|
||||
if config.History[idx].EmptyLayer {
|
||||
@ -317,12 +318,11 @@ func InitializeData(imageID string) ([]*Layer, []*filetree.FileTree, float64, fi
|
||||
Index: layerIdx,
|
||||
Tree: trees[layerIdx],
|
||||
RefTrees: trees,
|
||||
TarPath: manifest.LayerTarPaths[tarPathIdx],
|
||||
}
|
||||
|
||||
if len(manifest.LayerTarPaths) > idx {
|
||||
layers[layerIdx].TarPath = manifest.LayerTarPaths[layerIdx]
|
||||
}
|
||||
layerIdx--
|
||||
tarPathIdx++
|
||||
}
|
||||
|
||||
fmt.Println(" Analyzing layers...")
|
||||
|
@ -20,13 +20,24 @@ type Layer struct {
|
||||
RefTrees []*filetree.FileTree
|
||||
}
|
||||
|
||||
// Id returns the truncated id of the current layer.
|
||||
// ShortId returns the truncated id of the current layer.
|
||||
func (layer *Layer) TarId() string {
|
||||
return strings.TrimSuffix(layer.TarPath, "/layer.tar")
|
||||
}
|
||||
|
||||
// ShortId returns the truncated id of the current layer.
|
||||
func (layer *Layer) Id() string {
|
||||
return layer.History.ID
|
||||
}
|
||||
|
||||
// ShortId returns the truncated id of the current layer.
|
||||
func (layer *Layer) ShortId() string {
|
||||
rangeBound := 25
|
||||
if length := len(layer.History.ID); length < 25 {
|
||||
id := layer.Id()
|
||||
if length := len(id); length < 25 {
|
||||
rangeBound = length
|
||||
}
|
||||
id := layer.History.ID[0:rangeBound]
|
||||
id = id[0:rangeBound]
|
||||
|
||||
// show the tagged image as the last layer
|
||||
// if len(layer.History.Tags) > 0 {
|
||||
@ -40,7 +51,7 @@ func (layer *Layer) Id() string {
|
||||
func (layer *Layer) String() string {
|
||||
|
||||
return fmt.Sprintf(LayerFormat,
|
||||
layer.Id(),
|
||||
layer.ShortId(),
|
||||
humanize.Bytes(uint64(layer.History.Size)),
|
||||
strings.TrimPrefix(layer.History.CreatedBy, "/bin/sh -c "))
|
||||
}
|
||||
|
@ -123,7 +123,9 @@ func (view *DetailsView) Render() error {
|
||||
|
||||
// update contents
|
||||
view.view.Clear()
|
||||
fmt.Fprintln(view.view, Formatting.Header("Layer Command"))
|
||||
fmt.Fprintln(view.view, Formatting.Header("Digest: ")+currentLayer.Id())
|
||||
fmt.Fprintln(view.view, Formatting.Header("Tar ID: ")+currentLayer.TarId())
|
||||
fmt.Fprintln(view.view, Formatting.Header("Command:"))
|
||||
fmt.Fprintln(view.view, currentLayer.History.CreatedBy)
|
||||
|
||||
fmt.Fprintln(view.view, effStr)
|
||||
|
@ -193,7 +193,7 @@ func (view *LayerView) Render() error {
|
||||
layerId = fmt.Sprintf("%-25s", layer.History.ID)
|
||||
}
|
||||
|
||||
layerStr = fmt.Sprintf(image.LayerFormat, layerId, humanize.Bytes(uint64(layer.History.Size)), "FROM "+layer.Id())
|
||||
layerStr = fmt.Sprintf(image.LayerFormat, layerId, humanize.Bytes(uint64(layer.History.Size)), "FROM "+layer.ShortId())
|
||||
}
|
||||
|
||||
compareBar := view.renderCompareBar(idx)
|
||||
|
Loading…
x
Reference in New Issue
Block a user