diff --git a/service/lib/agama/autoyast/storage_reader.rb b/service/lib/agama/autoyast/storage_reader.rb index 54168f0b02..96a00e975c 100644 --- a/service/lib/agama/autoyast/storage_reader.rb +++ b/service/lib/agama/autoyast/storage_reader.rb @@ -34,20 +34,12 @@ def initialize(profile) @profile = profile end - # @return [Hash] Agama "storage" section + # @return [Hash] Agama "legacyAutoyastStorage" section def read drives = profile.fetch_as_array("partitioning") - return {} if drives.nil? + return {} if drives.empty? - # TODO: rely on AutoinstProfile classes - devices = drives.each_with_object([]) do |d, all| - next unless d["device"] - - all << d["device"] - end - return {} if devices.empty? - - { "storage" => { "bootDevice" => devices.first } } + { "legacyAutoyastStorage" => drives } end end end diff --git a/service/package/rubygem-agama-yast.changes b/service/package/rubygem-agama-yast.changes index fcfa23100d..06fb06a159 100644 --- a/service/package/rubygem-agama-yast.changes +++ b/service/package/rubygem-agama-yast.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Tue Jun 4 14:16:02 UTC 2024 - José Iván López González + +- Convert AutoYaST partitioning section to JSON + (gh#openSUSE/agama#1285). + ------------------------------------------------------------------- Mon May 27 12:43:49 UTC 2024 - José Iván López González diff --git a/service/test/agama/autoyast/converter_test.rb b/service/test/agama/autoyast/converter_test.rb index a61e940678..44256439c5 100644 --- a/service/test/agama/autoyast/converter_test.rb +++ b/service/test/agama/autoyast/converter_test.rb @@ -131,10 +131,13 @@ end end - context "when a storage device is selected" do - it "exports the device" do + context "when partitioning is defined" do + it "exports the drives information" do subject.to_agama(workdir) - expect(result["storage"]).to include("bootDevice" => "/dev/vda") + expect(result["legacyAutoyastStorage"]).to include({ + "device" => "/dev/vda", + "use" => "all" + }) end end diff --git a/service/test/agama/autoyast/storage_reader_test.rb b/service/test/agama/autoyast/storage_reader_test.rb index fd86698c4c..d8e6ce526e 100644 --- a/service/test/agama/autoyast/storage_reader_test.rb +++ b/service/test/agama/autoyast/storage_reader_test.rb @@ -51,10 +51,17 @@ end end + context "when there are no drives" do + let(:profile) { { "partitioning" => [] } } + + it "returns an empty hash" do + expect(subject.read).to be_empty + end + end + context "when there is a list of drives" do - it "uses the first 'device' key as 'bootDevice'" do - boot_device = subject.read.dig("storage", "bootDevice") - expect(boot_device).to eq("/dev/vda") + it "returns the list as 'legacyAutoyastStorage'" do + expect(subject.read["legacyAutoyastStorage"]).to eq(profile["partitioning"]) end end end