Skip to content

Commit

Permalink
Support files in argocd.argoproj.io/manifest-generate-paths annotation (
Browse files Browse the repository at this point in the history
#9908)

Signed-off-by: Jim Wright <jmwri93@gmail.com>
  • Loading branch information
jmwri authored Jul 8, 2022
1 parent 2d6ce08 commit 61c09dd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
9 changes: 7 additions & 2 deletions util/webhook/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,13 @@ func appFilesHaveChanged(app *v1alpha1.Application, changedFiles []string) bool
f = ensureAbsPath(f)
for _, item := range refreshPaths {
item = ensureAbsPath(item)

if _, err := security.EnforceToCurrentRoot(item, f); err == nil {
changed := false
if f == item {
changed = true
} else if _, err := security.EnforceToCurrentRoot(item, f); err == nil {
changed = true
}
if changed {
log.WithField("application", app.Name).Debugf("Application uses files that have changed")
return true
}
Expand Down
6 changes: 6 additions & 0 deletions util/webhook/webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,12 @@ func Test_getAppRefreshPrefix(t *testing.T) {
{"absolute path - not matching", getApp("/source/path1", "source/path"), []string{"source/path/my-deployment.yaml"}, false},
{"two relative paths - matching", getApp(".;../shared", "my-app"), []string{"shared/my-deployment.yaml"}, true},
{"two relative paths - not matching", getApp(".;../shared", "my-app"), []string{"README.md"}, false},
{"file relative path - matching", getApp("./my-deployment.yaml", "source/path"), []string{"source/path/my-deployment.yaml"}, true},
{"file relative path - not matching", getApp("./my-deployment.yaml", "source/path"), []string{"README.md"}, false},
{"file absolute path - matching", getApp("/source/path/my-deployment.yaml", "source/path"), []string{"source/path/my-deployment.yaml"}, true},
{"file absolute path - not matching", getApp("/source/path1/README.md", "source/path"), []string{"source/path/my-deployment.yaml"}, false},
{"file two relative paths - matching", getApp("./README.md;../shared/my-deployment.yaml", "my-app"), []string{"shared/my-deployment.yaml"}, true},
{"file two relative paths - not matching", getApp(".README.md;../shared/my-deployment.yaml", "my-app"), []string{"kustomization.yaml"}, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit 61c09dd

Please sign in to comment.