Skip to content
This repository has been archived by the owner on Jan 24, 2025. It is now read-only.

Commit

Permalink
Dynamically add agents
Browse files Browse the repository at this point in the history
  • Loading branch information
Akm0d committed Aug 27, 2024
1 parent fd73160 commit aebf6ac
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/soluble/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@
"ssh_target": {
"positional": True,
"display_priority": 0,
# TODO only for subcommands, not for the main command
"subcommands": ["minion"],
"subcommands": [],
"help": "Target for the salt-ssh command. This is typically a minion ID, wildcard, or grain.",
},
"salt_config_dir": {},
Expand Down
10 changes: 10 additions & 0 deletions src/soluble/soluble/init.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from soluble.conf import CLI_CONFIG
from soluble.conf import SUBCOMMANDS


def __init__(hub):
Expand Down Expand Up @@ -29,6 +30,15 @@ def cli(hub):
"""
Parse the config data and pass it to the actual runtime
"""
soluble_plugins = list(hub.soluble._loaded.keys() - {"init"})

# Dynamically add ssh_target to every subcommand
CLI_CONFIG["ssh_target"]["subcommands"] = soluble_plugins

# Dynamically create a subcommand for every soluble plugin
for plugin in soluble_plugins:
SUBCOMMANDS[plugin] = {"help": f"Create an ephemeral {plugin}"}

hub.pop.config.load(["soluble"], cli="soluble")
kwargs = dict(hub.OPT.soluble)
salt_ssh_opts = []
Expand Down
3 changes: 0 additions & 3 deletions src/soluble_minion/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,4 @@
},
}


SUBCOMMANDS = {"minion": {"help": "Create an ephemeral minion", "dyne": "soluble"}}

DYNE = {"soluble": ["soluble"]}

0 comments on commit aebf6ac

Please sign in to comment.