From a9c34d3aabf5ecb5bc473ffc4da0643f56f86120 Mon Sep 17 00:00:00 2001 From: Christian Richter Date: Fri, 19 Jul 2024 09:22:21 +0200 Subject: [PATCH] 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: