Skip to content

Commit

Permalink
Fix ProposalSettings conversion (#1628)
Browse files Browse the repository at this point in the history
yast/yast-storage-ng#1388 introduced a change in
the API of Y2Storage.

Agama was adapted at #1599, but one particular conversion was left
behind.

This PR fixes that omission.
  • Loading branch information
ancorgs committed Sep 22, 2024
2 parents 4d0d973 + 7ca1d08 commit 861bdbc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,16 @@ def convert
#
# @param target [Agama::Storage::ProposalSettings]
def space_actions_conversion(target)
target.space.actions = y2storage_settings.space_settings.actions
target.space.actions = y2storage_settings.space_settings.actions.map do |action|
[action.device, action_to_symbol(action)]
end.to_h
end

# @see #space_action_conversion
def action_to_symbol(action)
return :resize if action.is?(:resize)

action.mandatory ? :force_delete : :delete
end

# Some values of the volumes have to be recovered from Y2Storage proposal.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@

let(:y2storage_settings) do
Y2Storage::ProposalSettings.new.tap do |settings|
settings.space_settings.actions = {
"/dev/sda" => :force_delete,
"/dev/sdb1" => :resize
}
settings.space_settings.actions = [
Y2Storage::SpaceActions::Delete.new("/dev/sda", mandatory: true),
Y2Storage::SpaceActions::Resize.new("/dev/sdb1"),
Y2Storage::SpaceActions::Delete.new("/dev/sdb2")
]
end
end

Expand All @@ -45,7 +46,7 @@
settings.encryption.method = Y2Storage::EncryptionMethod::LUKS2
settings.encryption.pbkd_function = Y2Storage::PbkdFunction::ARGON2ID
settings.space.policy = :delete
settings.space.actions = []
settings.space.actions = {}
settings.volumes = [Agama::Storage::Volume.new("/test")]
end
end
Expand All @@ -72,7 +73,8 @@

expect(settings.space.actions).to eq(
"/dev/sda" => :force_delete,
"/dev/sdb1" => :resize
"/dev/sdb1" => :resize,
"/dev/sdb2" => :delete
)
end
end
Expand Down

0 comments on commit 861bdbc

Please sign in to comment.