Skip to content

Commit

Permalink
add quay user flag to replace manual editing of clowdenv (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
Blake Holifield authored Jul 13, 2021
1 parent 79d591b commit f81c18a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
18 changes: 12 additions & 6 deletions bonfire/bonfire.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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))

Expand All @@ -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)

Expand Down
5 changes: 4 additions & 1 deletion bonfire/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

Expand Down
7 changes: 7 additions & 0 deletions bonfire/resources/ephemeral-clowdenvironment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit f81c18a

Please sign in to comment.