Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Net 5229 create dedicated argocd stanza #2785

Merged
merged 11 commits into from
Aug 31, 2023
3 changes: 3 additions & 0 deletions .changelog/2785.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
Add new value `global.argocd.enabled`. Set this to `true` when using ArgoCD to deploy this chart.
```
4 changes: 4 additions & 0 deletions charts/consul/templates/server-acl-init-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ spec:
{{- if .Values.global.acls.annotations }}
{{- tpl .Values.global.acls.annotations . | nindent 8 }}
{{- end }}
{{- if .Values.global.argocd.enabled }}
"argocd.argoproj.io/hook": "Sync"
"argocd.argoproj.io/hook-delete-policy": "HookSucceeded"
{{- end }}
{{- if .Values.global.secretsBackend.vault.enabled }}

{{- /* Run the Vault agent as both an init container and sidecar.
Expand Down
36 changes: 36 additions & 0 deletions charts/consul/test/unit/server-acl-init-job.bats
Original file line number Diff line number Diff line change
Expand Up @@ -2296,3 +2296,39 @@ load _helpers
yq -r '.spec.template.metadata.annotations.foo' | tee /dev/stderr)
[ "${actual}" = "bar" ]
}

@test "serverACLInit/Job: argocd annotations are set if global.argocd.enabled is true" {
cd `chart_dir`
local actual=$(helm template \
-s templates/server-acl-init-job.yaml \
--set 'global.acls.manageSystemACLs=true' \
--set 'global.argocd.enabled=true' \
. | tee /dev/stderr |
yq -r '.spec.template.metadata.annotations["argocd.argoproj.io/hook"]' | tee /dev/stderr)
[ "${actual}" = "Sync" ]
local actual=$(helm template \
-s templates/server-acl-init-job.yaml \
--set 'global.acls.manageSystemACLs=true' \
--set 'global.argocd.enabled=true' \
. | tee /dev/stderr |
yq -r '.spec.template.metadata.annotations["argocd.argoproj.io/hook-delete-policy"]' | tee /dev/stderr)
[ "${actual}" = "HookSucceeded" ]
}

@test "serverACLInit/Job: argocd annotations are not set if global.argocd.enabled is false" {
cd `chart_dir`
local actual=$(helm template \
-s templates/server-acl-init-job.yaml \
--set 'global.acls.manageSystemACLs=true' \
--set 'global.argocd.enabled=false' \
. | tee /dev/stderr |
yq -r '.spec.template.metadata.annotations["argocd.argoproj.io/hook"]' | tee /dev/stderr)
[ "${actual}" = null ]
local actual=$(helm template \
-s templates/server-acl-init-job.yaml \
--set 'global.acls.manageSystemACLs=true' \
--set 'global.argocd.enabled=false' \
. | tee /dev/stderr |
yq -r '.spec.template.metadata.annotations["argocd.argoproj.io/hook-delete-policy"]' | tee /dev/stderr)
[ "${actual}" = null ]
}
8 changes: 8 additions & 0 deletions charts/consul/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,14 @@ global:
# @type: string
annotations: null

# If argocd.enabled is set to true, following annotations are added to
# job - server-acl-init-job
# annotations -
# argocd.argoproj.io/hook: Sync
# argocd.argoproj.io/hook-delete-policy: HookSucceeded
argocd:
enabled: false

# [Enterprise Only] This value refers to a Kubernetes or Vault secret that you have created
# that contains your enterprise license. It is required if you are using an
# enterprise binary. Defining it here applies it to your cluster once a leader
Expand Down
Loading