From b1765d03c17e17313f4c90a4d2052baba6cfe6ed Mon Sep 17 00:00:00 2001
From: Adam Gardner <philomory@gmail.com>
Date: Thu, 26 Nov 2020 05:27:14 -1000
Subject: [PATCH] [telegraf-ds] Add option for simple override of TOML config
 file contents (#239)

* Add support for overriding entire TOML config as an escape valve

* Update version number
---
 charts/telegraf-ds/Chart.yaml               |  4 +++-
 charts/telegraf-ds/templates/configmap.yaml |  5 +++++
 charts/telegraf-ds/values.yaml              | 15 +++++++++++++++
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/charts/telegraf-ds/Chart.yaml b/charts/telegraf-ds/Chart.yaml
index fdde1b2e..c33e3d03 100644
--- a/charts/telegraf-ds/Chart.yaml
+++ b/charts/telegraf-ds/Chart.yaml
@@ -1,6 +1,6 @@
 apiVersion: v1
 name: telegraf-ds
-version: 1.0.18
+version: 1.0.19
 appVersion: 1.16
 deprecated: false
 description: Telegraf is an agent written in Go for collecting, processing, aggregating, and writing metrics.
@@ -10,6 +10,8 @@ keywords:
 - timeseries
 - influxdata
 home: https://www.influxdata.com/time-series-platform/telegraf/
+sources:
+  - https://github.com/influxdata/helm-charts/charts/telegraf-ds
 maintainers:
 - name: rawkode
   email: rawkode@influxdata.com
diff --git a/charts/telegraf-ds/templates/configmap.yaml b/charts/telegraf-ds/templates/configmap.yaml
index b08f4af4..d87c01b1 100644
--- a/charts/telegraf-ds/templates/configmap.yaml
+++ b/charts/telegraf-ds/templates/configmap.yaml
@@ -5,6 +5,10 @@ metadata:
   labels:
     {{- include "telegraf.labels" . | nindent 4 }}
 data:
+{{- if .Values.override_config.toml }}
+  telegraf.conf: |+
+    {{- .Values.override_config.toml | nindent 4 }}
+{{- else }}
   telegraf.conf: |+
     {{ template "global_tags" .Values.config.global_tags }}
     {{ template "agent" .Values.config.agent }}
@@ -37,3 +41,4 @@ data:
     url = "https://$HOSTIP:10250"
     bearer_token = "/run/secrets/kubernetes.io/serviceaccount/token"
     insecure_skip_verify = true
+{{- end }}
\ No newline at end of file
diff --git a/charts/telegraf-ds/values.yaml b/charts/telegraf-ds/values.yaml
index 7ada355c..ac1c5ceb 100644
--- a/charts/telegraf-ds/values.yaml
+++ b/charts/telegraf-ds/values.yaml
@@ -65,6 +65,21 @@ serviceAccount:
 ## Ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/
 # priorityClassName: system-node-critical
 
+override_config:
+  toml: ~
+  # Provide a literal TOML config
+  # toml: |+
+  #   [global_tags]
+  #     foo = "bar"
+  #   [agent]
+  #     interval = "10s"
+  #   [[inputs.mem]]
+  #   [[outputs.influxdb_v2]]
+  #     urls           = ["https://us-west-2-1.aws.cloud2.influxdata.com"]
+  #     bucket         = "data"
+  #     organization   = "OurCompany"
+  #     token          = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+
 ## Exposed telegraf configuration
 ## ref: https://docs.influxdata.com/telegraf/v1.13/administration/configuration/
 config: