The tree output currently uses the same sort order as the existing
non-tree output, and orders the images by "created" time in descending
order;
docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> 8262a6d8c38a 7 minutes ago 13.6MB
docker-cli-dev latest f5f0547476ee 12 minutes ago 762MB
nginx alpine 2140dad235c1 2 weeks ago 76.7MB
alpine latest beefdbd8a1da 6 weeks ago 24.2MB
However, the `--tree` view does not have a `CREATED` column, which makes
the output order seem "random". With the tree view being more verbose,
it may also be harder to find back images in the list when they're not sorted
in an easy to discover way.
This patch changes the sort order:
- alphabetically (natural sort) for tagged images
- untagged images are sorted last, as they're likely less relevant
to the user, and should not be "polluting" th top of the list.
- if multiple untagged images exist, they are sorted by created
date (descending) to get a stable order.
Before this patch:
$ docker image ls --tree
IMAGE ID DISK USAGE CONTENT SIZE USED
<untagged> 20ad73eca911 13.6MB 4.09MB ✔
└─ linux/arm64 1ab6fc68586e 13.6MB 4.09MB ✔
<untagged> b3e87f642f5c 13.6MB 4.09MB
└─ linux/arm64 1ab6fc68586e 13.6MB 4.09MB
docker-cli-dev:latest f5f0547476ee 762MB 179MB ✔
└─ linux/arm64 18ca7881145d 762MB 179MB ✔
nginx:alpine 2140dad235c1 76.7MB 21.5MB
├─ linux/arm64/v8 d1f949a77b81 76.7MB 21.5MB
├─ linux/amd64 ae136e431e76 0B 0B
├─ linux/arm/v6 ae1ee4b63c14 0B 0B
├─ linux/arm/v7 20ad73eca911 0B 0B
├─ linux/386 1e69bfb21757 0B 0B
├─ linux/ppc64le 7fef8bcf8b6c 0B 0B
└─ linux/s390x 8c310bf29cfa 0B 0B
alpine:latest beefdbd8a1da 24.2MB 7.46MB
├─ linux/riscv64 80cde017a105 10.6MB 3.37MB
├─ linux/arm64/v8 9cee2b382fe2 13.6MB 4.09MB
├─ linux/amd64 33735bd63cf8 0B 0B
├─ linux/arm/v6 50f635c8b04d 0B 0B
├─ linux/arm/v7 f2f82d424957 0B 0B
├─ linux/386 b3e87f642f5c 0B 0B
├─ linux/ppc64le c7a6800e3dc5 0B 0B
└─ linux/s390x 2b5b26e09ca2 0B 0B
With this patch:
$ docker image ls --tree
IMAGE ID DISK USAGE CONTENT SIZE USED
alpine:latest beefdbd8a1da 24.2MB 7.46MB
├─ linux/riscv64 80cde017a105 10.6MB 3.37MB
├─ linux/arm64/v8 9cee2b382fe2 13.6MB 4.09MB
├─ linux/amd64 33735bd63cf8 0B 0B
├─ linux/arm/v6 50f635c8b04d 0B 0B
├─ linux/arm/v7 f2f82d424957 0B 0B
├─ linux/386 b3e87f642f5c 0B 0B
├─ linux/ppc64le c7a6800e3dc5 0B 0B
└─ linux/s390x 2b5b26e09ca2 0B 0B
docker-cli-dev:latest f5f0547476ee 762MB 179MB ✔
└─ linux/arm64 18ca7881145d 762MB 179MB ✔
nginx:alpine 2140dad235c1 76.7MB 21.5MB
├─ linux/arm64/v8 d1f949a77b81 76.7MB 21.5MB
├─ linux/amd64 ae136e431e76 0B 0B
├─ linux/arm/v6 ae1ee4b63c14 0B 0B
├─ linux/arm/v7 20ad73eca911 0B 0B
├─ linux/386 1e69bfb21757 0B 0B
├─ linux/ppc64le 7fef8bcf8b6c 0B 0B
└─ linux/s390x 8c310bf29cfa 0B 0B
<untagged> 20ad73eca911 13.6MB 4.09MB ✔
└─ linux/arm64 1ab6fc68586e 13.6MB 4.09MB ✔
<untagged> b3e87f642f5c 13.6MB 4.09MB
└─ linux/arm64 1ab6fc68586e 13.6MB 4.09MB
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Remove the registerCompletionFuncForGlobalFlags for now, as
the error it returned was ignored, so it didn't add much
benefit, other than abstracting things.
Split the underlying completion-functions to separate
functions, and add some basic tests for them.
Remove the completions helper, as it now didn't add much,
and it saved having the dependency on the package.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Before:
go test -test.coverprofile -
PASS
coverage: 65.2% of statements
ok github.com/docker/cli/templates 0.607s
After:
go test -test.coverprofile -
PASS
coverage: 95.7% of statements
ok github.com/docker/cli/templates 0.259s
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Prevent some tests from failing when running from a pre-compiled
testbinary, and discard output to make the output less noisy.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit implements a validation
method for the port mappings.
Also, it removes the ports validation
method from the expose property
since they do not accept the
same type of values.
Signed-off-by: Stavros Panakakis <stavrospanakakis@gmail.com>
When running tests from my IDE, it compiles the tests before running,
then executes the compiled binary to run the tests. Cobra doesn't like that,
because in that situation os.Args is taken as argument for the command that's
executed. The command that's tested now sees the `test-` flags as arguments
(`-test.v -test.run ..`), which causes various tests to fail ("Command XYZ
does not accept arguments").
# compile the tests:
go test -c -o foo.test
# execute the test:
./foo.test -test.v -test.run TestFoo
=== RUN TestFoo
Error: "foo" accepts no arguments.
Set arguments to an empty slice to make sure it doesn't inherit arguments
from the test-binary.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>