-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add home directory to config file search paths #1325
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
Conversation
Hey, thank you for opening your first Pull Request ! |
So, dumb question, but I must ask it: have you test it on your env? Since we cannot write the unit test for this. And I cannot test it on my laptop, I don't have external adds or usb sticks |
I have tested it but have not written automated tests for it. From another drive (
With v1.30.0:
You can notice the additional linters I enabled are correctly enabled. |
Cool, thanks |
So, we leave it like that and write no tests? |
Another question just to be sure since I haven't dug into the code, is the search order like this now so Given code in /mnt/path/go
|
We can write the test, but it will require some refactoring. |
it will work in this order:
the |
@bombsimon The home directory is added last, so it should be checked last.
However, there is a possibility for duplicate paths (effectively checking the same path twice). I can add a check to prevent this if needed. Proof:
@SVilgelm I am still a bit lost on how I could write those tests. Maybe it can be merged and tests added later by the core team? |
Duplicate paths fixed:
|
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.
Looks good to me. Thank you
r.log.Infof("Config search paths: %s", configSearchPaths) | ||
viper.SetConfigName(".golangci") | ||
for _, p := range configSearchPaths { | ||
viper.AddConfigPath(p) | ||
} | ||
} | ||
|
||
func sliceContains(slice []string, value string) bool { |
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 can't find where this function is used.
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.
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 think it would be better to move to slice utils or so, so we can reuse it later
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.
oops, my bad :(
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.
it's needed to avoid duplications in the list of folders
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.
Should I create a new package pkg/sliceutil
and put it there?
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.
yeah, it would be better if you move it to pkg/sliceutil
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.
LGTM
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.
LGTM
Hey, @System-Glitch — we just merged your PR to
By joining the team, you’ll be able to label issues, review pull requests, and merge approved pull requests. Thanks again! |
See #1324
Guidance required: tests don't pass if you have a configuration file in your home directory. This is because some tests check that config is not found. I need assistance on how to update tests properly.