Skip to content

Commit

Permalink
Allow both YAML string and objects to get passed in for OTEL config. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jefchien authored Jan 24, 2025
1 parent fa47d45 commit 9312162
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions charts/amazon-cloudwatch-observability/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,17 @@ Helper function to modify customer supplied agent config if ContainerInsights or
{{/*
Helper function to modify cloudwatch-agent YAML config
*/}}
{{- define "cloudwatch-agent.modify-yaml-config" -}}
{{- define "cloudwatch-agent.modify-otel-config" -}}
{{- $configCopy := deepCopy .OtelConfig }}
{{- if kindIs "string" $configCopy }}
{{- $configCopy = fromYaml $configCopy }}
{{- end }}

{{- range $name, $component := $configCopy }}
{{- if $component -}}
{{- if and $component (kindIs "map" $component) }}
{{- range $key, $value := $component }}
{{- if (and (quote $value | empty) (not (hasKey $component $key))) }}
{{- $component = set $component $key (dict) }}
{{- if eq $value nil }}
{{- $_ := set $component $key dict }}
{{- end -}}
{{- end }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ spec:
config: {{ include "cloudwatch-agent.modify-config" (merge (dict "Config" $agent.defaultConfig) $ ) }}
{{- end }}
{{- if $agent.otelConfig }}
otelConfig: {{ include "cloudwatch-agent.modify-yaml-config" (merge (dict "OtelConfig" $agent.otelConfig) . ) }}
otelConfig: {{ include "cloudwatch-agent.modify-otel-config" (merge (dict "OtelConfig" $agent.otelConfig) . ) }}
{{- end }}
{{- if $agent.prometheus.config }}
prometheus:
Expand Down

0 comments on commit 9312162

Please sign in to comment.