From 6762191f1cacd43b7f3807ab85ce3065820d4c7c Mon Sep 17 00:00:00 2001 From: Ori Hoch Date: Sat, 27 Jan 2024 18:36:47 +0200 Subject: [PATCH] add argocd plugin implementation --- .../templates/app-cwm-worker-ingress.yaml | 21 +++++++++++++++++++ apps/argocd-apps/templates/project-cwm.yaml | 14 +++++++++++++ .../__init__.py | 3 ++- 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 apps/argocd-apps/templates/app-cwm-worker-ingress.yaml create mode 100644 apps/argocd-apps/templates/project-cwm.yaml diff --git a/apps/argocd-apps/templates/app-cwm-worker-ingress.yaml b/apps/argocd-apps/templates/app-cwm-worker-ingress.yaml new file mode 100644 index 0000000..77f7fe2 --- /dev/null +++ b/apps/argocd-apps/templates/app-cwm-worker-ingress.yaml @@ -0,0 +1,21 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: cwm-worker-ingress +spec: + destination: + namespace: cwm-worker-ingress + server: 'https://kubernetes.default.svc' + project: cwm + syncPolicy: + syncOptions: + - CreateNamespace=true + source: + repoURL: git@github.com:CloudWebManage/cwm-worker-ingress.git + targetRevision: main + path: helm + plugin: + name: uumpa + env: + - name: CWM_APP + value: cwm-worker-ingress diff --git a/apps/argocd-apps/templates/project-cwm.yaml b/apps/argocd-apps/templates/project-cwm.yaml new file mode 100644 index 0000000..d2985b9 --- /dev/null +++ b/apps/argocd-apps/templates/project-cwm.yaml @@ -0,0 +1,14 @@ +apiVersion: argoproj.io/v1alpha1 +kind: AppProject +metadata: + name: cwm +spec: + destinations: + - name: '*' + namespace: '*' + server: https://kubernetes.default.svc + sourceRepos: + - git@github.com:CloudWebManage/cwm-worker-ingress.git + clusterResourceWhitelist: + - group: '*' + kind: '*' diff --git a/argocd_plugin/cwm_worker_cluster_argocd_plugin/__init__.py b/argocd_plugin/cwm_worker_cluster_argocd_plugin/__init__.py index 1b0f66d..d0a0db9 100644 --- a/argocd_plugin/cwm_worker_cluster_argocd_plugin/__init__.py +++ b/argocd_plugin/cwm_worker_cluster_argocd_plugin/__init__.py @@ -26,7 +26,8 @@ def add_cluster_values(cwm_app, cluster_name, path): def generate_template(cmd, cwd, data): cwm_app = os.environ.get('ARGOCD_ENV_CWM_APP') cluster_name = os.environ.get('CLUSTER_NAME') - cmd += add_cluster_values(cwm_app, cluster_name, cwd) + if cwm_app and cluster_name: + cmd += add_cluster_values(cwm_app, cluster_name, cwd) return cmd, cwd