Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
joseivanlopez committed Sep 3, 2024
1 parent 9e690b4 commit 21f27a5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 11 deletions.
11 changes: 7 additions & 4 deletions rust/agama-lib/share/examples/storage.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
},
"drives": [
{
"search": {
"name": "/dev/vda"
},
"search": "/dev/vda",
"ptableType": "gpt",
"partitions": [
{
Expand Down Expand Up @@ -60,7 +58,12 @@
]
},
{
"search": "/dev/vdb",
"search": {
"condition": {
"name": "/dev/vda"
},
"ifNotFound": "error"
},
"filesystem": {
"type": "ext4",
"path": "/var/log"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
34 changes: 28 additions & 6 deletions service/test/agama/storage/config_conversions/from_json_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -155,7 +163,10 @@
let(:config_json) do
{
drives: [
{ search: search }
{
search: search,
partitions: []
}
]
}
end
Expand All @@ -175,7 +186,7 @@
context "with a search section" do
let(:search) do
{
name: "/dev/vda",
condition: { name: "/dev/vda" },
ifNotFound: "skip"
}
end
Expand Down Expand Up @@ -268,7 +279,13 @@
{
drives: [
{
partitions: [{}]
partitions: [
{
filesystem: {
path: "/"
}
}
]
}
]
}
Expand All @@ -288,7 +305,12 @@
drives: [
{
partitions: [
{ search: search }
{
search: search,
filesystem: {
path: "/"
}
}
]
}
]
Expand All @@ -311,7 +333,7 @@
context "with a search section" do
let(:search) do
{
name: "/dev/vda1",
condition: { name: "/dev/vda1" },
ifNotFound: "skip"
}
end
Expand Down

0 comments on commit 21f27a5

Please sign in to comment.