Skip to content

Commit

Permalink
remove hard to read dictionary merges
Browse files Browse the repository at this point in the history
  • Loading branch information
kang-makes committed Sep 17, 2024
1 parent 2b7ef4d commit 5d0d42e
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,27 +120,27 @@ If you need a list of TODOs, just `grep TODO` on the `values.yaml` and look for

{{- /* Add to config k8s cluster and namespace config */ -}}
{{- $k8s := (dict "cluster_name" (include "newrelic.common.cluster" .) "namespace" .Release.Namespace) -}}
{{- $_ := mustMerge $config (dict "k8s" $k8s) -}}
{{- $config = mustMerge $config (dict "k8s" $k8s) -}}

{{- /* Add opamp if auth enabled */ -}}
{{- if ((.Values.config).auth).enabled -}}
{{- $opamp := (dict "endpoint" (include "newrelic-super-agent.config.endpoints.opamp" .)) -}}

{{- $auth_config := dict "token_url" (include "newrelic-super-agent.config.endpoints.tokenRenewal" .) "provider" "local" "private_key_path" "/etc/newrelic-super-agent/keys/from-secret.key" -}}
{{- $_ := mustMerge $opamp (dict "auth_config" $auth_config) -}}
{{- $opamp = mustMerge $opamp (dict "auth_config" $auth_config) -}}

{{- $_ := mustMerge $config (dict "opamp" $opamp) -}}
{{- $config = mustMerge $config (dict "opamp" $opamp) -}}
{{- end -}}

{{- /* Add subagents to the config */ -}}
{{- $agents := dict -}}
{{- range $subagent, $object := (include "newrelic-super-agent.config.agents.yaml" . | fromYaml) -}}
{{- $_ := mustMerge $agents (dict $subagent (dict "agent_type" $object.type)) -}}
{{- $agents = mustMerge $agents (dict $subagent (dict "agent_type" $object.type)) -}}
{{- end -}}
{{- $_ := mustMerge $config (dict "agents" $agents) -}}
{{- $config = mustMerge $config (dict "agents" $agents) -}}

{{- /* Overwrite $config with everything in `config.superAgent.content` if present */ -}}
{{- $_ := deepCopy (.Values.config.superAgent.content | default dict) | mustMergeOverwrite $config -}}
{{- $config = mustMergeOverwrite $config (deepCopy (((.Values.config).superAgent).content | default dict)) -}}
{{- $config | toYaml -}}
{{- end -}}

Expand Down

0 comments on commit 5d0d42e

Please sign in to comment.