Skip to content

inspect: add shell completion, improve flag-description for --type and improve validation #6052

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 6, 2025

Conversation

thaJeztah
Copy link
Member

@thaJeztah thaJeztah commented May 6, 2025

inspect: disable default (file) completion

Before this patch, flags and arguments would complete using filenames
from the current directory;

docker inspect --type <TAB>
AUTHORS       CONTRIBUTING.md             docs/             Makefile            SECURITY.md
...

docker inspect <TAB>

With this patch, no completion is provided;

docker inspect --type <TAB>
# no results

docker inspect <TAB>
# no results

inspect: add shell-completion for "--type" flag

With this patch:

docker inspect --type <TAB>
config     image    node    secret   task
container  network  plugin  service  volume

inspect: update flag description of "--type" flag

Before this patch:

docker inspect --help | grep '\-\-type'
      --type string     Return JSON for specified type

With this patch:

docker inspect --help | grep '\-\-type'
      --type string     Only inspect objects of the given type

inspect: improve (flag) validation

Produce an error if the --type flag was set, but an empty value
was passed.

Before this patch:

docker inspect --type "" foo
# json output

docker inspect --type unknown foo
"unknown" is not a valid value for --type

With this patch:

docker inspect --type "" foo
type is empty: must be one of "config", "container", "image", "network", "node", "plugin", "secret", "service", "task", "volume"

docker inspect --type unknown foo
unknown type: "unknown": must be one of "config", "container", "image", "network", "node", "plugin", "secret", "service", "task", "volume"

- Human readable description for the release notes

`docker inspect`: add shell completion, improve flag-description for `--type` and improve validation

- A picture of a cute animal (not mandatory but encouraged)

thaJeztah added 5 commits May 6, 2025 15:43
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Before this patch, flags and arguments would complete using filenames
from the current directory;

    docker inspect --type <TAB>
    AUTHORS       CONTRIBUTING.md             docs/             Makefile            SECURITY.md
    ...

    docker inspect <TAB>

With this patch, no completion is provided;

    docker inspect --type <TAB>
    # no results

    docker inspect <TAB>
    # no results

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
With this patch:

    docker inspect --type <TAB>
    config     image    node    secret   task
    container  network  plugin  service  volume

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Before this patch:

    docker inspect --help | grep '\-\-type'
          --type string     Return JSON for specified type

With this patch:

    docker inspect --help | grep '\-\-type'
          --type string     Only inspect objects of the given type

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Produce an error if the `--type` flag was set, but an empty value
was passed.

Before this patch:

    docker inspect --type "" foo
    # json output

    docker inspect --type unknown foo
    "unknown" is not a valid value for --type

With this patch:

    docker inspect --type "" foo
    type is empty: must be one of "config", "container", "image", "network", "node", "plugin", "secret", "service", "task", "volume"

    docker inspect --type unknown foo
    unknown type: "unknown": must be one of "config", "container", "image", "network", "node", "plugin", "secret", "service", "task", "volume"

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@codecov-commenter
Copy link

codecov-commenter commented May 6, 2025

Codecov Report

Attention: Patch coverage is 48.14815% with 14 lines in your changes missing coverage. Please review.

Project coverage is 59.07%. Comparing base (25a1681) to head (52752f3).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6052      +/-   ##
==========================================
+ Coverage   58.99%   59.07%   +0.08%     
==========================================
  Files         358      358              
  Lines       30004    30013       +9     
==========================================
+ Hits        17700    17731      +31     
+ Misses      11323    11301      -22     
  Partials      981      981              
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
@thaJeztah thaJeztah merged commit a2a1376 into docker:master May 6, 2025
105 checks passed
@thaJeztah thaJeztah deleted the inspect_completion branch May 6, 2025 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment