Merge branch 'master' into ignore-parse-errors
This commit is contained in:
commit
adc3e19822
@ -30,6 +30,7 @@ nfpms:
|
||||
- license: MIT
|
||||
maintainer: Alex Goodman
|
||||
homepage: https://github.com/wagoodman/dive/
|
||||
description: "A tool for exploring each layer in a docker image"
|
||||
formats:
|
||||
- rpm
|
||||
- deb
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/wagoodman/dive/runtime"
|
||||
)
|
||||
|
||||
@ -47,13 +48,13 @@ func doAnalyzeCmd(cmd *cobra.Command, args []string) {
|
||||
sourceType, imageStr = dive.DeriveImageSource(userImage)
|
||||
|
||||
if sourceType == dive.SourceUnknown {
|
||||
sourceStr, err := cmd.PersistentFlags().GetString("source")
|
||||
if err != nil {
|
||||
fmt.Printf("unable to determine image source: %v\n", err)
|
||||
sourceStr := viper.GetString("source")
|
||||
sourceType = dive.ParseImageSource(sourceStr)
|
||||
if sourceType == dive.SourceUnknown {
|
||||
fmt.Printf("unable to determine image source: %v\n", sourceStr)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
sourceType = dive.ParseImageSource(sourceStr)
|
||||
imageStr = userImage
|
||||
}
|
||||
|
||||
|
10
cmd/root.go
10
cmd/root.go
@ -70,6 +70,8 @@ func initCli() {
|
||||
|
||||
// initConfig reads in config file and ENV variables if set.
|
||||
func initConfig() {
|
||||
var err error
|
||||
|
||||
viper.SetDefault("log.level", log.InfoLevel.String())
|
||||
viper.SetDefault("log.path", "./dive.log")
|
||||
viper.SetDefault("log.enabled", false)
|
||||
@ -102,6 +104,12 @@ func initConfig() {
|
||||
viper.SetDefault("container-engine", "docker")
|
||||
viper.SetDefault("ignore-errors", false)
|
||||
|
||||
err = viper.BindPFlag("source", rootCmd.PersistentFlags().Lookup("source"))
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
viper.SetEnvPrefix("DIVE")
|
||||
// replace all - with _ when looking for matching environment variables
|
||||
viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
|
||||
@ -115,7 +123,7 @@ func initConfig() {
|
||||
} else {
|
||||
viper.SetConfigFile(cfgFile)
|
||||
}
|
||||
err := viper.ReadInConfig()
|
||||
err = viper.ReadInConfig()
|
||||
if err == nil {
|
||||
fmt.Println("Using config file:", viper.ConfigFileUsed())
|
||||
} else if cfgFile != "" {
|
||||
|
2
go.mod
2
go.mod
@ -43,7 +43,7 @@ require (
|
||||
github.com/wagoodman/keybinding v0.0.0-20181213133715-6a824da6df05
|
||||
golang.org/x/crypto v0.0.0-20190907121410-71b5226ff739
|
||||
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297
|
||||
golang.org/x/sys v0.0.0-20190907184412-d223b2b6db03 // indirect
|
||||
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4 // indirect
|
||||
golang.org/x/text v0.3.2 // indirect
|
||||
google.golang.org/genproto v0.0.0-20190620144150-6af8c5fc6601 // indirect
|
||||
google.golang.org/grpc v1.21.1 // indirect
|
||||
|
2
go.sum
2
go.sum
@ -241,6 +241,8 @@ golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190907184412-d223b2b6db03 h1:b3JiLYVaG9kHjTcOQIoUh978YMCO7oVTQQBLudU47zY=
|
||||
golang.org/x/sys v0.0.0-20190907184412-d223b2b6db03/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4 h1:sfkvUWPNGwSV+8/fNqctR5lS2AqCSqYwXdrjCxp/dXo=
|
||||
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
|
||||
|
Loading…
x
Reference in New Issue
Block a user