Skip to content

Commit

Permalink
Merge pull request #129 from metacoma/publish-pkg-argo-cd-order
Browse files Browse the repository at this point in the history
Fix camelCase and add more sync states
  • Loading branch information
Peefy authored Apr 24, 2024
2 parents 5937728 + 026cd18 commit 6338e4d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
6 changes: 3 additions & 3 deletions argo-cd-order/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import argoproj.v1alpha1 as argoproj
testApp = ArgoCdOrder.make({
preSync = [
PreSync = [
k8core.Namespace {
metadata.name = "test-namespace"
}
Expand All @@ -36,7 +36,7 @@ testApp = ArgoCdOrder.make({
}
}
] + yaml.decode_all(file.read("./knative-operator.yaml"))
sync = [
Sync = [
argoproj.Application {
metadata = {
name = "testApp"
Expand Down Expand Up @@ -70,7 +70,7 @@ testApp = ArgoCdOrder.make({
}
]
postSync = []
PostSync = []
})
Expand Down
4 changes: 2 additions & 2 deletions argo-cd-order/kcl.mod
Original file line number Diff line number Diff line change
@@ -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" }
17 changes: 12 additions & 5 deletions argo-cd-order/main.k
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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]] {
[
Expand Down

0 comments on commit 6338e4d

Please sign in to comment.