Merge pull request 'Add nixos module to import secrets automatically' (#154) from Mic92-mic92 into main

This commit is contained in:
clan-bot
2023-08-23 12:04:20 +00:00
21 changed files with 230 additions and 42 deletions

View File

@@ -1,15 +1,17 @@
import argparse
import sys
from types import ModuleType
from typing import Optional
from . import admin, config, secrets, update
from .errors import ClanError
from .ssh import cli as ssh_cli
has_argcomplete = True
argcomplete: Optional[ModuleType] = None
try:
import argcomplete
import argcomplete # type: ignore[no-redef]
except ImportError:
has_argcomplete = False
pass
# this will be the entrypoint under /bin/clan (see pyproject.toml config)
@@ -34,7 +36,7 @@ def main() -> None:
)
update.register_parser(parser_update)
if has_argcomplete:
if argcomplete:
argcomplete.autocomplete(parser)
if len(sys.argv) == 1:

View File

@@ -43,7 +43,7 @@ def get_user_name(user: str) -> str:
"""Ask the user for their name until a unique one is provided."""
while True:
name = input(
f"Enter your user name for which your sops key will be stored in the repository [default: {user}]: "
f"Your key is not yet added to the repository. Enter your user name for which your sops key will be stored in the repository [default: {user}]: "
)
if name:
user = name

View File

@@ -3,7 +3,6 @@
, black
, bubblewrap
, installShellFiles
, mypy
, nix
, openssh
, pytest
@@ -31,7 +30,6 @@ let
pytest
pytest-cov
pytest-subprocess
mypy
openssh
stdenv.cc
];
@@ -60,27 +58,17 @@ python3.pkgs.buildPythonPackage {
];
propagatedBuildInputs = dependencies;
passthru.tests = {
clan-mypy = runCommand "clan-mypy" { } ''
export CLAN_OPTIONS_FILE="${CLAN_OPTIONS_FILE}"
cp -r ${source} ./src
chmod +w -R ./src
cd ./src
${checkPython}/bin/mypy .
touch $out
'';
clan-pytest = runCommand "clan-tests"
{
nativeBuildInputs = [ age zerotierone bubblewrap sops nix openssh rsync stdenv.cc ];
} ''
export CLAN_OPTIONS_FILE="${CLAN_OPTIONS_FILE}"
cp -r ${source} ./src
chmod +w -R ./src
cd ./src
NIX_STATE_DIR=$TMPDIR/nix ${checkPython}/bin/python -m pytest -s ./tests
touch $out
'';
};
passthru.tests.clan-pytest = runCommand "clan-tests"
{
nativeBuildInputs = [ age zerotierone bubblewrap sops nix openssh rsync stdenv.cc ];
} ''
export CLAN_OPTIONS_FILE="${CLAN_OPTIONS_FILE}"
cp -r ${source} ./src
chmod +w -R ./src
cd ./src
NIX_STATE_DIR=$TMPDIR/nix ${checkPython}/bin/python -m pytest -s ./tests
touch $out
'';
passthru.devDependencies = [
ruff
@@ -89,6 +77,8 @@ python3.pkgs.buildPythonPackage {
wheel
] ++ testDependencies;
passthru.testDependencies = testDependencies;
makeWrapperArgs = [
"--set CLAN_FLAKE ${self}"
];