Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/469 size in layer details #522

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions runtime/ui/view/layer.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,14 @@ func (v *Layer) CursorUp() error {
return nil
}

// SetOrigin updates the origin of the layer view pane.
func (v *Layer) SetOrigin(x, y int) error {
if err := v.body.SetOrigin(x, y); err != nil {
return err
}
return nil
}

// SetCursor resets the cursor and orients the file tree view based on the given layer index.
func (v *Layer) SetCursor(layer int) error {
v.vm.LayerIndex = layer
Expand Down Expand Up @@ -340,6 +348,15 @@ func (v *Layer) Render() error {
return err
}
}

// Adjust origin, if necessary
maxBodyDisplayHeight := int(v.height())
if v.vm.LayerIndex > maxBodyDisplayHeight {
if err := v.SetOrigin(0, v.vm.LayerIndex-maxBodyDisplayHeight); err != nil {
return err
}
}

return nil
})
return nil
Expand Down
3 changes: 3 additions & 0 deletions runtime/ui/view/layer_details.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"strings"

"github.com/awesome-gocui/gocui"
"github.com/dustin/go-humanize"
"github.com/sirupsen/logrus"

"github.com/wagoodman/dive/dive/image"
Expand Down Expand Up @@ -82,9 +83,11 @@ func (v *LayerDetails) Render() error {
if v.CurrentLayer.Names != nil && len(v.CurrentLayer.Names) > 0 {
tags = strings.Join(v.CurrentLayer.Names, ", ")
}

lines = append(lines, []string{
format.Header("Tags: ") + tags,
format.Header("Id: ") + v.CurrentLayer.Id,
format.Header("Size: ") + humanize.Bytes(v.CurrentLayer.Size),
format.Header("Digest: ") + v.CurrentLayer.Digest,
format.Header("Command:"),
v.CurrentLayer.Command,
Expand Down