From 3c0928f0a2b9d67aad21947561f034fee37dfb0c Mon Sep 17 00:00:00 2001 From: Christian Richter Date: Thu, 5 May 2022 13:24:42 +0200 Subject: [PATCH 1/2] fix linewrap --- docs/helpers/adoc-generator.go.tmpl | 7 ++++--- docs/templates/ADOC.tmpl | 5 ++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/helpers/adoc-generator.go.tmpl b/docs/helpers/adoc-generator.go.tmpl index 07e29c8ced..73e7ac5cc8 100644 --- a/docs/helpers/adoc-generator.go.tmpl +++ b/docs/helpers/adoc-generator.go.tmpl @@ -15,7 +15,7 @@ import ( {{- end}}) type ConfigField struct { - Name string + EnvVars []string DefaultValue string Type string Description string @@ -86,8 +86,9 @@ func GetAnnotatedVariables(s interface{}) []ConfigField { if !ok { continue } - v := fmt.Sprintf("%v", value.Interface()) - fields = append(fields, ConfigField{Name: strings.ReplaceAll(env, ";", " +\n"), DefaultValue: v, Description: desc, Type: value.Type().Name()}) + v := fmt.Sprintf("%v", value.Interface()) + td := strings.Split(env, ";") + fields = append(fields, ConfigField{EnvVars: td, DefaultValue: v, Description: desc, Type: value.Type().Name()}) case reflect.Ptr: // PolicySelectors in the Proxy are being skipped atm // they are not configurable via env vars, if that changes diff --git a/docs/templates/ADOC.tmpl b/docs/templates/ADOC.tmpl index 4c01386ddb..03633fa07c 100644 --- a/docs/templates/ADOC.tmpl +++ b/docs/templates/ADOC.tmpl @@ -8,7 +8,10 @@ | Description {{- range .Fields}} -| `{{.Name}}` +{{ $numVars := len .EnvVars }} +| {{- range $i, $value := .EnvVars }}{{- if $i }} +{{ end }} +`{{- $value }}` +{{- end }} | {{.Type}} | {{.DefaultValue}} | {{.Description}} From 1e8fe52b3a37a60a7aeb1a0839250ad8082adafd Mon Sep 17 00:00:00 2001 From: Christian Richter Date: Thu, 5 May 2022 13:35:56 +0200 Subject: [PATCH 2/2] fix unescaped default values Signed-off-by: Christian Richter --- docs/helpers/environment-variable-docs-generator.go.tmpl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/helpers/environment-variable-docs-generator.go.tmpl b/docs/helpers/environment-variable-docs-generator.go.tmpl index bf640ec058..c2cac9c7f8 100644 --- a/docs/helpers/environment-variable-docs-generator.go.tmpl +++ b/docs/helpers/environment-variable-docs-generator.go.tmpl @@ -2,6 +2,7 @@ package main import ( "fmt" + "html" "io/ioutil" "log" "os" @@ -76,7 +77,7 @@ func GetAnnotatedVariables(s interface{}) []ConfigField { continue } v := fmt.Sprintf("%v", value.Interface()) - fields = append(fields, ConfigField{Name: strings.ReplaceAll(env, ";", "
"), DefaultValue: v, Description: desc, Type: value.Type().Name()}) + fields = append(fields, ConfigField{Name: strings.ReplaceAll(env, ";", "
"), DefaultValue: html.EscapeString(strings.Replace(v, "|", "\\|", -1)), Description: desc, Type: value.Type().Name()}) case reflect.Ptr: // PolicySelectors in the Proxy are being skipped atm // they are not configurable via env vars, if that changes