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

Helm - Twilio validation make auth fields optional #2674

Merged
merged 4 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 4 additions & 0 deletions helm/oncall/templates/_env.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,13 @@
secretKeyRef:
name: {{ .existingSecret }}
key: {{ required "oncall.twilio.accountSid is required if oncall.twilio.existingSecret is not empty" .accountSid | quote }}
{{- if .authTokenKey }}
- name: TWILIO_AUTH_TOKEN
valueFrom:
secretKeyRef:
name: {{ .existingSecret }}
key: {{ required "oncall.twilio.authTokenKey is required if oncall.twilio.existingSecret is not empty" .authTokenKey | quote }}
{{- end }}
- name: TWILIO_NUMBER
valueFrom:
secretKeyRef:
Expand All @@ -136,6 +138,7 @@
secretKeyRef:
name: {{ .existingSecret }}
key: {{ required "oncall.twilio.verifySidKey is required if oncall.twilio.existingSecret is not empty" .verifySidKey | quote }}
{{- if and .apiKeySidKey .apiKeySecretKey }}
- name: TWILIO_API_KEY_SID
valueFrom:
secretKeyRef:
Expand All @@ -146,6 +149,7 @@
secretKeyRef:
name: {{ .existingSecret }}
key: {{ required "oncall.twilio.apiKeySecretKey is required if oncall.twilio.existingSecret is not empty" .apiKeySecretKey | quote }}
{{- end }}
{{- else }}
{{- if .accountSid }}
- name: TWILIO_ACCOUNT_SID
Expand Down
48 changes: 48 additions & 0 deletions helm/oncall/tests/twilio_auth_env_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
suite: test Twilio auth envs for deployments
release:
name: oncall
templates:
- engine/deployment.yaml
tests:
- it: snippet.oncall.twilio.env -> should succeed if only apiKeySid and apiKeySecret are set
set:
oncall.twilio.existingSecret: unittest-secret
oncall.twilio.accountSid: "acc-sid"
oncall.twilio.phoneNumberKey: "phone-key"
oncall.twilio.verifySidKey: "verify-sid-key"
oncall.twilio.apiKeySidKey: "api-sid-key"
oncall.twilio.apiKeySecretKey: "api-secret-key"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: TWILIO_API_KEY_SID
valueFrom:
secretKeyRef:
key: api-sid-key
name: unittest-secret
- contains:
path: spec.template.spec.containers[0].env
content:
name: TWILIO_API_KEY_SECRET
valueFrom:
secretKeyRef:
key: api-secret-key
name: unittest-secret

- it: snippet.oncall.twilio.env -> should succeed if only authToken is set
set:
oncall.twilio.existingSecret: unittest-secret
oncall.twilio.accountSid: "acc-sid"
oncall.twilio.verifySidKey: "verify-sid-key"
oncall.twilio.phoneNumberKey: "phone-key"
oncall.twilio.authTokenKey: "auth-token-key"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: TWILIO_AUTH_TOKEN
valueFrom:
secretKeyRef:
key: auth-token-key
name: unittest-secret