Skip to content

Commit fc8191c

Browse files
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 #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 <[email protected]> Co-authored-by: Joey Orlando <[email protected]>
1 parent 8193786 commit fc8191c

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## Unreleased
9+
10+
### Fixed
11+
12+
- Fix helm env variable validation logic when specifying Twilio auth related values by @njohnstone2 ([#2674](https://github.com/grafana/oncall/pull/2674))
13+
814
## v1.3.19 (2023-07-28)
915

1016
### Fixed

helm/oncall/templates/_env.tpl

+4
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,13 @@
121121
secretKeyRef:
122122
name: {{ .existingSecret }}
123123
key: {{ required "oncall.twilio.accountSid is required if oncall.twilio.existingSecret is not empty" .accountSid | quote }}
124+
{{- if .authTokenKey }}
124125
- name: TWILIO_AUTH_TOKEN
125126
valueFrom:
126127
secretKeyRef:
127128
name: {{ .existingSecret }}
128129
key: {{ required "oncall.twilio.authTokenKey is required if oncall.twilio.existingSecret is not empty" .authTokenKey | quote }}
130+
{{- end }}
129131
- name: TWILIO_NUMBER
130132
valueFrom:
131133
secretKeyRef:
@@ -136,6 +138,7 @@
136138
secretKeyRef:
137139
name: {{ .existingSecret }}
138140
key: {{ required "oncall.twilio.verifySidKey is required if oncall.twilio.existingSecret is not empty" .verifySidKey | quote }}
141+
{{- if and .apiKeySidKey .apiKeySecretKey }}
139142
- name: TWILIO_API_KEY_SID
140143
valueFrom:
141144
secretKeyRef:
@@ -146,6 +149,7 @@
146149
secretKeyRef:
147150
name: {{ .existingSecret }}
148151
key: {{ required "oncall.twilio.apiKeySecretKey is required if oncall.twilio.existingSecret is not empty" .apiKeySecretKey | quote }}
152+
{{- end }}
149153
{{- else }}
150154
{{- if .accountSid }}
151155
- name: TWILIO_ACCOUNT_SID
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
suite: test Twilio auth envs for deployments
2+
release:
3+
name: oncall
4+
templates:
5+
- engine/deployment.yaml
6+
tests:
7+
- it: snippet.oncall.twilio.env -> should succeed if only apiKeySid and apiKeySecret are set
8+
set:
9+
oncall.twilio.existingSecret: unittest-secret
10+
oncall.twilio.accountSid: "acc-sid"
11+
oncall.twilio.phoneNumberKey: "phone-key"
12+
oncall.twilio.verifySidKey: "verify-sid-key"
13+
oncall.twilio.apiKeySidKey: "api-sid-key"
14+
oncall.twilio.apiKeySecretKey: "api-secret-key"
15+
asserts:
16+
- contains:
17+
path: spec.template.spec.containers[0].env
18+
content:
19+
name: TWILIO_API_KEY_SID
20+
valueFrom:
21+
secretKeyRef:
22+
key: api-sid-key
23+
name: unittest-secret
24+
- contains:
25+
path: spec.template.spec.containers[0].env
26+
content:
27+
name: TWILIO_API_KEY_SECRET
28+
valueFrom:
29+
secretKeyRef:
30+
key: api-secret-key
31+
name: unittest-secret
32+
33+
- it: snippet.oncall.twilio.env -> should succeed if only authToken is set
34+
set:
35+
oncall.twilio.existingSecret: unittest-secret
36+
oncall.twilio.accountSid: "acc-sid"
37+
oncall.twilio.verifySidKey: "verify-sid-key"
38+
oncall.twilio.phoneNumberKey: "phone-key"
39+
oncall.twilio.authTokenKey: "auth-token-key"
40+
asserts:
41+
- contains:
42+
path: spec.template.spec.containers[0].env
43+
content:
44+
name: TWILIO_AUTH_TOKEN
45+
valueFrom:
46+
secretKeyRef:
47+
key: auth-token-key
48+
name: unittest-secret

0 commit comments

Comments
 (0)