DockerCLI/cli
Sebastiaan van Stijn e26416f371
cli/registry/client: set actions when authn with token
When using a personal access token, Docker Hub produces an error if actions
are requested beyond the token's allowed actions. This resulted in errors
when using a PAT with limited permissions to do a "docker manifest inspect".

This patch sets actions to "pull" only by default, and requests "push" action
for requests that need it.

To verify:

- create a PAT with limited access (read-only)
- log in with your username and the PAT as password

Before this patch:

    docker manifest inspect ubuntu:latest
    Get "https://registry-1.docker.io/v2/library/ubuntu/manifests/latest": unauthorized: access token has insufficient scopes

With this patch applied:

    docker manifest inspect ubuntu:latest
    {
       "schemaVersion": 2,
       "mediaType": "application/vnd.oci.image.index.v1+json",
       "manifests": [
          {
             "mediaType": "application/vnd.oci.image.manifest.v1+json",
             "size": 424,
             "digest": "sha256:56887c5194fddd8db7e36ced1c16b3569d89f74c801dc8a5adbf48236fb34564",
             "platform": {
                "architecture": "amd64",
                "os": "linux"
             }
          },
          {
             "mediaType": "application/vnd.oci.image.manifest.v1+json",
             "size": 424,
             "digest": "sha256:c835a4f2a632bc91a2b494e871549f0dd83f2966c780e66435774e77e048ddf0",
             "platform": {
                "architecture": "arm",
                "os": "linux",
                "variant": "v7"
             }
          }
       ]
    }

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit d2047b954e)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-22 21:56:45 +02:00
..
command cli/command/volume: remove name for unused arg (revive) 2023-07-15 15:24:46 +02:00
compose cli/compose/schema: remove name for unused arg (revive) 2023-07-15 15:25:05 +02:00
config configfile: Initialize nil AuthConfigs 2023-07-19 16:18:16 +02:00
connhelper cli/connhelper/commandconn: remove name for unused arg (revive) 2023-07-15 15:25:23 +02:00
context context: avoid corrupt file writes 2023-03-01 16:14:03 +01:00
debug updated vendoring 2017-09-01 19:41:06 -04:00
flags docs: update description for docker -H flag 2023-05-08 15:11:10 +02:00
manifest manifest: save raw manifest content on download 2023-01-27 13:56:17 +00:00
registry/client cli/registry/client: set actions when authn with token 2023-08-22 21:56:45 +02:00
streams update docker, replace github.com/docker/pkg/term, github.com/docker/pkg/mount 2020-04-22 17:16:13 +02:00
trust cli/trust: remove name for unused args (revive) 2023-07-15 15:21:26 +02:00
version Move versioning variables to a separate package. 2019-01-29 11:26:40 +00:00
winresources Use goversioninfo to create Windows Version Info 2021-10-11 16:54:22 +02:00
cobra.go load plugin command stubs when required 2023-03-31 16:38:01 +02:00
cobra_test.go cli: use custom annotation for aliases 2022-06-28 17:32:09 +02:00
error.go Import docker/docker/cli 2017-04-17 17:40:59 -04:00
required.go format (GoDoc) comments with Go 1.19 to prepare for go updates 2022-07-19 19:10:16 +02:00
required_test.go cli: remove deprecated io/ioutil 2022-02-25 15:42:19 +01:00