Fix failure when using capital letters in image alias in 'FROM ... AS' instruction

The third library moby/buildkit lowers the image alias used in 'FROM .. AS' instruction.
This change fixes this issue by making the resolve of dependencies agnostic to case.

Fixes #592
Fixes #770
This commit is contained in:
Ben Einaudi
2019-12-06 12:04:26 +01:00
committed by Ben Einaudi
parent 034ac9e258
commit d22a7608c2
2 changed files with 15 additions and 5 deletions
+2 -1
View File
@@ -203,6 +203,7 @@ func targetStage(stages []instructions.Stage, target string) (int, error) {
// resolveStages resolves any calls to previous stages with names to indices
// Ex. --from=second_stage should be --from=1 for easier processing later on
// As third party library lowers stage name in FROM instruction, this function resolves stage case insensitively.
func resolveStages(stages []instructions.Stage) {
nameToIndex := make(map[string]string)
for i, stage := range stages {
@@ -214,7 +215,7 @@ func resolveStages(stages []instructions.Stage) {
switch c := cmd.(type) {
case *instructions.CopyCommand:
if c.From != "" {
if val, ok := nameToIndex[c.From]; ok {
if val, ok := nameToIndex[strings.ToLower(c.From)]; ok {
c.From = val
}