Skip to content

Commit 1c92cc2

Browse files
authored
Allow optional argument data_source_name in postgres-exporter (#1130)
1 parent 3d58bd5 commit 1c92cc2

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

postgres-exporter/main.libsonnet

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ local k = import 'ksonnet-util/kausal.libsonnet';
44
new(
55
name,
66
data_source_uri='$(HOSTNAME):$(PORT)/postgres',
7+
data_source_name='',
78
ssl=true,
89
image='quay.io/prometheuscommunity/postgres-exporter:v0.10.0',
910
):: {
@@ -28,10 +29,18 @@ local k = import 'ksonnet-util/kausal.libsonnet';
2829
1,
2930
[
3031
this.container
31-
// Force DATA_SOURCE_URI to be declared after the variables it references
32-
+ container.withEnvMap({
33-
DATA_SOURCE_URI: data_source_uri + ssl_suffix,
34-
}),
32+
// If data_source_name is not empty, use it instead of data_source_uri
33+
// with variable name DATA_SOURCE_NAME
34+
// Otherwise, use data_source_uri with variable name DATA_SOURCE_URI
35+
+ (
36+
if data_source_name != ''
37+
then container.withEnvMap({
38+
DATA_SOURCE_NAME: data_source_name + ssl_suffix,
39+
})
40+
else container.withEnvMap({
41+
DATA_SOURCE_URI: data_source_uri + ssl_suffix,
42+
})
43+
),
3544
]
3645
),
3746
},

0 commit comments

Comments
 (0)