Vars: rename 'keygen' to 'create_secrets_user'

This commit is contained in:
Johannes Kirschbauer
2025-07-06 19:58:04 +02:00
parent 2b3e847c28
commit a2c2d73e49
4 changed files with 13 additions and 6 deletions

View File

@@ -66,7 +66,7 @@ export const CreateClan = () => {
} }
// Will generate a key if it doesn't exist, and add a user to the clan // Will generate a key if it doesn't exist, and add a user to the clan
const k = await callApi("keygen", { const k = await callApi("create_secrets_user", {
flake_dir: target_dir[0], flake_dir: target_dir[0],
}).promise; }).promise;

View File

@@ -65,7 +65,7 @@ export const CreateClan = () => {
} }
// Will generate a key if it doesn't exist, and add a user to the clan // Will generate a key if it doesn't exist, and add a user to the clan
const k = await callApi("keygen", { const k = await callApi("create_secrets_user", {
flake_dir: target_dir[0], flake_dir: target_dir[0],
}).promise; }).promise;

View File

@@ -900,7 +900,9 @@ def test_fails_when_files_are_left_from_other_backend(
@pytest.mark.with_core @pytest.mark.with_core
def test_keygen(monkeypatch: pytest.MonkeyPatch, flake: ClanFlake) -> None: def test_create_sops_age_secrets(
monkeypatch: pytest.MonkeyPatch, flake: ClanFlake
) -> None:
monkeypatch.chdir(flake.path) monkeypatch.chdir(flake.path)
cli.run(["vars", "keygen", "--flake", str(flake.path), "--user", "user"]) cli.run(["vars", "keygen", "--flake", str(flake.path), "--user", "user"])
# check public key exists # check public key exists

View File

@@ -13,11 +13,16 @@ log = logging.getLogger(__name__)
@API.register @API.register
def keygen(flake_dir: Path, user: str | None = None, force: bool = False) -> None: def create_secrets_user(
flake_dir: Path, user: str | None = None, force: bool = False
) -> None:
"""
initialize sops keys for vars
"""
if user is None: if user is None:
user = os.getenv("USER", None) user = os.getenv("USER", None)
if not user: if not user:
msg = "No user provided and $USER is not set. Please provide a user via --user." msg = "No user provided and environment variable: '$USER' is not set. Please provide an explizit username via argument"
raise ClanError(msg) raise ClanError(msg)
pub_keys = maybe_get_admin_public_keys() pub_keys = maybe_get_admin_public_keys()
if not pub_keys: if not pub_keys:
@@ -34,7 +39,7 @@ def keygen(flake_dir: Path, user: str | None = None, force: bool = False) -> Non
def _command( def _command(
args: argparse.Namespace, args: argparse.Namespace,
) -> None: ) -> None:
keygen( create_secrets_user(
flake_dir=args.flake.path, flake_dir=args.flake.path,
user=args.user, user=args.user,
force=args.force, force=args.force,