Skip to content

Commit 4e1233e

Browse files
Feat(argo-sync-step): add new option (#717)
* add new option * add back compatability info
1 parent 65175e2 commit 4e1233e

File tree

8 files changed

+36
-19
lines changed

8 files changed

+36
-19
lines changed

graduated/gitops-argocd-sync/CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Changelog
2+
## [1.5.0] - 2025-01-29
3+
### Changed
4+
- Add APP_NAMESPACE option (supported from app-proxy v1.2600.1)
25

36
## [1.4.5] - 2024-04-04
47
### Fixed

graduated/gitops-argocd-sync/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Syncs Argo CD apps managed by our GitOps Runtimes using Codefresh API
1515
|:---------------|:------------------------------------------------------------------------------------------|:---------|:--------------------------------------------|
1616
| RUNTIME | The name of the GitOps Runtime managing the Argo CD Application | false | |
1717
| APPLICATION | The name of the Argo CD Application to be synced | false | |
18+
| APP_NAMESPACE | The namespace of the Argo CD Application to be synced, supported from app-proxy v1.2600.1 | true | |
1819
| ROLLBACK | Initiate a rollback to the previous revision if the Sync and Wait does not become healthy | true | |
1920
| WAIT_ROLLBACK | Wait for the app to be healthy after a rollback. Forces ROLLBACK to true | true | |
2021
| CA_BUNDLE | A base64 encoded string that contain the complete CA Certificate Bundle | true | |

graduated/gitops-argocd-sync/argocd_sync.py

+15-10
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@
1212

1313
RUNTIME = os.getenv('RUNTIME')
1414
APPLICATION = os.getenv('APPLICATION')
15+
APP_NAMESPACE = os.getenv('APP_NAMESPACE')
16+
17+
APP_DICTIONARY = {
18+
"applicationName": APPLICATION,
19+
}
20+
if APP_NAMESPACE is not None:
21+
APP_DICTIONARY["applicationNamespace"] = APP_NAMESPACE
22+
1523

1624
# Wait and Rollback options
1725
WAIT_HEALTHY = True if os.getenv('WAIT_HEALTHY', "false").lower() == "true" else False
@@ -43,6 +51,7 @@ def main():
4351

4452
logging.debug("RUNTIME: %s", RUNTIME)
4553
logging.debug("APPLICATION: %s", APPLICATION)
54+
logging.debug("NAMESPACE: %s", NAMESPACE)
4655
logging.debug("WAIT: %s", WAIT_HEALTHY)
4756
logging.debug("INTERVAL: %d", INTERVAL)
4857
logging.debug("MAX CHECKS: %s", MAX_CHECKS)
@@ -214,9 +223,7 @@ def get_app_status(ingress_host):
214223
)
215224
client = Client(transport=transport, fetch_schema_from_transport=False)
216225
query = get_query('get_app_status') ## gets gql query
217-
variables = {
218-
"name": APPLICATION
219-
}
226+
variables = {**APP_DICTIONARY}
220227
result = client.execute(query, variable_values=variables)
221228

222229
logging.debug("App Status result: %s", result)
@@ -276,12 +283,14 @@ def execute_argocd_sync(ingress_host):
276283
)
277284
client = Client(transport=transport, fetch_schema_from_transport=False)
278285
query = get_query('argocd_sync') ## gets gql query
286+
279287
variables = {
280-
"applicationName": APPLICATION,
288+
**APP_DICTIONARY,
281289
"options": {
282290
"prune": True
283291
}
284292
}
293+
285294
try:
286295
result = client.execute(query, variable_values=variables)
287296
except TransportQueryError as err:
@@ -312,9 +321,7 @@ def application_exist(ingress_host):
312321
)
313322
client = Client(transport=transport, fetch_schema_from_transport=False)
314323
query = get_query('get_app_existence') ## gets gql query
315-
variables = {
316-
"applicationName": APPLICATION
317-
}
324+
variables = {**APP_DICTIONARY}
318325
try:
319326
result = client.execute(query, variable_values=variables)
320327
except TransportQueryError as err:
@@ -346,9 +353,7 @@ def application_autosync(ingress_host):
346353
)
347354
client = Client(transport=transport, fetch_schema_from_transport=False)
348355
query = get_query('get_app_autosync') ## gets gql query
349-
variables = {
350-
"applicationName": APPLICATION
351-
}
356+
variables = {**APP_DICTIONARY}
352357
try:
353358
result = client.execute(query, variable_values=variables)
354359
except Exception as err:

graduated/gitops-argocd-sync/queries/argocd_sync.graphql

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
query sync($applicationName: String!, $options: SyncOptions) {
2-
sync(applicationName: $applicationName, options: $options) {
1+
query sync($applicationName: String!, $options: SyncOptions, $applicationNamespace: String) {
2+
sync(applicationName: $applicationName, options: $options, appNamespace: $applicationNamespace) {
33
metadata {
44
name
55
__typename

graduated/gitops-argocd-sync/queries/get_app_autosync.graphql

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
query appsyncstatus ($applicationName: String!) {
1+
query appsyncstatus ($applicationName: String!, $applicationNamespace: String) {
22

33
applicationProxyQuery(
4-
name: $applicationName
4+
name: $applicationName,
5+
appNamespace: $applicationNamespace
56
){
67
metadata {
78
name

graduated/gitops-argocd-sync/queries/get_app_existence.graphql

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
query appexistence ($applicationName: String!) {
1+
query appexistence ($applicationName: String!, $applicationNamespace: String) {
22
applicationProxyQuery(
3-
name: $applicationName
3+
name: $applicationName,
4+
appNamespace: $applicationNamespace
45
){
56
metadata {
67
name

graduated/gitops-argocd-sync/queries/get_app_status.graphql

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
query appstatus ($name: String!) {
1+
query appstatus ($name: String!, $applicationNamespace: String) {
22
applicationProxyQuery(
3-
name: $name
3+
name: $name,
4+
appNamespace: $applicationNamespace
45
){
56
metadata {
67
name

graduated/gitops-argocd-sync/step.yaml

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
kind: step-type
22
metadata:
33
name: gitops-argocd-sync
4-
version: 1.4.5
4+
version: 1.5.0
55
isPublic: true
66
description: Syncs Argo CD apps managed by our GitOps Runtimes
77
sources:
@@ -48,6 +48,7 @@ metadata:
4848
arguments:
4949
RUNTIME: my-runtime
5050
APPLICATION: my-app
51+
APP_NAMESPACE: my-app-ns
5152
WAIT_HEALTHY: true
5253
INTERVAL: 60
5354
MAX_CHECKS: 3
@@ -74,6 +75,10 @@ spec:
7475
"type": "string",
7576
"description": "The name of the Argo CD Application to be synced"
7677
},
78+
"APP_NAMESPACE": {
79+
"type": "string",
80+
"description": "The namespace of the Argo CD Application to be synced"
81+
},
7782
"WAIT_HEALTHY": {
7883
"type": "boolean",
7984
"description": "OPTIONAL - Wait for the app to be healthy",

0 commit comments

Comments
 (0)