-
-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor handling of inventory backend command line flag
This commit switches the inventory backend command line flag to the form `--inventory-backend=<backend name>`. Additionally, we restrict the allowed values for the flag to the known backends. To ensure the allowed values for the command line flag, and the known implementations are in sync, we introduce a dict holding the mapping from flag values to `Inventory` subclasses. Finally, we ensure that the selected backend is cached as a string in `cached.args["inventory-backend"]. Note that this is not how `cached.args` is used otherwise, but since it's unlikely that there ever will be a real command `inventory-backend`, this should be fine.
- Loading branch information
Showing
3 changed files
with
25 additions
and
12 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
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,2 +1,10 @@ | ||
from typing import Type | ||
|
||
from .inv_reclass import ReclassInventory | ||
from .inventory import Inventory | ||
|
||
# Dict mapping values for command line flag `--inventory-backend` to the | ||
# associated `Inventory` subclass. | ||
AVAILABLE_BACKENDS: dict[str, Type[Inventory]] = { | ||
"reclass": ReclassInventory, | ||
} |
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