agama-project / agama

A service-based Linux installer
https://agama-project.github.io/
GNU General Public License v2.0
143 stars 43 forks source link

Resolve search sections that match several devices #1691

Closed ancorgs closed 4 weeks ago

ancorgs commented 1 month ago

Problem

The search functionality described at auto_storage.md is pretty powerful. But the current implementation only allows to:

Solution

This implements several parts of the missing functionality, like:

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

coveralls commented 1 month ago

Pull Request Test Coverage Report for Build 11480395585

Details


Totals Coverage Status
Change from base Build 11460749266: 0.05%
Covered Lines: 16927
Relevant Lines: 23692

💛 - Coveralls
ancorgs commented 4 weeks ago

@joseivanlopez I updated the PR (using force push, sorry) to address all concerns. Please re-review