Skip to content
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

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

Merged

Conversation

thaJeztah
Copy link
Member

backport of #2934

fixes moby/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 <[email protected]>
(cherry picked from commit c85a37d)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
@codecov-io
Copy link

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     

Copy link
Collaborator

@cpuguy83 cpuguy83 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@silvin-lubecki silvin-lubecki left a comment

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.10 Feb 12, 2021
@thaJeztah thaJeztah deleted the 20.10_backport_fix_homedir_warning branch February 12, 2021 10:57
Sign up for free to 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