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

Support files in 'argocd.argoproj.io/manifest-generate-paths' annotation #9907 #9908

Merged
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
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