diff --git a/go.mod b/go.mod index d1577c7c..42a11883 100644 --- a/go.mod +++ b/go.mod @@ -32,6 +32,7 @@ require ( go.yaml.in/yaml/v3 v3.0.4 golang.org/x/sync v0.18.0 golang.org/x/term v0.37.0 + gopkg.in/yaml.v3 v3.0.1 helm.sh/helm/v3 v3.19.2 helm.sh/helm/v4 v4.0.1 k8s.io/apimachinery v0.34.2 @@ -323,7 +324,6 @@ require ( gopkg.in/gookit/color.v1 v1.1.6 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/api v0.34.2 // indirect k8s.io/apiextensions-apiserver v0.34.1 // indirect k8s.io/apiserver v0.34.1 // indirect diff --git a/pkg/state/envvals_loader.go b/pkg/state/envvals_loader.go index 78bf9a0b..4c3b5823 100644 --- a/pkg/state/envvals_loader.go +++ b/pkg/state/envvals_loader.go @@ -139,9 +139,15 @@ func (ld *EnvironmentValuesLoader) renderInBasePath(value any, r tmpl.TextRender return nil, fmt.Errorf("failed to get current working directory: %v", err) } + // If basePath is "." or already the current directory, no need to change + basePath := ld.storage.basePath + if basePath == "." || basePath == cwd { + return ld.renderTemplateExpressions(value, r) + } + // Change to basePath for rendering using the filesystem abstraction - if err := ld.fs.Chdir(ld.storage.basePath); err != nil { - return nil, fmt.Errorf("failed to change to base directory %q: %v", ld.storage.basePath, err) + if err := ld.fs.Chdir(basePath); err != nil { + return nil, fmt.Errorf("failed to change to base directory %q: %v", basePath, err) } // Ensure we change back to the original directory