diff --git a/graduated/gitops-argocd-sync/CHANGELOG.md b/graduated/gitops-argocd-sync/CHANGELOG.md index 84469f41c..867867a20 100644 --- a/graduated/gitops-argocd-sync/CHANGELOG.md +++ b/graduated/gitops-argocd-sync/CHANGELOG.md @@ -1,4 +1,7 @@ # Changelog +## [1.5.0] - 2025-01-29 +### Changed +- Add APP_NAMESPACE option (supported from app-proxy v1.2600.1) ## [1.4.5] - 2024-04-04 ### Fixed diff --git a/graduated/gitops-argocd-sync/README.md b/graduated/gitops-argocd-sync/README.md index a39b2abc4..cb30f5184 100644 --- a/graduated/gitops-argocd-sync/README.md +++ b/graduated/gitops-argocd-sync/README.md @@ -15,6 +15,7 @@ Syncs Argo CD apps managed by our GitOps Runtimes using Codefresh API |:---------------|:------------------------------------------------------------------------------------------|:---------|:--------------------------------------------| | RUNTIME | The name of the GitOps Runtime managing the Argo CD Application | false | | | APPLICATION | The name of the Argo CD Application to be synced | false | | +| APP_NAMESPACE | The namespace of the Argo CD Application to be synced, supported from app-proxy v1.2600.1 | true | | | ROLLBACK | Initiate a rollback to the previous revision if the Sync and Wait does not become healthy | true | | | WAIT_ROLLBACK | Wait for the app to be healthy after a rollback. Forces ROLLBACK to true | true | | | CA_BUNDLE | A base64 encoded string that contain the complete CA Certificate Bundle | true | | diff --git a/graduated/gitops-argocd-sync/argocd_sync.py b/graduated/gitops-argocd-sync/argocd_sync.py index c34e3a583..28efc3a8e 100644 --- a/graduated/gitops-argocd-sync/argocd_sync.py +++ b/graduated/gitops-argocd-sync/argocd_sync.py @@ -12,6 +12,14 @@ RUNTIME = os.getenv('RUNTIME') APPLICATION = os.getenv('APPLICATION') +APP_NAMESPACE = os.getenv('APP_NAMESPACE') + +APP_DICTIONARY = { + "applicationName": APPLICATION, +} +if APP_NAMESPACE is not None: + APP_DICTIONARY["applicationNamespace"] = APP_NAMESPACE + # Wait and Rollback options WAIT_HEALTHY = True if os.getenv('WAIT_HEALTHY', "false").lower() == "true" else False @@ -43,6 +51,7 @@ def main(): logging.debug("RUNTIME: %s", RUNTIME) logging.debug("APPLICATION: %s", APPLICATION) + logging.debug("NAMESPACE: %s", NAMESPACE) logging.debug("WAIT: %s", WAIT_HEALTHY) logging.debug("INTERVAL: %d", INTERVAL) logging.debug("MAX CHECKS: %s", MAX_CHECKS) @@ -214,9 +223,7 @@ def get_app_status(ingress_host): ) client = Client(transport=transport, fetch_schema_from_transport=False) query = get_query('get_app_status') ## gets gql query - variables = { - "name": APPLICATION - } + variables = {**APP_DICTIONARY} result = client.execute(query, variable_values=variables) logging.debug("App Status result: %s", result) @@ -276,12 +283,14 @@ def execute_argocd_sync(ingress_host): ) client = Client(transport=transport, fetch_schema_from_transport=False) query = get_query('argocd_sync') ## gets gql query + variables = { - "applicationName": APPLICATION, + **APP_DICTIONARY, "options": { "prune": True } } + try: result = client.execute(query, variable_values=variables) except TransportQueryError as err: @@ -312,9 +321,7 @@ def application_exist(ingress_host): ) client = Client(transport=transport, fetch_schema_from_transport=False) query = get_query('get_app_existence') ## gets gql query - variables = { - "applicationName": APPLICATION - } + variables = {**APP_DICTIONARY} try: result = client.execute(query, variable_values=variables) except TransportQueryError as err: @@ -346,9 +353,7 @@ def application_autosync(ingress_host): ) client = Client(transport=transport, fetch_schema_from_transport=False) query = get_query('get_app_autosync') ## gets gql query - variables = { - "applicationName": APPLICATION - } + variables = {**APP_DICTIONARY} try: result = client.execute(query, variable_values=variables) except Exception as err: diff --git a/graduated/gitops-argocd-sync/queries/argocd_sync.graphql b/graduated/gitops-argocd-sync/queries/argocd_sync.graphql index 91538460a..c9edc62b3 100644 --- a/graduated/gitops-argocd-sync/queries/argocd_sync.graphql +++ b/graduated/gitops-argocd-sync/queries/argocd_sync.graphql @@ -1,5 +1,5 @@ -query sync($applicationName: String!, $options: SyncOptions) { - sync(applicationName: $applicationName, options: $options) { +query sync($applicationName: String!, $options: SyncOptions, $applicationNamespace: String) { + sync(applicationName: $applicationName, options: $options, appNamespace: $applicationNamespace) { metadata { name __typename diff --git a/graduated/gitops-argocd-sync/queries/get_app_autosync.graphql b/graduated/gitops-argocd-sync/queries/get_app_autosync.graphql index df21f0180..0bd5903f0 100644 --- a/graduated/gitops-argocd-sync/queries/get_app_autosync.graphql +++ b/graduated/gitops-argocd-sync/queries/get_app_autosync.graphql @@ -1,7 +1,8 @@ -query appsyncstatus ($applicationName: String!) { +query appsyncstatus ($applicationName: String!, $applicationNamespace: String) { applicationProxyQuery( - name: $applicationName + name: $applicationName, + appNamespace: $applicationNamespace ){ metadata { name diff --git a/graduated/gitops-argocd-sync/queries/get_app_existence.graphql b/graduated/gitops-argocd-sync/queries/get_app_existence.graphql index dd173051e..13f5b3305 100644 --- a/graduated/gitops-argocd-sync/queries/get_app_existence.graphql +++ b/graduated/gitops-argocd-sync/queries/get_app_existence.graphql @@ -1,6 +1,7 @@ -query appexistence ($applicationName: String!) { +query appexistence ($applicationName: String!, $applicationNamespace: String) { applicationProxyQuery( - name: $applicationName + name: $applicationName, + appNamespace: $applicationNamespace ){ metadata { name diff --git a/graduated/gitops-argocd-sync/queries/get_app_status.graphql b/graduated/gitops-argocd-sync/queries/get_app_status.graphql index 574b0d645..9d470143e 100644 --- a/graduated/gitops-argocd-sync/queries/get_app_status.graphql +++ b/graduated/gitops-argocd-sync/queries/get_app_status.graphql @@ -1,6 +1,7 @@ -query appstatus ($name: String!) { +query appstatus ($name: String!, $applicationNamespace: String) { applicationProxyQuery( - name: $name + name: $name, + appNamespace: $applicationNamespace ){ metadata { name diff --git a/graduated/gitops-argocd-sync/step.yaml b/graduated/gitops-argocd-sync/step.yaml index 0ded3d0d4..1a818d700 100644 --- a/graduated/gitops-argocd-sync/step.yaml +++ b/graduated/gitops-argocd-sync/step.yaml @@ -1,7 +1,7 @@ kind: step-type metadata: name: gitops-argocd-sync - version: 1.4.5 + version: 1.5.0 isPublic: true description: Syncs Argo CD apps managed by our GitOps Runtimes sources: @@ -48,6 +48,7 @@ metadata: arguments: RUNTIME: my-runtime APPLICATION: my-app + APP_NAMESPACE: my-app-ns WAIT_HEALTHY: true INTERVAL: 60 MAX_CHECKS: 3 @@ -74,6 +75,10 @@ spec: "type": "string", "description": "The name of the Argo CD Application to be synced" }, + "APP_NAMESPACE": { + "type": "string", + "description": "The namespace of the Argo CD Application to be synced" + }, "WAIT_HEALTHY": { "type": "boolean", "description": "OPTIONAL - Wait for the app to be healthy",