Merge pull request #983 from cvgw/u/cvgw/fix-issue-519
Fix #519 capital letter in stage names
This commit is contained in:
commit
649a0ed99b
|
|
@ -0,0 +1,13 @@
|
||||||
|
FROM alpine as base_stage
|
||||||
|
|
||||||
|
RUN echo base_stage
|
||||||
|
|
||||||
|
|
||||||
|
FROM base_stage as BUG_stage
|
||||||
|
|
||||||
|
RUN echo BUG_stage
|
||||||
|
|
||||||
|
|
||||||
|
FROM BUG_stage as final_stage
|
||||||
|
|
||||||
|
RUN echo final_stage
|
||||||
|
|
@ -90,14 +90,17 @@ func Stages(opts *config.KanikoOptions) ([]config.KanikoStage, error) {
|
||||||
// baseImageIndex returns the index of the stage the current stage is built off
|
// baseImageIndex returns the index of the stage the current stage is built off
|
||||||
// returns -1 if the current stage isn't built off a previous stage
|
// returns -1 if the current stage isn't built off a previous stage
|
||||||
func baseImageIndex(currentStage int, stages []instructions.Stage) int {
|
func baseImageIndex(currentStage int, stages []instructions.Stage) int {
|
||||||
|
currentStageBaseName := strings.ToLower(stages[currentStage].BaseName)
|
||||||
|
|
||||||
for i, stage := range stages {
|
for i, stage := range stages {
|
||||||
if i > currentStage {
|
if i > currentStage {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if stage.Name == stages[currentStage].BaseName {
|
if stage.Name == currentStageBaseName {
|
||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -245,15 +248,19 @@ func ParseCommands(cmdArray []string) ([]instructions.Command, error) {
|
||||||
|
|
||||||
// SaveStage returns true if the current stage will be needed later in the Dockerfile
|
// SaveStage returns true if the current stage will be needed later in the Dockerfile
|
||||||
func saveStage(index int, stages []instructions.Stage) bool {
|
func saveStage(index int, stages []instructions.Stage) bool {
|
||||||
|
currentStageName := stages[index].Name
|
||||||
|
|
||||||
for stageIndex, stage := range stages {
|
for stageIndex, stage := range stages {
|
||||||
if stageIndex <= index {
|
if stageIndex <= index {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if stage.BaseName == stages[index].Name {
|
|
||||||
|
if strings.ToLower(stage.BaseName) == currentStageName {
|
||||||
if stage.BaseName != "" {
|
if stage.BaseName != "" {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue