clan-cli: secrets machines remove: update secrets after removing the key
Quick follow up to PR #2781, this commit does the same kind of logic but for machines instead of users and groups. Note that this only affects the `clan secrets machines remove` sub-command, and that `clan machines delete` still leaves unusable secrets & vars behind. This can be addressed in a different change.
This commit is contained in:
@@ -246,18 +246,18 @@ def add_secret(flake_dir: Path, group: str, name: str) -> None:
|
||||
)
|
||||
|
||||
|
||||
def get_groups(
|
||||
flake_dir: Path,
|
||||
type_name: str,
|
||||
name: str,
|
||||
) -> list[Path]:
|
||||
def get_groups(flake_dir: Path, what: str, name: str) -> list[str]:
|
||||
"""Returns the list of group names the given user or machine is part of."""
|
||||
assert what == "users" or what == "machines"
|
||||
|
||||
groups_dir = sops_groups_folder(flake_dir)
|
||||
if not groups_dir.exists():
|
||||
return []
|
||||
|
||||
groups = []
|
||||
if groups_dir.exists():
|
||||
for group in groups_dir.iterdir():
|
||||
if group.is_dir() and (group / type_name / name).exists():
|
||||
groups.append(group)
|
||||
for group in groups_dir.iterdir():
|
||||
if group.is_dir() and (group / what / name).is_symlink():
|
||||
groups.append(group.name)
|
||||
return groups
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user