From 8975d413efb9127b799c04002d2d62b627055e7a Mon Sep 17 00:00:00 2001 From: Christian Richter Date: Fri, 19 Jul 2024 09:08:57 +0200 Subject: [PATCH 1/5] add IntroductionVersion to adoc output Signed-off-by: Christian Richter --- docs/helpers/templates/adoc-generator.go.tmpl | 29 +++++++++++-------- docs/templates/ADOC.tmpl | 3 ++ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/docs/helpers/templates/adoc-generator.go.tmpl b/docs/helpers/templates/adoc-generator.go.tmpl index 74e185c566..a151085205 100644 --- a/docs/helpers/templates/adoc-generator.go.tmpl +++ b/docs/helpers/templates/adoc-generator.go.tmpl @@ -19,12 +19,13 @@ import ( // ConfigField is the representation of one configuration field type ConfigField struct { - EnvVars []string - DefaultValue string - Type string - Description string - VersionInfo string - DeprecationLink string + EnvVars []string + DefaultValue string + IntroductionVersion string + Type string + Description string + VersionInfo string + DeprecationLink string } // DeprecationField holds information about deprecation @@ -37,11 +38,12 @@ type DeprecationField struct { // EnvVar holds information about one envvar type EnvVar struct { - Name string - DefaultValue string - Type string - Description string - Services []string + Name string + IntroductionVersion string + DefaultValue string + Type string + Description string + Services []string } type templateData struct { @@ -103,6 +105,7 @@ func main() { } else { all[e] = EnvVar{ Name: e, + IntroductionVersion: f.IntroductionVersion, Description: f.Description, Type: f.Type, DefaultValue: f.DefaultValue, @@ -153,7 +156,7 @@ func main() { "Description": env.Description, "DefaultValue": env.DefaultValue, "Type": env.Type, - }) + }) } } @@ -198,6 +201,7 @@ func GetAnnotatedVariables(s interface{}, timestamp string) ([]ConfigField, []De if !ok { continue } + introductionVersion, _ := field.Tag.Lookup("introductionVersion") deprecationVersion, _ := field.Tag.Lookup("deprecationVersion") removalVersion, _ := field.Tag.Lookup("removalVersion") deprecationInfo, _ := field.Tag.Lookup("deprecationInfo") @@ -223,6 +227,7 @@ func GetAnnotatedVariables(s interface{}, timestamp string) ([]ConfigField, []De fields = append(fields, ConfigField{ EnvVars: td, + IntroductionVersion: introductionVersion, DefaultValue: v, Description: desc, Type: typeName, diff --git a/docs/templates/ADOC.tmpl b/docs/templates/ADOC.tmpl index 99d6921323..a9b7278d43 100644 --- a/docs/templates/ADOC.tmpl +++ b/docs/templates/ADOC.tmpl @@ -34,6 +34,7 @@ endif::[] [width="100%",cols="~,~,~,~",options="header"] |=== | Name +| IV | Type | Default Value | Description @@ -46,6 +47,8 @@ a| {{- range $i, $value := .EnvVars }}{{- if $i }} + {{- end }} + {{ .DeprecationLink }} a| [subs=-attributes] +++{{.IntroductionVersion}} ++ +a| [subs=-attributes] ++{{.Type}} ++ a| [subs=-attributes] ++{{.DefaultValue}} ++ From 7fb29d1d65152413d25b8f4cfc8157678d951236 Mon Sep 17 00:00:00 2001 From: Christian Richter Date: Fri, 19 Jul 2024 09:14:00 +0200 Subject: [PATCH 2/5] add IntroductionVersion to global adoc output Signed-off-by: Christian Richter --- docs/helpers/templates/adoc-generator.go.tmpl | 1 + docs/templates/ADOC_global.tmpl | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/docs/helpers/templates/adoc-generator.go.tmpl b/docs/helpers/templates/adoc-generator.go.tmpl index a151085205..1e772f859f 100644 --- a/docs/helpers/templates/adoc-generator.go.tmpl +++ b/docs/helpers/templates/adoc-generator.go.tmpl @@ -152,6 +152,7 @@ func main() { if len(env.Services) > 1 { tmplValues = append(tmplValues, map[string]interface{}{ "Name": env.Name, + "IntroductionVersion": env.IntroductionVersion, "Services": env.Services, "Description": env.Description, "DefaultValue": env.DefaultValue, diff --git a/docs/templates/ADOC_global.tmpl b/docs/templates/ADOC_global.tmpl index 424c010484..6c915f903a 100644 --- a/docs/templates/ADOC_global.tmpl +++ b/docs/templates/ADOC_global.tmpl @@ -6,6 +6,7 @@ [width="100%",cols="30%,25%,~,~,~",options="header"] |=== | Name +| IV | Services | Type | Default Value @@ -13,6 +14,9 @@ {{ range . }} a| `{{ .Name }}` +a| [subs=-attributes] +++{{ .IntroductionVersion }} ++ + a| [subs=attributes+] {{- range .Services}} * xref:{s-path}/{{ . }}.adoc[{{ . }}] + From a9c34d3aabf5ecb5bc473ffc4da0643f56f86120 Mon Sep 17 00:00:00 2001 From: Christian Richter Date: Fri, 19 Jul 2024 09:22:21 +0200 Subject: [PATCH 3/5] replace NEXT tokens Signed-off-by: Christian Richter --- docs/helpers/templates/adoc-generator.go.tmpl | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/docs/helpers/templates/adoc-generator.go.tmpl b/docs/helpers/templates/adoc-generator.go.tmpl index 1e772f859f..a4d86dbf62 100644 --- a/docs/helpers/templates/adoc-generator.go.tmpl +++ b/docs/helpers/templates/adoc-generator.go.tmpl @@ -105,7 +105,7 @@ func main() { } else { all[e] = EnvVar{ Name: e, - IntroductionVersion: f.IntroductionVersion, + IntroductionVersion: replaceEnvVarPlaceHolder(f.IntroductionVersion), Description: f.Description, Type: f.Type, DefaultValue: f.DefaultValue, @@ -152,7 +152,7 @@ func main() { if len(env.Services) > 1 { tmplValues = append(tmplValues, map[string]interface{}{ "Name": env.Name, - "IntroductionVersion": env.IntroductionVersion, + "IntroductionVersion": replaceEnvVarPlaceHolder(env.IntroductionVersion), "Services": env.Services, "Description": env.Description, "DefaultValue": env.DefaultValue, @@ -184,6 +184,15 @@ func main() { fmt.Println("done") } +func replaceEnvVarPlaceHolder(s string) string { + return strings.Replace( + strings.Replace(s, "%%NEXT%%", "next", -1), + "%%NEXT_PRODUCTION_VERSION%%", + "next-prod", + -1, + ) +} + func GetAnnotatedVariables(s interface{}, timestamp string) ([]ConfigField, []DeprecationField) { t := reflect.TypeOf(s) v := reflect.ValueOf(s) @@ -228,7 +237,7 @@ func GetAnnotatedVariables(s interface{}, timestamp string) ([]ConfigField, []De fields = append(fields, ConfigField{ EnvVars: td, - IntroductionVersion: introductionVersion, + IntroductionVersion: replaceEnvVarPlaceHolder(introductionVersion), DefaultValue: v, Description: desc, Type: typeName, @@ -237,10 +246,10 @@ func GetAnnotatedVariables(s interface{}, timestamp string) ([]ConfigField, []De if deprecationLink != "" { deprecations = append(deprecations, DeprecationField{ - DeprecationVersion: deprecationVersion, + DeprecationVersion: replaceEnvVarPlaceHolder(deprecationVersion), DeprecationInfo: deprecationInfo, DeprecationReplacement: deprecationReplacement, - RemovalVersion: removalVersion, + RemovalVersion: replaceEnvVarPlaceHolder(removalVersion), }) } case reflect.Ptr: From 51138a63ff24cfc43a672bdcdd0e21766d6ff749 Mon Sep 17 00:00:00 2001 From: Christian Richter Date: Fri, 19 Jul 2024 09:47:25 +0200 Subject: [PATCH 4/5] fix intendation Signed-off-by: Christian Richter --- docs/helpers/templates/adoc-generator.go.tmpl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/helpers/templates/adoc-generator.go.tmpl b/docs/helpers/templates/adoc-generator.go.tmpl index a4d86dbf62..598d21cdcf 100644 --- a/docs/helpers/templates/adoc-generator.go.tmpl +++ b/docs/helpers/templates/adoc-generator.go.tmpl @@ -21,7 +21,7 @@ import ( type ConfigField struct { EnvVars []string DefaultValue string - IntroductionVersion string + IntroductionVersion string Type string Description string VersionInfo string @@ -38,12 +38,12 @@ type DeprecationField struct { // EnvVar holds information about one envvar type EnvVar struct { - Name string + Name string IntroductionVersion string - DefaultValue string - Type string - Description string - Services []string + DefaultValue string + Type string + Description string + Services []string } type templateData struct { From 57d59de6e2ac1cefb97536c4759abe63e0646acb Mon Sep 17 00:00:00 2001 From: Christian Richter Date: Fri, 19 Jul 2024 09:54:18 +0200 Subject: [PATCH 5/5] fix intendation Signed-off-by: Christian Richter --- docs/helpers/templates/adoc-generator.go.tmpl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/helpers/templates/adoc-generator.go.tmpl b/docs/helpers/templates/adoc-generator.go.tmpl index 598d21cdcf..262876c5ca 100644 --- a/docs/helpers/templates/adoc-generator.go.tmpl +++ b/docs/helpers/templates/adoc-generator.go.tmpl @@ -38,12 +38,12 @@ type DeprecationField struct { // EnvVar holds information about one envvar type EnvVar struct { - Name string + Name string IntroductionVersion string - DefaultValue string - Type string - Description string - Services []string + DefaultValue string + Type string + Description string + Services []string } type templateData struct {