make host key check an enum instead of an literal type

this is more typesafe at runtime.
This commit is contained in:
Jörg Thalheim
2025-07-02 17:33:32 +02:00
parent 7f4f11751e
commit 543c518ed0
11 changed files with 63 additions and 44 deletions

View File

@@ -12,6 +12,7 @@ from clan_lib.machines.suggestions import validate_machine_names
from clan_lib.ssh.remote import Remote
from clan_cli.completions import add_dynamic_completer, complete_machines
from clan_cli.host_key_check import add_host_key_check_arg
from .types import machine_name_type
@@ -54,12 +55,7 @@ def register_update_hardware_config(parser: argparse.ArgumentParser) -> None:
nargs="?",
help="ssh address to install to in the form of user@host:2222",
)
parser.add_argument(
"--host-key-check",
choices=["strict", "ask", "tofu", "none"],
default="ask",
help="Host key (.ssh/known_hosts) check mode.",
)
add_host_key_check_arg(parser)
parser.add_argument(
"--password",
help="Pre-provided password the cli will prompt otherwise if needed.",

View File

@@ -13,6 +13,7 @@ from clan_cli.completions import (
complete_machines,
complete_target_host,
)
from clan_cli.host_key_check import add_host_key_check_arg
from clan_cli.machines.hardware import HardwareConfig
from clan_cli.ssh.deploy_info import DeployInfo, find_reachable_host, ssh_command_parse
@@ -97,12 +98,7 @@ def register_install_parser(parser: argparse.ArgumentParser) -> None:
help="do not reboot after installation (deprecated)",
default=False,
)
parser.add_argument(
"--host-key-check",
choices=["strict", "ask", "tofu", "none"],
default="ask",
help="Host key (.ssh/known_hosts) check mode.",
)
add_host_key_check_arg(parser)
parser.add_argument(
"--build-on",
choices=[x.value for x in BuildOn],

View File

@@ -16,6 +16,7 @@ from clan_cli.completions import (
complete_machines,
complete_tags,
)
from clan_cli.host_key_check import add_host_key_check_arg
log = logging.getLogger(__name__)
@@ -163,12 +164,7 @@ def register_update_parser(parser: argparse.ArgumentParser) -> None:
)
add_dynamic_completer(tag_parser, complete_tags)
parser.add_argument(
"--host-key-check",
choices=["strict", "ask", "tofu", "none"],
default="ask",
help="Host key (.ssh/known_hosts) check mode.",
)
add_host_key_check_arg(parser)
parser.add_argument(
"--target-host",
type=str,