Skip to content

Commit

Permalink
Add support for setting custom ENV variables in scenarios
Browse files Browse the repository at this point in the history
[noissue]
  • Loading branch information
lubosmj committed Sep 22, 2023
1 parent 1ee39ae commit 4bfc3e1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,16 @@ The following settings are stored in `template_config.yml`.

pulp_settings_<scenario>
A dictionary of settings that the plugin <scenario> tests can set
additionally. `<scenario>` is one of "azure", "s3", "stream".
additionally. `<scenario>` is one of "azure", "s3", "gcp".

pulp_env A dictionary of ENV variables used globally by all runners. The variables
are translated to separate ENV layers in Containerfile configuring the base
Pulp image.

pulp_env_<scenario>
A dictionary of ENV variables that will be translated to separate ENV
layers in Containerfile configuring the base Pulp image. `<scenario>` is one
of "azure", "s3", "gcp".

pydocstyle Boolean, whether to have flake8 use pydocstyle to check for compliance with
Python docstring conventions.
Expand Down
5 changes: 4 additions & 1 deletion plugin-template
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,15 @@ DEFAULT_SETTINGS = {
"pre_job_template": None,
"publish_docs_to_pulpprojectdotorg": False,
"pulpprojectdotorg_key_id": None,
"pulp_env": {},
"pulp_env_azure": {},
"pulp_env_gcp": {},
"pulp_env_s3": {},
"pulp_scheme": "https",
"pulp_settings_azure": None,
"pulp_settings_gcp": None,
"pulp_settings": None,
"pulp_settings_s3": None,
"pulp_settings_stream": None,
"pydocstyle": True,
"pypi_username": None,
"python_version": "3.8",
Expand Down
12 changes: 12 additions & 0 deletions templates/github/.ci/ansible/Containerfile.j2.copy
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ RUN pip3 install
{%- endif -%}
{%- endfor %}

{% if pulp_env is defined and pulp_env %}
{% for key, value in pulp_env.items() %}
ENV {{ key | upper }}={{ value }}
{% endfor %}
{% endif %}

{% if pulp_scenario_env is defined and pulp_scenario_env %}
{% for key, value in pulp_scenario_env.items() %}
ENV {{ key | upper }}={{ value }}
{% endfor %}
{% endif %}

USER pulp:pulp
RUN PULP_STATIC_ROOT=/var/lib/operator/static/ PULP_CONTENT_ORIGIN=localhost \
/usr/local/bin/pulpcore-manager collectstatic --clear --noinput --link
Expand Down
4 changes: 4 additions & 0 deletions templates/github/.github/workflows/scripts/install.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ services:
VARSYAML

cat >> vars/main.yaml << VARSYAML
pulp_env: {{ pulp_env | tojson }}
pulp_settings: {{ pulp_settings | tojson }}
pulp_scheme: {{ pulp_scheme }}
{% if python_version == "3.6" %}
Expand Down Expand Up @@ -108,6 +109,7 @@ if [ "$TEST" = "s3" ]; then
minio_access_key: "'$MINIO_ACCESS_KEY'"\
minio_secret_key: "'$MINIO_SECRET_KEY'"\
pulp_scenario_settings: {{ pulp_settings_s3 | tojson }}\
pulp_scenario_env: {{ pulp_env_s3 | tojson }}\
' vars/main.yaml

{%- if test_reroute %}
Expand All @@ -133,6 +135,7 @@ if [ "$TEST" = "azure" ]; then
command: "azurite-blob --blobHost 0.0.0.0{% if pulp_scheme == "https" %} --cert /etc/pulp/azcert.pem --key /etc/pulp/azkey.pem{% endif %}"' vars/main.yaml
sed -i -e '$a azure_test: true\
pulp_scenario_settings: {{ pulp_settings_azure | tojson }}\
pulp_scenario_env: {{ pulp_env_azure | tojson }}\
' vars/main.yaml
fi
{%- endif %}
Expand All @@ -154,6 +157,7 @@ if [ "$TEST" = "gcp" ]; then
command: "{% if pulp_scheme == "https" %} -cert-location /etc/pulp/gcpcert.pem {% else %} -scheme http{% endif %}"' vars/main.yaml
sed -i -e '$a gcp_test: true\
pulp_scenario_settings: {{ pulp_settings_gcp | tojson }}\
pulp_scenario_env: {{ pulp_env_gcp | tojson }}\
' vars/main.yaml
fi
{%- endif %}
Expand Down

0 comments on commit 4bfc3e1

Please sign in to comment.