Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions charts/gitops-runtime/templates/gitops-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
{{- $_ := set $gitopsOperatorContext.Values.global.codefresh.tls.caCerts.secretKeyRef "key" (.Values.global.codefresh.tls.caCerts.secret.create | ternary (default "ca-bundle.crt" .Values.global.codefresh.tls.caCerts.secret.key) .Values.global.codefresh.tls.caCerts.secretKeyRef.key) }}
{{- end }}

{{- if and (gt (int $gitopsOperatorContext.Values.replicaCount) 1 ) }}
{{- $_ := set $gitopsOperatorContext.Values.env "LEADER_ELECT" "true" }}
{{- else }}
{{- $_ := set $gitopsOperatorContext.Values.env "LEADER_ELECT" "false" }}
{{- end }}

{{- include "gitops-operator.resources" $gitopsOperatorContext}}

{{- end }}
36 changes: 36 additions & 0 deletions charts/gitops-runtime/tests/gitops-operator_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
suite: Test GitOps Operator
templates:
- gitops-operator.yaml
- charts/gitops-operator/*
tests:
- it: should have LEADER_ELECT set to true if replicaCount is greater than 1
values:
- ./values/mandatory-values.yaml
template: gitops-operator.yaml
documentSelector:
path: kind
value: Deployment
set:
gitops-operator.replicaCount: 2
asserts:
- contains:
path: spec.template.spec.containers[1].env
content:
name: LEADER_ELECT
value: "true"

- it: should have LEADER_ELECT set to false if replicaCount is 1
values:
- ./values/mandatory-values.yaml
template: gitops-operator.yaml
documentSelector:
path: kind
value: Deployment
set:
gitops-operator.replicaCount: 1
asserts:
- contains:
path: spec.template.spec.containers[1].env
content:
name: LEADER_ELECT
value: "false"