Skip to content

feat(Project): add MBR and hybrid volume schemas#329

Merged
lengau merged 13 commits intomainfrom
work/volume-structure
Apr 27, 2026
Merged

feat(Project): add MBR and hybrid volume schemas#329
lengau merged 13 commits intomainfrom
work/volume-structure

Conversation

@lengau
Copy link
Copy Markdown
Collaborator

@lengau lengau commented Apr 21, 2026

This adds the ability to accept projects with mbr and mbr,gpt (hybrid) volume schemas. We don't implement this currently, we just accept projects that have it.

IMAGECRAFT-111


Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends Imagecraft’s project model to accept additional volume schemas (mbr and mbr,gpt hybrid) by refactoring the volume schema into a discriminated union of concrete volume/structure types, and adds tests/fixtures to validate the new parsing behavior.

Changes:

  • Refactor Volume into a discriminated union (GPTVolume, MBRVolume, HybridVolume) with schema-specific StructureItem types and validation.
  • Update GPT-only packing/image-creation codepaths to type against GPTVolume while continuing to reject non-GPT schemas at image creation time.
  • Add unit + integration test coverage and new valid/invalid project fixtures for MBR and hybrid schemas; adjust YAML reference generation inputs.

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/unit/services/test_image.py Update mocks to use GPT-specific structure item type.
tests/unit/pack/test_image.py Switch volume parsing in tests to GPTVolume.
tests/unit/pack/test_grubutil.py Switch volume parsing in tests to GPTVolume.
tests/unit/pack/test_gptutil.py Switch volume parsing in tests to GPTVolume.
tests/unit/models/test_volume.py Add extensive validation tests for MBR/hybrid and discriminated union behavior.
tests/unit/models/test_project.py Add tests for partition-name generation across schema-specific structure items.
tests/integration/services/valid-projects/simple/imagecraft.yaml Add a GPT-valid sample project for integration testing.
tests/integration/services/valid-projects/simple-mbr/imagecraft.yaml Add an MBR-valid sample project for integration testing.
tests/integration/services/valid-projects/simple-hybrid/imagecraft.yaml Add a hybrid-valid sample project for integration testing.
tests/integration/services/test_project.py Add integration tests that load all valid/invalid project fixtures.
tests/integration/services/invalid-projects/mbr-unsupported-fields/imagecraft.yaml Add invalid MBR fixture to ensure unsupported structure keys are rejected.
tests/integration/services/invalid-projects/mbr-unsupported-fields/error.txt Expected error output for invalid MBR fixture.
tests/integration/services/invalid-projects/hybrid-unsupported-fields/imagecraft.yaml Add invalid hybrid fixture to ensure unsupported structure keys are rejected.
tests/integration/services/invalid-projects/hybrid-unsupported-fields/error.txt Expected error output for invalid hybrid fixture.
tests/integration/services/invalid-projects/gpt-unsupported-fields/imagecraft.yaml Add invalid GPT fixture to ensure unsupported structure keys are rejected.
tests/integration/services/invalid-projects/gpt-unsupported-fields/error.txt Expected error output for invalid GPT fixture.
tests/integration/conftest.py Enable required craft-parts features for integration tests.
imagecraft/subprocesses.py Capture stderr by default in the subprocess wrapper.
imagecraft/services/image.py Cast GPT layouts to GPTVolume at the GPT-only image-creation callsite.
imagecraft/pack/gptutil.py Type GPT utilities explicitly to GPTVolume; adjust partition JSON generation.
imagecraft/models/volume.py Introduce schema-specific volume + structure item models and new schemas/roles.
imagecraft/models/init.py Re-export GPT-specific models and update public model exports.
docs/reference/imagecraft-yaml.rst Update kitbash-field references to GPT-specific model types.

Comment thread imagecraft/models/volume.py Outdated
Comment thread docs/reference/imagecraft-yaml.rst
Comment thread tests/integration/services/test_project.py
Comment thread tests/integration/services/test_project.py
Comment thread imagecraft/pack/gptutil.py
@lengau lengau requested review from smethnani and tigarmo April 23, 2026 18:02
@lengau lengau marked this pull request as ready for review April 23, 2026 18:02
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Alex Lowe <alex.lowe@canonical.com>
Signed-off-by: Alex Lowe <alex.lowe@canonical.com>
@lengau lengau merged commit 805f640 into main Apr 27, 2026
18 checks passed
@lengau lengau deleted the work/volume-structure branch April 27, 2026 17:16
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.

4 participants