Skip to content

Commit fc99af2

Browse files
[Common library] Region updates, added resolve function, region aware endpoint lookup. (#2225)
<!-- Thank you for contributing to New Relic's Helm charts. Before you submit this PR we'd like to make sure you are aware of our technical requirements: * https://github.com/newrelic-experimental/helm-charts/blob/master/CONTRIBUTING.md#technical-requirements For a quick overview across what we will look at reviewing your PR, please read our review guidelines: * https://github.com/newrelic-experimental/helm-charts/blob/master/REVIEW_GUIDELINES.md Following our best practices right from the start will accelerate the review process and help get your PR merged quicker. When updates to your PR are requested, please add new commits and do not squash the history. This will make it easier to identify new changes. The PR will be squashed anyways when it is merged. Thanks. For fast feedback, please @-mention maintainers that are listed in the Chart.yaml file. Please make sure you test your changes before you push them. Once pushed, a Github Action will run across your changes and do some initial checks and linting. These checks run very quickly. Please check the results. We would like these checks to pass before we even continue reviewing your changes. --> #### What this PR does / why we need it: #### Which issue this PR fixes Adds support for Japan and GOV regions in region TPL. Talking with DB we decided to make region names more uniform so shortened staging and local to "dev" Which is why we are bumping the chart version to 2.0.0 Digging through this chart it looks like the ONLY thing that regions are used for is to set ULS, which makes sense. There really shouldn't be any changes to our charts other than collection endpoints. So I scraped all of the endpoints in this repo, and created an "endpoint" template that uses the region template to automatically give the right endpoint. I flushed out the JP endpoints using Discovery and to decide the name of each endpoint. Added some helper functions for users who really want to know what region they are in for reasons other than endpoints. Also added some functions to make checking for value overrides in the root and global fields a lot easier. This is probably the number one duplicated code block that we have. So having a function we can call instead of re-writing this logic over and over is a huge boon to our helm charts. #### Special notes for your reviewer: #### Checklist [Place an '[x]' (no spaces) in all applicable fields. Please remove unrelated fields.] - [x] Chart Version bumped - [x] Variables are documented in the README.md - [x] Title of the PR starts with chart name (e.g. `[mychartname]`) # Release Notes to Publish (nr-k8s-otel-collector) If this PR contains changes in `nr-k8s-otel-collector`, please complete the following section. All other charts should ignore this section. <!--BEGIN-RELEASE-NOTES--> ## 🚀 What's Changed * Tell the world about the latest changes in the chart. <!--END-RELEASE-NOTES-->
1 parent 245bef7 commit fc99af2

17 files changed

Lines changed: 799 additions & 68 deletions

.github/workflows/lint_test_charts.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
check_filenames: true
1515
check_hidden: true
1616
skip: ./.git
17-
ignore_words_list: enver,NotIn,aks,commitish
17+
ignore_words_list: enver,NotIn,aks,commitish,NPE,DNE,NAN
1818

1919
lint-test:
2020
name: Lint and test charts

library/CHART-TEMPLATE/Chart.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
dependencies:
22
- name: common-library
33
repository: file://../common-library
4-
version: 1.3.3
5-
digest: sha256:a6cccdb998711673638d38bed3e2406bc1871245eec5a14a054a594bcdaba3a2
6-
generated: "2025-06-03T11:13:13.110324-07:00"
4+
version: 2.0.0
5+
digest: sha256:1ea3dd548c85651d52456ac555b6adf8af0f64d8523341a7f2504e24880fae5a
6+
generated: "2026-04-27T21:18:30.561623-07:00"

library/CHART-TEMPLATE/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 1.3.3
18+
version: 2.0.0
1919

2020
# This is the version number of the application being deployed. This version number should be
2121
# incremented each time you make changes to the application. Versions are not expected to
@@ -25,7 +25,7 @@ appVersion: "1.16.0"
2525

2626
dependencies:
2727
- name: common-library
28-
version: 1.3.3
28+
version: 2.0.0
2929
repository: file://../common-library # We keep this as a file to test things immediately locally/in the pipeline
3030

3131
keywords:
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ include "newrelic.common.naming.fullname" . }}-example-cm-endpoint-lookup
5+
namespace: {{ .Release.Namespace }}
6+
data:
7+
{{/* Otel has endpoints for US, EU, JP, GOV, and STG */}}
8+
otel: "{{- include "newrelic.common.otlp_endpoint" . -}}"
9+
10+
{{/* Some usecases require more than a domain, here's an example where we look up the base domain and append a path to it */}}
11+
endpoint_with_path: "{{- include "newrelic.common.otlp_endpoint" . -}}/v1/supplementary/path"

library/CHART-TEMPLATE/templates/example-cm-region.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,11 @@ metadata:
55
name: {{ include "newrelic.common.naming.fullname" . }}-examples-region
66
namespace: {{ .Release.Namespace }}
77
data:
8-
region: {{ include "newrelic.common.region" . }}
8+
region: "{{ include "newrelic.common.region" . }}"
9+
10+
is_us: "{{ if include "newrelic.common.region.is_us" . }}Yes{{ else }}NO{{ end }}"
11+
is_eu: "{{ if include "newrelic.common.region.is_eu" . }}Yes{{ else }}NO{{ end }}"
12+
is_jp: "{{ if include "newrelic.common.region.is_jp" . }}Yes{{ else }}NO{{ end }}"
13+
is_gov: "{{ if include "newrelic.common.region.is_gov" . }}Yes{{ else }}NO{{ end }}"
14+
is_stg: "{{ if include "newrelic.common.region.is_stg" . }}Yes{{ else }}NO{{ end }}"
15+
is_dev: "{{ if include "newrelic.common.region.is_dev" . }}Yes{{ else }}NO{{ end }}"
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# This is a dummy CM to test the resolve template
2+
# and give examples on how to use it
3+
apiVersion: v1
4+
kind: ConfigMap
5+
metadata:
6+
name: {{ include "newrelic.common.naming.fullname" . }}-examples-cm-resolve
7+
namespace: {{ .Release.Namespace }}
8+
data:
9+
{{/* Using lookup With Default */}}
10+
custom: {{ include "newrelic.common.resolve" (dict "ctx" . "key" "custom" "default" "myDefaultData") -}}
11+
12+
{{/* Look up only will return nothing if value not found */}}
13+
proxy: {{ include "newrelic.common.resolve" (dict "ctx" . "key" "proxy") -}}
14+
15+
{{/* Example of using lookup with custom logic to set default */}}
16+
endpoint: {{ include "newrelic.common.resolve" (dict "ctx" . "key" "endpoint") | default "inline-default" -}}
17+
18+
{{/* Example of using lookup test with a nested two-level path */}}
19+
nested_two_deep: {{ include "newrelic.common.resolve" (dict "ctx" . "key" "nested.value") -}}
20+
21+
{{/* Example of using lookup test with a nested three-level path */}}
22+
nested_three_deep: {{ include "newrelic.common.resolve" (dict "ctx" . "key" "nested.secondLevel.value") -}}
23+
24+
{{/* Example of using lookup with default with a nested path */}}
25+
nested_two_deep_with_default: {{ include "newrelic.common.resolve" (dict "ctx" . "key" "nested.value" "default" "defaultNestedValue") -}}
26+
27+
{{/* Example of looking up a nested path that doesn't exist... (Test that this doesn't cause errors) */}}
28+
nested_value_DNE: {{ include "newrelic.common.resolve" (dict "ctx" . "key" "nested.blah.value.DNE") -}}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
suite: test endpoints tpl
2+
templates:
3+
- templates/example-cm-endpoint-lookup.yaml
4+
release:
5+
name: my-release
6+
namespace: my-namespace
7+
tests:
8+
- it: Should return US endpoint by default
9+
asserts:
10+
- equal:
11+
path: data.otel
12+
value: https://otlp.nr-data.net
13+
14+
- it: Should append path to endpoint
15+
asserts:
16+
- equal:
17+
path: data.endpoint_with_path
18+
value: https://otlp.nr-data.net/v1/supplementary/path
19+
20+
- it: Should return EU endpoint
21+
set:
22+
licenseKey: eu01NotARelLicenceKeyFFFFNRAL
23+
asserts:
24+
- equal:
25+
path: data.otel
26+
value: https://otlp.eu01.nr-data.net
27+
28+
- it: Should return Japan endpoint
29+
set:
30+
licenseKey: jpx1NotARelLicenceKeyFFFFNRAL
31+
asserts:
32+
- equal:
33+
path: data.otel
34+
value: https://otlp.jp.nr-data.net
35+
36+
- it: Should return Gov endpoint
37+
set:
38+
fedramp:
39+
enabled: true
40+
asserts:
41+
- equal:
42+
path: data.otel
43+
value: https://gov-otlp.nr-data.net
44+
45+
- it: Should return staging endpoint
46+
set:
47+
nrStaging: true
48+
asserts:
49+
- equal:
50+
path: data.otel
51+
value: https://staging-otlp.nr-data.net
52+
53+
- it: Should should fail if region supplied that doesn't have an endpoint
54+
set:
55+
region: dev
56+
asserts:
57+
- failedTemplate:
58+
errorMessage: "This chart does not have support for the region provided 'DEV'. Please either supply an override URL via .Values.otlpEndpoint or .Values.global.otlpEndpoint, or set a different region."
59+
60+
61+
- it: Should use override endpoint if provided even if region doesn't have a supported endpoint
62+
set:
63+
otlpEndpoint: https://my-custom-endpoint.com
64+
region: dev
65+
asserts:
66+
- equal:
67+
path: data.otel
68+
value: https://my-custom-endpoint.com

library/CHART-TEMPLATE/tests/cl-images_registry_test.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ release:
66
name: my-release
77
namespace: my-namespace
88
tests:
9-
- it: does not set registry if not specified
9+
- it: Sets docker.io as default registry if no registry set.
1010
asserts:
1111
- equal:
1212
path: spec.template.spec.containers[0].image
13-
value: nginx:1.16.0
13+
value: docker.io/nginx:1.16.0
1414

1515
- it: sets registry if specified in values
1616
set:
@@ -50,7 +50,7 @@ tests:
5050
asserts:
5151
- equal:
5252
path: spec.template.spec.containers[0].image
53-
value: nginx:1.16.0
53+
value: docker.io/nginx:1.16.0
5454

5555
- it: does not break if global.image=null
5656
set:
@@ -59,4 +59,4 @@ tests:
5959
asserts:
6060
- equal:
6161
path: spec.template.spec.containers[0].image
62-
value: nginx:1.16.0
62+
value: docker.io/nginx:1.16.0

library/CHART-TEMPLATE/tests/cl-region.yaml

Lines changed: 155 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ tests:
2020
path: data.region
2121
value: US
2222

23-
- it: Detects an EU license key
23+
- it: Detects EU license key
2424
set:
2525
global: null
2626
region: null
@@ -30,6 +30,16 @@ tests:
3030
path: data.region
3131
value: EU
3232

33+
- it: Detects Japan license key
34+
set:
35+
global: null
36+
region: null
37+
licenseKey: jpxNotARelLicenceKeyFFFFNRAL
38+
asserts:
39+
- equal:
40+
path: data.region
41+
value: JP
42+
3343
- it: Set region (globally)
3444
set:
3545
global:
@@ -47,20 +57,161 @@ tests:
4757
path: data.region
4858
value: EU
4959

60+
- it: Set Japan region (globally)
61+
set:
62+
global:
63+
region: JP
64+
asserts:
65+
- equal:
66+
path: data.region
67+
value: JP
68+
69+
- it: Set Japan region (locally)
70+
set:
71+
region: JP
72+
asserts:
73+
- equal:
74+
path: data.region
75+
value: JP
76+
5077
- it: Overrides global region with the local one
5178
set:
5279
global:
5380
region: EU
54-
region: local
81+
region: DEV
5582
asserts:
5683
- equal:
5784
path: data.region
58-
value: Local
85+
value: DEV
5986

6087
- it: Honors staging flag
6188
set:
6289
nrStaging: true
6390
asserts:
6491
- equal:
6592
path: data.region
66-
value: Staging
93+
value: STG
94+
95+
- it: Honors global staging flag
96+
set:
97+
global.nrStaging: true
98+
asserts:
99+
- equal:
100+
path: data.region
101+
value: STG
102+
103+
- it: Honors fedramp flag
104+
set:
105+
fedramp:
106+
enabled: true
107+
asserts:
108+
- equal:
109+
path: data.region
110+
value: GOV
111+
112+
- it: Honors global fedramp flag
113+
set:
114+
global:
115+
fedramp:
116+
enabled: true
117+
asserts:
118+
- equal:
119+
path: data.region
120+
value: GOV
121+
122+
- it: Convenience Functions work for US
123+
set:
124+
global:
125+
region: US
126+
asserts:
127+
- equal:
128+
path: data
129+
value:
130+
region: US
131+
is_us: Yes
132+
is_eu: NO
133+
is_jp: NO
134+
is_gov: NO
135+
is_stg: NO
136+
is_dev: NO
137+
138+
139+
140+
- it: Convenience Functions work for EU
141+
set:
142+
global:
143+
region: EU
144+
asserts:
145+
- equal:
146+
path: data
147+
value:
148+
region: EU
149+
is_us: NO
150+
is_eu: Yes
151+
is_jp: NO
152+
is_gov: NO
153+
is_stg: NO
154+
is_dev: NO
155+
156+
- it: Convenience Functions work for JP
157+
set:
158+
global:
159+
region: JP
160+
asserts:
161+
- equal:
162+
path: data
163+
value:
164+
region: JP
165+
is_us: NO
166+
is_eu: NO
167+
is_jp: Yes
168+
is_gov: NO
169+
is_stg: NO
170+
is_dev: NO
171+
172+
- it: Convenience Functions work for Gov
173+
set:
174+
fedramp:
175+
enabled: true
176+
asserts:
177+
- equal:
178+
path: data
179+
value:
180+
region: GOV
181+
is_us: NO
182+
is_eu: NO
183+
is_jp: NO
184+
is_gov: Yes
185+
is_stg: NO
186+
is_dev: NO
187+
188+
- it: Convenience Functions work for STG
189+
set:
190+
global:
191+
nrStaging: true
192+
asserts:
193+
- equal:
194+
path: data
195+
value:
196+
region: STG
197+
is_us: NO
198+
is_eu: NO
199+
is_jp: NO
200+
is_gov: NO
201+
is_stg: Yes
202+
is_dev: NO
203+
204+
- it: Convenience Functions work for Dev
205+
set:
206+
region: dev
207+
asserts:
208+
- equal:
209+
path: data
210+
value:
211+
region: DEV
212+
is_us: NO
213+
is_eu: NO
214+
is_jp: NO
215+
is_gov: NO
216+
is_stg: NO
217+
is_dev: Yes

0 commit comments

Comments
 (0)