Skip to content

Commit

Permalink
Quote string variables in conf
Browse files Browse the repository at this point in the history
  • Loading branch information
sjberman committed Apr 24, 2024
1 parent 8e26539 commit 2731246
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions internal/mode/static/nginx/config/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ func TestGenerate(t *testing.T) {
g.Expect(httpCfg).To(ContainSubstring("upstream"))
g.Expect(httpCfg).To(ContainSubstring("split_clients"))

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

g.Expect(files[2].Type).To(Equal(file.TypeRegular))
g.Expect(files[2].Path).To(Equal("/etc/nginx/conf.d/config-version.conf"))
Expand Down
8 changes: 4 additions & 4 deletions internal/mode/static/nginx/config/telemetry_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package config

const otelTemplateText = `
otel_exporter {
endpoint {{ .Endpoint }};
endpoint "{{ .Endpoint }}";
{{- if .Interval }}
interval {{ .Interval }};
interval "{{ .Interval }}";
{{- end }}
{{- if .BatchSize }}
batch_size {{ .BatchSize }};
Expand All @@ -14,9 +14,9 @@ otel_exporter {
{{- end }}
}
otel_service_name {{ .ServiceName }};
otel_service_name "{{ .ServiceName }}";
{{- range $attr := .SpanAttributes }}
otel_span_attr {{ $attr.Key }} {{ $attr.Value }};
otel_span_attr "{{ $attr.Key }}" "{{ $attr.Value }}";
{{- end }}
`
12 changes: 6 additions & 6 deletions internal/mode/static/nginx/config/telemetry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ func TestExecuteTelemetry(t *testing.T) {

g := NewWithT(t)
expSubStrings := map[string]int{
"endpoint 1.2.3.4:123;": 1,
"otel_service_name ngf:gw-ns:gw-name:my-name;": 1,
"interval 5s;": 1,
"batch_size 512;": 1,
"batch_count 4;": 1,
"otel_span_attr": 2,
`endpoint "1.2.3.4:123";`: 1,
`otel_service_name "ngf:gw-ns:gw-name:my-name";`: 1,
`interval "5s";`: 1,
"batch_size 512;": 1,
"batch_count 4;": 1,
"otel_span_attr": 2,
}

for expSubStr, expCount := range expSubStrings {
Expand Down

0 comments on commit 2731246

Please sign in to comment.