[release-1.x backport] logName(): lazily lookup userName instead of on init() #144
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
backport of #143 for the release-1.x branch
What this PR does / why we need it:
Commit c46b9e1 (#123, and backported to v1 through #124) implemented a workaround for situations on Windows where
user.Current()
was not available.On Linux/Unix ennvironments,
user.Current()
may be calling (among others)getgrnam_r
(https://linux.die.net/man/3/getgrgid_r), which:This means that the
init()
function might be making network connections,which is not desirable.
This patch changes the lookup to be performed lazily. A
sync.Once
wasadded so that lookup is only performed once (to keep the behavior that
was previously provided by using
init()
.Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Relates to #123
Relates to docker/cli#2420
Special notes for your reviewer:
Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.
If accepted, I would like this to see this backported to the v1 branch (and possibly included in a
v1.0.1
orv1.0.2
release)Release note: