Skip to content

Commit 57cad48

Browse files
authored
Use proxy for external preprod environments (#194)
* using proxy to access Pyxis * proxy only for external pyxis * black format * added the documentation url
1 parent 9753ef6 commit 57cad48

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

ansible/roles/operator-pipeline/templates/openshift/pipelines/operator-ci-pipeline.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,8 @@ spec:
451451
value: "$(tasks.set-env.results.pyxis_url)"
452452
- name: pipeline_name
453453
value: "$(context.pipelineRun.name)"
454+
- name: env
455+
value: $(params.env)
454456

455457
- name: show-support-link
456458
taskRef:

ansible/roles/operator-pipeline/templates/openshift/tasks/upload-pipeline-logs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ spec:
2727
description: Operator package name
2828
- name: pipeline_name
2929
description: Tekton pipeline run name where logs will be gathered from
30+
- name: env
31+
description: Environment. One of [dev, qa, stage, prod]
3032
results:
3133
- name: pipeline_log_url
3234
workspaces:
@@ -52,6 +54,8 @@ spec:
5254
value: $(params.pyxis_cert_path)
5355
- name: PYXIS_KEY_PATH
5456
value: $(params.pyxis_key_path)
57+
- name: ENVIRONMENT
58+
value: $(params.env)
5559
script: |
5660
#! /usr/bin/env bash
5761
echo "Uploading pipeline logs"

operator-pipeline-images/operatorcert/pyxis.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,17 @@ def _get_session() -> requests.Session:
3535
api_key = os.environ.get("PYXIS_API_KEY")
3636
cert = os.environ.get("PYXIS_CERT_PATH")
3737
key = os.environ.get("PYXIS_KEY_PATH")
38+
env = os.environ.get("ENVIRONMENT")
39+
40+
# Document about the proxy configuration:
41+
# https://source.redhat.com/groups/public/customer-platform-devops/digital_experience_operations_dxp_ops_wiki/using_squid_proxy_to_access_akamai_preprod_domains_over_vpn
42+
proxies = {}
43+
# If it's external preprod
44+
if env != "prod" and api_key:
45+
proxies = {
46+
"http": "http://squid.corp.redhat.com:3128",
47+
"https": "http://squid.corp.redhat.com:3128",
48+
}
3849

3950
# API key or cert + key need to be provided using env variable
4051
if not api_key and (not cert or not key):
@@ -44,12 +55,20 @@ def _get_session() -> requests.Session:
4455
)
4556

4657
session = requests.Session()
58+
4759
if api_key:
4860
LOGGER.debug("Pyxis session using API key is created")
4961
session.headers.update({"X-API-KEY": api_key})
5062
else:
5163
LOGGER.debug("Pyxis session using cert + key is created")
5264
session.cert = (cert, key)
65+
66+
if proxies:
67+
LOGGER.debug(
68+
"Pyxis session configured for Proxy (external preprod environment)"
69+
)
70+
session.proxies.update(proxies)
71+
5372
return session
5473

5574

0 commit comments

Comments
 (0)