From c3e84d1256a7f33633911033ba95c260f4849151 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Thu, 27 Jan 2022 23:36:50 +0100 Subject: [PATCH] Add env vars in build settings + alt install method --- src/runboat/k8s.py | 6 +++--- src/runboat/kubefiles/runboat-clone-and-install.sh | 10 +++++++++- src/runboat/settings.py | 10 +++++++--- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/runboat/k8s.py b/src/runboat/k8s.py index c3e9030..0b1015c 100644 --- a/src/runboat/k8s.py +++ b/src/runboat/k8s.py @@ -171,9 +171,9 @@ def make_deployment_vars( commit_info=commit_info, image_name=image_name, image_tag=image_tag, - build_env=settings.build_env or {}, - build_secret_env=settings.build_secret_env or {}, - build_template_vars=settings.build_template_vars or {}, + build_env=settings.build_env | build_settings.env, + build_secret_env=settings.build_secret_env | build_settings.secret_env, + build_template_vars=settings.build_template_vars | build_settings.template_vars, ) diff --git a/src/runboat/kubefiles/runboat-clone-and-install.sh b/src/runboat/kubefiles/runboat-clone-and-install.sh index d666548..2f8d21e 100755 --- a/src/runboat/kubefiles/runboat-clone-and-install.sh +++ b/src/runboat/kubefiles/runboat-clone-and-install.sh @@ -15,7 +15,15 @@ git fetch origin $RUNBOAT_GIT_REF:build git checkout build # Install. -oca_install_addons +INSTALL_METHOD=${INSTALL_METHOD:-oca_install_addons} +if [[ "${INSTALL_METHOD}" == "oca_install_addons" ]] ; then + oca_install_addons +elif [[ "${INSTALL_METHOD}" == "editable_pip_install" ]] ; then + pip install -e . +else + echo "Unsupported INSTALL_METHOD: '${INSTALL_METHOD}'" + exit 1 +fi # Keep a copy of the venv that we can re-use for shorter startup time. DEBIAN_FRONTEND=noninteractive apt-get -yqq install rsync diff --git a/src/runboat/settings.py b/src/runboat/settings.py index 6d2a356..c535240 100644 --- a/src/runboat/settings.py +++ b/src/runboat/settings.py @@ -7,6 +7,10 @@ from .exceptions import RepoOrBranchNotSupported class BuildSettings(BaseModel): image: str # container image:tag + # These extend the respective global settings. + env: dict[str, str] = {} + secret_env: dict[str, str] = {} + template_vars: dict[str, str] = {} class RepoSettings(BaseModel): @@ -40,13 +44,13 @@ class Settings(BaseSettings): # The wildcard domain where the builds will be reacheable. build_domain: str # A dictionary of environment variables to set in the build container and jobs. - build_env: dict[str, str] | None + build_env: dict[str, str] = {} # A dictionary of secret environment variables to set in the build container and # jobs. - build_secret_env: dict[str, str] | None + build_secret_env: dict[str, str] = {} # A dictionary of variables to be set in the jinja rendering context for the # kubefiles. - build_template_vars: dict[str, str] | None + build_template_vars: dict[str, str] = {} # The token to use for the GitHub api calls (to query branches and pull requests, # and report build statuses). github_token: str | None