Skip to content

Commit

Permalink
Net 5229 create dedicated argocd stanza (#2785)
Browse files Browse the repository at this point in the history
* enable argocd

* adds bats test and setting argo annotations if global.argocd.enabled = true

* update comment

* added change log

* Update charts/consul/templates/gateway-cleanup-job.yaml

Co-authored-by: Ganesh S <ganesh.seetharaman@hashicorp.com>

* comments fixes

* fix line diff

* change log fix

* fix comment

* Update .changelog/2785.txt

Co-authored-by: Luke Kysow <1034429+lkysow@users.noreply.github.com>

---------

Co-authored-by: Ganesh S <ganesh.seetharaman@hashicorp.com>
Co-authored-by: Luke Kysow <1034429+lkysow@users.noreply.github.com>
  • Loading branch information
3 people authored Aug 31, 2023
1 parent 3056323 commit ef30dc0
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
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

0 comments on commit ef30dc0

Please sign in to comment.