Skip to content
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
4 changes: 2 additions & 2 deletions cmd/executor/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func ValidateFlags(opts *config.KanikoOptions) {
// RootCmd is the kaniko command that is run
var RootCmd = &cobra.Command{
Use: "executor",
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
if cmd.Use == "executor" {

if err := logging.Configure(logLevel, logFormat, logTimestamp); err != nil {
Expand Down Expand Up @@ -186,7 +186,7 @@ var RootCmd = &cobra.Command{
}
return nil
},
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, _ []string) {
if !checkContained() {
if !force {
exit(errors.New("kaniko should only be run inside of a container, run with the --force flag if you are sure you want to continue"))
Expand Down
6 changes: 3 additions & 3 deletions cmd/executor/cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,23 +120,23 @@ func TestResolveEnvironmentBuildArgs(t *testing.T) {
description: "do not replace when environment variable is present and value is specified",
input: []string{"variable1=value1", "variable2=value2"},
expected: []string{"variable1=value1", "variable2=value2"},
mockedEnvironmentResolver: func(variable string) string {
mockedEnvironmentResolver: func(_ string) string {
return "unexpected"
},
},
{
description: "do not replace when environment variable is present and empty value is specified",
input: []string{"variable1="},
expected: []string{"variable1="},
mockedEnvironmentResolver: func(variable string) string {
mockedEnvironmentResolver: func(_ string) string {
return "unexpected"
},
},
{
description: "replace with empty value when environment variable is not present or empty and value is not specified",
input: []string{"variable1", "variable2=value2"},
expected: []string{"variable1=", "variable2=value2"},
mockedEnvironmentResolver: func(variable string) string {
mockedEnvironmentResolver: func(_ string) string {
return ""
},
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/executor/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func init() {
var versionCmd = &cobra.Command{
Use: "version",
Short: "Print the version number of kaniko",
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, _ []string) {
fmt.Println("Kaniko version : ", version.Version())
},
}
4 changes: 2 additions & 2 deletions cmd/warmer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func init() {

var RootCmd = &cobra.Command{
Use: "cache warmer",
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
PersistentPreRunE: func(_ *cobra.Command, _ []string) error {
if err := logging.Configure(logLevel, logFormat, logTimestamp); err != nil {
return err
}
Expand Down Expand Up @@ -95,7 +95,7 @@ var RootCmd = &cobra.Command{

return nil
},
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, _ []string) {
if _, err := os.Stat(opts.CacheDir); os.IsNotExist(err) {
err = os.MkdirAll(opts.CacheDir, 0o755)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion integration/tar.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func tarballOfDirectory(pathToDir string, f io.Writer) error {
tarWriter := util.NewTar(f)
defer tarWriter.Close()

walkFn := func(path string, d fs.DirEntry, err error) error {
walkFn := func(path string, _ fs.DirEntry, err error) error {
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/buildcontext/https_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestBuildWithHttpsTar(t *testing.T) {
}{
{
name: "test http bad status",
serverHandler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
serverHandler: http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusBadRequest)
_, err := w.Write([]byte("corrupted message"))
if err != nil {
Expand All @@ -39,7 +39,7 @@ func TestBuildWithHttpsTar(t *testing.T) {
},
{
name: "test http bad data",
serverHandler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
serverHandler: http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
_, err := w.Write([]byte("corrupted message"))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ type CachingAddCommand struct {
extractFn util.ExtractFunction
}

func (ca *CachingAddCommand) ExecuteCommand(config *v1.Config, buildArgs *dockerfile.BuildArgs) error {
func (ca *CachingAddCommand) ExecuteCommand(_ *v1.Config, _ *dockerfile.BuildArgs) error {
logrus.Infof("Found cached layer, extracting to filesystem")
var err error

Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type CmdCommand struct {

// ExecuteCommand executes the CMD command
// Argument handling is the same as RUN.
func (c *CmdCommand) ExecuteCommand(config *v1.Config, buildArgs *dockerfile.BuildArgs) error {
func (c *CmdCommand) ExecuteCommand(config *v1.Config, _ *dockerfile.BuildArgs) error {
var newCommand []string
if c.cmd.PrependShell {
// This is the default shell on Linux
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ type CachingCopyCommand struct {
extractFn util.ExtractFunction
}

func (cr *CachingCopyCommand) ExecuteCommand(config *v1.Config, buildArgs *dockerfile.BuildArgs) error {
func (cr *CachingCopyCommand) ExecuteCommand(_ *v1.Config, _ *dockerfile.BuildArgs) error {
logrus.Infof("Found cached layer, extracting to filesystem")
var err error

Expand Down
4 changes: 2 additions & 2 deletions pkg/commands/copy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,7 @@ func TestCopyCommand_ExecuteCommand_Extended(t *testing.T) {
uid := os.Getuid()
gid := os.Getgid()

getActiveUserGroup = func(userStr string, chownStr string, _ []string) (int64, int64, error) {
getActiveUserGroup = func(_ string, _ string, _ []string) (int64, int64, error) {
return int64(uid), int64(gid), nil
}

Expand Down Expand Up @@ -1087,7 +1087,7 @@ func TestCopyCommand_ExecuteCommand_Extended(t *testing.T) {
original := getActiveUserGroup
defer func() { getActiveUserGroup = original }()

getActiveUserGroup = func(userStr string, chownStr string, _ []string) (int64, int64, error) {
getActiveUserGroup = func(_ string, _ string, _ []string) (int64, int64, error) {
return 12345, 12345, nil
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type EntrypointCommand struct {
}

// ExecuteCommand handles command processing similar to CMD and RUN,
func (e *EntrypointCommand) ExecuteCommand(config *v1.Config, buildArgs *dockerfile.BuildArgs) error {
func (e *EntrypointCommand) ExecuteCommand(config *v1.Config, _ *dockerfile.BuildArgs) error {
var newCommand []string
if e.cmd.PrependShell {
// This is the default shell on Linux
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type HealthCheckCommand struct {
}

// ExecuteCommand handles command processing similar to CMD and RUN,
func (h *HealthCheckCommand) ExecuteCommand(config *v1.Config, buildArgs *dockerfile.BuildArgs) error {
func (h *HealthCheckCommand) ExecuteCommand(config *v1.Config, _ *dockerfile.BuildArgs) error {
check := convertDockerHealthConfigToContainerRegistryFormat(*h.cmd.Health)
config.Healthcheck = &check

Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/onbuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type OnBuildCommand struct {
}

// ExecuteCommand adds the specified expression in Onbuild to the config
func (o *OnBuildCommand) ExecuteCommand(config *v1.Config, buildArgs *dockerfile.BuildArgs) error {
func (o *OnBuildCommand) ExecuteCommand(config *v1.Config, _ *dockerfile.BuildArgs) error {
logrus.Info("Cmd: ONBUILD")
logrus.Infof("Args: %s", o.cmd.Expression)
if config.OnBuild == nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ func (cr *CachingRunCommand) IsArgsEnvsRequiredInCache() bool {
return true
}

func (cr *CachingRunCommand) ExecuteCommand(config *v1.Config, buildArgs *dockerfile.BuildArgs) error {
func (cr *CachingRunCommand) ExecuteCommand(_ *v1.Config, _ *dockerfile.BuildArgs) error {
logrus.Infof("Found cached layer, extracting to filesystem")
var err error

Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func Test_addDefaultHOME(t *testing.T) {
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
original := userLookup
userLookup = func(username string) (*user.User, error) { return test.mockUser, test.lookupError }
userLookup = func(_ string) (*user.User, error) { return test.mockUser, test.lookupError }
defer func() {
userLookup = original
}()
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type ShellCommand struct {
}

// ExecuteCommand handles command processing similar to CMD and RUN,
func (s *ShellCommand) ExecuteCommand(config *v1.Config, buildArgs *dockerfile.BuildArgs) error {
func (s *ShellCommand) ExecuteCommand(config *v1.Config, _ *dockerfile.BuildArgs) error {
config.Shell = s.cmd.Shell
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/workdir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ var workdirTests = []struct {
}

// For testing
func mockDir(path string, mode os.FileMode, uid, gid int64) error {
func mockDir(_ string, _ os.FileMode, _, _ int64) error {
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/creds/env_keychain.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ type envCredentialsHelper struct{}

var EnvCredentialsHelper = &envCredentialsHelper{}

func (ech *envCredentialsHelper) Add(c *credentials.Credentials) error {
func (ech *envCredentialsHelper) Add(_ *credentials.Credentials) error {
return errors.New("unsupported operation")
}

func (ech *envCredentialsHelper) Delete(serverURL string) error {
func (ech *envCredentialsHelper) Delete(_ string) error {
return errors.New("unsupported operation")
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/dockerfile/dockerfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func baseImageIndex(currentStage int, stages []instructions.Stage) int {
return -1
}

func lintWarnFunc(rulename, description, url, fmtmsg string, location []parser.Range) {
func lintWarnFunc(rulename, _, url, fmtmsg string, location []parser.Range) {
if len(location) > 0 {
logrus.Warnf("%s: %s (line %d)\n\t%s", rulename, fmtmsg, location[0].Start.Line, url)
} else {
Expand Down
4 changes: 2 additions & 2 deletions pkg/executor/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ COPY --from=second /bar /bat
defer func() {
dockerfile.GetRemoteOnBuild = original
}()
dockerfile.GetRemoteOnBuild = func(baseName string, metaArgs []instructions.ArgCommand, opts *config.KanikoOptions) ([]string, error) {
dockerfile.GetRemoteOnBuild = func(baseName string, _ []instructions.ArgCommand, _ *config.KanikoOptions) ([]string, error) {
switch baseName {
case "alpine":
// if image is "alpine" then add ONBUILD to its config
Expand Down Expand Up @@ -1411,7 +1411,7 @@ RUN foobar
opts: &config.KanikoOptions{InitialFSUnpacked: true},
stage: config.KanikoStage{Index: 0},
crossStageDeps: true,
mockGetFSFromImage: func(root string, img v1.Image, extract util.ExtractFunction) ([]string, error) {
mockGetFSFromImage: func(_ string, _ v1.Image, _ util.ExtractFunction) ([]string, error) {
return nil, errors.New("getFSFromImage shouldn't be called if fs is already unpacked")
},
},
Expand Down
12 changes: 6 additions & 6 deletions pkg/executor/fakes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type MockDockerCommand struct {
argToCompositeCache bool
}

func (m MockDockerCommand) ExecuteCommand(c *v1.Config, args *dockerfile.BuildArgs) error { return nil }
func (m MockDockerCommand) ExecuteCommand(_ *v1.Config, _ *dockerfile.BuildArgs) error { return nil }
func (m MockDockerCommand) String() string {
return m.command
}
Expand All @@ -70,11 +70,11 @@ func (m MockDockerCommand) ProvidesFilesToSnapshot() bool {
return true
}

func (m MockDockerCommand) CacheCommand(image v1.Image) commands.DockerCommand {
func (m MockDockerCommand) CacheCommand(_ v1.Image) commands.DockerCommand {
return m.cacheCommand
}

func (m MockDockerCommand) FilesUsedFromContext(c *v1.Config, args *dockerfile.BuildArgs) ([]string, error) {
func (m MockDockerCommand) FilesUsedFromContext(_ *v1.Config, _ *dockerfile.BuildArgs) ([]string, error) {
return m.contextFiles, nil
}

Expand Down Expand Up @@ -103,7 +103,7 @@ type MockCachedDockerCommand struct {
argToCompositeCache bool
}

func (m MockCachedDockerCommand) ExecuteCommand(c *v1.Config, args *dockerfile.BuildArgs) error {
func (m MockCachedDockerCommand) ExecuteCommand(_ *v1.Config, _ *dockerfile.BuildArgs) error {
return nil
}

Expand All @@ -119,15 +119,15 @@ func (m MockCachedDockerCommand) ProvidesFilesToSnapshot() bool {
return true
}

func (m MockCachedDockerCommand) CacheCommand(image v1.Image) commands.DockerCommand {
func (m MockCachedDockerCommand) CacheCommand(_ v1.Image) commands.DockerCommand {
return nil
}

func (m MockCachedDockerCommand) ShouldDetectDeletedFiles() bool {
return false
}

func (m MockCachedDockerCommand) FilesUsedFromContext(c *v1.Config, args *dockerfile.BuildArgs) ([]string, error) {
func (m MockCachedDockerCommand) FilesUsedFromContext(_ *v1.Config, _ *dockerfile.BuildArgs) ([]string, error) {
return m.contextFiles, nil
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/executor/push_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ func resetCalledCount() {
checkPushPermsCallCount = 0
}

func fakeCheckPushPermission(ref name.Reference, kc authn.Keychain, t http.RoundTripper) error {
func fakeCheckPushPermission(_ name.Reference, _ authn.Keychain, _ http.RoundTripper) error {
checkPushPermsCallCount++
return nil
}
Expand Down Expand Up @@ -449,7 +449,7 @@ func TestSkipPushPermission(t *testing.T) {
}
}

func TestHelperProcess(t *testing.T) {
func TestHelperProcess(_ *testing.T) {
if os.Getenv("GO_WANT_HELPER_PROCESS") != "1" {
return
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/image/image_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func Test_StandardImage(t *testing.T) {
defer func() {
RetrieveRemoteImage = original
}()
mock := func(image string, opts config.RegistryOptions, _ string) (v1.Image, error) {
mock := func(_ string, _ config.RegistryOptions, _ string) (v1.Image, error) {
return nil, nil
}
RetrieveRemoteImage = mock
Expand Down Expand Up @@ -87,7 +87,7 @@ func Test_OciImage(t *testing.T) {
defer func() {
retrieveOciImage = original
}()
mock := func(index int) (v1.Image, error) {
mock := func(_ int) (v1.Image, error) {
return nil, nil
}
retrieveOciImage = mock
Expand Down
6 changes: 3 additions & 3 deletions pkg/image/remote/remote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func Test_RetrieveRemoteImage_skipFallback(t *testing.T) {
SkipDefaultRegistryFallback: false,
}

remoteImageFunc = func(ref name.Reference, options ...remote.Option) (v1.Image, error) {
remoteImageFunc = func(ref name.Reference, _ ...remote.Option) (v1.Image, error) {
if ref.Context().Registry.Name() == registryMirror {
return nil, errors.New("no image found")
}
Expand All @@ -220,7 +220,7 @@ func Test_RetryRetrieveRemoteImageSucceeds(t *testing.T) {
ImageDownloadRetry: 2,
}
attempts := 0
remoteImageFunc = func(ref name.Reference, options ...remote.Option) (v1.Image, error) {
remoteImageFunc = func(_ name.Reference, _ ...remote.Option) (v1.Image, error) {
if attempts < 2 {
attempts++
return nil, errors.New("no image found")
Expand All @@ -241,7 +241,7 @@ func Test_NoRetryRetrieveRemoteImageFails(t *testing.T) {
ImageDownloadRetry: 0,
}
attempts := 0
remoteImageFunc = func(ref name.Reference, options ...remote.Option) (v1.Image, error) {
remoteImageFunc = func(_ name.Reference, _ ...remote.Option) (v1.Image, error) {
if attempts < 1 {
attempts++
return nil, errors.New("no image found")
Expand Down
2 changes: 1 addition & 1 deletion pkg/snapshot/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (s *Snapshotter) TakeSnapshot(files []string, shdCheckDelete bool) (string,
// Get whiteout paths
var filesToWhiteout []string
if shdCheckDelete {
_, deletedFiles, err := util.WalkFS(s.directory, s.l.GetCurrentPaths(), func(s string) (bool, error) {
_, deletedFiles, err := util.WalkFS(s.directory, s.l.GetCurrentPaths(), func(_ string) (bool, error) {
return true, nil
})
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions pkg/util/fs_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ func IsInIgnoreList(path string) bool {
return IsInProvidedIgnoreList(path, ignorelist)
}

func CheckCleanedPathAgainstProvidedIgnoreList(path string, wl []IgnoreListEntry) bool {
func CheckCleanedPathAgainstProvidedIgnoreList(path string, _ []IgnoreListEntry) bool {
for _, wl := range ignorelist {
if hasCleanedFilepathPrefix(path, wl.Path, wl.PrefixMatchOnly) {
return true
Expand Down Expand Up @@ -970,7 +970,7 @@ func CopyFile(src, dest string, context FileContext, uid, gid int64, chmod mode.
return false, CopyCapabilities(src, dest)
}

func CopyFileInternal(src, dest string, context FileContext) error {
func CopyFileInternal(src, dest string, _ FileContext) error {
fi, err := os.Stat(src)
if err != nil {
return err
Expand Down Expand Up @@ -1204,7 +1204,7 @@ func CopyFileOrSymlink(src string, destDir string, root string) error {
}
opts := otiai10Cpy.Options{
PreserveTimes: true,
Skip: func(info os.FileInfo, src, dest string) (bool, error) {
Skip: func(_ os.FileInfo, src, _ string) (bool, error) {
return strings.HasSuffix(src, config.KanikoDir), nil
},
FS: FSys,
Expand Down
Loading
Loading