diff --git a/pkg/skaffold/deploy/kustomize.go b/pkg/skaffold/deploy/kustomize.go index aa2f78faade..54a0cd57fda 100644 --- a/pkg/skaffold/deploy/kustomize.go +++ b/pkg/skaffold/deploy/kustomize.go @@ -164,7 +164,8 @@ func dependenciesForKustomization(dir string) ([]string, error) { path, err := findKustomizationConfig(dir) if err != nil { - return nil, err + // No kustomiization config found so assume it's remote and stop traversing + return deps, nil } buf, err := ioutil.ReadFile(path) @@ -217,7 +218,7 @@ func dependenciesForKustomization(dir string) ([]string, error) { return deps, nil } -// A kustomization config must be at the root of the direectory. Kustomize will +// A Kustomization config must be at the root of the directory. Kustomize will // error if more than one of these files exists so order doesn't matter. func findKustomizationConfig(dir string) (string, error) { candidates := []string{"kustomization.yaml", "kustomization.yml", "Kustomization"} diff --git a/pkg/skaffold/deploy/kustomize_test.go b/pkg/skaffold/deploy/kustomize_test.go index 02f913c8cf4..58f33a03346 100644 --- a/pkg/skaffold/deploy/kustomize_test.go +++ b/pkg/skaffold/deploy/kustomize_test.go @@ -157,12 +157,13 @@ func TestKustomizeCleanup(t *testing.T) { func TestDependenciesForKustomization(t *testing.T) { tests := []struct { - description string - yaml string - expected []string - shouldErr bool - createFiles map[string]string - configName string + description string + yaml string + expected []string + shouldErr bool + skipConfigCreation bool + createFiles map[string]string + configName string }{ { description: "resources", @@ -272,23 +273,21 @@ func TestDependenciesForKustomization(t *testing.T) { { description: "mixture of config names", yaml: `resources: [app.yaml, base1, base2]`, - expected: []string{"Kustomization", "app.yaml", "base1/kustomization.yml", "base1/app.yaml", "base2/Kustomization", "base2/app.yaml"}, + expected: []string{"Kustomization", "app.yaml", "base1/kustomization.yml", "base1/app.yaml", "base2/kustomization.yaml", "base2/app.yaml"}, createFiles: map[string]string{ - "app.yaml": "", - "base1/kustomization.yml": `resources: [app.yaml]`, - "base1/app.yaml": "", - "base2/Kustomization": `resources: [app.yaml]`, - "base2/app.yaml": "", + "app.yaml": "", + "base1/kustomization.yml": `resources: [app.yaml]`, + "base1/app.yaml": "", + "base2/kustomization.yaml": `resources: [app.yaml]`, + "base2/app.yaml": "", }, configName: "Kustomization", }, { - description: "no kustomization config", - yaml: `resources: [foo]`, - shouldErr: true, - createFiles: map[string]string{ - "foo/invalid-config-name": "", - }, + description: "remote or missing root kustomization config", + expected: []string{}, + configName: "missing-or-remote-root-config", + skipConfigCreation: true, }, } for _, test := range tests { @@ -297,8 +296,11 @@ func TestDependenciesForKustomization(t *testing.T) { test.configName = "kustomization.yaml" } - tmpDir := t.NewTempDir(). - Write(test.configName, test.yaml) + tmpDir := t.NewTempDir() + + if !test.skipConfigCreation { + tmpDir.Write(test.configName, test.yaml) + } for path, contents := range test.createFiles { tmpDir.Write(path, contents)