Skip to content

Commit cedaf2d

Browse files
committed
improve regions handling logic to allow override region specific settings without setting region to custom
1 parent 3880ed7 commit cedaf2d

File tree

3 files changed

+49
-9
lines changed

3 files changed

+49
-9
lines changed

charts/shield/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ maintainers:
1313
- name: mavimo
1414
1515
type: application
16-
version: 1.3.1
16+
version: 1.3.2
1717
appVersion: "1.0.0"

charts/shield/templates/common/_regions.tpl

+7-7
Original file line numberDiff line numberDiff line change
@@ -180,16 +180,16 @@
180180

181181
{{- define "common.collector_endpoint" }}
182182
{{- $regions := fromYaml (include "common.regions" .) }}
183-
{{- if ne "custom" .Values.sysdig_endpoint.region }}
184-
{{- get (get $regions .Values.sysdig_endpoint.region) "collector_endpoint" }}
183+
{{- if not .Values.sysdig_endpoint.collector.host }}
184+
{{- get (get $regions .Values.sysdig_endpoint.region) "collector_endpoint" }}
185185
{{- else }}
186186
{{- .Values.sysdig_endpoint.collector.host }}
187187
{{- end }}
188188
{{- end }}
189189

190190
{{- define "common.monitor_api_endpoint" }}
191191
{{- $regions := fromYaml (include "common.regions" .) }}
192-
{{- if hasKey $regions .Values.sysdig_endpoint.region }}
192+
{{- if not .Values.sysdig_endpoint.api_url }}
193193
{{- get (get $regions .Values.sysdig_endpoint.region) "monitor_api_endpoint" }}
194194
{{- else }}
195195
{{- .Values.sysdig_endpoint.api_url }}
@@ -198,18 +198,18 @@
198198

199199
{{- define "common.secure_api_endpoint" }}
200200
{{- $regions := fromYaml (include "common.regions" .) }}
201-
{{- if ne "custom" .Values.sysdig_endpoint.region }}
201+
{{- if not .Values.sysdig_endpoint.api_url }}
202202
{{- get (get $regions .Values.sysdig_endpoint.region) "secure_api_endpoint" }}
203203
{{- else }}
204-
{{- .Values.sysdig_endpoint.api_url }}
204+
{{- .Values.sysdig_endpoint.api_url }}
205205
{{- end }}
206206
{{- end }}
207207

208208
{{- define "common.secure_ui" }}
209209
{{- $regions := fromYaml (include "common.regions" .) }}
210-
{{- if ne "custom" .Values.sysdig_endpoint.region }}
210+
{{- if not .Values.sysdig_endpoint.api_url }}
211211
{{- get (get $regions .Values.sysdig_endpoint.region) "secure_ui" }}
212212
{{- else }}
213-
{{- .Values.sysdig_endpoint.api_url}}
213+
{{- .Values.sysdig_endpoint.api_url }}
214214
{{- end }}
215215
{{- end }}

charts/shield/tests/common/regions_test.yaml

+41-1
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,59 @@ tests:
1111
set:
1212
sysdig_endpoint:
1313
region: "eu1"
14+
api_url:
15+
collector:
16+
host:
17+
port:
1418
asserts:
1519
- matchRegex:
1620
path: data["dragent.yaml"]
1721
pattern: |
1822
collector: ingest-eu1.app.sysdig.com
19-
collector_port: 6443
2023
2124
- it: API endpoint validation
2225
set:
2326
sysdig_endpoint:
2427
region: "us1"
28+
api_url:
29+
collector:
30+
host:
31+
port:
2532
asserts:
2633
- matchRegex:
2734
path: data["dragent.yaml"]
2835
pattern: |
2936
sysdig_api_endpoint: secure.sysdig.com
37+
38+
- it: Collector and API endpoint validation when collector host and port set, but region is not custom and api_url is not set.
39+
set:
40+
cluster_config:
41+
name: test-cluster
42+
sysdig_endpoint:
43+
region: "us2"
44+
collector:
45+
host: ingest-alt-us2.app.sysdig.com
46+
port: 443
47+
api_url:
48+
asserts:
49+
- matchRegex:
50+
path: data["dragent.yaml"]
51+
pattern: |
52+
collector: ingest-alt-us2.app.sysdig.com
53+
collector_port: 443
54+
- matchRegex:
55+
path: data["dragent.yaml"]
56+
pattern: |
57+
sysdig_api_endpoint: us2.app.sysdig.com
58+
59+
- it: Collector host, port and API endpoint validation when region is custom.
60+
asserts:
61+
- matchRegex:
62+
path: data["dragent.yaml"]
63+
pattern: |
64+
collector: example.com
65+
collector_port: 6443
66+
- matchRegex:
67+
path: data["dragent.yaml"]
68+
pattern: |
69+
sysdig_api_endpoint: https://www.example.com

0 commit comments

Comments
 (0)