Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions service/lib/agama/autoyast/storage_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions service/package/rubygem-agama-yast.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Tue Jun 4 14:16:02 UTC 2024 - José Iván López González <jlopez@suse.com>

- 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 <jlopez@suse.com>

Expand Down
9 changes: 6 additions & 3 deletions service/test/agama/autoyast/converter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 10 additions & 3 deletions service/test/agama/autoyast/storage_reader_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down