Skip to content

Commit 0081b2f

Browse files
committed
Quote string variables in conf
1 parent ced51ce commit 0081b2f

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

internal/mode/static/nginx/config/generator_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ func TestGenerate(t *testing.T) {
9595
g.Expect(httpCfg).To(ContainSubstring("upstream"))
9696
g.Expect(httpCfg).To(ContainSubstring("split_clients"))
9797

98-
g.Expect(httpCfg).To(ContainSubstring("endpoint 1.2.3.4:123;"))
99-
g.Expect(httpCfg).To(ContainSubstring("interval 5s;"))
98+
g.Expect(httpCfg).To(ContainSubstring(`endpoint "1.2.3.4:123";`))
99+
g.Expect(httpCfg).To(ContainSubstring(`interval "5s";`))
100100
g.Expect(httpCfg).To(ContainSubstring("batch_size 512;"))
101101
g.Expect(httpCfg).To(ContainSubstring("batch_count 4;"))
102-
g.Expect(httpCfg).To(ContainSubstring("otel_service_name ngf:gw-ns:gw-name:my-name;"))
102+
g.Expect(httpCfg).To(ContainSubstring(`otel_service_name "ngf:gw-ns:gw-name:my-name";`))
103103

104104
g.Expect(files[2].Type).To(Equal(file.TypeRegular))
105105
g.Expect(files[2].Path).To(Equal("/etc/nginx/conf.d/config-version.conf"))

internal/mode/static/nginx/config/telemetry_template.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ package config
22

33
const otelTemplateText = `
44
otel_exporter {
5-
endpoint {{ .Endpoint }};
5+
endpoint "{{ .Endpoint }}";
66
{{- if .Interval }}
7-
interval {{ .Interval }};
7+
interval "{{ .Interval }}";
88
{{- end }}
99
{{- if .BatchSize }}
1010
batch_size {{ .BatchSize }};
@@ -14,9 +14,9 @@ otel_exporter {
1414
{{- end }}
1515
}
1616
17-
otel_service_name {{ .ServiceName }};
17+
otel_service_name "{{ .ServiceName }}";
1818
1919
{{- range $attr := .SpanAttributes }}
20-
otel_span_attr {{ $attr.Key }} {{ $attr.Value }};
20+
otel_span_attr "{{ $attr.Key }}" "{{ $attr.Value }}";
2121
{{- end }}
2222
`

internal/mode/static/nginx/config/telemetry_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ func TestExecuteTelemetry(t *testing.T) {
3333

3434
g := NewWithT(t)
3535
expSubStrings := map[string]int{
36-
"endpoint 1.2.3.4:123;": 1,
37-
"otel_service_name ngf:gw-ns:gw-name:my-name;": 1,
38-
"interval 5s;": 1,
39-
"batch_size 512;": 1,
40-
"batch_count 4;": 1,
41-
"otel_span_attr": 2,
36+
`endpoint "1.2.3.4:123";`: 1,
37+
`otel_service_name "ngf:gw-ns:gw-name:my-name";`: 1,
38+
`interval "5s";`: 1,
39+
"batch_size 512;": 1,
40+
"batch_count 4;": 1,
41+
"otel_span_attr": 2,
4242
}
4343

4444
for expSubStr, expCount := range expSubStrings {

0 commit comments

Comments
 (0)