gofmt
This commit is contained in:
parent
8ca96849da
commit
e700ec3745
@ -1,12 +1,12 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/spf13/cobra"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"github.com/fatih/color"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
"github.com/wagoodman/dive/image"
|
"github.com/wagoodman/dive/image"
|
||||||
"github.com/wagoodman/dive/ui"
|
"github.com/wagoodman/dive/ui"
|
||||||
"github.com/fatih/color"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
// analyze takes a docker image tag, digest, or id and displayes the
|
// analyze takes a docker image tag, digest, or id and displayes the
|
||||||
|
10
cmd/build.go
10
cmd/build.go
@ -1,14 +1,14 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/spf13/cobra"
|
|
||||||
"os/exec"
|
|
||||||
"os"
|
|
||||||
"strings"
|
|
||||||
"io/ioutil"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
"github.com/wagoodman/dive/image"
|
"github.com/wagoodman/dive/image"
|
||||||
"github.com/wagoodman/dive/ui"
|
"github.com/wagoodman/dive/ui"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// buildCmd represents the build command
|
// buildCmd represents the build command
|
||||||
|
@ -2,11 +2,11 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"github.com/mitchellh/go-homedir"
|
"github.com/mitchellh/go-homedir"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
log "github.com/sirupsen/logrus"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
var cfgFile string
|
var cfgFile string
|
||||||
|
@ -40,7 +40,7 @@ type FileInfo struct {
|
|||||||
type DiffType int
|
type DiffType int
|
||||||
|
|
||||||
// NewNodeData creates an empty NodeData struct for a FileNode
|
// NewNodeData creates an empty NodeData struct for a FileNode
|
||||||
func NewNodeData() (*NodeData) {
|
func NewNodeData() *NodeData {
|
||||||
return &NodeData{
|
return &NodeData{
|
||||||
ViewInfo: *NewViewInfo(),
|
ViewInfo: *NewViewInfo(),
|
||||||
FileInfo: FileInfo{},
|
FileInfo: FileInfo{},
|
||||||
@ -49,7 +49,7 @@ func NewNodeData() (*NodeData) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Copy duplicates a NodeData
|
// Copy duplicates a NodeData
|
||||||
func (data *NodeData) Copy() (*NodeData) {
|
func (data *NodeData) Copy() *NodeData {
|
||||||
return &NodeData{
|
return &NodeData{
|
||||||
ViewInfo: *data.ViewInfo.Copy(),
|
ViewInfo: *data.ViewInfo.Copy(),
|
||||||
FileInfo: *data.FileInfo.Copy(),
|
FileInfo: *data.FileInfo.Copy(),
|
||||||
@ -57,7 +57,6 @@ func (data *NodeData) Copy() (*NodeData) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// NewViewInfo creates a default ViewInfo
|
// NewViewInfo creates a default ViewInfo
|
||||||
func NewViewInfo() (view *ViewInfo) {
|
func NewViewInfo() (view *ViewInfo) {
|
||||||
return &ViewInfo{
|
return &ViewInfo{
|
||||||
@ -120,7 +119,6 @@ func (data *FileInfo) Compare(other FileInfo) DiffType {
|
|||||||
return Changed
|
return Changed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// String of a DiffType
|
// String of a DiffType
|
||||||
func (diff DiffType) String() string {
|
func (diff DiffType) String() string {
|
||||||
switch diff {
|
switch diff {
|
||||||
@ -145,5 +143,3 @@ func (diff DiffType) merge(other DiffType) DiffType {
|
|||||||
}
|
}
|
||||||
return Changed
|
return Changed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,7 +66,6 @@ func Efficiency(trees []*FileTree) (float64, EfficiencySlice) {
|
|||||||
tree.VisitDepthChildFirst(visitor, visitEvaluator)
|
tree.VisitDepthChildFirst(visitor, visitEvaluator)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// calculate the score
|
// calculate the score
|
||||||
var minimumPathSizes int64
|
var minimumPathSizes int64
|
||||||
var discoveredPathSizes int64
|
var discoveredPathSizes int64
|
||||||
@ -81,5 +80,3 @@ func Efficiency(trees []*FileTree) (float64, EfficiencySlice) {
|
|||||||
|
|
||||||
return score, inefficientMatches
|
return score, inefficientMatches
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,4 +47,3 @@ package filetree
|
|||||||
// t.Fatalf("Expected %f but got %f", expected, actual)
|
// t.Fatalf("Expected %f but got %f", expected, actual)
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
@ -44,7 +44,6 @@ func TestAddChild(t *testing.T) {
|
|||||||
t.Errorf("Expected 'ones' payload to be %+v got %+v.", expectedFC, actualFC)
|
t.Errorf("Expected 'ones' payload to be %+v got %+v.", expectedFC, actualFC)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRemoveChild(t *testing.T) {
|
func TestRemoveChild(t *testing.T) {
|
||||||
|
@ -2,9 +2,9 @@ package filetree
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
"github.com/satori/go.uuid"
|
"github.com/satori/go.uuid"
|
||||||
"sort"
|
"sort"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -13,10 +13,10 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
"github.com/wagoodman/dive/filetree"
|
|
||||||
"golang.org/x/net/context"
|
|
||||||
"github.com/wagoodman/jotframe"
|
|
||||||
"github.com/k0kubun/go-ansi"
|
"github.com/k0kubun/go-ansi"
|
||||||
|
"github.com/wagoodman/dive/filetree"
|
||||||
|
"github.com/wagoodman/jotframe"
|
||||||
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: this file should be rethought... but since it's only for preprocessing it'll be tech debt for now.
|
// TODO: this file should be rethought... but since it's only for preprocessing it'll be tech debt for now.
|
||||||
@ -263,7 +263,6 @@ func InitializeData(imageID string) ([]*Layer, []*filetree.FileTree) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
go processLayerTar(line, layerMap, name, tarredBytes)
|
go processLayerTar(line, layerMap, name, tarredBytes)
|
||||||
|
|
||||||
} else if name == "manifest.json" {
|
} else if name == "manifest.json" {
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package image
|
package image
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wagoodman/dive/filetree"
|
|
||||||
"strings"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/dustin/go-humanize"
|
"github.com/dustin/go-humanize"
|
||||||
|
"github.com/wagoodman/dive/filetree"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -44,4 +44,3 @@ func (layer *Layer) String() string {
|
|||||||
humanize.Bytes(uint64(layer.History.Size)),
|
humanize.Bytes(uint64(layer.History.Size)),
|
||||||
strings.TrimPrefix(layer.History.CreatedBy, "/bin/sh -c "))
|
strings.TrimPrefix(layer.History.CreatedBy, "/bin/sh -c "))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1
main.go
1
main.go
@ -33,4 +33,3 @@ var (
|
|||||||
func main() {
|
func main() {
|
||||||
cmd.Execute()
|
cmd.Execute()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,12 +3,12 @@ package ui
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/dustin/go-humanize"
|
||||||
"github.com/jroimartin/gocui"
|
"github.com/jroimartin/gocui"
|
||||||
"github.com/lunixbochs/vtclean"
|
"github.com/lunixbochs/vtclean"
|
||||||
"strings"
|
|
||||||
"github.com/wagoodman/dive/filetree"
|
"github.com/wagoodman/dive/filetree"
|
||||||
"strconv"
|
"strconv"
|
||||||
"github.com/dustin/go-humanize"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DetailsView holds the UI objects and data models for populating the lower-left pane. Specifically the pane that
|
// DetailsView holds the UI objects and data models for populating the lower-left pane. Specifically the pane that
|
||||||
@ -61,7 +61,9 @@ func (view *DetailsView) Setup(v *gocui.View, header *gocui.View) error {
|
|||||||
|
|
||||||
// IsVisible indicates if the details view pane is currently initialized.
|
// IsVisible indicates if the details view pane is currently initialized.
|
||||||
func (view *DetailsView) IsVisible() bool {
|
func (view *DetailsView) IsVisible() bool {
|
||||||
if view == nil {return false}
|
if view == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/jroimartin/gocui"
|
"github.com/jroimartin/gocui"
|
||||||
"github.com/wagoodman/dive/filetree"
|
|
||||||
"github.com/lunixbochs/vtclean"
|
"github.com/lunixbochs/vtclean"
|
||||||
|
"github.com/wagoodman/dive/filetree"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -102,7 +102,9 @@ func (view *FileTreeView) height() uint {
|
|||||||
|
|
||||||
// IsVisible indicates if the file tree view pane is currently initialized
|
// IsVisible indicates if the file tree view pane is currently initialized
|
||||||
func (view *FileTreeView) IsVisible() bool {
|
func (view *FileTreeView) IsVisible() bool {
|
||||||
if view == nil {return false}
|
if view == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +180,6 @@ func (view *FileTreeView) CursorDown() error {
|
|||||||
return view.Render()
|
return view.Render()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// CursorUp moves the cursor up and renders the view.
|
// CursorUp moves the cursor up and renders the view.
|
||||||
// Note: we cannot use the gocui buffer since any state change requires writing the entire tree to the buffer.
|
// Note: we cannot use the gocui buffer since any state change requires writing the entire tree to the buffer.
|
||||||
// Instead we are keeping an upper and lower bounds of the tree string to render and only flushing
|
// Instead we are keeping an upper and lower bounds of the tree string to render and only flushing
|
||||||
|
@ -55,7 +55,9 @@ func (view *FilterView) Setup(v *gocui.View, header *gocui.View) error {
|
|||||||
|
|
||||||
// IsVisible indicates if the filter view pane is currently initialized
|
// IsVisible indicates if the filter view pane is currently initialized
|
||||||
func (view *FilterView) IsVisible() bool {
|
func (view *FilterView) IsVisible() bool {
|
||||||
if view == nil {return false}
|
if view == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return !view.hidden
|
return !view.hidden
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,10 +3,10 @@ package ui
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/jroimartin/gocui"
|
|
||||||
"github.com/wagoodman/dive/image"
|
|
||||||
"github.com/lunixbochs/vtclean"
|
|
||||||
"github.com/dustin/go-humanize"
|
"github.com/dustin/go-humanize"
|
||||||
|
"github.com/jroimartin/gocui"
|
||||||
|
"github.com/lunixbochs/vtclean"
|
||||||
|
"github.com/wagoodman/dive/image"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -69,7 +69,9 @@ func (view *LayerView) Setup(v *gocui.View, header *gocui.View) error {
|
|||||||
|
|
||||||
// IsVisible indicates if the layer view pane is currently initialized.
|
// IsVisible indicates if the layer view pane is currently initialized.
|
||||||
func (view *LayerView) IsVisible() bool {
|
func (view *LayerView) IsVisible() bool {
|
||||||
if view == nil {return false}
|
if view == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +210,6 @@ func (view *LayerView) Render() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// KeyHelp indicates all the possible actions a user can take while the current pane is selected.
|
// KeyHelp indicates all the possible actions a user can take while the current pane is selected.
|
||||||
func (view *LayerView) KeyHelp() string {
|
func (view *LayerView) KeyHelp() string {
|
||||||
return renderStatusOption("^L", "Show layer changes", view.CompareMode == CompareLayer) +
|
return renderStatusOption("^L", "Show layer changes", view.CompareMode == CompareLayer) +
|
||||||
|
@ -40,7 +40,9 @@ func (view *StatusView) Setup(v *gocui.View, header *gocui.View) error {
|
|||||||
|
|
||||||
// IsVisible indicates if the status view pane is currently initialized.
|
// IsVisible indicates if the status view pane is currently initialized.
|
||||||
func (view *StatusView) IsVisible() bool {
|
func (view *StatusView) IsVisible() bool {
|
||||||
if view == nil {return false}
|
if view == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
21
ui/ui.go
21
ui/ui.go
@ -5,10 +5,10 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
|
"github.com/fatih/color"
|
||||||
"github.com/jroimartin/gocui"
|
"github.com/jroimartin/gocui"
|
||||||
"github.com/wagoodman/dive/filetree"
|
"github.com/wagoodman/dive/filetree"
|
||||||
"github.com/wagoodman/dive/image"
|
"github.com/wagoodman/dive/image"
|
||||||
"github.com/fatih/color"
|
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
"runtime/pprof"
|
"runtime/pprof"
|
||||||
@ -35,14 +35,14 @@ func debugPrint(s string) {
|
|||||||
|
|
||||||
// Formatting defines standard functions for formatting UI sections.
|
// Formatting defines standard functions for formatting UI sections.
|
||||||
var Formatting struct {
|
var Formatting struct {
|
||||||
Header func(...interface{})(string)
|
Header func(...interface{}) string
|
||||||
Selected func(...interface{})(string)
|
Selected func(...interface{}) string
|
||||||
StatusSelected func(...interface{})(string)
|
StatusSelected func(...interface{}) string
|
||||||
StatusNormal func(...interface{})(string)
|
StatusNormal func(...interface{}) string
|
||||||
StatusControlSelected func(...interface{})(string)
|
StatusControlSelected func(...interface{}) string
|
||||||
StatusControlNormal func(...interface{})(string)
|
StatusControlNormal func(...interface{}) string
|
||||||
CompareTop func(...interface{})(string)
|
CompareTop func(...interface{}) string
|
||||||
CompareBottom func(...interface{})(string)
|
CompareBottom func(...interface{}) string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Views contains all rendered UI panes.
|
// Views contains all rendered UI panes.
|
||||||
@ -179,7 +179,6 @@ func isNewView(errs ...error) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// layout defines the definition of the window pane size and placement relations to one another. This
|
// layout defines the definition of the window pane size and placement relations to one another. This
|
||||||
// is invoked at application start and whenever the screen dimensions change.
|
// is invoked at application start and whenever the screen dimensions change.
|
||||||
func layout(g *gocui.Gui) error {
|
func layout(g *gocui.Gui) error {
|
||||||
@ -260,7 +259,6 @@ func layout(g *gocui.Gui) error {
|
|||||||
Views.Filter.Setup(view, header)
|
Views.Filter.Setup(view, header)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -324,7 +322,6 @@ func Run(layers []*image.Layer, refTrees []*filetree.FileTree) {
|
|||||||
Views.Details = NewDetailsView("details", g)
|
Views.Details = NewDetailsView("details", g)
|
||||||
Views.lookup[Views.Details.Name] = Views.Details
|
Views.lookup[Views.Details.Name] = Views.Details
|
||||||
|
|
||||||
|
|
||||||
g.Cursor = false
|
g.Cursor = false
|
||||||
//g.Mouse = true
|
//g.Mouse = true
|
||||||
g.SetManagerFunc(layout)
|
g.SetManagerFunc(layout)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user