Skip to content

Commit

Permalink
fix: remote kustomize manifest being watched
Browse files Browse the repository at this point in the history
  • Loading branch information
ericzzzzzzz committed Jul 29, 2023
1 parent 21602b7 commit 4f4d57e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
25 changes: 25 additions & 0 deletions pkg/skaffold/deploy/kubectl/kustomize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,9 @@ func TestDependenciesForKustomization(t *testing.T) {
- path: patch1.yaml
target:
kind: Deployment`},
createFiles: map[string]string{
"patch1.yaml": "",
},
expected: []string{"kustomization.yaml", "patch1.yaml"},
},
{
Expand All @@ -282,8 +285,19 @@ func TestDependenciesForKustomization(t *testing.T) {
kustomizations: map[string]string{"kustomization.yaml": `patches:
- path: patch1.yaml
- path: path/patch2.yaml`},
createFiles: map[string]string{
"patch1.yaml": "",
"path/patch2.yaml": "",
},
expected: []string{"kustomization.yaml", "patch1.yaml", "path/patch2.yaml"},
},
{
description: "ignore patches legacy, path doesn't exist",
kustomizations: map[string]string{"kustomization.yaml": `patches:
- path: patch1.yaml
- path: path/patch2.yaml`},
expected: []string{"kustomization.yaml"},
},
{
description: "patchesStrategicMerge",
kustomizations: map[string]string{"kustomization.yaml": `patchesStrategicMerge: [patch1.yaml, "patch2.yaml", 'path/patch3.yaml']`},
Expand All @@ -306,8 +320,19 @@ func TestDependenciesForKustomization(t *testing.T) {
kustomizations: map[string]string{"kustomization.yaml": `patchesJson6902:
- path: patch1.json
- path: path/patch2.json`},
createFiles: map[string]string{
"patch1.json": "",
"path/patch2.json": "",
},
expected: []string{"kustomization.yaml", "patch1.json", "path/patch2.json"},
},
{
description: "ignore patches json 6902 path doesn't exist",
kustomizations: map[string]string{"kustomization.yaml": `patchesJson6902:
- path: patch1.json`,
},
expected: []string{"kustomization.yaml"},
},
{
description: "ignore patch without path",
kustomizations: map[string]string{"kustomization.yaml": `patchesJson6902:
Expand Down
8 changes: 8 additions & 0 deletions pkg/skaffold/render/renderer/kustomize/kustomize.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,12 +479,20 @@ func DependenciesForKustomization(dir string) ([]string, error) {

for _, patch := range content.Patches {
if patch.Path != "" {
local, _ := pathExistsLocally(patch.Path, dir)
if !local {
continue
}
deps = append(deps, filepath.Join(dir, patch.Path))
}
}

for _, jsonPatch := range content.PatchesJson6902 {
if jsonPatch.Path != "" {
local, _ := pathExistsLocally(jsonPatch.Path, dir)
if !local {
continue
}
deps = append(deps, filepath.Join(dir, jsonPatch.Path))
}
}
Expand Down

0 comments on commit 4f4d57e

Please sign in to comment.