fix: require --image-platform with --metadata-file for multi-platform targets - #767
Open
ianpittwood wants to merge 1 commit into
Open
fix: require --image-platform with --metadata-file for multi-platform targets#767ianpittwood wants to merge 1 commit into
ianpittwood wants to merge 1 commit into
Conversation
… targets A target built for more than one platform in a single invocation produces a single metadata entry describing an index/manifest-list descriptor with no platform field. BuildMetadata.platform then returns None, so ImageTarget.image_reference()/get_merge_sources() lose the exact per-platform digest and `dgoss run --metadata-file` / `ci publish` fall back to tags. Enforce the "one platform per invocation" rule: when --metadata-file is set, error out (naming the offending targets) unless the effective build resolves to a single platform. Also document the metadata write semantics in --metadata-file help. Refs #739
3 tasks
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.
What
Adds a guard to
bakery build: when--metadata-fileis set, the build errorsout unless the effective build resolves to a single platform. The error
names the offending target(s) and tells the user to pass a single
--image-platform.Why
Per #739, a target built for more than one platform in a single invocation
produces one metadata entry describing an index/manifest-list descriptor with
no
platformfield.BuildMetadata.platformthen returnsNone, which:ImageTarget.image_reference(platform=...)fall back to a tag-basedreference, so
bakery dgoss run --metadata-filestops testing the exact builtdigest;
ImageTarget.get_merge_sources()to a singleNone-keyed source,losing per-platform merge inputs.
The practical rule "one platform per
bakery buildinvocation when the metadatafile is consumed by
dgoss run/ci publish" was documented nowhere andunenforced. This makes it a hard constraint at the CLI boundary instead of a
silent, downstream-only failure.
Changes
cli/build.py: guard beforebuild_targets— effective per-target platformcount is
--image-platformif given, else the target'simage_os.platforms(falling back to
DEFAULT_PLATFORMS). Any target with >1 → exit 1.--metadata-filehelp now documents the per-UID keying and the single-platformrequirement.
--image-platformerrors; with a single--image-platformbuilds; multiple--image-platformflags error;single-platform builds.
Refs #739
Notes
This PR scopes to the constraint requested. The broader doc rewrites in #739
(imagetools help, CONTRIBUTING strategy section, README) are not included here.