diff --git a/rust/agama-lib/share/examples/storage.json b/rust/agama-lib/share/examples/storage.json index 67ce91dfc3..aa39914563 100644 --- a/rust/agama-lib/share/examples/storage.json +++ b/rust/agama-lib/share/examples/storage.json @@ -6,9 +6,7 @@ }, "drives": [ { - "search": { - "name": "/dev/vda" - }, + "search": "/dev/vda", "ptableType": "gpt", "partitions": [ { @@ -60,7 +58,12 @@ ] }, { - "search": "/dev/vdb", + "search": { + "condition": { + "name": "/dev/vda" + }, + "ifNotFound": "error" + }, "filesystem": { "type": "ext4", "path": "/var/log" diff --git a/service/lib/agama/storage/config_conversions/search/from_json.rb b/service/lib/agama/storage/config_conversions/search/from_json.rb index f6f2995f7b..a03be629d0 100644 --- a/service/lib/agama/storage/config_conversions/search/from_json.rb +++ b/service/lib/agama/storage/config_conversions/search/from_json.rb @@ -55,7 +55,7 @@ def convert(default = nil) def convert_name return search_json if search_json.is_a?(String) - search_json[:name] + search_json.dig(:condition, :name) end # @return [Symbol, nil] diff --git a/service/test/agama/storage/config_conversions/from_json_test.rb b/service/test/agama/storage/config_conversions/from_json_test.rb index 827dad915c..6f899caeac 100644 --- a/service/test/agama/storage/config_conversions/from_json_test.rb +++ b/service/test/agama/storage/config_conversions/from_json_test.rb @@ -140,7 +140,15 @@ end context "omitting search for a drive" do - let(:config_json) { { drives: [{}] } } + let(:config_json) do + { + drives: [ + { + partitions: [] + } + ] + } + end it "sets the default search" do config = subject.convert @@ -155,7 +163,10 @@ let(:config_json) do { drives: [ - { search: search } + { + search: search, + partitions: [] + } ] } end @@ -175,7 +186,7 @@ context "with a search section" do let(:search) do { - name: "/dev/vda", + condition: { name: "/dev/vda" }, ifNotFound: "skip" } end @@ -268,7 +279,13 @@ { drives: [ { - partitions: [{}] + partitions: [ + { + filesystem: { + path: "/" + } + } + ] } ] } @@ -288,7 +305,12 @@ drives: [ { partitions: [ - { search: search } + { + search: search, + filesystem: { + path: "/" + } + } ] } ] @@ -311,7 +333,7 @@ context "with a search section" do let(:search) do { - name: "/dev/vda1", + condition: { name: "/dev/vda1" }, ifNotFound: "skip" } end