|
6 | 6 | "errors" |
7 | 7 | "fmt" |
8 | 8 | "io" |
| 9 | + "maps" |
9 | 10 | "os" |
10 | 11 | "path" |
11 | 12 | "path/filepath" |
@@ -512,7 +513,7 @@ func (s *StageExecutor) performCopy(excludes []string, copies ...imagebuilder.Co |
512 | 513 | } |
513 | 514 | } |
514 | 515 | if additionalBuildContext == nil { |
515 | | - if isStage, err := s.executor.waitForStage(s.ctx, from, s.stages[:s.index]); isStage && err != nil { |
| 516 | + if isStage, _, err := s.executor.waitForStage(s.ctx, from, s.stages[:s.index]); isStage && err != nil { |
516 | 517 | return err |
517 | 518 | } |
518 | 519 | if other, ok := s.executor.stages[from]; ok && other.index < s.index { |
@@ -677,7 +678,7 @@ func (s *StageExecutor) runStageMountPoints(mountList []string) (map[string]inte |
677 | 678 | // If the source's name corresponds to the |
678 | 679 | // result of an earlier stage, wait for that |
679 | 680 | // stage to finish being built. |
680 | | - if isStage, err := s.executor.waitForStage(s.ctx, from, s.stages[:s.index]); isStage && err != nil { |
| 681 | + if isStage, _, err := s.executor.waitForStage(s.ctx, from, s.stages[:s.index]); isStage && err != nil { |
681 | 682 | return nil, err |
682 | 683 | } |
683 | 684 | // If the source's name is a stage, return a |
@@ -1149,8 +1150,13 @@ func (s *StageExecutor) Execute(ctx context.Context, base string) (imgID string, |
1149 | 1150 | // If not, then go on assuming that it's just a regular image that's |
1150 | 1151 | // either in local storage, or one that we have to pull from a |
1151 | 1152 | // registry, subject to the passed-in pull policy. |
1152 | | - if isStage, err := s.executor.waitForStage(ctx, base, s.stages[:s.index]); isStage && err != nil { |
| 1153 | + // This helper will also return the final resolved argument list from |
| 1154 | + // the parent state. |
| 1155 | + if isStage, parentArgs, err := s.executor.waitForStage(ctx, base, s.stages[:s.index]); isStage && err != nil { |
1153 | 1156 | return "", nil, false, err |
| 1157 | + } else { |
| 1158 | + // Update the start args with those from the parent stage |
| 1159 | + maps.Insert(ib.Args, maps.All(parentArgs)) |
1154 | 1160 | } |
1155 | 1161 | pullPolicy := s.executor.pullPolicy |
1156 | 1162 | s.executor.stagesLock.Lock() |
@@ -1369,7 +1375,7 @@ func (s *StageExecutor) Execute(ctx context.Context, base string) (imgID string, |
1369 | 1375 | // If the source's name corresponds to the |
1370 | 1376 | // result of an earlier stage, wait for that |
1371 | 1377 | // stage to finish being built. |
1372 | | - if isStage, err := s.executor.waitForStage(ctx, from, s.stages[:s.index]); isStage && err != nil { |
| 1378 | + if isStage, _, err := s.executor.waitForStage(ctx, from, s.stages[:s.index]); isStage && err != nil { |
1373 | 1379 | return "", nil, false, err |
1374 | 1380 | } |
1375 | 1381 | if otherStage, ok := s.executor.stages[from]; ok && otherStage.index < s.index { |
@@ -1742,6 +1748,8 @@ func (s *StageExecutor) Execute(ctx context.Context, base string) (imgID string, |
1742 | 1748 | } |
1743 | 1749 | } |
1744 | 1750 |
|
| 1751 | + s.executor.freezeArgs(s.name, ib.Args) |
| 1752 | + |
1745 | 1753 | return imgID, ref, onlyBaseImage, nil |
1746 | 1754 | } |
1747 | 1755 |
|
|
0 commit comments