From e99ced2a20715ccb50e0ee3507cc6b6570849cba Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 29 Jul 2024 10:26:07 +0200 Subject: [PATCH] turn ssh arguments into environment variables --- spcd.sh | 10 +++++++--- spcd/__init__.py | 8 ++++---- spcd/cmd.py | 5 ++++- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/spcd.sh b/spcd.sh index 458b709..f2f47d6 100644 --- a/spcd.sh +++ b/spcd.sh @@ -45,9 +45,13 @@ spcd_main() { spcd_list_environment_variables() { spcd_step "List environment variables" for spcd_lev__name in $(printenv | cut -d = -f 1 | sort); do - spcd_lev__text="" - eval "spcd_lev__text=\"\${${spcd_lev__name}}\"" - echo "${spcd_lev__name}=${spcd_lev__text}" + if [ "${spcd_lev__name}" != "SPCD_SSH_KEY" ]; then + spcd_lev__text= + eval "spcd_lev__text=\"\${${spcd_lev__name}}\"" + echo "${spcd_lev__name}=${spcd_lev__text}" + else + echo "${spcd_lev__name}" + fi done } diff --git a/spcd/__init__.py b/spcd/__init__.py index 2403025..aeca5f2 100644 --- a/spcd/__init__.py +++ b/spcd/__init__.py @@ -44,7 +44,6 @@ def install_commands(path: str) -> None: for command in [ "browse-workspace", "build-project", - "clone-branch", "list-environment", "synchronize", ]: @@ -57,17 +56,18 @@ def main(main: str) -> None: name = Path(path).name if name == "__main__.py": clone_project_branch() - set_ssh(*arguments) + set_ssh() install_commands(main) else: function = getattr(cmd, name.replace("-", "_")) function(*arguments) -def set_ssh(*arguments: list[str]) -> None: +def set_ssh() -> None: step("Set SSH") # get variables - ssh_key, ssh_hosts = arguments + ssh_hosts = projects.environment.get("SPCD_SSH_HOSTS") + ssh_key = projects.environment.get("SPCD_SSH_KEY") # set key type ssh_type = "ed25519" # set home directory diff --git a/spcd/cmd.py b/spcd/cmd.py index 052a9f0..1e72336 100644 --- a/spcd/cmd.py +++ b/spcd/cmd.py @@ -25,7 +25,10 @@ def spcd_build_project() -> None: def spcd_list_environment() -> None: for variable, value in sorted(projects.environment.items()): - log.info(f"{variable} = {value}") + if variable != "SPCD_SSH_KEY": + log.info(f"{variable} = {value}") + else: + log.info(f"{variable}") def spcd_synchronize() -> None: