diff --git a/.golangci.yaml b/.golangci.yaml index bb2c7b5a9..7f15cd61f 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -150,6 +150,9 @@ linters: disable: - errcheck - gas + - scopelint + - bodyclose + - staticcheck disable-all: false presets: - bugs diff --git a/cmd/executor/cmd/root.go b/cmd/executor/cmd/root.go index ca3a43ba5..e7a058abd 100644 --- a/cmd/executor/cmd/root.go +++ b/cmd/executor/cmd/root.go @@ -46,7 +46,7 @@ var ( func init() { RootCmd.PersistentFlags().StringVarP(&logLevel, "verbosity", "v", constants.DefaultLogLevel, "Log level (debug, info, warn, error, fatal, panic") RootCmd.PersistentFlags().BoolVarP(&force, "force", "", false, "Force building outside of a container") - addKanikoOptionsFlags(RootCmd) + addKanikoOptionsFlags() addHiddenFlags(RootCmd) } @@ -118,7 +118,7 @@ var RootCmd = &cobra.Command{ } // addKanikoOptionsFlags configures opts -func addKanikoOptionsFlags(cmd *cobra.Command) { +func addKanikoOptionsFlags() { RootCmd.PersistentFlags().StringVarP(&opts.DockerfilePath, "dockerfile", "f", "Dockerfile", "Path to the dockerfile to be built.") RootCmd.PersistentFlags().StringVarP(&opts.SrcContext, "context", "c", "/workspace/", "Path to the dockerfile build context.") RootCmd.PersistentFlags().StringVarP(&opts.Bucket, "bucket", "b", "", "Name of the GCS bucket from which to access build context as tarball.") diff --git a/cmd/warmer/cmd/root.go b/cmd/warmer/cmd/root.go index 207c0519a..b0e3c9076 100644 --- a/cmd/warmer/cmd/root.go +++ b/cmd/warmer/cmd/root.go @@ -36,8 +36,8 @@ var ( func init() { RootCmd.PersistentFlags().StringVarP(&logLevel, "verbosity", "v", constants.DefaultLogLevel, "Log level (debug, info, warn, error, fatal, panic") - addKanikoOptionsFlags(RootCmd) - addHiddenFlags(RootCmd) + addKanikoOptionsFlags() + addHiddenFlags() } var RootCmd = &cobra.Command{ @@ -65,7 +65,7 @@ var RootCmd = &cobra.Command{ } // addKanikoOptionsFlags configures opts -func addKanikoOptionsFlags(cmd *cobra.Command) { +func addKanikoOptionsFlags() { RootCmd.PersistentFlags().VarP(&opts.Images, "image", "i", "Image to cache. Set it repeatedly for multiple images.") RootCmd.PersistentFlags().StringVarP(&opts.CacheDir, "cache-dir", "c", "/cache", "Directory of the cache.") RootCmd.PersistentFlags().BoolVarP(&opts.Force, "force", "f", false, "Force cache overwriting.") @@ -73,7 +73,7 @@ func addKanikoOptionsFlags(cmd *cobra.Command) { } // addHiddenFlags marks certain flags as hidden from the executor help text -func addHiddenFlags(cmd *cobra.Command) { +func addHiddenFlags() { RootCmd.PersistentFlags().MarkHidden("azure-container-registry-config") } diff --git a/integration/integration_test.go b/integration/integration_test.go index de3900667..246e9e6cb 100644 --- a/integration/integration_test.go +++ b/integration/integration_test.go @@ -155,7 +155,8 @@ func TestRun(t *testing.T) { t.SkipNow() } - imageBuilder.FilesBuilt[dockerfile] = buildImage(t, dockerfile, imageBuilder) + buildImage(t, dockerfile, imageBuilder) + imageBuilder.FilesBuilt[dockerfile] = true dockerImage := GetDockerImage(config.imageRepo, dockerfile) kanikoImage := GetKanikoImage(config.imageRepo, dockerfile) @@ -280,7 +281,8 @@ func TestLayers(t *testing.T) { t.SkipNow() } - imageBuilder.FilesBuilt[dockerfile] = buildImage(t, dockerfile, imageBuilder) + buildImage(t, dockerfile, imageBuilder) + imageBuilder.FilesBuilt[dockerfile] = true // Pull the kaniko image dockerImage := GetDockerImage(config.imageRepo, dockerfile) @@ -297,9 +299,9 @@ func TestLayers(t *testing.T) { } } -func buildImage(t *testing.T, dockerfile string, imageBuilder *DockerFileBuilder) bool { +func buildImage(t *testing.T, dockerfile string, imageBuilder *DockerFileBuilder) { if imageBuilder.FilesBuilt[dockerfile] { - return true + return } if err := imageBuilder.BuildImage( @@ -308,7 +310,8 @@ func buildImage(t *testing.T, dockerfile string, imageBuilder *DockerFileBuilder t.Errorf("Error building image: %s", err) t.FailNow() } - return true + + return } // Build each image with kaniko twice, and then make sure they're exactly the same diff --git a/pkg/commands/shell.go b/pkg/commands/shell.go index 88b7310d9..996c928fd 100644 --- a/pkg/commands/shell.go +++ b/pkg/commands/shell.go @@ -18,7 +18,7 @@ package commands import ( "github.com/GoogleContainerTools/kaniko/pkg/dockerfile" - "github.com/google/go-containerregistry/pkg/v1" + v1 "github.com/google/go-containerregistry/pkg/v1" "github.com/moby/buildkit/frontend/dockerfile/instructions" ) diff --git a/pkg/commands/shell_test.go b/pkg/commands/shell_test.go index 75e9eaa7b..47692ab5c 100644 --- a/pkg/commands/shell_test.go +++ b/pkg/commands/shell_test.go @@ -19,7 +19,7 @@ import ( "testing" "github.com/GoogleContainerTools/kaniko/testutil" - "github.com/google/go-containerregistry/pkg/v1" + v1 "github.com/google/go-containerregistry/pkg/v1" "github.com/moby/buildkit/frontend/dockerfile/instructions" ) diff --git a/pkg/commands/stopsignal.go b/pkg/commands/stopsignal.go index 476376c87..b28d8eba3 100644 --- a/pkg/commands/stopsignal.go +++ b/pkg/commands/stopsignal.go @@ -20,7 +20,7 @@ import ( "github.com/GoogleContainerTools/kaniko/pkg/dockerfile" "github.com/GoogleContainerTools/kaniko/pkg/util" "github.com/docker/docker/pkg/signal" - "github.com/google/go-containerregistry/pkg/v1" + v1 "github.com/google/go-containerregistry/pkg/v1" "github.com/moby/buildkit/frontend/dockerfile/instructions" "github.com/sirupsen/logrus" ) diff --git a/pkg/commands/stopsignal_test.go b/pkg/commands/stopsignal_test.go index 66d5de3dd..ab6bb3a7c 100644 --- a/pkg/commands/stopsignal_test.go +++ b/pkg/commands/stopsignal_test.go @@ -20,7 +20,7 @@ import ( "github.com/GoogleContainerTools/kaniko/pkg/dockerfile" "github.com/GoogleContainerTools/kaniko/testutil" - "github.com/google/go-containerregistry/pkg/v1" + v1 "github.com/google/go-containerregistry/pkg/v1" "github.com/moby/buildkit/frontend/dockerfile/instructions" ) diff --git a/pkg/commands/user.go b/pkg/commands/user.go index a8cfb2774..e6a5e1ab9 100644 --- a/pkg/commands/user.go +++ b/pkg/commands/user.go @@ -21,7 +21,7 @@ import ( "github.com/GoogleContainerTools/kaniko/pkg/dockerfile" "github.com/GoogleContainerTools/kaniko/pkg/util" - "github.com/google/go-containerregistry/pkg/v1" + v1 "github.com/google/go-containerregistry/pkg/v1" "github.com/moby/buildkit/frontend/dockerfile/instructions" "github.com/sirupsen/logrus" ) diff --git a/pkg/commands/user_test.go b/pkg/commands/user_test.go index 12afcb02f..18b28b023 100644 --- a/pkg/commands/user_test.go +++ b/pkg/commands/user_test.go @@ -21,7 +21,7 @@ import ( "github.com/GoogleContainerTools/kaniko/pkg/dockerfile" "github.com/GoogleContainerTools/kaniko/testutil" - "github.com/google/go-containerregistry/pkg/v1" + v1 "github.com/google/go-containerregistry/pkg/v1" "github.com/moby/buildkit/frontend/dockerfile/instructions" ) diff --git a/pkg/commands/volume.go b/pkg/commands/volume.go index b6d92bf53..476a2c52a 100644 --- a/pkg/commands/volume.go +++ b/pkg/commands/volume.go @@ -23,7 +23,7 @@ import ( "github.com/GoogleContainerTools/kaniko/pkg/dockerfile" "github.com/GoogleContainerTools/kaniko/pkg/util" - "github.com/google/go-containerregistry/pkg/v1" + v1 "github.com/google/go-containerregistry/pkg/v1" "github.com/moby/buildkit/frontend/dockerfile/instructions" "github.com/sirupsen/logrus" ) diff --git a/pkg/commands/volume_test.go b/pkg/commands/volume_test.go index 9616006b8..a40865d16 100644 --- a/pkg/commands/volume_test.go +++ b/pkg/commands/volume_test.go @@ -21,7 +21,7 @@ import ( "github.com/GoogleContainerTools/kaniko/pkg/dockerfile" "github.com/GoogleContainerTools/kaniko/testutil" - "github.com/google/go-containerregistry/pkg/v1" + v1 "github.com/google/go-containerregistry/pkg/v1" "github.com/moby/buildkit/frontend/dockerfile/instructions" ) diff --git a/pkg/commands/workdir.go b/pkg/commands/workdir.go index 179a6d4c8..273432052 100644 --- a/pkg/commands/workdir.go +++ b/pkg/commands/workdir.go @@ -23,7 +23,7 @@ import ( "github.com/GoogleContainerTools/kaniko/pkg/dockerfile" "github.com/GoogleContainerTools/kaniko/pkg/util" - "github.com/google/go-containerregistry/pkg/v1" + v1 "github.com/google/go-containerregistry/pkg/v1" "github.com/moby/buildkit/frontend/dockerfile/instructions" "github.com/sirupsen/logrus" ) diff --git a/pkg/commands/workdir_test.go b/pkg/commands/workdir_test.go index be67098fa..7a95ccad0 100644 --- a/pkg/commands/workdir_test.go +++ b/pkg/commands/workdir_test.go @@ -22,7 +22,7 @@ import ( "github.com/GoogleContainerTools/kaniko/pkg/dockerfile" "github.com/GoogleContainerTools/kaniko/testutil" - "github.com/google/go-containerregistry/pkg/v1" + v1 "github.com/google/go-containerregistry/pkg/v1" "github.com/moby/buildkit/frontend/dockerfile/instructions" ) diff --git a/pkg/image/image.go b/pkg/image/image.go index cc57538c7..dbb5a9e9d 100644 --- a/pkg/image/image.go +++ b/pkg/image/image.go @@ -20,7 +20,7 @@ import ( "os" "strings" - "github.com/google/go-containerregistry/pkg/v1" + v1 "github.com/google/go-containerregistry/pkg/v1" "github.com/sirupsen/logrus" ) diff --git a/pkg/util/image_util_test.go b/pkg/util/image_util_test.go index c44fe8a58..08faf0e80 100644 --- a/pkg/util/image_util_test.go +++ b/pkg/util/image_util_test.go @@ -22,7 +22,7 @@ import ( "github.com/GoogleContainerTools/kaniko/pkg/config" "github.com/GoogleContainerTools/kaniko/testutil" - "github.com/google/go-containerregistry/pkg/v1" + v1 "github.com/google/go-containerregistry/pkg/v1" "github.com/google/go-containerregistry/pkg/v1/empty" "github.com/moby/buildkit/frontend/dockerfile/instructions" "github.com/moby/buildkit/frontend/dockerfile/parser"