DockerCLI/cli/command/trust
Sebastiaan van Stijn 9e620e990f
implement docker push -a/--all-tags
The `docker push` command up until [v0.9.1](https://github.com/moby/moby/blob/v0.9.1/api/client.go#L998)
always pushed all tags of a given image, so `docker push foo/bar` would push (e.g.)
all of  `foo/bar:latest`, `foo:/bar:v1`, `foo/bar:v1.0.0`.

Pushing all tags of an image was not desirable in many case, so docker v0.10.0
enhanced `docker push` to optionally specify a tag to push (`docker push foo/bar:v1`)
(see https://github.com/moby/moby/issues/3411 and the pull request that implemented
this: https://github.com/moby/moby/pull/4948).

This behavior exists up until today, and is confusing, because unlike other commands,
`docker push` does not default to use the `:latest` tag when omitted, but instead
makes it push "all tags of the image"

For example, in the following situation;

```
docker images

REPOSITORY          TAG                        IMAGE ID            CREATED             SIZE
thajeztah/myimage   latest                     b534869c81f0        41 hours ago        1.22MB
```

Running `docker push thajeztah/myimage` seemingly does the expected behavior (it
pushes `thajeztah/myimage:latest` to Docker Hub), however, it does not so for the
reason expected (`:latest` being the default tag), but because `:latest` happens
to be the only tag present for the `thajeztah/myimage` image.

If another tag exists for the image:

```
docker images

REPOSITORY          TAG                        IMAGE ID            CREATED             SIZE
thajeztah/myimage   latest                     b534869c81f0        41 hours ago        1.22MB
thajeztah/myimage   v1.0.0                     b534869c81f0        41 hours ago        1.22MB
```

Running the same command (`docker push thajeztah/myimage`) will push _both_ images
to Docker Hub.

> Note that the behavior described above is currently not (clearly) documented;
> the `docker push` reference documentation (https://docs.docker.com/engine/reference/commandline/push/)
does not mention that omitting the tag will push all tags

This patch changes the default behavior, and if no tag is specified, `:latest` is
assumed. To push _all_ tags, a new flag (`-a` / `--all-tags`) is added, similar
to the flag that's present on `docker pull`.

With this change:

- `docker push myname/myimage` will be the equivalent of `docker push myname/myimage:latest`
- to push all images, the user needs to set a flag (`--all-tags`), so `docker push --all-tags myname/myimage:latest`

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-01-28 16:21:06 +01:00
..
testdata [WIP] fix trust inspect typo 'AdminstrativeKeys' 2018-08-19 17:57:04 -07:00
cmd.go Merge pull request #935 from n4ss/trust-out-of-experimental2 2018-03-13 16:59:50 -07:00
common.go [WIP] fix trust inspect typo 'AdminstrativeKeys' 2018-08-19 17:57:04 -07:00
common_test.go use sortorder lib for sorting in trust package 2018-08-08 12:20:10 -04:00
formatter.go formatter package heavy refactoring 2018-10-23 17:05:44 +02:00
formatter_test.go formatter package heavy refactoring 2018-10-23 17:05:44 +02:00
helpers.go Move notary to its new location 2017-10-30 17:21:41 +01:00
helpers_test.go Update tests to use gotest.tools 👼 2018-06-08 18:24:26 +02:00
inspect.go [WIP] fix trust inspect typo 'AdminstrativeKeys' 2018-08-19 17:57:04 -07:00
inspect_pretty.go formatter package heavy refactoring 2018-10-23 17:05:44 +02:00
inspect_pretty_test.go cli/command/trust/inspect_pretty_test.go:399:24: SA4010: this result of append is never used, except maybe in other appends (staticcheck) 2019-10-31 19:22:10 +01:00
inspect_test.go refactor trust inspect command unit tests to table-driven style 2018-08-08 13:50:00 -04:00
key.go Move Docker Trust out of experimental 2018-03-09 13:29:14 -08:00
key_generate.go cli/command/trust: SA1006: printf-style with no further arguments (staticcheck) 2019-10-31 19:22:28 +01:00
key_generate_test.go Update tests to use gotest.tools 👼 2018-06-08 18:24:26 +02:00
key_load.go Windows: skip permissions check on key 2019-06-25 00:12:01 +02:00
key_load_test.go cli/command/trust: Using the variable on range scope `keyBytes` in function literal (scopelint) 2019-10-31 19:22:35 +01:00
revoke.go Add more content trust tests 2018-03-19 10:02:40 +01:00
revoke_test.go refactored trust revoke command unit tests to use table-driven style 2018-08-09 15:58:54 -04:00
sign.go implement docker push -a/--all-tags 2020-01-28 16:21:06 +01:00
sign_test.go cli/command/trust/sign_test.go:119:70: unnecessary conversion (unconvert) 2019-10-31 19:22:23 +01:00
signer.go Move Docker Trust out of experimental 2018-03-09 13:29:14 -08:00
signer_add.go Add more content trust tests 2018-03-19 10:02:40 +01:00
signer_add_test.go Update tests to use gotest.tools 👼 2018-06-08 18:24:26 +02:00
signer_remove.go Update hints for linting 2018-07-13 11:18:50 +02:00
signer_remove_test.go Merge pull request #1112 from n4ss/fix-trust-signer-remove 2018-06-15 08:18:29 -07:00