move FlakeId to flake id

move FlakeId to flake id
This commit is contained in:
Jörg Thalheim
2024-07-03 13:03:40 +02:00
parent 0c12157c61
commit 5b606c035f
30 changed files with 91 additions and 93 deletions

View File

@@ -74,7 +74,7 @@ def list_groups(flake_dir: Path) -> list[Group]:
def list_command(args: argparse.Namespace) -> None:
for group in list_groups(Path(args.flake)):
for group in list_groups(args.flake.path):
print(group.name)
if group.machines:
print("machines:")
@@ -158,7 +158,7 @@ def add_user(flake_dir: Path, group: str, name: str) -> None:
def add_user_command(args: argparse.Namespace) -> None:
add_user(Path(args.flake), args.group, args.user)
add_user(args.flake.path, args.group, args.user)
def remove_user(flake_dir: Path, group: str, name: str) -> None:
@@ -166,7 +166,7 @@ def remove_user(flake_dir: Path, group: str, name: str) -> None:
def remove_user_command(args: argparse.Namespace) -> None:
remove_user(Path(args.flake), args.group, args.user)
remove_user(args.flake.path, args.group, args.user)
def add_machine(flake_dir: Path, group: str, name: str) -> None:
@@ -184,7 +184,7 @@ def add_machine(flake_dir: Path, group: str, name: str) -> None:
def add_machine_command(args: argparse.Namespace) -> None:
add_machine(Path(args.flake), args.group, args.machine)
add_machine(args.flake.path, args.group, args.machine)
def remove_machine(flake_dir: Path, group: str, name: str) -> None:
@@ -192,7 +192,7 @@ def remove_machine(flake_dir: Path, group: str, name: str) -> None:
def remove_machine_command(args: argparse.Namespace) -> None:
remove_machine(Path(args.flake), args.group, args.machine)
remove_machine(args.flake.path, args.group, args.machine)
def add_group_argument(parser: argparse.ArgumentParser) -> None:
@@ -209,7 +209,7 @@ def add_secret(flake_dir: Path, group: str, name: str) -> None:
def add_secret_command(args: argparse.Namespace) -> None:
add_secret(Path(args.flake), args.group, args.secret)
add_secret(args.flake.path, args.group, args.secret)
def remove_secret(flake_dir: Path, group: str, name: str) -> None:
@@ -224,7 +224,7 @@ def remove_secret(flake_dir: Path, group: str, name: str) -> None:
def remove_secret_command(args: argparse.Namespace) -> None:
remove_secret(Path(args.flake), args.group, args.secret)
remove_secret(args.flake.path, args.group, args.secret)
def register_groups_parser(parser: argparse.ArgumentParser) -> None:

View File

@@ -40,15 +40,15 @@ def import_sops(args: argparse.Namespace) -> None:
file=sys.stderr,
)
continue
if (sops_secrets_folder(Path(args.flake)) / k / "secret").exists():
if (sops_secrets_folder(args.flake.path) / k / "secret").exists():
print(
f"WARNING: {k} already exists, skipping",
file=sys.stderr,
)
continue
encrypt_secret(
Path(args.flake),
sops_secrets_folder(Path(args.flake)) / k,
args.flake.path,
sops_secrets_folder(args.flake.path) / k,
v,
add_groups=args.group,
add_machines=args.machine,

View File

@@ -58,7 +58,7 @@ def show_command(args: argparse.Namespace) -> None:
def update_command(args: argparse.Namespace) -> None:
flake_dir = Path(args.flake)
flake_dir = args.flake.path
commit_files(update_secrets(flake_dir), flake_dir, "Updated secrets with new keys.")

View File

@@ -81,7 +81,7 @@ def remove_secret(flake_dir: Path, machine: str, secret: str) -> None:
def list_command(args: argparse.Namespace) -> None:
if args.flake is None:
raise ClanError("Could not find clan flake toplevel directory")
lst = list_machines(Path(args.flake))
lst = list_machines(args.flake.path)
if len(lst) > 0:
print("\n".join(lst))
@@ -89,31 +89,31 @@ def list_command(args: argparse.Namespace) -> None:
def add_command(args: argparse.Namespace) -> None:
if args.flake is None:
raise ClanError("Could not find clan flake toplevel directory")
add_machine(Path(args.flake), args.machine, args.key, args.force)
add_machine(args.flake.path, args.machine, args.key, args.force)
def get_command(args: argparse.Namespace) -> None:
if args.flake is None:
raise ClanError("Could not find clan flake toplevel directory")
print(get_machine(Path(args.flake), args.machine))
print(get_machine(args.flake.path, args.machine))
def remove_command(args: argparse.Namespace) -> None:
if args.flake is None:
raise ClanError("Could not find clan flake toplevel directory")
remove_machine(Path(args.flake), args.machine)
remove_machine(args.flake.path, args.machine)
def add_secret_command(args: argparse.Namespace) -> None:
if args.flake is None:
raise ClanError("Could not find clan flake toplevel directory")
add_secret(Path(args.flake), args.machine, args.secret)
add_secret(args.flake.path, args.machine, args.secret)
def remove_secret_command(args: argparse.Namespace) -> None:
if args.flake is None:
raise ClanError("Could not find clan flake toplevel directory")
remove_secret(Path(args.flake), args.machine, args.secret)
remove_secret(args.flake.path, args.machine, args.secret)
def register_machines_parser(parser: argparse.ArgumentParser) -> None:

View File

@@ -158,7 +158,7 @@ def remove_secret(flake_dir: Path, secret: str) -> None:
def remove_command(args: argparse.Namespace) -> None:
remove_secret(Path(args.flake), args.secret)
remove_secret(args.flake.path, args.secret)
def add_secret_argument(parser: argparse.ArgumentParser, autocomplete: bool) -> None:
@@ -270,7 +270,7 @@ class ListSecretsOptions:
def list_command(args: argparse.Namespace) -> None:
options = ListSecretsOptions(
flake=FlakeId(args.flake),
flake=args.flake,
pattern=args.pattern,
)
lst = list_secrets(options.flake.path, options.pattern)
@@ -287,7 +287,7 @@ def decrypt_secret(flake_dir: Path, secret: str) -> str:
def get_command(args: argparse.Namespace) -> None:
print(decrypt_secret(Path(args.flake), args.secret), end="")
print(decrypt_secret(args.flake.path, args.secret), end="")
def set_command(args: argparse.Namespace) -> None:
@@ -300,8 +300,8 @@ def set_command(args: argparse.Namespace) -> None:
elif tty.is_interactive():
secret_value = getpass.getpass(prompt="Paste your secret: ")
encrypt_secret(
Path(args.flake),
sops_secrets_folder(Path(args.flake)) / args.secret,
args.flake.path,
sops_secrets_folder(args.flake.path) / args.secret,
secret_value,
args.user,
args.machine,
@@ -310,7 +310,7 @@ def set_command(args: argparse.Namespace) -> None:
def rename_command(args: argparse.Namespace) -> None:
flake_dir = Path(args.flake)
flake_dir = args.flake.path
old_path = sops_secrets_folder(flake_dir) / args.secret
new_path = sops_secrets_folder(flake_dir) / args.new_name
if not old_path.exists():

View File

@@ -86,7 +86,7 @@ def remove_secret(flake_dir: Path, user: str, secret: str) -> None:
def list_command(args: argparse.Namespace) -> None:
if args.flake is None:
raise ClanError("Could not find clan flake toplevel directory")
lst = list_users(Path(args.flake))
lst = list_users(args.flake.path)
if len(lst) > 0:
print("\n".join(lst))
@@ -94,31 +94,31 @@ def list_command(args: argparse.Namespace) -> None:
def add_command(args: argparse.Namespace) -> None:
if args.flake is None:
raise ClanError("Could not find clan flake toplevel directory")
add_user(Path(args.flake), args.user, args.key, args.force)
add_user(args.flake.path, args.user, args.key, args.force)
def get_command(args: argparse.Namespace) -> None:
if args.flake is None:
raise ClanError("Could not find clan flake toplevel directory")
print(get_user(Path(args.flake), args.user))
print(get_user(args.flake.path, args.user))
def remove_command(args: argparse.Namespace) -> None:
if args.flake is None:
raise ClanError("Could not find clan flake toplevel directory")
remove_user(Path(args.flake), args.user)
remove_user(args.flake.path, args.user)
def add_secret_command(args: argparse.Namespace) -> None:
if args.flake is None:
raise ClanError("Could not find clan flake toplevel directory")
add_secret(Path(args.flake), args.user, args.secret)
add_secret(args.flake.path, args.user, args.secret)
def remove_secret_command(args: argparse.Namespace) -> None:
if args.flake is None:
raise ClanError("Could not find clan flake toplevel directory")
remove_secret(Path(args.flake), args.user, args.secret)
remove_secret(args.flake.path, args.user, args.secret)
def register_users_parser(parser: argparse.ArgumentParser) -> None: