-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
config: don't call homedir on init() #2161
Conversation
Can you elaborate on this? My $0.02: since golang |
arg; you're right; I was thinking the package was still using the runc / libcontainer stuff, but that was removed in moby/moby@a8608b5#diff-1b2f13bed97df1999bf7f922eb2f0909 |
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
@kolyshkin let me know what you think; I think it still makes sense to get this info lazily, but happy to close otherwise |
Actually; let me make one small change, and don't attempt to set the dir if it's non-empty (which could be if a user of this package calls |
8244019
to
59f9565
Compare
I don't like this change -- now you have two "run once" guards, and they are scattered. Maybe it's better to rewrite |
@kolyshkin it's a bit problematic; tbh I think this package is way too complex
It's a global / package level variable that can be set to a default, but also overwritten by a "setter". eg, someone could set the directory; Line 46 in 7a279af
In which case we don't want to overwrite it with the default Someone could load the config, and specify the configDir Lines 82 to 85 in 7a279af
In which case And worst case; if the specified location couldn't be found, in which case the current config location is neither the one specified, nor the default one, but a completely different path: Lines 108 to 112 in 7a279af
|
This tripped us up, so I had to land a workaround: google/go-containerregistry#568 I'm in favor of this change :) |
@kolyshkin PTAL |
59f9565
to
8b1e7dc
Compare
This patch changes the package to lazily obtain the user's home- directory on first use, instead of when initializing the package. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
8b1e7dc
to
8a30653
Compare
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
The
homedir.Get()
function can call out to external applications to get user information.This patch changes the package to lazily obtain the user's home-directory on first use, instead of when initializing the package.
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)