diff --git a/CHANGELOG.md b/CHANGELOG.md index c11bd126..0ab02d05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Fixed + +- Fix helm env variable validation logic when specifying Twilio auth related values by @njohnstone2 ([#2674](https://github.com/grafana/oncall/pull/2674)) + ## v1.3.19 (2023-07-28) ### Fixed diff --git a/helm/oncall/templates/_env.tpl b/helm/oncall/templates/_env.tpl index 3632789e..6ee7207a 100644 --- a/helm/oncall/templates/_env.tpl +++ b/helm/oncall/templates/_env.tpl @@ -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: @@ -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: @@ -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 diff --git a/helm/oncall/tests/twilio_auth_env_test.yaml b/helm/oncall/tests/twilio_auth_env_test.yaml new file mode 100644 index 00000000..01ee8be7 --- /dev/null +++ b/helm/oncall/tests/twilio_auth_env_test.yaml @@ -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