Address code review comments; review unnecessary error check
This commit is contained in:
parent
da6f099820
commit
cd1b957e43
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue