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

feat: add support for filtering apps by path and files #21126

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

slashexx
Copy link

@slashexx slashexx commented Dec 11, 2024

Fixes #21052

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • The title of the PR conforms to the Toolchain Guide
  • I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • I have signed off all my commits as required by DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My build is green (troubleshooting builds).
  • My new feature complies with the feature status guidelines.
  • I have added a brief description of why this PR is necessary and/or what this PR solves.
  • Optional. My organization is added to USERS.md.
  • Optional. For bug fixes, I've indicated what older releases this fix should be cherry-picked into (this may or may not happen depending on risk/complexity).

@slashexx slashexx requested a review from a team as a code owner December 11, 2024 08:23
Copy link

bunnyshell bot commented Dec 11, 2024

🔴 Preview Environment stopped on Bunnyshell

See: Environment Details | Pipeline Logs

Available commands (reply to this comment):

  • 🔵 /bns:start to start the environment
  • 🚀 /bns:deploy to redeploy the environment
  • /bns:delete to remove the environment

@slashexx slashexx marked this pull request as draft December 11, 2024 08:23
Signed-off-by: slashexx <[email protected]>
Copy link

codecov bot commented Dec 11, 2024

Codecov Report

Attention: Patch coverage is 72.97297% with 10 lines in your changes missing coverage. Please review.

Project coverage is 53.46%. Comparing base (bcf2143) to head (e43f346).

Files with missing lines Patch % Lines
cmd/argocd/commands/app.go 0.00% 10 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

Copy link
Member

@nitishfy nitishfy left a 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?

@nitishfy nitishfy self-assigned this Jan 21, 2025
@slashexx
Copy link
Author

@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 !

@slashexx slashexx marked this pull request as ready for review January 21, 2025 10:20
@slashexx slashexx requested a review from a team as a code owner January 21, 2025 10:20
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+"/")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

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+"/")) {
Copy link
Member

@nitishfy nitishfy Jan 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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?

Copy link
Author

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 ?

Copy link
Member

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

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+"/")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Member

@nitishfy nitishfy left a 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.

@slashexx
Copy link
Author

slashexx commented Jan 24, 2025

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 --file flag accordingly as well.

@agaudreault agaudreault self-assigned this Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLI app list should be able to filter based on a list of files
3 participants