Introduce stringify function for integrations (#16140)
Fotis Voutsas committed
Oct 6, 2023 at 11:09 UTC
f69ad3fbcc71f84d83d8418838b531804072a0c5
4 files changed
+14
-4
integrations/gen_integrations.py
+10
@@ -140,9 +140,19 @@ def get_jinja_env():
140
lstrip_blocks=True,
141
)
142
143
+ _jinja_env.globals.update(strfy=strfy)
144
+
145
return _jinja_env
146
147
148
+def strfy(value):
149
+ if not isinstance(value, str):
150
+ return value
151
+
152
+ return ' '.join([v.strip() for v in value.strip().split("\n") if v])
153
+
154
+
155
+
156
def get_category_sets(categories):
157
default = set()
158
valid = set()
integrations/templates/alerts.md
+1
-1
@@ -7,7 +7,7 @@ The following alerts are available:
7
| Alert name | On metric | Description |
8
|:------------|:----------|:------------|
9
[% for alert in entry.alerts %]
10
-| [ [[ alert.name ]] ]([[ alert.link ]]) | [[ alert.metric ]] | [[ alert.info ]] |
10
+| [ [[ strfy(alert.name) ]] ]([[ strfy(alert.link) ]]) | [[ strfy(alert.metric) ]] | [[ strfy(alert.info) ]] |
11
[% endfor %]
12
[% else %]
13
There are no alerts configured by default for this integration.
integrations/templates/metrics.md
+2
-2
@@ -21,7 +21,7 @@ Labels:
21
| Label | Description |
22
|:-----------|:----------------|
23
[% for label in scope.labels %]
24
-| [[ label.name ]] | [[ label.description ]] |
24
+| [[ strfy(label.name) ]] | [[ strfy(label.description) ]] |
25
[% endfor %]
26
[% else %]
27
This scope has no labels.
@@ -34,7 +34,7 @@ Metrics:
34
|:------|:----------|:----|[% for a in entry.metrics.availability %]:---:|[% endfor %]
35
36
[% for metric in scope.metrics %]
37
-| [[ metric.name ]] | [% for d in metric.dimensions %][[ d.name ]][% if not loop.last %], [% endif %][% endfor %] | [[ metric.unit ]] |[% for a in entry.metrics.availability %] [% if not metric.availability|length or a in metric.availability %]•[% else %] [% endif %] |[% endfor %]
37
+| [[ strfy(metric.name) ]] | [% for d in metric.dimensions %][[ strfy(d.name) ]][% if not loop.last %], [% endif %][% endfor %] | [[ strfy(metric.unit) ]] |[% for a in entry.metrics.availability %] [% if not metric.availability|length or a in metric.availability %]•[% else %] [% endif %] |[% endfor %]
38
39
[% endfor %]
40
integrations/templates/setup.md
+1
-1
@@ -65,7 +65,7 @@ There is no configuration file.
65
| Name | Description | Default | Required |
66
|:----|:-----------|:-------|:--------:|
67
[% for item in entry.setup.configuration.options.list %]
68
-| [[ item.name ]] | [[ item.description ]] | [[ item.default ]] | [[ item.required ]] |
68
+| [[ strfy(item.name) ]] | [[ strfy(item.description) ]] | [[ strfy(item.default) ]] | [[ strfy(item.required) ]] |
69
[% endfor %]
70
71
[% for item in entry.setup.configuration.options.list %]