Skip to content

Commit fccb63a

Browse files
CR-21153: create an option for using it with self-signed certificate (#658)
* [CR-21153]: v1.4.0 adding unsecure option * upgrading image * Adding debug info * upgrade packages * Upgrade pip and do not use slim version * [CR-21153] 1.4.1 Adding CA_BUNDLE option * Fixed logic * Remove double code ------- Signed-off-by: Laurent Rochette <laurent.rochette@codefresh.io> Co-authored-by: Francisco Cocozza <39525266+francisco-codefresh@users.noreply.github.com>
1 parent db00daf commit fccb63a

File tree

5 files changed

+42
-14
lines changed

5 files changed

+42
-14
lines changed

incubating/argo-cd-sync/CHANGELOG.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
# Changelog
2-
## [1.3.1] - 2023-09-18
2+
3+
## [1.4.1] - 2023-10-31
4+
### Changed
5+
Add CA_BUNDLE option
6+
7+
## [1.4.0] - 2023-10-30
38
### Changed
9+
Add INSECURE option
410

11+
## [1.3.1] - 2023-09-18
512
### Fixed
613
- CVE-2023-37920 - upgrade Python module certifi to 2023.7.22
714
- CVE-2019-8457 - upgrade base image to python:3.11.5-slim-bookworm
@@ -10,5 +17,3 @@
1017
### Changed
1118
- Adding IMAGE_NAME parameter
1219
- Adding example
13-
14-
### Fixed

incubating/argo-cd-sync/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
FROM python:3.11.5-slim-bookworm
1+
FROM python:3.12.0-bookworm
22
WORKDIR /app
33
COPY requirements.txt requirements.txt
4+
RUN pip3 install --upgrade pip
45
RUN pip3 install -r requirements.txt
56
COPY queries queries/
67
COPY argocd_sync.py run.py

incubating/argo-cd-sync/argocd_sync.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@
2424
CF_STEP_NAME= os.getenv('CF_STEP_NAME', 'STEP_NAME')
2525
LOG_LEVEL = os.getenv('LOG_LEVEL', "info")
2626

27+
# Check the certificate or not accessing the API endpoint
28+
VERIFY = True if os.getenv('INSECURE', "False").lower() == "false" else False
29+
CA_BUNDLE = os.getenv('CA_BUNDLE')
30+
31+
if CA_BUNDLE != None:
32+
VERIFY='/root/bundle.pem'
33+
2734
#######################################################################
2835

2936

@@ -37,6 +44,8 @@ def main():
3744
logging.debug("INTERVAL: %d", INTERVAL)
3845
logging.debug("MAX CHECKS: %s", MAX_CHECKS)
3946
logging.debug("ROLLBACK: %s", ROLLBACK)
47+
logging.debug("VERIFY: %s", VERIFY)
48+
logging.debug("BUNDLE: %s", CA_BUNDLE)
4049

4150
ingress_host = get_runtime_ingress_host()
4251
execute_argocd_sync(ingress_host)
@@ -83,7 +92,7 @@ def getRevision(namespace):
8392
transport = RequestsHTTPTransport(
8493
url=gql_api_endpoint,
8594
headers={'authorization': CF_API_KEY},
86-
verify=True,
95+
verify=VERIFY,
8796
retries=3,
8897
)
8998
client = Client(transport=transport, fetch_schema_from_transport=False)
@@ -139,7 +148,7 @@ def rollback(ingress_host, namespace, revision):
139148
transport = RequestsHTTPTransport(
140149
url=runtime_api_endpoint,
141150
headers={'authorization': CF_API_KEY},
142-
verify=True,
151+
verify=VERIFY,
143152
retries=3,
144153
)
145154
client = Client(transport=transport, fetch_schema_from_transport=False)
@@ -163,7 +172,7 @@ def get_app_status(namespace):
163172
transport = RequestsHTTPTransport(
164173
url=gql_api_endpoint,
165174
headers={'authorization': CF_API_KEY},
166-
verify=True,
175+
verify=VERIFY,
167176
retries=3,
168177
)
169178
client = Client(transport=transport, fetch_schema_from_transport=False)
@@ -189,7 +198,7 @@ def get_runtime():
189198
transport = RequestsHTTPTransport(
190199
url = CF_URL + '/2.0/api/graphql',
191200
headers={'authorization': CF_API_KEY},
192-
verify=True,
201+
verify=VERIFY,
193202
retries=3,
194203
)
195204
client = Client(transport=transport, fetch_schema_from_transport=False)
@@ -225,7 +234,7 @@ def execute_argocd_sync(ingress_host):
225234
transport = RequestsHTTPTransport(
226235
url=runtime_api_endpoint,
227236
headers={'authorization': CF_API_KEY},
228-
verify=True,
237+
verify=VERIFY,
229238
retries=3,
230239
)
231240
client = Client(transport=transport, fetch_schema_from_transport=False)

incubating/argo-cd-sync/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ idna==3.4
77
multidict==6.0.4
88
requests==2.28.2
99
requests-toolbelt==0.10.1
10-
urllib3==1.26.15
11-
yarl==1.8.2
10+
urllib3==1.26.16
11+
yarl==1.9.2

incubating/argo-cd-sync/step.yaml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
kind: step-type
22
metadata:
33
name: argo-cd-sync
4-
version: 1.3.1
4+
version: 1.4.1
55
isPublic: true
66
description: Syncs Argo CD apps managed by our GitOps Runtimes
77
sources:
88
- 'https://github.com/codefresh-io/steps/tree/master/incubating/argo-cd-sync'
99
stage: incubating
1010
maintainers:
1111
- name: Francisco Cocozza
12-
- email: francisco@codefresh.io
12+
email: francisco@codefresh.io
1313
- name: Laurent Rochette
14-
- email: laurent.rochette@codefresh.io
14+
email: laurent.rochette@codefresh.io
1515
categories:
1616
- GitOps
1717
official: true
@@ -99,6 +99,15 @@ spec:
9999
"description": "OPTIONAL - Wait for the app to be healthy after a rollback. Forces ROLLBACK to true",
100100
"default": false
101101
},
102+
"CA_BUNDLE": {
103+
"type": "string",
104+
"description": "OPTIONAL - a base64 encoded stringnthat contain the complete CA Certificate Bundle"
105+
},
106+
"INSECURE": {
107+
"type": "boolean",
108+
"description": "OPTIONAL - to allow the usage of a self-signed certificate in the chain to reach the API endpoint",
109+
"default": false
110+
},
102111
"LOG_LEVEL": {
103112
"type": "string",
104113
"description": "OPTIONAL - set the log level, e.g. 'debug', 'info', 'warn', 'error', 'critical' (default 'error')",
@@ -145,8 +154,12 @@ spec:
145154
- '[[ $key ]]=[[ $val ]]'
146155
[[- end ]]
147156
commands:
157+
[[ if .Arguments.CA_BUNDLE ]]
158+
- echo [[ .Arguments.CA_BUNDLE ]] | base64 -d >/root/bundle.pem
159+
[[ end ]]
148160
- cd /app
149161
- python3 run.py
162+
150163
delimiters:
151164
left: '[['
152165
right: ']]'

0 commit comments

Comments
 (0)