From 8b2572dde8c20f7ca75565a51c3cc94c2bd23337 Mon Sep 17 00:00:00 2001 From: Ryabin Sergey Date: Wed, 24 Apr 2024 17:12:31 +0200 Subject: [PATCH 1/2] Fix camelCase and and more sync states Remove sync-wave annotation for resources in "Sync" state --- argo-cd-order/kcl.mod | 4 ++-- argo-cd-order/main.k | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/argo-cd-order/kcl.mod b/argo-cd-order/kcl.mod index 7386832a..ea004fda 100644 --- a/argo-cd-order/kcl.mod +++ b/argo-cd-order/kcl.mod @@ -1,7 +1,7 @@ [package] name = "argo-cd-order" -edition = "v0.1.0" -version = "0.1.0" +edition = "v0.1.1" +version = "0.1.1" [dependencies] json_merge_patch = { oci = "oci://ghcr.io/kcl-lang/json_merge_patch", tag = "0.1.0" } diff --git a/argo-cd-order/main.k b/argo-cd-order/main.k index 6d4ba318..678a0527 100644 --- a/argo-cd-order/main.k +++ b/argo-cd-order/main.k @@ -2,9 +2,14 @@ import json_merge_patch as p WAVE_MIN = 0 validatedAnnotations = lambda a: {str:str} { - assert a["argocd.argoproj.io/hook"] in ["preSync", "sync", "postSync"] + assert a["argocd.argoproj.io/hook"] in ["PreSync", "Sync", "PostSync", "SyncFail", "SyncFail"] assert int(a["argocd.argoproj.io/sync-wave"]) >= WAVE_MIN - a + # Don't explicitly specify a sync-wave for the "Sync" state; let's keep the behavior as the default. + if a["argocd.argoproj.io/hook"] == "Sync": + r = { "argocd.argoproj.io/sync-wave" = a["argocd.argoproj.io/sync-wave"]} + else: + r = a + r } schema ArgoCdManifest: @@ -47,9 +52,11 @@ schema ArgoCdOrder: For more details: https://argo-cd.readthedocs.io/en/stable/user-guide/sync-waves/ """ - preSync: [any] - sync: [any] - postSync: [any] + PreSync: [any] = [] + Sync: [any] = [] + Skip: [any] = [] + PostSync: [any] = [] + SyncFail: [any] = [] make = lambda argoCdApp: ArgoCdOrder -> [[ArgoCdManifest]] { [ From 026cd18c595625779b89d306b539182c61f8cc10 Mon Sep 17 00:00:00 2001 From: Ryabin Sergey Date: Wed, 24 Apr 2024 17:12:31 +0200 Subject: [PATCH 2/2] Fix camelCase and and more sync states Remove sync-wave annotation for resources in "Sync" state Update README with latest changes --- argo-cd-order/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/argo-cd-order/README.md b/argo-cd-order/README.md index 136df578..947c2374 100644 --- a/argo-cd-order/README.md +++ b/argo-cd-order/README.md @@ -22,7 +22,7 @@ import argoproj.v1alpha1 as argoproj testApp = ArgoCdOrder.make({ - preSync = [ + PreSync = [ k8core.Namespace { metadata.name = "test-namespace" } @@ -36,7 +36,7 @@ testApp = ArgoCdOrder.make({ } } ] + yaml.decode_all(file.read("./knative-operator.yaml")) - sync = [ + Sync = [ argoproj.Application { metadata = { name = "testApp" @@ -70,7 +70,7 @@ testApp = ArgoCdOrder.make({ } ] - postSync = [] + PostSync = [] })