diff --git a/cmd/kaniko-docker/main.go b/cmd/kaniko-docker/main.go index c43ae59..2dc4183 100644 --- a/cmd/kaniko-docker/main.go +++ b/cmd/kaniko-docker/main.go @@ -132,6 +132,11 @@ func main() { Usage: "Set this flag if you only want to build the image, without pushing to a registry", EnvVar: "PLUGIN_NO_PUSH", }, + cli.StringFlag{ + Name: "verbosity", + Usage: "Set this flag with value as oneof to set the logging level for kaniko. Defaults to info.", + EnvVar: "PLUGIN_VERBOSITY", + }, } if err := app.Run(os.Args); err != nil { @@ -161,6 +166,7 @@ func run(c *cli.Context) error { CacheTTL: c.Int("cache-ttl"), DigestFile: defaultDigestFile, NoPush: c.Bool("no-push"), + Verbosity: c.String("verbosity"), }, Artifact: kaniko.Artifact{ Tags: c.StringSlice("tags"), diff --git a/cmd/kaniko-ecr/main.go b/cmd/kaniko-ecr/main.go index 0870848..af68108 100644 --- a/cmd/kaniko-ecr/main.go +++ b/cmd/kaniko-ecr/main.go @@ -122,6 +122,11 @@ func main() { Usage: "Set this flag if you only want to build the image, without pushing to a registry", EnvVar: "PLUGIN_NO_PUSH", }, + cli.StringFlag{ + Name: "verbosity", + Usage: "Set this flag with value as oneof to set the logging level for kaniko. Defaults to info.", + EnvVar: "PLUGIN_VERBOSITY", + }, } if err := app.Run(os.Args); err != nil { @@ -150,6 +155,7 @@ func run(c *cli.Context) error { CacheTTL: c.Int("cache-ttl"), DigestFile: defaultDigestFile, NoPush: c.Bool("no-push"), + Verbosity: c.String("verbosity"), }, Artifact: kaniko.Artifact{ Tags: c.StringSlice("tags"), diff --git a/cmd/kaniko-gcr/main.go b/cmd/kaniko-gcr/main.go index 80f1699..ce5511c 100644 --- a/cmd/kaniko-gcr/main.go +++ b/cmd/kaniko-gcr/main.go @@ -118,6 +118,11 @@ func main() { Usage: "Set this flag if you only want to build the image, without pushing to a registry", EnvVar: "PLUGIN_NO_PUSH", }, + cli.StringFlag{ + Name: "verbosity", + Usage: "Set this flag as --verbosity= to set the logging level for kaniko. Defaults to info.", + EnvVar: "PLUGIN_VERBOSITY", + }, } if err := app.Run(os.Args); err != nil { @@ -150,6 +155,7 @@ func run(c *cli.Context) error { CacheTTL: c.Int("cache-ttl"), DigestFile: defaultDigestFile, NoPush: c.Bool("no-push"), + Verbosity: c.String("verbosity"), }, Artifact: kaniko.Artifact{ Tags: c.StringSlice("tags"), diff --git a/kaniko.go b/kaniko.go index 18c3554..4271f00 100644 --- a/kaniko.go +++ b/kaniko.go @@ -27,6 +27,7 @@ type ( CacheTTL int // Cache timeout in hours DigestFile string // Digest file location NoPush bool // Set this flag if you only want to build the image, without pushing to a registry + Verbosity string // Log level } // Artifact defines content of artifact file Artifact struct { @@ -88,10 +89,10 @@ func (p Plugin) Exec() error { if p.Build.EnableCache == true { cmdArgs = append(cmdArgs, fmt.Sprintf("--cache=true")) - } - if p.Build.CacheRepo != "" { - cmdArgs = append(cmdArgs, fmt.Sprintf("--cache-repo=%s", p.Build.CacheRepo)) + if p.Build.CacheRepo != "" { + cmdArgs = append(cmdArgs, fmt.Sprintf("--cache-repo=%s", p.Build.CacheRepo)) + } } if p.Build.CacheTTL != 0 { @@ -115,6 +116,10 @@ func (p Plugin) Exec() error { } } + if p.Build.Verbosity != "" { + cmdArgs = append(cmdArgs, fmt.Sprintf("--verbosity=%s", p.Build.Verbosity)) + } + cmd := exec.Command("/kaniko/executor", cmdArgs...) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr