Files
otel-demo/chart/templates/_pod.tpl
Scaffolder 92edf90fd9
Some checks failed
CI Pipeline / Build and Test (push) Successful in 4s
Security Scanning / Trivy — Filesystem & Dependency Scan (push) Failing after 7s
Security Scanning / Gitleaks — Secret Scan (push) Failing after 7s
Security Scanning / Security Summary (push) Failing after 3s
Build and Publish TechDocs / build-and-publish (push) Successful in 1m2s
initial commit
Change-Id: I8e318861a258686ddc53dda08858f74c573a6520
2026-04-02 13:07:28 +00:00

64 lines
2.0 KiB
Smarty

{{/*
Get Pod Env
- Merges default environment variables (if used) with component environment variables.
- If using defaults, will pull out OTEL_RESOURCE_ATTRIBUTES from the list to be reused later.
- An environment variable named OTEL_RESOURCE_ATTRIBUTES_EXTRA will have its value appended to the value of the
OTEL_RESOURCE_ATTRIBUTES environment variable if it exists.
- The OTEL_RESOURCES_ATTRIBUTES environment variable will typically use Kubernetes environment variable expansion and
should be last.
*/}}
{{- define "otel-demo.pod.env" -}}
{{- $resourceAttributesEnv := dict }}
{{- $allEnvs := list }}
{{- if .useDefault.env }}
{{- $defaultEnvs := include "otel-demo.envOverriden" (dict "env" .defaultValues.env "envOverrides" .defaultValues.envOverrides) | mustFromJson }}
{{- range $defaultEnvs }}
{{- if eq .name "OTEL_RESOURCE_ATTRIBUTES" }}
{{- $resourceAttributesEnv = . }}
{{- else }}
{{- $allEnvs = append $allEnvs . }}
{{- end }}
{{- end }}
{{- end }}
{{- if or .env .envOverrides }}
{{- $localEnvs := include "otel-demo.envOverriden" . | mustFromJson }}
{{- range $localEnvs }}
{{- if eq .name "OTEL_RESOURCE_ATTRIBUTES" }}
{{- $resourceAttributesEnv = . }}
{{- else if and $resourceAttributesEnv (eq .name "OTEL_RESOURCE_ATTRIBUTES_EXTRA") }}
{{- $newValue := (printf "%s,%s" (get $resourceAttributesEnv "value") .value) }}
{{- $resourceAttributesEnv = dict "name" "OTEL_RESOURCE_ATTRIBUTES" "value" $newValue }}
{{- else }}
{{- $allEnvs = append $allEnvs . }}
{{- end }}
{{- end }}
{{- end }}
{{- if $resourceAttributesEnv }}
{{- $allEnvs = append $allEnvs $resourceAttributesEnv }}
{{- end }}
{{- tpl (toYaml $allEnvs) . }}
{{- end }}
{{/*
Get Pod ports
*/}}
{{- define "otel-demo.pod.ports" -}}
{{- if .ports }}
{{- range $port := .ports }}
- containerPort: {{ $port.value }}
name: {{ $port.name}}
{{- end }}
{{- end }}
{{- if .service }}
{{- if .service.port }}
- containerPort: {{.service.port}}
name: service
{{- end }}
{{- end }}
{{- end }}