-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
feat: add support for filtering apps by path and files #21126
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: slashexx <[email protected]>
🔴 Preview Environment stopped on BunnyshellSee: Environment Details | Pipeline Logs Available commands (reply to this comment):
|
Signed-off-by: slashexx <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #21126 +/- ##
==========================================
- Coverage 55.45% 53.46% -1.99%
==========================================
Files 339 339
Lines 57196 57233 +37
==========================================
- Hits 31718 30602 -1116
- Misses 22812 23998 +1186
+ Partials 2666 2633 -33 ☔ View full report in Codecov by Sentry. |
Signed-off-by: slashexx <[email protected]>
Signed-off-by: slashexx <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this PR ready for review? Also, can you fix the CI checks?
Signed-off-by: slashexx <[email protected]>
Signed-off-by: slashexx <[email protected]>
Signed-off-by: slashexx <[email protected]>
Signed-off-by: slashexx <[email protected]>
Signed-off-by: slashexx <[email protected]>
Signed-off-by: slashexx <[email protected]>
@nitishfy Thanks for following up, apologies for the delay in fixing this. The CI checks should now work fine, I've also marked this PR as ready for review, PTAL ! |
util/argo/argo.go
Outdated
func FilterByPath(apps []argoappv1.Application, path string) []argoappv1.Application { | ||
filteredApps := make([]argoappv1.Application, 0) | ||
for _, app := range apps { | ||
if app.Spec.Source != nil && (app.Spec.Source.Path == path || strings.HasPrefix(app.Spec.Source.Path, path+"/")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if app.Spec.Source != nil && (app.Spec.Source.Path == path || strings.HasPrefix(app.Spec.Source.Path, path+"/")) { | |
if app.Spec.Source != nil && (app.Spec.Source.Path == path || strings.HasPrefix(app.Spec.Source.Path, path+"/")) { |
You'd also need to filter the apps that consist of multiple sources. Right now, it only checks for a single source application.
util/argo/argo.go
Outdated
func FilterByPath(apps []argoappv1.Application, path string) []argoappv1.Application { | ||
filteredApps := make([]argoappv1.Application, 0) | ||
for _, app := range apps { | ||
if app.Spec.Source != nil && (app.Spec.Source.Path == path || strings.HasPrefix(app.Spec.Source.Path, path+"/")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if app.Spec.Source != nil && (app.Spec.Source.Path == path || strings.HasPrefix(app.Spec.Source.Path, path+"/")) { | |
if app.Spec.Source != nil && app.Spec.Source.Path == path { |
why are you checking for strings.HasPrefix()
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @nitishfy , apologies I'm a bit new around here.
I've put it like that so it compares the exact path along with subdirectories and all ?
Is it not required ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'd need to check for absolute and relative path here instead of just checking if a path consist of /
. Isn't this the intended behaviour? cc @agaudreault
util/argo/argo.go
Outdated
func FilterByPath(apps []argoappv1.Application, path string) []argoappv1.Application { | ||
filteredApps := make([]argoappv1.Application, 0) | ||
for _, app := range apps { | ||
if app.Spec.Source != nil && (app.Spec.Source.Path == path || strings.HasPrefix(app.Spec.Source.Path, path+"/")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if app.Spec.Source != nil && (app.Spec.Source.Path == path || strings.HasPrefix(app.Spec.Source.Path, path+"/")) { | |
if app.Spec.Source != nil && (app.Spec.Source.Path == path || strings.HasPrefix(app.Spec.Source.Path, path+"/")) { |
Checking for a path is simply not sufficient. You should also check for a absolute/relative path too. For eg. in any setup, I should be simply able to pass the file path to a file that exists locally and it should internally check if any application is using that specified path for sync operation.
@agaudreault Isn't this what we plan to do? Otherwise with the current setup we just pass an argument to the path flag and check if that matches with the source path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this. I've not reviewed the --file
flag implementation yet. However, i think a lot of things can be improved for the --path
flag implementation.
Thanks for reviewing this PR, I'll make the required changes and change |
Fixes #21052
Checklist: