diff options
author | springcomet <aviv.shavit@gmail.com> | 2020-12-12 14:46:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-12 07:46:09 -0500 |
commit | 3430221adae6ba5ead4859a7260cd9cb343771cf (patch) | |
tree | 9c5db7a6dce9784011c8ab53615e5dea70656498 /runtime/ui/view/details.go | |
parent | 739416b7b686eeccdcf5bfe6a85b3d2bf0ca8592 (diff) |
Add image name to details view (#325)
* Add image name to details view
When frequently opening multiple images perhaps concurrently on multiple
terminals, it would be convenient to have the image name displayed.
This commit adds the image name to the Image Details view.
Image name is trickled down as an additional string argument
design alternatives discarded:
pass in analysis struct - is not related to analysis
pass new struct with image attributes - premature abstraction
* Fix CI lint errors
Co-authored-by: Aviv Shavit <aviv.shavit@aquasec.com>
Diffstat (limited to 'runtime/ui/view/details.go')
-rw-r--r-- | runtime/ui/view/details.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/runtime/ui/view/details.go b/runtime/ui/view/details.go index 95ee962..02262d1 100644 --- a/runtime/ui/view/details.go +++ b/runtime/ui/view/details.go @@ -21,6 +21,7 @@ type Details struct { gui *gocui.Gui view *gocui.View header *gocui.View + imageName string efficiency float64 inefficiencies filetree.EfficiencySlice imageSize uint64 @@ -29,12 +30,13 @@ type Details struct { } // newDetailsView creates a new view object attached the the global [gocui] screen object. -func newDetailsView(gui *gocui.Gui, efficiency float64, inefficiencies filetree.EfficiencySlice, imageSize uint64) (controller *Details) { +func newDetailsView(gui *gocui.Gui, imageName string, efficiency float64, inefficiencies filetree.EfficiencySlice, imageSize uint64) (controller *Details) { controller = new(Details) // populate main fields controller.name = "details" controller.gui = gui + controller.imageName = imageName controller.efficiency = efficiency controller.inefficiencies = inefficiencies controller.imageSize = imageSize @@ -148,6 +150,7 @@ func (v *Details) Render() error { } } + imageNameStr := fmt.Sprintf("%s %s", format.Header("Image name:"), v.imageName) imageSizeStr := fmt.Sprintf("%s %s", format.Header("Total Image size:"), humanize.Bytes(v.imageSize)) effStr := fmt.Sprintf("%s %d %%", format.Header("Image efficiency score:"), int(100.0*v.efficiency)) wastedSpaceStr := fmt.Sprintf("%s %s", format.Header("Potential wasted space:"), humanize.Bytes(uint64(wastedSpace))) @@ -179,6 +182,7 @@ func (v *Details) Render() error { lines = append(lines, format.Header("Command:")) lines = append(lines, v.currentLayer.Command) lines = append(lines, "\n"+imageHeaderStr) + lines = append(lines, imageNameStr) lines = append(lines, imageSizeStr) lines = append(lines, wastedSpaceStr) lines = append(lines, effStr+"\n") |