DockerCLI/cli/config/configfile
Sebastiaan van Stijn 3f19902eae
Config-file: remove User-Agent from config.json when saving
The config.json allows for setting custom HTTP headers, but given that
User-Agent is not customizable, we should remove it from the config before saving;

Before this change;

    $ 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
    {
        "auths": {
            "https://index.docker.io/v1/": {
                "auth": "<base64 auth>"
            }
        },
        "HttpHeaders": {
            "User-Agent": "Docker-Client/19.03.12 (linux)"
        }
    }

    $ 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-10-01 15:04:39 +02:00
..
testdata Simplify cli plugin config file entry 2019-02-25 10:38:48 +00:00
file.go Config-file: remove User-Agent from config.json when saving 2020-10-01 15:04:39 +02:00
file_test.go Config-file: remove User-Agent from config.json when saving 2020-10-01 15:04:39 +02:00
file_unix.go config: preserve ownership and permissions on configfile 2019-12-17 09:57:33 +01:00
file_windows.go config: preserve ownership and permissions on configfile 2019-12-17 09:57:33 +01:00