Code Monkey home page Code Monkey logo

Comments (2)

sciurus avatar sciurus commented on July 18, 2024

My read of https://github.com/influxdata/tick-charts/blob/master/telegraf-s/templates/_helpers.tpl#L94-L175 is that it's essentially duplicated twice in order to handle multiple levels of nesting.

I.E. if I set

    config:
      inputs:
        defaultdisk:
          disk:
            tagpass:
                fstype:
                    - ext4
                foo:
                    bar:
                        - baz

then change the helper to

+++ b/libs/influx/k8s/charts/telegraf/templates/_helpers.tpl
@@ -95,7 +95,7 @@ We truncate at 24 chars because some Kubernetes name fields are limited to this
 {{- range $inputIdx, $configObject := . -}}
     {{- range $input, $config := . -}}
 
-    [[inputs.{{- $input }}]]
+    [[FIRSTinputs.{{- $input }}]]
     {{- if $config -}}
     {{- $tp := typeOf $config -}}
     {{- if eq $tp "map[string]interface {}" -}}
@@ -139,7 +139,7 @@ We truncate at 24 chars because some Kubernetes name fields are limited to this
       ]
           {{- end }}
           {{- if eq $tp "map[string]interface {}" }}
-      [[inputs.{{ $input }}.{{ $key }}]]
+      [[SECONDinputs.{{ $input }}.{{ $key }}]]
             {{- range $k, $v := $value }}
               {{- $tps := typeOf $v }}
               {{- if eq $tps "string" }}
@@ -160,7 +160,7 @@ We truncate at 24 chars because some Kubernetes name fields are limited to this
         ]
               {{- end }}
               {{- if eq $tps "map[string]interface {}"}}
-        [[inputs.{{ $input }}.{{ $key }}.{{ $k }}]]
+        [[THIRDinputs.{{ $input }}.{{ $key }}.{{ $k }}]]
                 {{- range $foo, $bar := $v }}
             {{ $foo }} = {{ $bar | quote }}
                 {{- end }}
@@ -172,4 +172,4 @@ We truncate at 24 chars because some Kubernetes name fields are limited to this

and render it I get the TOML

    [[FIRSTinputs.disk]]
      [[SECONDinputs.disk.tagpass]]
        [[THIRDinputs.disk.tagpass.foo]]
            bar = "[baz]"
        fstype = [
            "ext4",
        ]

(The way baz is rendered there is unexpected, but that tangential to what I'm after)

I guess the additional levels use [[in order to support plugins like postgresql_extensible, where you could have miltiple[[inputs.postgresql_extensible.query]] inside [[inputs.postgresql_extensible]]

The only fix that comes to my mind is to make this even more comples by adding some logic at https://github.com/influxdata/tick-charts/blob/master/telegraf-s/templates/_helpers.tpl#L141-L142 to check the key name against namepass, namedrop, tagpass, and tagdrop and use [] if they match and [[]] if they don't.

from tick-charts.

sciurus avatar sciurus commented on July 18, 2024

I've solved our immediate issue by this diff to our fork of the chart:

diff --git a/libs/influx/k8s/charts/telegraf/templates/_helpers.tpl b/libs/influx/k8s/charts/telegraf/templates/_helpers.tpl
index 93ace660..322bfd60 100755
--- a/libs/influx/k8s/charts/telegraf/templates/_helpers.tpl
+++ b/libs/influx/k8s/charts/telegraf/templates/_helpers.tpl
@@ -139,7 +139,11 @@ We truncate at 24 chars because some Kubernetes name fields are limited to this
       ]
           {{- end }}
           {{- if eq $tp "map[string]interface {}" }}
+            {{- if eq $key "tagpass" }}
+      [inputs.{{ $input }}.{{ $key }}]
+            {{- else }}
       [[inputs.{{ $input }}.{{ $key }}]]
+            {{- end }}
             {{- range $k, $v := $value }}
               {{- $tps := typeOf $v }}
               {{- if eq $tps "string" }}
@@ -172,4 +176,4 @@ We truncate at 24 chars because some Kubernetes name fields are limited to this

If these charts are still maintained, I'm happy to sign a CLA and collaborate on a more general fix.

from tick-charts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.