Address code review comments; review unnecessary error check

This commit is contained in:
Priya Wadhwa
2018-09-17 11:11:51 +01:00
parent da6f099820
commit cd1b957e43
3 changed files with 11 additions and 10 deletions
+4 -7
View File
@@ -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
}