Fixes #2046: make target stage lookup case insensitive (#2047)

This commit is contained in:
François JACQUES 2022-04-12 15:54:14 +02:00 committed by GitHub
parent f930b75b8b
commit f9c5745c63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -197,7 +197,7 @@ func targetStage(stages []instructions.Stage, target string) (int, error) {
return len(stages) - 1, nil
}
for i, stage := range stages {
if stage.Name == target {
if strings.EqualFold(stage.Name, target) {
return i, nil
}
}

View File

@ -261,6 +261,9 @@ func Test_targetStage(t *testing.T) {
FROM scratch AS second
COPY --from=0 /hi /hi2
FROM scratch AS UPPER_CASE
COPY --from=0 /hi /hi2
FROM scratch
COPY --from=second /hi2 /hi3
`
@ -280,10 +283,16 @@ func Test_targetStage(t *testing.T) {
targetIndex: 1,
shouldErr: false,
},
{
name: "test valid upper case target",
target: "UPPER_CASE",
targetIndex: 2,
shouldErr: false,
},
{
name: "test no target",
target: "",
targetIndex: 2,
targetIndex: 3,
shouldErr: false,
},
{