-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ability to specify externally created service account and just …
…to override sa name without overriding fullname from tpl
- Loading branch information
Showing
14 changed files
with
273 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
chart/helm3/sops-secrets-operator/templates/service_account.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
{{- if .Values.rbac.enabled }} | ||
{{- if (and .Values.rbac.enabled .Values.serviceAccount.enabled) }} | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
{{- with .Values.serviceAccount.annotations }} | ||
annotations: | ||
{{ toYaml . | indent 4 }} | ||
{{- end }} | ||
name: {{ include "sops-secrets-operator.fullname" . }} | ||
name: {{ .Values.serviceAccount.name | default (tpl ( include "sops-secrets-operator.fullname" . ) .) }} | ||
labels: | ||
{{ include "sops-secrets-operator.labels" . | indent 4 }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{{- if and (not .Values.serviceAccount.enabled) (not .Values.serviceAccount.name) }} | ||
{{- fail "Error: serviceAccount 'name' must be set if serviceAccount 'enabled' is set to false" }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
chart/helm3/sops-secrets-operator/tests/service_account_test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
suite: operator service account tests | ||
templates: | ||
- service_account.yaml | ||
|
||
tests: | ||
|
||
# api | ||
- it: should set correct kind and apiVersion | ||
asserts: | ||
- isKind: | ||
of: ServiceAccount | ||
- isAPIVersion: | ||
of: v1 | ||
- hasDocuments: | ||
count: 1 | ||
|
||
# deployment metadata and labels | ||
- it: should correctly render default service account metadata | ||
release: | ||
name: sops | ||
namespace: sops | ||
asserts: | ||
- equal: | ||
path: metadata.name | ||
value: sops-sops-secrets-operator | ||
- equal: | ||
path: metadata.labels | ||
# UPDATE_HERE | ||
value: | ||
app.kubernetes.io/instance: sops | ||
app.kubernetes.io/managed-by: Helm | ||
app.kubernetes.io/name: sops-secrets-operator | ||
app.kubernetes.io/version: 0.14.1 | ||
helm.sh/chart: sops-secrets-operator-0.20.3 | ||
|
||
# custom name | ||
- it: should correctly render custome service account name | ||
release: | ||
name: sops | ||
namespace: sops | ||
set: | ||
serviceAccount: | ||
name: AzureSA | ||
asserts: | ||
- equal: | ||
path: metadata.name | ||
value: AzureSA | ||
|
||
# sa disabled | ||
- it: should not render service account if disabled | ||
release: | ||
name: sops | ||
namespace: sops | ||
set: | ||
serviceAccount: | ||
enabled: false | ||
asserts: | ||
- hasDocuments: | ||
count: 0 | ||
|
||
# rbac disabled | ||
- it: should not render service account if rbac disabled | ||
release: | ||
name: sops | ||
namespace: sops | ||
set: | ||
rbac: | ||
enabled: false | ||
asserts: | ||
- hasDocuments: | ||
count: 0 | ||
|
||
# both sa and rbac are disabled | ||
- it: should not render service account if rbac and sa are disabled | ||
release: | ||
name: sops | ||
namespace: sops | ||
set: | ||
serviceAccount: | ||
enabled: false | ||
rbac: | ||
enabled: false | ||
asserts: | ||
- hasDocuments: | ||
count: 0 | ||
|
||
# sa empty annotations | ||
- it: sa annotations should be empty by default | ||
asserts: | ||
- notExists: | ||
path: metadata.annotations | ||
|
||
# sa annotations | ||
- it: sa annotations should be empty by default | ||
set: | ||
serviceAccount: | ||
annotations: | ||
abc: "abc" | ||
asserts: | ||
- equal: | ||
path: metadata.annotations | ||
value: | ||
abc: abc |
30 changes: 30 additions & 0 deletions
30
chart/helm3/sops-secrets-operator/tests/validation_test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
suite: "Validation Tests" | ||
|
||
templates: | ||
- "templates/validation.yaml" | ||
|
||
tests: | ||
- it: "should succeed if '.serviceAccount.enabled' is true (default case)" | ||
set: | ||
serviceAccount: | ||
enabled: true | ||
name: | ||
asserts: | ||
- notFailedTemplate: {} | ||
|
||
- it: "should succeed if '.serviceAccount.enabled' is false and 'name' is set" | ||
set: | ||
serviceAccount: | ||
enabled: false | ||
name: "AzureSA" | ||
asserts: | ||
- notFailedTemplate: {} | ||
|
||
- it: "should fail if '.serviceAccount.enabled' is false and '.serviceAccount.name' is not set" | ||
set: | ||
serviceAccount: | ||
enabled: false | ||
name: "" | ||
asserts: | ||
- failedTemplate: | ||
errorMessage: "Error: serviceAccount 'name' must be set if serviceAccount 'enabled' is set to false" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.