-
Notifications
You must be signed in to change notification settings - Fork 26
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
Adding ignoreSubpaths possibility #432
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/crumbhole/argocd-lovely-plugin/pkg/features" | ||
"os" | ||
"path/filepath" | ||
"regexp" | ||
"strings" | ||
|
||
"github.com/crumbhole/argocd-lovely-plugin/pkg/features" | ||
) | ||
|
||
// PackageDirectories is an array of sub-application paths | ||
|
@@ -17,6 +19,23 @@ func (d *PackageDirectories) checkFile(path string, info os.DirEntry, err error) | |
if err != nil { | ||
return err | ||
} | ||
|
||
// Check if path matches any ignored subpaths | ||
ignoreSubpaths, err := features.GetIgnoreSubpaths() | ||
if err != nil { | ||
return err | ||
} | ||
for _, subpath := range ignoreSubpaths { | ||
// Remove any leading "../" from the subpath | ||
for strings.HasPrefix(subpath, "../") { | ||
subpath = subpath[len("../"):] | ||
} | ||
|
||
if strings.Contains(path, filepath.Clean(subpath)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd like a solid match here. We're only matching directories, so I'd check for If I have
And I ignore There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gosh, that was lame. You're absolutely right. I'm doing the update. |
||
return nil // Skip processing if the path matches any ignored subpath | ||
} | ||
} | ||
|
||
if !info.IsDir() { | ||
yamlRegexp := regexp.MustCompile(features.GetDetectionRegex()) | ||
dir := filepath.Dir(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.
This is a surprising thing, why are we removing some part of the path that the user has supplied?
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.
I thought users would give a path with a potential leading "../", (which would never match), but later I figured it's unlikely.
I'll update the docs that the given paths should be relative to the application base directory.