Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with remote Kustomizations in dev mode. (#2581) #2611

Merged
merged 1 commit into from
Aug 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pkg/skaffold/deploy/kustomize.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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"}
Expand Down
42 changes: 22 additions & 20 deletions pkg/skaffold/deploy/kustomize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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 {
Expand All @@ -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)
Expand Down