clan-cli: machines delete: delete the machine's vars and secrets

When a machine is deleted with `clan machines delete`, remove its
vars and legacy secrets, and update any secrets that reference the
machine's key.

This command is a superset of `clan secrets machine delete`, and I am
wondering if we could remove the `clan secrets machine` subcommand,
unless there is an use case for having a machine defined without its
key, and any secrets/vars?

Note:

- This deletes the `ListSecretsOptions` dataclass, as it did not seem to
  bring any value, especially since `list_secrets` was receiving its
  individual members instead of the whole dataclass. We can always bring
  it back if complexity grows to demand it.
This commit is contained in:
Louis Opter
2025-02-07 11:31:38 +00:00
committed by Mic92
parent f7bec766bc
commit cd248b69db
3 changed files with 45 additions and 25 deletions

View File

@@ -208,16 +208,11 @@ def complete_secrets(
Provides completion functionality for clan secrets
"""
from .clan_uri import Flake
from .secrets.secrets import ListSecretsOptions, list_secrets
from .secrets.secrets import list_secrets
flake = clan_dir_result if (clan_dir_result := clan_dir(None)) is not None else "."
options = ListSecretsOptions(
flake=Flake(flake),
pattern=None,
)
secrets = list_secrets(options.flake.path, options.pattern)
secrets = list_secrets(Flake(flake).path)
secrets_dict = dict.fromkeys(secrets, "secret")
return secrets_dict