Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Raid Luks and Integrity to context manager #2450

Merged
merged 1 commit into from
Feb 5, 2024
Merged

Conversation

schaefi
Copy link
Collaborator

@schaefi schaefi commented Feb 4, 2024

Change the RaidDevice, LuksDevice and IntegrityDevice classes to context manager. All code using this classes moved to:

with RaidDevice(...) as raid:
    raid.some_member()

with LuksDevice(...) as luks:
    luks.some_member()

with IntegrityDevice(...) as integrity:
    integrity.some_member()

In addition to the context manager move, the use of them has been refactored into a nested structure of supported device layouts inside the disk builder.

This is related to Issue #2412

@schaefi schaefi requested a review from dcermak February 4, 2024 18:42
@schaefi schaefi self-assigned this Feb 4, 2024
@schaefi schaefi changed the title Move Raid Luks and Integrity context manager Move Raid Luks and Integrity to context manager Feb 4, 2024
Copy link
Collaborator

@dcermak dcermak left a comment

Choose a reason for hiding this comment

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

I think the new code in disk.py could use a bit of simplification

kiwi/builder/disk.py Outdated Show resolved Hide resolved
Change the RaidDevice, LuksDevice and IntegrityDevice classes
to context manager:

with RaidDevice(...) as raid:
    raid.some_member()

with LuksDevice(...) as luks:
    luks.some_member()

with IntegrityDevice(...) as integrity:
    integrity.some_member()

In the context of the disk builder an ExitStack is used to
handle the new context manager based classes

This is related to Issue #2412
Copy link
Collaborator

@dcermak dcermak left a comment

Choose a reason for hiding this comment

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

Looks much better, thanks!

Just added one question about a code addition

kiwi/builder/disk.py Show resolved Hide resolved
@dcermak dcermak merged commit 9cf961e into main Feb 5, 2024
13 checks passed
@dcermak dcermak deleted the nested_build_process branch February 5, 2024 10:46
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.

2 participants