Skip to content

[20.10 backport] cli/config: prevent warning if HOME is not set - #2958

Merged
silvin-lubecki merged 1 commit into
docker:20.10from
thaJeztah:20.10_backport_fix_homedir_warning
Feb 12, 2021
Merged

[20.10 backport] cli/config: prevent warning if HOME is not set#2958
silvin-lubecki merged 1 commit into
docker:20.10from
thaJeztah:20.10_backport_fix_homedir_warning

Conversation

@thaJeztah

Copy link
Copy Markdown
Member

backport of #2934

fixesmoby/moby#41890 WARNING: Error loading config file: .dockercfg: $HOME is not defined

commit c2626a8 (#2101) replaced the use of github.com/docker/docker/pkg/homedir with Golang's os.UserHomeDir().

This change was partially reverted in 7a279af (#2111) to account for situations where $HOME is not set.

In situations where no configuration file is present in ~/.config/, the CLI falls back to looking for the (deprecated) ~/.dockercfg configuration file, which was still using os.UserHomeDir(), which produces an error/warning if $HOME is not set.

This patch introduces a helper function and a global variable to get the user's home-directory. The global variable is used to prevent repeatedly looking up the user's information (which, depending on the setup can be a costly operation).

- Description for the changelog

- Fix "`WARNING: Error loading config file: .dockercfg: $HOME is not defined`"

- A picture of a cute animal (not mandatory but encouraged)

commit c2626a8 replaced the use of
github.com/docker/docker/pkg/homedir with Golang's os.UserHomeDir().
This change was partially reverted in 7a279af
to account for situations where `$HOME` is not set.
In situations where no configuration file is present in `~/.config/`, the CLI
falls back to looking for the (deprecated) `~/.dockercfg` configuration file,
which was still using `os.UserHomeDir()`, which produces an error/warning if
`$HOME` is not set.
This patch introduces a helper function and a global variable to get the user's
home-directory. The global variable is used to prevent repeatedly looking up
the user's information (which, depending on the setup can be a costly operation).
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit c85a37d)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@codecov-io

Copy link
Copy Markdown

Codecov Report

Merging #2958 (d513e46) into 20.10 (48d30b5) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@ Coverage Diff @@## 20.10 #2958 +/- ##
==========================================
+ Coverage 57.02% 57.03% +0.01% 
==========================================
Files 297 297 Lines 18666 18667 +1 ==========================================
+ Hits 10644 10647 +3 + Misses 7157 7156 -1 + Partials 865 864 -1 

@cpuguy83cpuguy83 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@silvin-lubeckisilvin-lubecki left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@silvin-lubecki
silvin-lubecki merged commit 3e293e6 into docker:20.10Feb 12, 2021
@thaJeztah
thaJeztah deleted the 20.10_backport_fix_homedir_warning branch February 12, 2021 10:57
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@thaJeztah@codecov-io@cpuguy83@silvin-lubecki