From 0e152650413a7c333bf60a651e8eddd13f834a60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Sj=C3=B8rslev?= Date: Tue, 18 Jun 2024 14:30:17 +0200 Subject: [PATCH] Add Sprig template functions to provisioner (#5099) --- admin/provisioner/kubernetes.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/admin/provisioner/kubernetes.go b/admin/provisioner/kubernetes.go index 60843f287b9..21d375a3249 100644 --- a/admin/provisioner/kubernetes.go +++ b/admin/provisioner/kubernetes.go @@ -11,6 +11,7 @@ import ( "text/template" "time" + "github.com/Masterminds/sprig/v3" "github.com/c2h5oh/datasize" retryablehttp "github.com/hashicorp/go-retryablehttp" "go.uber.org/multierr" @@ -87,8 +88,14 @@ func NewKubernetes(spec json.RawMessage) (*KubernetesProvisioner, error) { return nil, err } + // Add Sprig template functions (removing functions that leak host info) + // Derived from Helm: https://github.com/helm/helm/blob/main/pkg/engine/funcs.go + funcMap := sprig.TxtFuncMap() + delete(funcMap, "env") + delete(funcMap, "expandenv") + // Parse the template definitions - templates := template.Must(template.New("").ParseFiles( + templates := template.Must(template.New("").Funcs(funcMap).ParseFiles( ksp.TemplatePaths.HTTPIngress, ksp.TemplatePaths.GRPCIngress, ksp.TemplatePaths.Service,