-
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
configfile: Initialize nil AuthConfigs #4418
configfile: Initialize nil AuthConfigs #4418
Conversation
Thank you for contributing! It appears your commit message is missing a DCO sign-off, We require all commit messages to have a
There is no need to open a new pull request, but to fix this (and make CI pass), Unfortunately, it's not possible to do so through GitHub's web UI, so this needs You can find some instructions in the output of the DCO check (which can be found Steps to do so "roughly" come down to:
Sorry for the hassle (I wish GitHub would make this a bit easier to do), and let me know if you need help or more detailed instructions! |
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.
Thank you for the contribution!
In addition to the missing DCO, I have one suggestion.
cli/config/credentials/file_store.go
Outdated
if authConfigs == nil { | ||
authConfigs = make(map[string]types.AuthConfig) | ||
} |
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.
This won't save the auth in the ConfigFile
because we create a completely new map here.
Instead of doing the nil check on caller side, we need to solve this issue in the GetAuthConfigs
directly:
cli/cli/config/configfile/file.go
Lines 95 to 98 in df04aca
// GetAuthConfigs returns the mapping of repo to auth configuration | |
func (configFile *ConfigFile) GetAuthConfigs() map[string]types.AuthConfig { | |
return configFile.AuthConfigs | |
} |
This way we also won't have to do the nil check in all the places GetAuthConfigs is called (there are currently no other places which break with nil value though).
fd814b8
to
9a4552d
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #4418 +/- ##
==========================================
+ Coverage 58.97% 59.40% +0.43%
==========================================
Files 286 288 +2
Lines 24771 24780 +9
==========================================
+ Hits 14608 14721 +113
+ Misses 9276 9173 -103
+ Partials 887 886 -1 |
Initialize AuthConfigs map if it's nil before returning it. This fixes fileStore.Store nil dereference panic when adding a new key to the map. Signed-off-by: Danial Gharib <danial.mail.gh@gmail.com> Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
9a4552d
to
ad43df5
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.
I went ahead and applied my suggestion as we'd like to get this in for the next patch release.
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
we should look at some of the follow-ups as well, but this fixes the immediate issue
- What I did
- How I did it
- How to verify it
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)