Helm - Twilio validation make auth fields optional (#2674)

# What this PR does
When configuring twilio auth only the provided values are templated. 

## Which issue(s) this PR fixes
https://github.com/grafana/oncall/issues/2654

## Checklist

- [X] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)

---------

Co-authored-by: Joey Orlando <joey.orlando@grafana.com>
Co-authored-by: Joey Orlando <joseph.t.orlando@gmail.com>
This commit is contained in:
Nelson 2023-07-31 18:25:30 +10:00 committed by GitHub
parent 81937868b4
commit fc8191c7db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 58 additions and 0 deletions

View file

@ -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

View file

@ -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

View file

@ -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