-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Adds glob support for filepath in tools command #4105
Adds glob support for filepath in tools command #4105
Conversation
- Adds glob check - Adds test and test files Signed-off-by: someshkoli <kolisomesh27@gmail.com>
cmd/thanos/tools.go
Outdated
@@ -39,26 +41,33 @@ func checkRulesFiles(logger log.Logger, files *[]string) error { | |||
|
|||
for _, fn := range *files { | |||
level.Info(logger).Log("msg", "checking", "filename", fn) | |||
f, err := os.Open(fn) | |||
matches, err := filepath.Glob(fn) | |||
if matches == nil { |
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.
We should check the err
first and then matches
, because matches
will most likely be nil
in case there is some other error and we will be overwriting that error with "Matching file not found".
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.
Right 🤔
Signed-off-by: someshkoli <kolisomesh27@gmail.com>
Signed-off-by: someshkoli <kolisomesh27@gmail.com>
Also, I guess these change should not affect e2e 🤔, not sure why its failing :\ |
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.
Just some suggestions/questions but overall LGTM! Thank you for your work on this feature (:
Signed-off-by: someshkoli <kolisomesh27@gmail.com>
Signed-off-by: someshkoli <kolisomesh27@gmail.com>
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.
Awesome work! Thanks a lot
failed.Add(err) | ||
continue | ||
} | ||
defer func() { _ = f.Close() }() |
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.
Typically we'd use rununtil.CloseWithLogOnErr
but since at the end the process closes immediately, this is fine. Just something to keep in mind for future contributions 👍
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.
Got it, Thanks 🙌
Changes
Adds glob check for filepaths provided via cli. Checks for each matching file path and throws
Matching file not found
error if no file matches the pattern.fixes #4082
Verification
Added a basic unit test