diff --git a/pkg/constants/constants.go b/pkg/constants/constants.go index bcc658fca..d8fcc722e 100644 --- a/pkg/constants/constants.go +++ b/pkg/constants/constants.go @@ -55,9 +55,13 @@ const ( S3BuildContextPrefix = "s3://" LocalDirBuildContextPrefix = "dir://" + HOME = "HOME" // DefaultHOMEValue is the default value Docker sets for $HOME - HOME = "HOME" DefaultHOMEValue = "/root" + + // Docker command names + Cmd = "cmd" + Entrypoint = "entrypoint" ) // KanikoBuildFiles is the list of files required to build kaniko diff --git a/pkg/executor/build.go b/pkg/executor/build.go index 8b9659a76..923741126 100644 --- a/pkg/executor/build.go +++ b/pkg/executor/build.go @@ -145,9 +145,7 @@ func DoBuild(opts *config.KanikoOptions) (v1.Image, error) { return nil, err } } - if err := reviewConfig(stage, &imageConfig.Config); err != nil { - return nil, err - } + reviewConfig(stage, &imageConfig.Config) sourceImage, err = mutate.Config(sourceImage, imageConfig.Config) if err != nil { return nil, err @@ -235,20 +233,19 @@ func resolveOnBuild(stage *config.KanikoStage, config *v1.Config) error { // reviewConfig makes sure the value of CMD is correct after building the stage // If ENTRYPOINT was set in this stage but CMD wasn't, then CMD should be cleared out // See Issue #346 for more info -func reviewConfig(stage config.KanikoStage, config *v1.Config) error { +func reviewConfig(stage config.KanikoStage, config *v1.Config) { entrypoint := false cmd := false for _, c := range stage.Commands { - if c.Name() == "cmd" { + if c.Name() == constants.Cmd { cmd = true } - if c.Name() == "entrypoint" { + if c.Name() == constants.Entrypoint { entrypoint = true } } if entrypoint && !cmd { config.Cmd = nil } - return nil } diff --git a/pkg/executor/build_test.go b/pkg/executor/build_test.go index 51eca6f99..edf162261 100644 --- a/pkg/executor/build_test.go +++ b/pkg/executor/build_test.go @@ -59,8 +59,8 @@ func Test_reviewConfig(t *testing.T) { Cmd: test.originalCmd, Entrypoint: test.originalEntrypoint, } - err := reviewConfig(stage(t, test.dockerfile), config) - testutil.CheckErrorAndDeepEqual(t, false, err, test.expectedCmd, config.Cmd) + reviewConfig(stage(t, test.dockerfile), config) + testutil.CheckErrorAndDeepEqual(t, false, nil, test.expectedCmd, config.Cmd) }) } }