feat: refactor flag for displaying scratch images#684
Merged
patrickhoefler merged 1 commit intomainfrom Jul 13, 2025
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors Dockerfile scratch image handling by replacing the old boolean flag with a new three‐mode --scratch enum, updates parsing logic and helper functions accordingly, and refreshes documentation and tests to cover all modes.
- Replace
--separate-scratchbool flag with--scratchenum (collapsed,hidden,separated) in CLI, loader, and converter - Refactor
dockerfileToSimplifiedDockerfileinto smaller helper functions and updateaddExternalImagesfor multi-mode scratch handling - Enhance tests for all scratch modes, remove deprecated tests, and update documentation and testing guidelines
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/dockerfile2dot/load.go | Change loader signature to accept scratchMode |
| internal/dockerfile2dot/convert.go | Refactor scratch logic into helper functions |
| internal/dockerfile2dot/convert_test.go | Add tests for collapsed, hidden, and separated modes |
| internal/dockerfile2dot/load_test.go | Update loader tests to use default collapsed mode |
| internal/cmd/root.go | Remove old flag, register new enum-based --scratch |
| internal/cmd/root_test.go | Update CLI tests for the new scratch flag |
| README.md | Document the new --scratch flag and its modes |
| .github/copilot-instructions.md | Expand testing guidelines including edge cases and make check |
Comments suppressed due to low confidence (4)
internal/cmd/root.go:28
- Replacing the
--separate-scratchflag with--scratchis a breaking change for CLI consumers; please add a deprecation notice or migration guide in the CHANGELOG or documentation.
scratchFlag enum
.github/copilot-instructions.md:24
- This guideline assumes a
make checktarget exists; please verify that your Makefile or CI configuration defines this target or update the instructions accordingly.
- Always use `make check` for efficient linting and testing - it runs golangci-lint, tests with coverage, and enforces code quality standards in one command
internal/cmd/root_test.go:495
- [nitpick] The test names mix phrases like 'collapsed mode' and 'hidden mode'; consider standardizing the format (e.g.,
scratch flag: <mode>) to make each case clearer.
name: "scratch flag collapsed mode",
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 a new
--scratchflag to replace the--separate-scratchflag, enhancing the flexibility of handling scratch images in Dockerfile visualizations. It also updates related documentation and tests to reflect these changes. Additionally, improvements were made to testing guidelines and test coverage.Core Feature Update: Scratch Image Handling
--separate-scratchflag with the--scratchflag, which supports three modes:collapsed,hidden, andseparatedfor handling scratch images (README.md,internal/cmd/root.go,internal/dockerfile2dot/convert.go). [1] [2] [3]dockerfileToSimplifiedDockerfileand related helper functions to handle the three modes of the--scratchflag, including skipping scratch images in hidden mode and generating unique IDs for separated mode (internal/dockerfile2dot/convert.go). [1] [2]Testing Enhancements
--scratchflag in all three modes (collapsed,hidden,separated) and edge cases like invalid modes (internal/cmd/root_test.go,internal/dockerfile2dot/convert_test.go). [1] [2]--separate-scratchflag and added cleanup logic for output files in tests (internal/cmd/root_test.go).Documentation Updates
README.mdto document the new--scratchflag and its modes (README.md)..github/copilot-instructions.mdto emphasize comprehensive test coverage, including edge cases and error conditions (.github/copilot-instructions.md).Code Quality Improvements
dockerfileToSimplifiedDockerfilefunction by introducing helper functions (processFromInstruction,processCopyInstruction, etc.) for better maintainability and readability (internal/dockerfile2dot/convert.go).These changes collectively improve the flexibility of scratch image handling, enhance test coverage, and maintain high code quality.