mz334: move resolveCrossStageCommands forwards#337
Conversation
|
note that this temporarily makes the whole Well no, currently you can workaround that issue by not taking any optimizations, ie. |
c4959c5 to
21a4da2
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the handling of cross-stage command resolution by moving the transformation of named stage references to numeric indices earlier in the build process. Instead of resolving COPY --from=<stage_name> to COPY --from=<index> later during ResolveCrossStageInstructions, this transformation now happens immediately when KanikoStage objects are created in MakeKanikoStages.
Key changes:
- Cross-stage command resolution moved from
ResolveCrossStageInstructionstoMakeKanikoStages - Simplified
fetchExtraStagesto only handle numeric stage references and remote images - Updated
skipUnusedStagesto remove named reference handling logic
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| pkg/executor/build.go | Removed named stage tracking in fetchExtraStages and call to ResolveCrossStageCommands in ResolveCrossStageInstructions |
| pkg/dockerfile/dockerfile.go | Made ResolveCrossStageCommands private, added stage name resolution in MakeKanikoStages, simplified skipUnusedStages |
| pkg/dockerfile/dockerfile_test.go | Updated tests to use MakeKanikoStages and set feature flag environment variable |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f287003 to
456a9cf
Compare
456a9cf to
ac9dd38
Compare
ac9dd38 to
0a60a90
Compare
|
as the ONBUILD references are now resolved earlier, we can safely take this refactoring |
|
AI summary review: OverviewRefactoring that moves cross-stage reference resolution (e.g., Key Changes
Analysis✅ Strengths
🔍 Considerations
📝 Minor Notes
Recommendation✅ APPROVE - Solid refactoring that simplifies code and improves architecture. No significant risks identified. |
This is a refactoring in preparation for #334
Description
When we create KanikoStage's we replace all baseImage references with numeric references. But we keep both named and numeric references in
COPY --from. ieCOPY --from=baseorCOPY --from=0(yes this is valid syntax). Later we replace those references a bit hidden as part ofResolveCrossStageInstructions. With this change we just move that transformation to the beginning, so when you have a KanikoStage you are guaranteed to only have numeric references to other stages.