Fix initializing client modifying custom HTTPHeaders#2756
Merged
silvin-lubecki merged 1 commit intodocker:masterfrom Sep 30, 2020
Merged
Fix initializing client modifying custom HTTPHeaders#2756silvin-lubecki merged 1 commit intodocker:masterfrom
silvin-lubecki merged 1 commit intodocker:masterfrom
Conversation
When initializing the API client, the User-Agent was added to any custom
HTTPHeaders that were configured. However, because the map was not properly
dereferenced, the original map was modified, causing the User-Agent to also
be saved to config.json after `docker login` and `docker logout`:
Before this change;
$ cat ~/.docker/config.json
cat: can't open '/root/.docker/config.json': No such file or directory
$ docker login -u myusername
Password:
...
Login Succeeded
$ cat ~/.docker/config.json
{
"auths": {
"https://index.docker.io/v1/": {
"auth": "<base64 auth>"
}
},
"HttpHeaders": {
"User-Agent": "Docker-Client/19.03.12 (linux)"
}
}
$ docker logout
{
"auths": {},
"HttpHeaders": {
"User-Agent": "Docker-Client/19.03.12 (linux)"
}
}
After this change:
$ cat ~/.docker/config.json
cat: can't open '/root/.docker/config.json': No such file or directory
$ docker login -u myusername
Password:
...
Login Succeeded
$ cat ~/.docker/config.json
{
"auths": {
"https://index.docker.io/v1/": {
"auth": "<base64 auth>"
}
}
}
$ docker logout
Removing login credentials for https://index.docker.io/v1/
$ cat ~/.docker/config.json
{
"auths": {}
}
Signed-off-by: Sebastiaan van Stijn <[email protected]>
Member
Author
|
@silvin-lubecki PTAL |
Codecov Report
@@ Coverage Diff @@
## master #2756 +/- ##
==========================================
- Coverage 57.15% 57.15% -0.01%
==========================================
Files 297 297
Lines 18657 18656 -1
==========================================
- Hits 10663 10662 -1
Misses 7132 7132
Partials 862 862 |
silvin-lubecki
approved these changes
Sep 30, 2020
Contributor
silvin-lubecki
left a comment
There was a problem hiding this comment.
LGTM, thanks for fixing, that bugged me for a long time 😄
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When initializing the API client, the User-Agent was added to any custom
HTTPHeaders that were configured. However, because the map was not properly
dereferenced, the original map was modified, causing the User-Agent to also
be saved to config.json after
docker loginanddocker logout:Before this change;
After this change:
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)