Commit Graph

21 Commits

Author SHA1 Message Date
Sebastiaan van Stijn 809eb8cdee
images: print hint when invoking "docker images" with ambiguous argument
The `docker images` top-level subcommand predates the `docker <object> <verb>`
convention (e.g. `docker image ls`), but accepts a positional argument to
search/filter images by name (globbing). It's common for users to accidentally
mistake these commands, and to use (e.g.) `docker images ls`, expecting
to see all images, but ending up with an empty list because no image named
"ls" was found.

Disallowing these search-terms would be a breaking change, but we can print
and informational message to help the users correct their mistake.

Before this patch:

    docker images ls
    REPOSITORY   TAG       IMAGE ID   CREATED   SIZE

With this patch applied:

    docker images ls
    REPOSITORY   TAG       IMAGE ID   CREATED   SIZE

    No images found matching "ls": did you mean "docker image ls"?

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-02-03 18:10:55 +01:00
Paweł Gronowski 4fa2fe9b9e
Replace deprecated types.Image* usage
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-01-24 14:59:10 +01:00
Sebastiaan van Stijn 46d0ba20f1
vendor: github.com/docker/docker cdb3f9fb8dca (v25.0.0-dev)
full diff: d3afa80b96...cdb3f9fb8d

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-13 22:09:04 +02:00
Paweł Gronowski a1953e19b2
test/cli: Use empty array as empty output of images/json
Tests mocking the output of GET images/json with fakeClient used an
array with one empty element as an empty response.
Change it to just an empty array.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-02-24 15:05:32 +01:00
Sebastiaan van Stijn d14b5bff80
cli/command/image: remove deprecated io/ioutil and use t.TempDir()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-02-25 15:41:55 +01:00
Dominik Braun 1570025f00 Remove 'images' alias from 'image ls' command
Signed-off-by: Dominik Braun <Dominik.Braun@nbsp.de>

Remove assertion for 'images' alias of 'image ls'

Signed-off-by: Dominik Braun <Dominik.Braun@nbsp.de>
2020-06-15 17:48:43 +02:00
Sebastiaan van Stijn 719169db63
Replace deprecated Cobra command.SetOutput() with command.SetOut()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-05-07 14:25:59 +02:00
Sebastiaan van Stijn 2c0e93063b
bump gotest.tools v3.0.1 for compatibility with Go 1.14
full diff: https://github.com/gotestyourself/gotest.tools/compare/v2.3.0...v3.0.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-02-23 00:28:55 +01:00
Vincent Demeester 2c4de4fb5e
Update tests to use gotest.tools 👼
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2018-06-08 18:24:26 +02:00
Daniel Nephin baf65a5502 Convert to assert.NilError
Using:

  git grep -l '^\s\+assert\.Check(t, err)$' | \
    xargs sed -i -e 's/^\(\s\+assert\)\.Check(t, err)$/\1.NilError(t, err)/'

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-03-06 15:27:34 -05:00
Daniel Nephin 681c921528 Remove testutil
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-03-06 14:38:35 -05:00
Daniel Nephin 39c2ca57c1 Automated migration
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-03-05 19:41:17 -05:00
Daniel Nephin 846a31aa50 Use new internal testutil.ErrorContains()
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-08-22 10:14:25 -04:00
Daniel Nephin b3f843afe2 Move internal/test package out of cli.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-08-22 10:14:25 -04:00
Daniel Nephin 75f7bfedf8 Update image command tests to use the new golden
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-08-16 14:20:36 -04:00
Sebastiaan van Stijn b9a7f35e02
Singularize / pluralize "argument(s)" in error message
The validation functions to test for the number of passed arguments did not
pluralize `argument(s)`, and used `argument(s)` in all cases.

This patch adds a simple `pluralize()` helper to improve this.

Before this change, `argument(s)` was used in all cases:

    $ docker container ls foobar
    "docker container ls" accepts no argument(s).

    $ docker network create one two
    "docker network create" requires exactly 1 argument(s).

    $ docker network connect
    "docker network connect" requires exactly 2 argument(s).

    $ docker volume create one two
    "docker volume create" requires at most 1 argument(s).

After this change, `argument(s)` is properly singularized or plurarized:

    $ docker container ls foobar
    "docker container ls" accepts no arguments.

    $ docker network create one two
    "docker network create" requires exactly 1 argument.

    $ docker network connect
    "docker network connect" requires exactly 2 arguments.

    $ docker volume create one two
    "docker volume create" requires at most 1 argument.

Test cases were updated accordingly.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2017-08-12 18:25:38 +02:00
Daniel Nephin 42a3800783 Update some tests to remove unnecessary buffers.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-07-11 17:52:43 -04:00
Daniel Nephin 3da0cbfdd1 Remove unnecessary use of SetConfigfile
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-07-11 14:49:30 -04:00
Daniel Nephin 69b142b52a Update FakeCli to remove duplication in tests.
Use byte buffers by default, since that is what is done most of the time.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-07-11 14:49:30 -04:00
Aaron Lehmann 6f94ab98f5 cli: Correct command/image tests for testify
These tests were caught in the crossfire of the transition to testify.
testify has a few subtle differences from the similar custom framework
it replaced:

- Error behaves differently
- Equal takes its arguments in a different order

This PR also takes the opportunity to use a few shorthands from testify,
such as Len, True, and False.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2017-05-03 18:45:48 -07:00
Ignacio Capurro e7793092a2 Unit tests for cli/commands/image (except build and tag)
Signed-off-by: Ignacio Capurro <icapurrofagian@gmail.com>
2017-05-03 18:40:22 -07:00