Skip to content

Commit

Permalink
fix(lib): Don't construct when referencing a stage
Browse files Browse the repository at this point in the history
  • Loading branch information
pan93412 committed Sep 25, 2023
1 parent fa12a74 commit 516e143
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions pkg/zeaburpack/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,22 @@ func buildImage(opt *buildImageOptions) error {
stageLines := make([]int, 0)

for i, line := range lines {
instruction, imageRefString, found := strings.Cut(line, " ")

// We only care about FROM instructions.
if !found || strings.ToLower(instruction) != "from" {
fromStatement, isFromStatement := ParseFrom(line)
if !isFromStatement {
continue
}

// Construct the reference.
newRef := refConstructor.Construct(imageRefString)
newRef := refConstructor.Construct(fromStatement.Source)

// Replace this FROM line.
lines[i] = instruction + " " + newRef
fromStatement.Source = newRef
lines[i] = fromStatement.String()

// Mark this FROM line as a stage.
if stage, ok := fromStatement.Stage.Get(); ok {
refConstructor.AddStage(stage)
}
stageLines = append(stageLines, i)
}

Expand Down

0 comments on commit 516e143

Please sign in to comment.