-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[common-library] Add missing features to the common library (NR-281093)…
… (#1463) #### Is this a new chart No #### What this PR does / why we need it: We thought that some of the features that we need for the super-agent would be awesome to have them at `common-library` level. We need the chart to be able to calculate the region (or let the user to specify it) and a new API Key. #### Which issue this PR fixes #### Special notes for your reviewer: To read it easier, I would go commit by commit as I added a new feature with its own documentation on each commit. #### Checklist - [x] Chart Version bumped - [x] Variables are documented in the README.md - [x] Title of the PR starts with chart name (e.g. `[mychartname]`) --------- Co-authored-by: Daniel Budziwojski <[email protected]>
- Loading branch information
1 parent
6798faa
commit e398ef4
Showing
17 changed files
with
491 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
dependencies: | ||
- name: common-library | ||
repository: file://../common-library | ||
version: 1.2.0 | ||
digest: sha256:ca0a371fb6ce46b821593db9949d1942f2fdf40b54df1eff377ac094bc3d78fa | ||
generated: "2024-06-19T10:51:12.685283+02:00" | ||
version: 1.3.0 | ||
digest: sha256:862a49e42a8198a0070eb5ddae2a2d1e535f9e2e8d75e3ec17d722552a0e7c4e | ||
generated: "2024-08-13T16:29:35.296624+02:00" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# This is a dummy CM to test that region is templated and how to use it | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ include "newrelic.common.naming.fullname" . }}-examples-region | ||
namespace: {{ .Release.Namespace }} | ||
data: | ||
region: {{ include "newrelic.common.region" . }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# This is a dummy CM to test what API Key helpers of the common library return | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ include "newrelic.common.naming.fullname" . }}-examples-userkey | ||
namespace: {{ .Release.Namespace }} | ||
data: | ||
userkey-secret-name: {{ include "newrelic.common.userKey.secretName" . }} | ||
userkey-secret-key-name: {{ include "newrelic.common.userKey.secretKeyName" . }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{{- /* Common library will take care of creating User Key' secret or not. */ -}} | ||
{{- include "newrelic.common.userKey.secret" . -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
suite: test region helper | ||
templates: | ||
- templates/example-cm-region.yaml | ||
release: | ||
name: my-release | ||
namespace: my-namespace | ||
tests: | ||
- it: Is US by default | ||
asserts: | ||
- equal: | ||
path: data.region | ||
value: US | ||
|
||
- it: Is US with everything null | ||
set: | ||
global: null | ||
region: null | ||
asserts: | ||
- equal: | ||
path: data.region | ||
value: US | ||
|
||
- it: Detects an EU license key | ||
set: | ||
global: null | ||
region: null | ||
licenseKey: eu01xx77XXXXf1XXXX0bXXXX6aXXXX9eFFFFNRAL | ||
asserts: | ||
- equal: | ||
path: data.region | ||
value: EU | ||
|
||
- it: Set region (globally) | ||
set: | ||
global: | ||
region: EU | ||
asserts: | ||
- equal: | ||
path: data.region | ||
value: EU | ||
|
||
- it: Set region (locally) | ||
set: | ||
region: EU | ||
asserts: | ||
- equal: | ||
path: data.region | ||
value: EU | ||
|
||
- it: Overrides global region with the local one | ||
set: | ||
global: | ||
region: EU | ||
region: local | ||
asserts: | ||
- equal: | ||
path: data.region | ||
value: Local | ||
|
||
- it: Honors staging flag | ||
set: | ||
nrStaging: true | ||
asserts: | ||
- equal: | ||
path: data.region | ||
value: Staging |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
suite: test user key helpers | ||
templates: | ||
- templates/example-cm-userkey.yaml | ||
release: | ||
name: my-release | ||
namespace: my-namespace | ||
tests: | ||
- it: creates secret names for local user key | ||
set: | ||
userKey: local | ||
asserts: | ||
- equal: | ||
path: data.userkey-secret-name | ||
value: my-release-CHART-TEMPLATE-userkey | ||
- equal: | ||
path: data.userkey-secret-key-name | ||
value: userKey | ||
- it: creates secret names for global user key | ||
set: | ||
global: | ||
userKey: local | ||
asserts: | ||
- equal: | ||
path: data.userkey-secret-name | ||
value: my-release-CHART-TEMPLATE-userkey | ||
- equal: | ||
path: data.userkey-secret-key-name | ||
value: userKey | ||
|
||
- it: returns local custom secret names | ||
set: | ||
customUserKeySecretName: local | ||
customUserKeySecretKey: localkey | ||
asserts: | ||
- equal: | ||
path: data.userkey-secret-name | ||
value: local | ||
- equal: | ||
path: data.userkey-secret-key-name | ||
value: localkey | ||
- it: returns global custom secret names | ||
set: | ||
global: | ||
customUserKeySecretName: global | ||
customUserKeySecretKey: globalkey | ||
asserts: | ||
- equal: | ||
path: data.userkey-secret-name | ||
value: global | ||
- equal: | ||
path: data.userkey-secret-key-name | ||
value: globalkey | ||
- it: local secret names override global secret names | ||
set: | ||
customUserKeySecretName: local | ||
customUserKeySecretKey: localkey | ||
global: | ||
customUserKeySecretName: global | ||
customUserKeySecretKey: globalkey | ||
asserts: | ||
- equal: | ||
path: data.userkey-secret-name | ||
value: local | ||
- equal: | ||
path: data.userkey-secret-key-name | ||
value: localkey |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
suite: test user key secret | ||
templates: | ||
- templates/example-userkey-secret.yaml | ||
release: | ||
name: my-release | ||
namespace: my-namespace | ||
tests: | ||
- it: errors if userKey is empty | ||
set: | ||
global: null | ||
userKey: null | ||
asserts: | ||
- failedTemplate: | ||
errorMessage: You must specify a userKey or a customUserKeySecretName containing it | ||
- it: creates secret with local license key | ||
set: | ||
global: null | ||
userKey: local | ||
asserts: | ||
- equal: | ||
path: data.userKey | ||
value: bG9jYWw= # echo -n local | base64 | ||
- it: creates secret with global license key | ||
set: | ||
userKey: null | ||
global: | ||
userKey: global | ||
asserts: | ||
- equal: | ||
path: data.userKey | ||
value: Z2xvYmFs # echo -n global | base64 | ||
- it: local overrides global | ||
set: | ||
userKey: local | ||
global: | ||
userKey: global | ||
asserts: | ||
- equal: | ||
path: data.userKey | ||
value: bG9jYWw= # echo -n local | base64 | ||
|
||
- it: does not create a secret if one is provided locally | ||
set: | ||
userKey: I exist but will be ignored | ||
customUserKeySecretName: foo | ||
asserts: | ||
- hasDocuments: | ||
count: 0 | ||
- it: does not create a secret if one is provided globally | ||
set: | ||
userKey: I exist but will be ignored | ||
global: | ||
customUserKeySecretName: foo | ||
asserts: | ||
- hasDocuments: | ||
count: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.