vars/keygen: add --no-interactive flags
This is useful to force on-interactive mode with automatic key selection. In unit tests this is necessary. When debugging a test on a real terminal interactive mode is not desired
This commit is contained in:
@@ -37,6 +37,7 @@ class SopsSetup:
|
||||
str(flake_path),
|
||||
"--user",
|
||||
self.user,
|
||||
"--no-interactive",
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
@@ -137,6 +137,13 @@ def create_secrets_user_auto(
|
||||
def _command(
|
||||
args: argparse.Namespace,
|
||||
) -> None:
|
||||
if args.no_interactive:
|
||||
create_secrets_user(
|
||||
flake_dir=args.flake.path,
|
||||
user=args.user,
|
||||
force=args.force,
|
||||
)
|
||||
else:
|
||||
create_secrets_user_auto(
|
||||
flake_dir=args.flake.path,
|
||||
user=args.user,
|
||||
@@ -155,4 +162,10 @@ def register_keygen_parser(parser: argparse.ArgumentParser) -> None:
|
||||
"-f", "--force", help="overwrite existing user", action="store_true"
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--no-interactive",
|
||||
help="Run in non-interactive mode, using keys from the machine if available",
|
||||
action="store_true",
|
||||
)
|
||||
|
||||
parser.set_defaults(func=_command)
|
||||
|
||||
Reference in New Issue
Block a user