secrets: commit when renaming secrets
This commit is contained in:
parent
7208d63e78
commit
65d2a4e081
@ -272,13 +272,19 @@ def set_command(args: argparse.Namespace) -> None:
|
|||||||
|
|
||||||
|
|
||||||
def rename_command(args: argparse.Namespace) -> None:
|
def rename_command(args: argparse.Namespace) -> None:
|
||||||
old_path = sops_secrets_folder(Path(args.flake)) / args.secret
|
flake_dir = Path(args.flake)
|
||||||
new_path = sops_secrets_folder(Path(args.flake)) / args.new_name
|
old_path = sops_secrets_folder(flake_dir) / args.secret
|
||||||
|
new_path = sops_secrets_folder(flake_dir) / args.new_name
|
||||||
if not old_path.exists():
|
if not old_path.exists():
|
||||||
raise ClanError(f"Secret '{args.secret}' does not exist")
|
raise ClanError(f"Secret '{args.secret}' does not exist")
|
||||||
if new_path.exists():
|
if new_path.exists():
|
||||||
raise ClanError(f"Secret '{args.new_name}' already exists")
|
raise ClanError(f"Secret '{args.new_name}' already exists")
|
||||||
os.rename(old_path, new_path)
|
os.rename(old_path, new_path)
|
||||||
|
commit_files(
|
||||||
|
[old_path, new_path],
|
||||||
|
flake_dir,
|
||||||
|
f"Rename secret {args.secret} to {args.new_name}",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def register_secrets_parser(subparser: argparse._SubParsersAction) -> None:
|
def register_secrets_parser(subparser: argparse._SubParsersAction) -> None:
|
||||||
|
Loading…
Reference in New Issue
Block a user