From f81c18a9ba1d081ce06e75396435af914447c823 Mon Sep 17 00:00:00 2001 From: Blake Holifield Date: Tue, 13 Jul 2021 13:36:34 -0500 Subject: [PATCH] add quay user flag to replace manual editing of clowdenv (#76) --- bonfire/bonfire.py | 18 ++++++++++++------ bonfire/processor.py | 5 ++++- .../resources/ephemeral-clowdenvironment.yaml | 7 +++++++ 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/bonfire/bonfire.py b/bonfire/bonfire.py index 1c678a65..a1dfdc40 100755 --- a/bonfire/bonfire.py +++ b/bonfire/bonfire.py @@ -375,6 +375,12 @@ def _validate_resource_arguments(ctx, param, value): help="Target namespace of the ClowdEnvironment (default: none)", type=str, ), + click.option( + "--quay-user", + "-u", + help="Quay username for pullSecret provider", + type=str, + ), click.option( "--clowd-env", "-e", @@ -785,11 +791,11 @@ def _err_handler(): click.echo(ns) -def _process_clowdenv(target_namespace, env_name, template_file): +def _process_clowdenv(target_namespace, quay_user, env_name, template_file): env_name = _get_env_name(target_namespace, env_name) try: - clowd_env_config = process_clowd_env(target_namespace, env_name, template_file) + clowd_env_config = process_clowd_env(target_namespace, quay_user, env_name, template_file) except ValueError as err: _error(str(err)) @@ -798,21 +804,21 @@ def _process_clowdenv(target_namespace, env_name, template_file): @main.command("process-env") @options(_clowdenv_process_options) -def _cmd_process_clowdenv(namespace, clowd_env, template_file): +def _cmd_process_clowdenv(namespace, quay_user, clowd_env, template_file): """Process ClowdEnv template and print output""" - clowd_env_config = _process_clowdenv(namespace, clowd_env, template_file) + clowd_env_config = _process_clowdenv(namespace, quay_user, clowd_env, template_file) print(json.dumps(clowd_env_config, indent=2)) @main.command("deploy-env") @options(_clowdenv_process_options) @options(_timeout_option) -def _cmd_deploy_clowdenv(namespace, clowd_env, template_file, timeout): +def _cmd_deploy_clowdenv(namespace, quay_user, clowd_env, template_file, timeout): """Process ClowdEnv template and deploy to a cluster""" _warn_if_unsafe(namespace) try: - clowd_env_config = _process_clowdenv(namespace, clowd_env, template_file) + clowd_env_config = _process_clowdenv(namespace, quay_user, clowd_env, template_file) log.debug("ClowdEnvironment config:\n%s", clowd_env_config) diff --git a/bonfire/processor.py b/bonfire/processor.py index 4860b255..e0b29d30 100644 --- a/bonfire/processor.py +++ b/bonfire/processor.py @@ -52,7 +52,7 @@ def _set_replicas(items): log.debug("set replicas to '1' on ClowdApp '%s'", i["metadata"]["name"]) -def process_clowd_env(target_ns, env_name, template_path): +def process_clowd_env(target_ns, quay_user, env_name, template_path): log.info("processing ClowdEnvironment") env_template_path = Path(template_path if template_path else conf.DEFAULT_CLOWDENV_TEMPLATE) @@ -65,8 +65,11 @@ def process_clowd_env(target_ns, env_name, template_path): params = dict() params["ENV_NAME"] = env_name + if quay_user: + params["PULL_SECRET_NAME"] = f"{quay_user}-pull-secret" if target_ns: params["NAMESPACE"] = target_ns + params["PULL_SECRET_NAMESPACE"] = target_ns processed_template = process_template(template_data, params=params) diff --git a/bonfire/resources/ephemeral-clowdenvironment.yaml b/bonfire/resources/ephemeral-clowdenvironment.yaml index 405d1db2..c813cbd4 100644 --- a/bonfire/resources/ephemeral-clowdenvironment.yaml +++ b/bonfire/resources/ephemeral-clowdenvironment.yaml @@ -18,6 +18,9 @@ objects: cpu: 30m memory: 128Mi providers: + pullSecrets: + - name: ${PULL_SECRET_NAME} + namespace: ${PULL_SECRET_NAMESPACE} testing: # Level of access the testing pod has in the namespace k8sAccessLevel: edit @@ -70,3 +73,7 @@ parameters: - name: ENV_NAME description: Name of the ClowdEnvironment required: true +- name: PULL_SECRET_NAME + value: quay-cloudservices-pull +- name: PULL_SECRET_NAMESPACE + value: ephemeral-base