From 01909fdf39a1f2d71d958666d66ff6e1b6f65845 Mon Sep 17 00:00:00 2001 From: Jabar Asadi Date: Tue, 10 Oct 2023 13:53:59 +0200 Subject: [PATCH] feat: code review --- apptests/kustomize/kustomize.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/apptests/kustomize/kustomize.go b/apptests/kustomize/kustomize.go index a49ef3e9b6..4d59b49686 100644 --- a/apptests/kustomize/kustomize.go +++ b/apptests/kustomize/kustomize.go @@ -1,8 +1,6 @@ package kustomize import ( - "os" - "github.com/drone/envsubst" "sigs.k8s.io/kustomize/api/krusty" "sigs.k8s.io/kustomize/api/resmap" @@ -28,10 +26,6 @@ func New(dir string, subs map[string]string) *Kustomize { // Build runs the kustomization process on the directory and substitutes the // environment variables in the resources. func (k *Kustomize) Build() error { - for k, v := range k.substitutes { - os.Setenv(k, v) - } - opts := krusty.MakeDefaultOptions() opts.Reorder = krusty.ReorderOptionLegacy @@ -49,7 +43,9 @@ func (k *Kustomize) Build() error { return err } - out, err := envsubst.EvalEnv(string(yaml)) + out, err := envsubst.Eval(string(yaml), func(s string) string { + return k.substitutes[s] + }) if err != nil { return err }