Skip to content

Commit

Permalink
storage: improvements in JSON conversions (agama-project#1713)
Browse files Browse the repository at this point in the history
Improvements in JSON conversions for storage config:

* Do not fail when setting config
agama-project#1706.
* Do not generate search wildcard. The *search* JSON is always generated
in its expanded form.
  • Loading branch information
joseivanlopez authored Oct 30, 2024
2 parents aa2bb2c + f2052af commit b0d9d1b
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 20 deletions.
3 changes: 0 additions & 3 deletions service/lib/agama/storage/config_conversions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ module Agama
module Storage
# Conversions for the storage config.
module ConfigConversions
# Reserved string for Configs::Search meaning 'match all devices if there is any'
SEARCH_ANYTHING_STRING = "*"
private_constant :SEARCH_ANYTHING_STRING
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ def convert

private

# Reserved search value meaning 'match all devices or ignore the section'.
#
# { search: "*" } is a shortcut for { search: { ifNotFound: "skip" } }.
SEARCH_ANYTHING_STRING = "*"
private_constant :SEARCH_ANYTHING_STRING

alias_method :search_json, :config_json

# @see Base#conversions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@ def self.config_type
Configs::Search
end

# @see Base#convert
def convert
return SEARCH_ANYTHING_STRING if config.all_if_any?

super
end

private

# @see Base#conversions
Expand Down
7 changes: 0 additions & 7 deletions service/lib/agama/storage/configs/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,6 @@ def always_match?
name.nil?
end

# Whether the search matches all the available devices, skipping if none is found
#
# @return [Boolean]
def all_if_any?
always_match? && max.nil? && if_not_found == :skip
end

# Whether the section containing the search should be skipped
#
# @return [Boolean]
Expand Down
10 changes: 9 additions & 1 deletion service/package/rubygem-agama-yast.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
-------------------------------------------------------------------
Wed Oct 30 11:33:54 UTC 2024 - José Iván López González <[email protected]>

- Storage: do not generate config json with search wildcard
(gh#agama-project/agama#1713).
- Storage: fix issue when setting config
(gh#agama-project/agama#1706).

-------------------------------------------------------------------
Thu Oct 24 14:44:35 UTC 2024 - Ancor Gonzalez Sosa <[email protected]>

Expand All @@ -21,7 +29,7 @@ Wed Oct 16 15:09:31 UTC 2024 - Imobach Gonzalez Sosa <[email protected]>

- Add support for running user-defined scripts after the
installation (gh#agama-project/agama#1673).

-------------------------------------------------------------------
Wed Oct 16 14:35:47 UTC 2024 - José Iván López González <[email protected]>

Expand Down
8 changes: 6 additions & 2 deletions service/test/agama/storage/config_conversions/to_json_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,15 @@
context "if there are no conditions or limits and errors should be skipped" do
let(:search) { { ifNotFound: "skip" } }

it "generates a wildcard" do
it "generates the expected JSON" do
config_json = result_scope.call(subject.convert)
search_json = config_json[:search]

expect(search_json).to eq "*"
expect(search_json).to eq(
{
ifNotFound: "skip"
}
)
end
end
end
Expand Down

0 comments on commit b0d9d1b

Please sign in to comment.