feat: add --separate-scratch flag#683
Merged
patrickhoefler merged 3 commits intomainfrom Jul 12, 2025
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new --separate-scratch flag to control whether scratch images are collapsed into one node or kept separate, refactors external-image handling to use unique IDs, and updates tests, documentation, and the build system accordingly.
- Introduce
--separate-scratchflag in CLI and propagate through parsing and graph generation - Refactor
ExternalImageandWaitForto include anIDfield and update all references - Enhance tests and documentation; add a
checkMakefile target
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/dockerfile2dot/structs.go | Added ID fields and improved comments |
| internal/dockerfile2dot/load.go | Updated function signature to accept separateScratch |
| internal/dockerfile2dot/load_test.go | Simplified test to only check error, removed output assertions |
| internal/dockerfile2dot/convert.go | Propagate separateScratch flag and update external images logic |
| internal/dockerfile2dot/convert_test.go | Added separateScratch cases and updated expected IDs |
| internal/dockerfile2dot/build.go | Use waitFor.ID instead of name when creating edges |
| internal/dockerfile2dot/build_test.go | New test for separate-scratch graph labels |
| internal/cmd/root.go | Register --separate-scratch flag |
| internal/cmd/root_test.go | CLI integration test for the new flag |
| README.md | Documented the new flag |
| Makefile | Added check target |
| .github/copilot-instructions.md | Added testing and quality guidelines |
Comments suppressed due to low confidence (2)
internal/dockerfile2dot/load_test.go:54
- The test no longer verifies the returned SimplifiedDockerfile value, reducing coverage of parsing logic. Consider reintroducing assertions (e.g., using cmp.Diff or explicit field checks) to validate the parsed output.
_, err := LoadAndParseDockerfile(
README.md:157
- The indentation of the
--separate-scratchentry doesn’t align with the other flags; adjust leading spaces so it lines up consistently in the flags list.
--separate-scratch create separate nodes for each scratch image instead of collapsing them
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several changes to improve the functionality, testing, and maintainability of the
dockerfile2dottool. The most significant updates include the addition of a--separate-scratchflag to handle scratch images uniquely, refactoring to useIDinstead ofNamefor external image identification, and enhancements to the testing guidelines and code quality documentation.New Feature:
--separate-scratchFlag--separate-scratchflag to create separate nodes for each scratch image in the graph instead of collapsing them. This includes updates to the CLI (internal/cmd/root.go) and corresponding tests (internal/cmd/root_test.go). [1] [2] [3] [4] [5] [6]Refactoring: External Image Identification
IDinstead ofNamefor identifying external images, ensuring unique identification and improving maintainability. Changes span multiple files includinginternal/dockerfile2dot/build.go,internal/dockerfile2dot/convert.go, and their respective tests. [1] [2] [3] [4] [5] [6] [7]Documentation and Testing Guidelines
.github/copilot-instructions.mdfile outlining testing guidelines and code quality standards, emphasizing clean testing, proper assertions, and consistent naming conventions.Build Process Improvements
checktarget in theMakefilethat runs both linting and tests, streamlining the build process.Minor Enhancements and Fixes
addExternalImagesto handle theseparateScratchflag, ensuring unique IDs for scratch instances and avoiding duplicate entries. [1] [2]internal/dockerfile2dot/convert_test.goto align with the newID-based external image identification and the--separate-scratchfunctionality. [1] [2] [3]