Skip to content

fix: require --image-platform with --metadata-file for multi-platform targets - #767

Open
ianpittwood wants to merge 1 commit into
mainfrom
fix/739-metadata-single-platform
Open

fix: require --image-platform with --metadata-file for multi-platform targets#767
ianpittwood wants to merge 1 commit into
mainfrom
fix/739-metadata-single-platform

Conversation

@ianpittwood

Copy link
Copy Markdown
Contributor

What

Adds a guard to bakery build: when --metadata-file is set, the build errors
out 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 platform field. BuildMetadata.platform then returns None, which:

  • makes ImageTarget.image_reference(platform=...) fall back to a tag-based
    reference, so bakery dgoss run --metadata-file stops testing the exact built
    digest;
  • collapses ImageTarget.get_merge_sources() to a single None-keyed source,
    losing per-platform merge inputs.

The practical rule "one platform per bakery build invocation when the metadata
file is consumed by dgoss run / ci publish" was documented nowhere and
unenforced. This makes it a hard constraint at the CLI boundary instead of a
silent, downstream-only failure.

Changes

  • cli/build.py: guard before build_targets — effective per-target platform
    count is --image-platform if given, else the target's image_os.platforms
    (falling back to DEFAULT_PLATFORMS). Any target with >1 → exit 1.
  • --metadata-file help now documents the per-UID keying and the single-platform
    requirement.
  • Tests: multi-platform without --image-platform errors; with a single
    --image-platform builds; multiple --image-platform flags 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.

… 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
@github-actions

Copy link
Copy Markdown

Test Results

2 250 tests  +4   2 250 ✅ +4   7m 45s ⏱️ -7s
    1 suites ±0       0 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit d049ce6. ± Comparison against base commit 91d0066.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant