-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve search sections that match several devices (#1691)
## Problem The search functionality described at `auto_storage.md` is pretty powerful. But the current implementation only allows to: - search by name - return 0 or 1 devices per search ## Solution This implements several parts of the missing functionality, like: - Ability to match more than one device per `search` section - Limit the number of matches by using `max`. This pull request does not add the ability to use other conditions or matching order beyond `name`. So it's only possible to search either for a device with a given name, either for all the devices sorted by name. The syntax for the latter would be this (a search with no conditions): ``` { "search": {} } ``` For readability, the following alternative syntax is also introduced at this pull request: ``` { "search": "*" } ``` The new default for drive entries (if omitted) becomes: ``` { "search": { "max": 1 } } ``` If several devices match with a given `search` section, the corresponding configuration containing the `search` is replicated as many times as needed. Eg. in a system with two disks, the following config... ``` { "storage": { "drives": [ { "search": "*" } ] } } ``` ...is expanded into: ``` { "storage": { "drives": [ { "search": "*" }, { "search": "*" } ] } } ``` This also makes sure everything keeps working when an `alias` is used together with a `search` that matches several devices (so all the resulting config objects share the same alias). ## Testing - Adapted existing unit tests and added a new ones regarding the `search` functionality - Added a new unit test to check that resolving a config into several ones (potentially with a shared alias) works as expected.
- Loading branch information
Showing
17 changed files
with
576 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,9 +67,7 @@ | |
"deleteIfNeeded": true | ||
}, | ||
{ | ||
"search": { | ||
"ifNotFound": "skip" | ||
}, | ||
"search": "*", | ||
"delete": true | ||
}, | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
------------------------------------------------------------------- | ||
Thu Oct 24 13:07:50 UTC 2024 - Ancor Gonzalez Sosa <[email protected]> | ||
|
||
- Storage: support to match several devices with every 'search' | ||
section (gh#agama-project/agama#1691). | ||
|
||
------------------------------------------------------------------- | ||
Tue Oct 22 09:48:57 UTC 2024 - José Iván López González <[email protected]> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.