Skip to content

oci: standardize flashable artifact and annotation contracts#14

Open
bennyz wants to merge 1 commit into
jumpstarter-dev:mainfrom
bennyz:centralize-annotations
Open

oci: standardize flashable artifact and annotation contracts#14
bennyz wants to merge 1 commit into
jumpstarter-dev:mainfrom
bennyz:centralize-annotations

Conversation

@bennyz
Copy link
Copy Markdown
Member

@bennyz bennyz commented May 28, 2026

Replace scattered string-matching with two formal abstractions:

  • FlashableArtifact enum: central registry of supported disk image media types (raw, qcow2, simg) across both automotive and embedded prefixes. Replaces ad-hoc starts_with() checks in layer selection and flash validation.

  • AnnotationSchema struct: configurable annotation key resolution for multi-partition extraction. Ships GENERIC (dev.jumpstarter.fls/) and AUTOMOTIVE (automotive.sdv.cloud.redhat.com/) presets with auto-detection. Replaces hardcoded automotive annotation keys.

Fixes #12

Replace scattered string-matching with two formal abstractions:

- FlashableArtifact enum: central registry of supported disk image
  media types (raw, qcow2, simg) across both automotive and embedded
  prefixes. Replaces ad-hoc starts_with() checks in layer selection
  and flash validation.

- AnnotationSchema struct: configurable annotation key resolution for
  multi-partition extraction. Ships GENERIC (dev.jumpstarter.fls/*)
  and AUTOMOTIVE (automotive.sdv.cloud.redhat.com/*) presets with
  auto-detection. Replaces hardcoded automotive annotation keys.

Assisted-by: claude-opus-4.6
Signed-off-by: Benny Zlotnik <bzlotnik@redhat.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR introduces a pluggable annotation schema system to replace hardcoded automotive OCI annotation key constants, and abstracts disk image format detection via a new FlashableArtifact enum. The changes configure which partition and default-partition annotation keys are used during OCI extraction, while supporting both automotive and embedded disk media-type prefixes.

Changes

Configurable OCI annotation schemas and flashable artifact abstraction

Layer / File(s) Summary
Core annotation schema types and resolution
src/fls/annotation_schema.rs, src/fls/mod.rs
AnnotationSchema struct with preset constants (GENERIC, AUTOMOTIVE) defines partition and default-partition keys. Helper functions resolve the first matching schema by checking layer annotations, return defaults when custom schemas are empty, and format schema keys for error messages. Full unit test coverage validates preset values, search order, resolution logic, and schema fallback behavior.
FlashableArtifact enum and disk format abstraction
src/fls/oci/manifest.rs
New FlashableArtifact enum models disk image formats (DiskRaw, DiskQcow2, DiskSimg) and parses media types from both application/vnd.automotive.disk and application/vnd.embedded.disk prefixes. Provides format suffix helpers, flashability checking, and supported-types enumeration. Descriptor::flashable_artifact() converts media types into the enum. Includes comprehensive unit tests for parsing, suffix mapping, and round-trip validation.
Manifest layer selection using FlashableArtifact
src/fls/oci/manifest.rs
Manifest::get_single_layer fallback now uses FlashableArtifact::is_flashable() to select the first flashable disk layer, replacing the prior hardcoded automotive disk prefix check.
OCI extraction and flashing with schema-driven partition resolution
src/fls/oci/from_oci.rs
extract_files_by_annotations_to_dir and extract_files_by_annotations_with_overrides_to_dir resolve an annotation schema from manifest layers and read partition keys from schema.partition_key instead of automotive constants. New parse_default_partitions(manifest, schema) helper parses defaults using schema.default_partitions_key. flash_from_oci validates flashability via FlashableArtifact::is_flashable() and reports supported types on validation failure. Error messages report searched partition keys via searched_keys_display().
Configuration and initialization
src/fls/oci/mod.rs, src/fls/options.rs, src/main.rs, src/fls/fastboot.rs, tests/oci_extract.rs
OciOptions.annotation_schemas (Vec) field stores the active schemas; empty vector triggers auto-detection via AnnotationSchema::default_search_order(). Initialized in command paths (main.rs, fastboot.rs) and test fixtures. oci/mod.rs visibility changed to pub(crate) to enable cross-module schema access. fastboot.rs error handling updated to report "No recognized annotation schema detected" when partition extraction fails.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • jumpstarter-dev/fls#9: Updates flash_from_oci flashable layer validation via media-type check, directly related to the new FlashableArtifact::is_flashable() abstraction introduced here.
  • jumpstarter-dev/fls#6: Previously added automotive-specific OCI annotation constants; this PR replaces that hardcoded approach with the configurable AnnotationSchema system.

Suggested reviewers

  • mangelajo

Poem

🐰 A rabbit hops through OCI's door,
With schemas flexible, not hardcoded anymore!
Flashable artifacts dance and play,
Supporting embedded disks—hip, hip, hooray! 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and clearly describes the main change: introducing standardized abstractions for flashable artifacts and annotation contracts to replace scattered string-matching.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The pull request description clearly relates to the changeset, explaining the introduction of FlashableArtifact enum and AnnotationSchema struct to replace scattered string-matching logic.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

Actionable comments posted: 0

@bennyz bennyz requested a review from mangelajo May 28, 2026 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support more generic media types for disk image layer selection

1 participant