From 88d0c1e9def5f4bcb9ada76a77252e73db7855a5 Mon Sep 17 00:00:00 2001 From: Pete Wall Date: Tue, 4 Jun 2024 13:32:46 -0400 Subject: [PATCH] Always call tpl outside of with blocks to preserve backwards compatibility Signed-off-by: Pete Wall --- charts/k8s-monitoring/templates/_configs.tpl | 6 +++--- .../templates/alloy_config/_cluster_events.alloy.txt | 6 ++++-- .../templates/alloy_config/_operator_objects.txt | 2 +- .../templates/alloy_config/_pod_logs_processor.alloy.txt | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/charts/k8s-monitoring/templates/_configs.tpl b/charts/k8s-monitoring/templates/_configs.tpl index 359093a25e..a78e3f45cc 100644 --- a/charts/k8s-monitoring/templates/_configs.tpl +++ b/charts/k8s-monitoring/templates/_configs.tpl @@ -96,7 +96,7 @@ {{- include "alloy.config.logging" .Values.alloy.logging}} {{- if .Values.extraConfig }} - {{- tpl .Values.extraConfig . | indent 0 }} + {{- tpl .Values.extraConfig $ | indent 0 }} {{- end }} {{- end -}} @@ -107,7 +107,7 @@ {{- include "alloy.config.logging" (index .Values "alloy-events").logging }} {{- if .Values.logs.cluster_events.extraConfig }} - {{- tpl .Values.logs.cluster_events.extraConfig . | indent 0 }} + {{- tpl .Values.logs.cluster_events.extraConfig $ | indent 0 }} {{- end }} {{- end -}} @@ -120,7 +120,7 @@ {{- include "alloy.config.logging" (index .Values "alloy-logs").logging }} {{- if .Values.logs.extraConfig }} - {{- tpl .Values.logs.extraConfig . | indent 0 }} + {{- tpl .Values.logs.extraConfig $ | indent 0 }} {{- end }} {{- end -}} diff --git a/charts/k8s-monitoring/templates/alloy_config/_cluster_events.alloy.txt b/charts/k8s-monitoring/templates/alloy_config/_cluster_events.alloy.txt index f5473447c0..46609075b0 100644 --- a/charts/k8s-monitoring/templates/alloy_config/_cluster_events.alloy.txt +++ b/charts/k8s-monitoring/templates/alloy_config/_cluster_events.alloy.txt @@ -13,11 +13,13 @@ loki.source.kubernetes_events "cluster_events" { } loki.process "cluster_events" { -{{- if .extraStageBlocks }} -{{ tpl .extraStageBlocks . | indent 2 }} +{{- end }} {{/* Avoid calling tpl inside of a with block, makes for better backwards compatibility */}} +{{- if .Values.logs.cluster_events.extraStageBlocks }} +{{ tpl .Values.logs.cluster_events.extraStageBlocks $ | indent 2 }} {{- end }} forward_to = [ loki.process.logs_service.receiver, +{{- with .Values.logs.cluster_events }} {{- if .logToStdout }} loki.echo.cluster_events.receiver, {{- end }} diff --git a/charts/k8s-monitoring/templates/alloy_config/_operator_objects.txt b/charts/k8s-monitoring/templates/alloy_config/_operator_objects.txt index 7eb0989862..5333a55d22 100644 --- a/charts/k8s-monitoring/templates/alloy_config/_operator_objects.txt +++ b/charts/k8s-monitoring/templates/alloy_config/_operator_objects.txt @@ -149,7 +149,7 @@ loki.source.podlogs "podlogs_objects" { loki.process "podlogs_objects" { {{- if .Values.logs.podLogsObjects.extraStageBlocks }} -{{ tpl .Values.logs.podLogsObjects.extraStageBlocks . | indent 2 }} +{{ tpl .Values.logs.podLogsObjects.extraStageBlocks $ | indent 2 }} {{- end }} forward_to = [loki.process.logs_service.receiver] } diff --git a/charts/k8s-monitoring/templates/alloy_config/_pod_logs_processor.alloy.txt b/charts/k8s-monitoring/templates/alloy_config/_pod_logs_processor.alloy.txt index 234e13cbeb..a4b9ba30bb 100644 --- a/charts/k8s-monitoring/templates/alloy_config/_pod_logs_processor.alloy.txt +++ b/charts/k8s-monitoring/templates/alloy_config/_pod_logs_processor.alloy.txt @@ -50,7 +50,7 @@ loki.process "pod_logs" { } {{- if .Values.logs.pod_logs.extraStageBlocks }} -{{ tpl .Values.logs.pod_logs.extraStageBlocks . | indent 2 }} +{{ tpl .Values.logs.pod_logs.extraStageBlocks $ | indent 2 }} {{ end }} forward_to = [loki.process.logs_service.receiver] }