Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Commit f9c5745

Browse files
authored
Fixes #2046: make target stage lookup case insensitive (#2047)
1 parent f930b75 commit f9c5745

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

pkg/dockerfile/dockerfile.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ func targetStage(stages []instructions.Stage, target string) (int, error) {
197197
return len(stages) - 1, nil
198198
}
199199
for i, stage := range stages {
200-
if stage.Name == target {
200+
if strings.EqualFold(stage.Name, target) {
201201
return i, nil
202202
}
203203
}

pkg/dockerfile/dockerfile_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,9 @@ func Test_targetStage(t *testing.T) {
261261
FROM scratch AS second
262262
COPY --from=0 /hi /hi2
263263
264+
FROM scratch AS UPPER_CASE
265+
COPY --from=0 /hi /hi2
266+
264267
FROM scratch
265268
COPY --from=second /hi2 /hi3
266269
`
@@ -280,10 +283,16 @@ func Test_targetStage(t *testing.T) {
280283
targetIndex: 1,
281284
shouldErr: false,
282285
},
286+
{
287+
name: "test valid upper case target",
288+
target: "UPPER_CASE",
289+
targetIndex: 2,
290+
shouldErr: false,
291+
},
283292
{
284293
name: "test no target",
285294
target: "",
286-
targetIndex: 2,
295+
targetIndex: 3,
287296
shouldErr: false,
288297
},
289298
{

0 commit comments

Comments
 (0)