From 07b3a485a8dca87ef729b1db4368a7ee2b26c92b Mon Sep 17 00:00:00 2001 From: Ancor Gonzalez Sosa Date: Sun, 22 Sep 2024 21:31:30 +0200 Subject: [PATCH] Fix ProposalSettings conversion --- .../proposal_settings_conversions/from_y2storage.rb | 11 ++++++++++- .../from_y2storage_test.rb | 10 +++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/service/lib/agama/storage/proposal_settings_conversions/from_y2storage.rb b/service/lib/agama/storage/proposal_settings_conversions/from_y2storage.rb index 4a5f26983f..a9712086e7 100644 --- a/service/lib/agama/storage/proposal_settings_conversions/from_y2storage.rb +++ b/service/lib/agama/storage/proposal_settings_conversions/from_y2storage.rb @@ -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. diff --git a/service/test/agama/storage/proposal_settings_conversions/from_y2storage_test.rb b/service/test/agama/storage/proposal_settings_conversions/from_y2storage_test.rb index cb4b4b4dd0..1f92e6685c 100644 --- a/service/test/agama/storage/proposal_settings_conversions/from_y2storage_test.rb +++ b/service/test/agama/storage/proposal_settings_conversions/from_y2storage_test.rb @@ -30,10 +30,10 @@ 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") + ] end end @@ -45,7 +45,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