Skip to content

Commit 1ea5eb0

Browse files
authored
fix: render file template with map[string]any (#9929)
1 parent a24a1e6 commit 1ea5eb0

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

controllers/apps/component/transformer_component_template.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ package component
2121

2222
import (
2323
"fmt"
24-
"maps"
2524
"reflect"
2625
"strings"
2726
"text/template"
@@ -258,9 +257,9 @@ func renderFileTemplateData(transCtx *componentTransformContext,
258257
rendered = make(map[string]string)
259258
)
260259

261-
variables := make(map[string]string)
262-
if synthesizedComp.TemplateVars != nil {
263-
maps.Copy(variables, synthesizedComp.TemplateVars)
260+
variables := make(map[string]any)
261+
for k, v := range synthesizedComp.TemplateVars {
262+
variables[k] = v
264263
}
265264
for k, v := range fileTemplate.Variables {
266265
variables[k] = v // override

pkg/controller/component/vars.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ func resolveValueReferenceNEscaping(templateVars, credentialVars map[string]core
239239
func evaluateObjectVarsExpression(definedVars []appsv1.EnvVar, credentialVars []corev1.EnvVar, vars *[]corev1.EnvVar) error {
240240
var (
241241
isValues = make(map[string]bool)
242-
values = make(map[string]string)
242+
values = make(map[string]any)
243243
)
244244
normalize := func(name string) string {
245245
return strings.ReplaceAll(name, "-", "_")

pkg/kbagent/service/action_utils.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"context"
2525
"fmt"
2626
"io"
27-
"maps"
2827
"net"
2928
"net/http"
3029
"os"
@@ -601,9 +600,11 @@ func renderTemplateData(action string, parameters map[string]string, data string
601600
return buf.String(), nil
602601
}
603602

604-
func mergeEnvWith(parameters map[string]string) map[string]string {
605-
result := make(map[string]string)
606-
maps.Copy(result, parameters)
603+
func mergeEnvWith(parameters map[string]string) map[string]any {
604+
result := make(map[string]any)
605+
for k, v := range parameters {
606+
result[k] = v
607+
}
607608
for _, e := range os.Environ() {
608609
kv := strings.Split(e, "=")
609610
if _, ok := result[kv[0]]; !ok {

0 commit comments

Comments
 (0)