clan-cli/secrets: suggest clan vars keygen instead
This commit is contained in:
@@ -27,7 +27,7 @@ from .sops import (
|
||||
read_keys,
|
||||
update_keys,
|
||||
)
|
||||
from .types import VALID_SECRET_NAME, VALID_USER_NAME, secret_name_type
|
||||
from .types import VALID_SECRET_NAME, secret_name_type
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@@ -158,32 +158,10 @@ def encrypt_secret(
|
||||
admin_keys = sops.ensure_admin_public_keys(flake_dir)
|
||||
|
||||
if not admin_keys:
|
||||
users = list_objects(
|
||||
sops_users_folder(flake_dir),
|
||||
is_valid=lambda name: VALID_USER_NAME.match(name) is not None,
|
||||
)
|
||||
msg = (
|
||||
"No admin keys found.\n\n"
|
||||
"Please run 'clan secrets key generate' to create a key. "
|
||||
"Please run 'clan vars keygen' to generate and set up keys."
|
||||
)
|
||||
if (count := len(users)) > 1:
|
||||
msg += (
|
||||
f"Then run 'clan secrets users add-key' "
|
||||
f"to add the key to an user you already have "
|
||||
f"({', '.join(users)}), or use 'clan secrets users add' "
|
||||
f"to create a new user with the new key."
|
||||
)
|
||||
elif count == 1:
|
||||
msg += (
|
||||
f"Then run 'clan secrets users add-key {users[0]}' "
|
||||
f"to add the key to the user you already have, or use "
|
||||
f"'clan secrets users add' to create a new user "
|
||||
f"with the new key."
|
||||
)
|
||||
else:
|
||||
msg += (
|
||||
"Then run 'clan secrets users add' to associate the key with an user."
|
||||
)
|
||||
raise ClanError(msg)
|
||||
|
||||
username = next(iter(admin_keys)).username
|
||||
|
||||
Reference in New Issue
Block a user