From 246c54a18b0cd4a6910fb75b18916c8c5244c757 Mon Sep 17 00:00:00 2001 From: Natasha Sarkar Date: Wed, 18 Aug 2021 13:47:43 -0700 Subject: [PATCH] suggested changes --- api/internal/target/kusttarget.go | 11 ++- api/krusty/fnplugin_test.go | 118 +++++++++++++------------ api/krusty/fnplugin_test/fnexectest.sh | 24 ----- api/resmap/resmap.go | 4 - api/resmap/reswrangler.go | 13 --- kyaml/fn/runtime/exec/exec.go | 12 +-- kyaml/kio/kioutil/kioutil.go | 4 + kyaml/runfn/runfn.go | 28 ++++-- 8 files changed, 100 insertions(+), 114 deletions(-) delete mode 100755 api/krusty/fnplugin_test/fnexectest.sh diff --git a/api/internal/target/kusttarget.go b/api/internal/target/kusttarget.go index 046ed27a17..f601b42530 100644 --- a/api/internal/target/kusttarget.go +++ b/api/internal/target/kusttarget.go @@ -264,7 +264,7 @@ func (kt *KustTarget) configureExternalGenerators() ([]resmap.Generator, error) return nil, err } m := ra.ResMap() - err = m.AnnotateAll(kioutil.PathAnnotation, kt.ldr.Root()) + err = m.AnnotateAll(kioutil.WorkingDirAnnotation, kt.ldr.Root()) if err != nil { return nil, err } @@ -300,12 +300,17 @@ func (kt *KustTarget) configureExternalTransformers(transformers []string) ([]re } ra.AppendAll(rm) } - ra, err := kt.accumulateResources(ra, transformerPaths, &resource.Origin{}) + ra, err := kt.accumulateResources(ra, transformerPaths, &resource.Origin{}) + if err != nil { + return nil, err + } + m := ra.ResMap() + err = m.AnnotateAll(kioutil.WorkingDirAnnotation, kt.ldr.Root()) if err != nil { return nil, err } - return kt.pLdr.LoadTransformers(kt.ldr, kt.validator, ra.ResMap()) + return kt.pLdr.LoadTransformers(kt.ldr, kt.validator, m) } func (kt *KustTarget) runValidators(ra *accumulator.ResAccumulator) error { diff --git a/api/krusty/fnplugin_test.go b/api/krusty/fnplugin_test.go index 554b5637f9..d4d7057ccf 100644 --- a/api/krusty/fnplugin_test.go +++ b/api/krusty/fnplugin_test.go @@ -7,17 +7,46 @@ import ( "testing" "github.com/stretchr/testify/assert" - "sigs.k8s.io/kustomize/api/internal/utils" - "sigs.k8s.io/kustomize/api/krusty" kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest" "sigs.k8s.io/kustomize/kyaml/filesys" ) +const execFile = `#!/bin/sh + +cat <