Skip to content

Commit

Permalink
Fixes GoogleContainerTools#2046: make target stage lookup case insens…
Browse files Browse the repository at this point in the history
…itive
  • Loading branch information
hypnoce committed Apr 12, 2022
1 parent f930b75 commit 723a67a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/dockerfile/dockerfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
11 changes: 10 additions & 1 deletion pkg/dockerfile/dockerfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
`
Expand All @@ -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,
},
{
Expand Down

0 comments on commit 723a67a

Please sign in to comment.