-
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.
support staging and licenseKey on the config
- Loading branch information
1 parent
8251ec6
commit 7ec3d4b
Showing
7 changed files
with
139 additions
and
38 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,5 +1,5 @@ | ||
config: | ||
opamp: | ||
endpoint: https://opamp.service.newrelic.com/v1/opamp | ||
headers: | ||
api-key: 1234567890abcdef1234567890abcdef12345678 | ||
global: | ||
licenseKey: 1234567890abcdef1234567890abcdef12345678 | ||
|
||
# The agent is going to test that is able to call OpAmp service so we set a valid server to connect to. | ||
nrStaging: true |
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,22 +1,72 @@ | ||
{{- /* | ||
`newrelic-super-agent.config` builds the configuration from config on the values and add more config options like | ||
Return the name of the configMap holding the Super Agent's config. Defaults to release's fill name suffiexed with "-config" | ||
*/ -}} | ||
{{- define "newrelic-super-agent.config.name" -}} | ||
{{- .Values.config.name | default (include "newrelic.common.naming.truncateToDNSWithSuffix" ( dict "name" (include "newrelic.common.naming.fullname" .) "suffix" "config" )) -}} | ||
{{- end -}} | ||
|
||
|
||
{{- /* | ||
Return the key name of the configMap holding the Super Agent's config. Defaults to "config.yaml" | ||
*/ -}} | ||
{{- define "newrelic-super-agent.config.key" -}} | ||
{{- .Values.config.key | default "config.yaml" -}} | ||
{{- end -}} | ||
{{- /* | ||
This function simply templates the default configuration for the agent. | ||
*/ -}} | ||
{{- define "newrelic-super-agent.config.defaultConfig" -}} | ||
opamp: | ||
endpoint: COMPLETE-ME | ||
headers: | ||
api-key: COMPLETE-ME | ||
{{- end -}} | ||
{{- /* | ||
Builds the configuration from config on the values and add more config options like | ||
cluster name, licenses, and custom attributes | ||
*/ -}} | ||
{{- define "newrelic-super-agent.config" -}} | ||
{{- define "newrelic-super-agent.config.content" -}} | ||
{{- /* | ||
TODO: | ||
This snippet should execute always to block all unsupported features from the common-lirary that are not yet supported | ||
by this chart. | ||
There are a lot of TODOs to be made in this chart yet and some of them are going to impact the YAML that holds the | ||
config. | ||
TODO: Remove this file when the Super Agent supports licensekey as an envVar. | ||
*/ -}} | ||
{{ $licenseKey := include "newrelic.common.license._licenseKey" . }} | ||
{{- if or (include "newrelic.common.license._customSecretName" .) (include "newrelic.common.license._customSecretKey" .) -}} | ||
{{- fail "Common library supports setting an external custom secret for the license but the super agent still does not support the license by an env var. You must specify a .licenseKey or .global.licenseKey" -}} | ||
{{- end -}} | ||
{{- if not $licenseKey -}} | ||
{{- fail "You must specify .licenseKey or .global.licenseKey" -}} | ||
{{- end -}} | ||
This is the helper that templates the config. For this iteration we simply copy the `config` object from the values | ||
and template it in the config map. | ||
{{- /* | ||
TODO: There are a lot of TODOs to be made in this chart yet and some of them are going to impact the YAML that holds | ||
the config. | ||
If you need a list of TODOs, just `grep TODO` on the `values.yaml` and look for things that are yet to be implemented. | ||
*/ -}} | ||
{{- $config := fromYaml (include "newrelic-super-agent.config.defaultConfig" .) -}} | ||
{{- if .Values.config.content -}} | ||
{{- $_ := deepCopy .Values.config.content | mustMergeOverwrite $config -}} | ||
{{- end -}} | ||
{{- if .Values.config -}} | ||
{{- .Values.config | toYaml -}} | ||
{{- if include "newrelic.common.fedramp.enabled" . -}} | ||
{{- fail "FedRAMP is not supported yet" -}}{{- /* TODO: Add FedRamp support */ -}} | ||
{{- else if include "newrelic.common.nrStaging" . -}} | ||
{{- $_ := set $config.opamp "endpoint" "https://opamp.staging-service.newrelic.com/v1/opamp" -}} | ||
{{- else -}} | ||
{{- /* TODO: Is this the prod URL? */ -}} | ||
{{- $_ := set $config.opamp "endpoint" "https://opamp.service.newrelic.com/v1/opamp" -}} | ||
{{- end -}} | ||
{{- /* We have to use common library internals because the agent does not support envvars yet */ -}} | ||
{{- /* TODO: Remove this when the sa supports licenseKeys from envVars */ -}} | ||
{{- $_ := set $config.opamp.headers "api-key" $licenseKey -}} | ||
{{- $config | toYaml -}} | ||
{{- end -}} |
12 changes: 5 additions & 7 deletions
12
charts/super-agent-deployment/templates/configmap-superagent-config.yaml
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,15 +1,13 @@ | ||
{{- $name := include "newrelic.common.naming.truncateToDNSWithSuffix" ( dict "name" (include "newrelic.common.naming.fullname" .) "suffix" "config" ) -}} | ||
{{- $namespace := .Release.Namespace -}} | ||
{{- with ( include "newrelic-super-agent.config" . ) -}} | ||
{{- if .Values.config.create -}} | ||
--- | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ $name }} | ||
namespace: {{ $namespace }} | ||
name: {{ include "newrelic-super-agent.config.name" . }} | ||
namespace: {{ .Release.Namespace }} | ||
labels: | ||
{{- include "newrelic.common.labels" $ | nindent 4 }} | ||
apiVersion: v1 | ||
data: | ||
config.yaml: | | ||
{{- . | nindent 4 }} | ||
{{ include "newrelic-super-agent.config.key" . }}: | | ||
{{- include "newrelic-super-agent.config.content" . | nindent 4 }} | ||
{{- end }} |
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,36 @@ | ||
suite: licenseKey temporary tests | ||
# These tests are to test that a missing licenseKey actually aborts templating the chart. | ||
# This should be something that the common-library should do, but the common library does | ||
# it while templating the secret with the license to be used as a envVar. | ||
# As the super agent does not support it as a envvar (yet), we added it directly on the | ||
# configuration file. The consequence is that the chart is able to template without | ||
# license. | ||
# TODO: Remove this file when the Super Agent supports licensekey as an envVar. | ||
templates: | ||
- templates/configmap-superagent-config.yaml | ||
release: | ||
name: my-release | ||
namespace: my-namespace | ||
tests: | ||
- it: Empty licenses abort the template | ||
set: | ||
global: | ||
licenseKey: "" | ||
licenseKey: "" | ||
asserts: | ||
- failedTemplate: | ||
errorMessage: You must specify .licenseKey or .global.licenseKey | ||
- it: Using custom secret abort the template | ||
set: | ||
global: | ||
customSecretName: non-empty | ||
asserts: | ||
- failedTemplate: | ||
errorMessage: Common library supports setting an external custom secret for the license but the super agent still does not support the license by an env var. You must specify a .licenseKey or .global.licenseKey | ||
- it: Using custom secret abort the template | ||
set: | ||
global: | ||
customSecretLicenseKey: non-empty | ||
asserts: | ||
- failedTemplate: | ||
errorMessage: Common library supports setting an external custom secret for the license but the super agent still does not support the license by an env var. You must specify a .licenseKey or .global.licenseKey |
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