diff --git a/pkg/appdir/walk_kustomize_files.go b/pkg/appdir/walk_kustomize_files.go index b285a2b..3df01fd 100644 --- a/pkg/appdir/walk_kustomize_files.go +++ b/pkg/appdir/walk_kustomize_files.go @@ -40,6 +40,7 @@ func walkKustomizeFiles(result *AppDirectory, fs fs.FS, appName, dirpath string) kustomize struct { Bases []string `yaml:"bases"` + Components []string `yaml:"components"` Resources []string `yaml:"resources"` PatchesJson6902 []patchJson6902 `yaml:"patchesJson6902"` PatchesStrategicMerge []string `yaml:"patchesStrategicMerge"` @@ -66,7 +67,7 @@ func walkKustomizeFiles(result *AppDirectory, fs fs.FS, appName, dirpath string) for _, resource := range kustomize.Resources { if isGoGetterIsh(resource) { - // no reason to walk remote files, since they can't be changed + // no reason to walk remote files, since they can't be changed in this PR continue } @@ -110,6 +111,17 @@ func walkKustomizeFiles(result *AppDirectory, fs fs.FS, appName, dirpath string) } } + for _, componentPath := range kustomize.Components { + if isGoGetterIsh(componentPath) { + continue + } + relPath := filepath.Join(dirpath, componentPath) + result.addDir(appName, relPath) + if err = walkKustomizeFiles(result, fs, appName, relPath); err != nil { + log.Warn().Err(err).Msgf("failed to read kustomize.yaml from components in %s", relPath) + } + } + for _, patchFile := range kustomize.PatchesStrategicMerge { relPath := filepath.Join(dirpath, patchFile) result.addFile(appName, relPath) diff --git a/pkg/appdir/walk_kustomize_files_test.go b/pkg/appdir/walk_kustomize_files_test.go index c5b77fa..434a58a 100644 --- a/pkg/appdir/walk_kustomize_files_test.go +++ b/pkg/appdir/walk_kustomize_files_test.go @@ -55,6 +55,10 @@ resources: - file1.yaml - ../overlays/base - /common/overlays/prod + +components: +- ../components/one/ +- ../components/two/ `)}, "test/overlays/base/kustomization.yaml": { Data: toBytes(` @@ -73,6 +77,8 @@ resources: "common/overlays/prod/kustomization.yaml": {Data: toBytes("hello: world")}, "test/overlays/base/some-file1.yaml": {Data: toBytes("hello: world")}, "test/overlays/base/some-file2.yaml": {Data: toBytes("hello: world")}, + "test/components/one/kustomization.yaml": {Data: toBytes("hello: world")}, + "test/components/two/kustomization.yaml": {Data: toBytes("hello: world")}, } ) @@ -135,6 +141,12 @@ resources: kustomizeApp1Name, kustomizeApp2Name, }, + "test/components/one": { + kustomizeApp2Name, + }, + "test/components/two": { + kustomizeApp2Name, + }, }, appdir.appDirs) assert.Equal(t, map[string][]string{