DockerCLI/cli/command
Sebastiaan van Stijn 2b1138c118
Fix initializing client modifying custom HTTPHeaders
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 <github@gone.nl>
2020-09-29 17:24:07 +02:00
..
builder Fix builder prune -a/--all flag description 2020-02-18 14:30:28 +01:00
checkpoint Replace deprecated Cobra command.SetOutput() with command.SetOut() 2020-05-07 14:25:59 +02:00
commands Remove "docker engine" subcommands 2019-12-12 17:51:25 +01:00
config formatter: reduce minimum width for columns in table-view 2020-08-31 16:31:15 +02:00
container formatter: reduce minimum width for columns in table-view 2020-08-31 16:31:15 +02:00
context formatter: reduce minimum width for columns in table-view 2020-08-31 16:31:15 +02:00
formatter formatter: reduce minimum width for columns in table-view 2020-08-31 16:31:15 +02:00
idresolver bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-02-23 00:28:55 +01:00
image Add test-case for env with, and without = 2020-09-23 20:33:48 +02:00
inspect bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-02-23 00:28:55 +01:00
manifest Subcommand `docker manifest rm` 2020-09-15 16:26:47 -04:00
network formatter: reduce minimum width for columns in table-view 2020-08-31 16:31:15 +02:00
node formatter: reduce minimum width for columns in table-view 2020-08-31 16:31:15 +02:00
plugin formatter: reduce minimum width for columns in table-view 2020-08-31 16:31:15 +02:00
registry formatter: reduce minimum width for columns in table-view 2020-08-31 16:31:15 +02:00
secret formatter: reduce minimum width for columns in table-view 2020-08-31 16:31:15 +02:00
service Fix 2 typos 2020-09-18 09:26:39 -06:00
stack formatter: reduce minimum width for columns in table-view 2020-08-31 16:31:15 +02:00
swarm Replace deprecated Cobra command.SetOutput() with command.SetOut() 2020-05-07 14:25:59 +02:00
system Replace vbom.ml/util with fvbommel/sortorder 2020-08-28 15:35:42 +02:00
task formatter: reduce minimum width for columns in table-view 2020-08-31 16:31:15 +02:00
testdata Dynamically register kubernetes context store endpoint type. 2019-05-20 13:28:11 +01:00
trust formatter: reduce minimum width for columns in table-view 2020-08-31 16:31:15 +02:00
volume formatter: reduce minimum width for columns in table-view 2020-08-31 16:31:15 +02:00
cli.go Fix initializing client modifying custom HTTPHeaders 2020-09-29 17:24:07 +02:00
cli_options.go update docker, replace github.com/docker/pkg/term, github.com/docker/pkg/mount 2020-04-22 17:16:13 +02:00
cli_options_test.go bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-02-23 00:28:55 +01:00
cli_test.go Fix initializing client modifying custom HTTPHeaders 2020-09-29 17:24:07 +02:00
context.go Don't loose additional metadata fields 2020-06-10 15:07:23 +02:00
context_test.go Don't loose additional metadata fields 2020-06-10 15:07:23 +02:00
defaultcontextstore.go Push check for kubernetes requirement down into the endpoint 2019-05-20 13:28:11 +01:00
defaultcontextstore_test.go bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-02-23 00:28:55 +01:00
events_utils.go updated vendoring 2017-09-01 19:41:06 -04:00
orchestrator.go Fast Context Switch: commands 2019-01-10 22:25:43 +01:00
orchestrator_test.go bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-02-23 00:28:55 +01:00
registry.go update docker, replace github.com/docker/pkg/term, github.com/docker/pkg/mount 2020-04-22 17:16:13 +02:00
registry_test.go bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-02-23 00:28:55 +01:00
streams.go Extract streams helpers from command package to their own package to remove a cyclic dependency from command to internal/containerizedengine 2019-01-28 14:36:00 +01:00
trust.go Refactor content_trust cli/flags handling 2018-03-08 15:00:43 -05:00
utils.go docker cp: prevent NPE when failing to stat destination 2019-12-09 15:32:02 +01:00
utils_test.go bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-02-23 00:28:55 +01:00