Commit Graph

202 Commits

Author SHA1 Message Date
Sebastiaan van Stijn ae2b58fd98
Merge pull request #4700 from thaJeztah/wire_up_contexts
Plumb contexts through commands
2023-12-13 22:29:51 +01:00
Sebastiaan van Stijn 8f13b04162
cli/command: remove "logentries" driver from tests and fixtures
This driver has been deprecated and removed because the service
is no longer operational. Remove it from the tests to better reflect
reality.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-12-13 13:18:16 +01:00
Brian Goff 5400a48aaf
Plumb contexts through commands
This is to prepare for otel support.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-12-12 22:30:16 +01:00
David Karlsson 8bbc97c867 prune: fix build cache prune warning
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
2023-12-05 20:11:15 +01:00
Sebastiaan van Stijn 0e73168b7e
golangci-lint: revive: enable use-any
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-11-20 19:52:46 +01:00
Sebastiaan van Stijn 8e9aec6904
golangci-lint: revive: enable import-shadowing
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-11-20 19:52:41 +01:00
Sebastiaan van Stijn 2d61f70f00
golangci-lint: govet: enable shadow check
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-11-20 16:02:18 +01:00
Sebastiaan van Stijn 8e98c765f8
cli/command/system: fix deprecated comments (gocritic)
cli/command/system/info.go:470:1: deprecatedComment: use `Deprecated: ` (note the casing) instead of `DEPRECATED: ` (gocritic)
    // DEPRECATED: warnings are now generated by the daemon, and returned in
    ^
    cli/command/system/info.go:492:1: deprecatedComment: use `Deprecated: ` (note the casing) instead of `DEPRECATED: ` (gocritic)
    // DEPRECATED: warnings are now generated by the daemon, and returned in
    ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-11-20 16:02:17 +01:00
Sebastiaan van Stijn a2c9f3c6ce
linting: address else/if/elseif statements found by gocritic
cli/command/formatter/tabwriter/tabwriter.go:579:10: elseif: can replace 'else {if cond {}}' with 'else if cond {}' (gocritic)
              } else {
                     ^
    cli/connhelper/connhelper.go:43:2: singleCaseSwitch: should rewrite switch statement to if statement (gocritic)
    	switch scheme := u.Scheme; scheme {
    	^
    cli/compose/loader/loader.go:666:10: elseif: can replace 'else {if cond {}}' with 'else if cond {}' (gocritic)
    		} else {
    		       ^
    opts/hosts_test.go:173:10: elseif: can replace 'else {if cond {}}' with 'else if cond {}' (gocritic)
    		} else {
    		       ^
    cli-plugins/manager/candidate_test.go:78:4: ifElseChain: rewrite if-else to switch statement (gocritic)
    			if tc.err != "" {
    			^
    cli/command/checkpoint/formatter.go:15:2: singleCaseSwitch: should rewrite switch statement to if statement (gocritic)
    	switch source {
    	^
    cli/command/image/formatter_history.go:25:2: singleCaseSwitch: should rewrite switch statement to if statement (gocritic)
    	switch source {
    	^
    cli/command/service/scale.go:107:2: ifElseChain: rewrite if-else to switch statement (gocritic)
    	if serviceMode.Replicated != nil {
    	^
    cli/command/service/update.go:804:9: elseif: can replace 'else {if cond {}}' with 'else if cond {}' (gocritic)
    	} else {
    	       ^
    cli/command/service/update.go:222:2: ifElseChain: rewrite if-else to switch statement (gocritic)
    	if sendAuth {
    	^
    cli/command/container/formatter_diff.go:17:2: singleCaseSwitch: should rewrite switch statement to if statement (gocritic)
    	switch source {
    	^
    cli/command/container/start.go:79:2: ifElseChain: rewrite if-else to switch statement (gocritic)
    	if opts.Attach || opts.OpenStdin {
    	^
    cli/command/container/utils.go:84:11: elseif: can replace 'else {if cond {}}' with 'else if cond {}' (gocritic)
    			} else {
    			       ^
    cli/command/container/exec_test.go:200:11: elseif: can replace 'else {if cond {}}' with 'else if cond {}' (gocritic)
    			} else {
    			       ^
    cli/command/container/logs_test.go:52:11: elseif: can replace 'else {if cond {}}' with 'else if cond {}' (gocritic)
    			} else {
    			       ^
    cli/command/container/opts_test.go:1014:10: elseif: can replace 'else {if cond {}}' with 'else if cond {}' (gocritic)
    		} else {
    		       ^
    cli/command/system/info.go:297:7: singleCaseSwitch: should rewrite switch statement to if statement (gocritic)
    						switch o.Key {
    						^
    cli/command/system/version.go:164:4: singleCaseSwitch: should rewrite switch statement to if statement (gocritic)
    			switch component.Name {
    			^
    cli/command/system/info_test.go:478:4: ifElseChain: rewrite if-else to switch statement (gocritic)
    			if tc.expectedOut != "" {
    			^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-11-20 16:02:16 +01:00
Sebastiaan van Stijn d0dee3cebe
linting: Consider pre-allocating sliceVar (prealloc)
While updating, also addressed some redundant fmt.Sprintf()

    opts/throttledevice.go:86:2: Consider pre-allocating `out` (prealloc)
        var out []string
        ^
    opts/ulimit.go:37:2: Consider pre-allocating `out` (prealloc)
        var out []string
        ^
    opts/ulimit.go:47:2: Consider pre-allocating `ulimits` (prealloc)
        var ulimits []*units.Ulimit
        ^
    opts/weightdevice.go:68:2: Consider pre-allocating `out` (prealloc)
        var out []string
        ^
    cli/context/store/metadatastore.go:96:2: Consider pre-allocating `res` (prealloc)
        var res []Metadata
        ^
    cli/context/store/store.go:127:2: Consider pre-allocating `names` (prealloc)
        var names []string
        ^
    cli/compose/loader/loader.go:223:2: Consider pre-allocating `keys` (prealloc)
        var keys []string
        ^
    cli/compose/loader/loader.go:397:2: Consider pre-allocating `services` (prealloc)
        var services []types.ServiceConfig
        ^
    cli/command/stack/loader/loader.go:63:2: Consider pre-allocating `msgs` (prealloc)
        var msgs []string
        ^
    cli/command/stack/loader/loader.go:118:2: Consider pre-allocating `configFiles` (prealloc)
        var configFiles []composetypes.ConfigFile
        ^
    cli/command/formatter/container.go:245:2: Consider pre-allocating `joinLabels` (prealloc)
        var joinLabels []string
        ^
    cli/command/formatter/container.go:265:2: Consider pre-allocating `mounts` (prealloc)
        var mounts []string
        ^
    cli/command/formatter/container.go:316:2: Consider pre-allocating `result` (prealloc)
        var result []string
        ^
    cli/command/formatter/displayutils.go:43:2: Consider pre-allocating `display` (prealloc)
        var (
        ^
    cli/command/formatter/volume.go:103:2: Consider pre-allocating `joinLabels` (prealloc)
        var joinLabels []string
        ^
    cli-plugins/manager/manager_test.go:49:2: Consider pre-allocating `dirs` (prealloc)
        var dirs []string
        ^
    cli/command/swarm/init.go:69:2: Consider pre-allocating `defaultAddrPool` (prealloc)
        var defaultAddrPool []string
        ^
    cli/command/manifest/push.go:195:2: Consider pre-allocating `blobReqs` (prealloc)
        var blobReqs []manifestBlob
        ^
    cli/command/secret/formatter.go:111:2: Consider pre-allocating `joinLabels` (prealloc)
        var joinLabels []string
        ^
    cli/command/network/formatter.go:104:2: Consider pre-allocating `joinLabels` (prealloc)
        var joinLabels []string
        ^
    cli/command/context/list.go:52:2: Consider pre-allocating `contexts` (prealloc)
        var contexts []*formatter.ClientContext
        ^
    cli/command/config/formatter.go:104:2: Consider pre-allocating `joinLabels` (prealloc)
        var joinLabels []string
        ^
    cli/command/trust/common_test.go:23:2: Consider pre-allocating `targetNames` (prealloc)
        var targetNames []string
        ^
    cli/command/service/generic_resource_opts.go:55:2: Consider pre-allocating `generic` (prealloc)
        var generic []swarm.GenericResource
        ^
    cli/command/service/generic_resource_opts.go:98:2: Consider pre-allocating `l` (prealloc)
        var l []swarm.GenericResource
        ^
    cli/command/service/opts.go:378:2: Consider pre-allocating `netAttach` (prealloc)
        var netAttach []swarm.NetworkAttachmentConfig
        ^
    cli/command/service/update.go:731:2: Consider pre-allocating `limits` (prealloc)
        var limits []*units.Ulimit
        ^
    cli/command/service/update.go:1315:2: Consider pre-allocating `newNetworks` (prealloc)
        var newNetworks []swarm.NetworkAttachmentConfig
        ^
    cli/command/service/update.go:1514:2: Consider pre-allocating `out` (prealloc)
        var out []string
        ^
    cli/compose/convert/service.go:713:2: Consider pre-allocating `ulimits` (prealloc)
        var ulimits []*units.Ulimit
        ^
    cli/compose/convert/volume.go:13:2: Consider pre-allocating `mounts` (prealloc)
        var mounts []mount.Mount
        ^
    cli/command/stack/swarm/list.go:39:2: Consider pre-allocating `stacks` (prealloc)
        var stacks []*formatter.Stack
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-11-20 16:02:16 +01:00
Sebastiaan van Stijn 04af128211
vendor: github.com/docker/docker 7abd7fa73965 (v25.0.0-dev)
full diff: a65c948e7e...7abd7fa739

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-09-05 13:43:35 +02:00
Sebastiaan van Stijn 6dfdd1eae9
cli/command/system: fix "docker events" not supporting --format=json
Before this patch:

    docker events --format=json
    json
    json
    json
    ^C

With this patch:

    docker events --format=json
    {"status":"create","id":"4ac3bba8abd68961e627540fed81ad16d55b88e45629d7cdb792126d09b6488d","from":"hello-world","Type":"container","Action":"create","Actor":{"ID":"4ac3bba8abd68961e627540fed81ad16d55b88e45629d7cdb792126d09b6488d","Attributes":{"image":"hello-world","name":"dreamy_goldstine"}},"scope":"local","time":1693168508,"timeNano":1693168508190136885}
    {"status":"attach","id":"4ac3bba8abd68961e627540fed81ad16d55b88e45629d7cdb792126d09b6488d","from":"hello-world","Type":"container","Action":"attach","Actor":{"ID":"4ac3bba8abd68961e627540fed81ad16d55b88e45629d7cdb792126d09b6488d","Attributes":{"image":"hello-world","name":"dreamy_goldstine"}},"scope":"local","time":1693168508,"timeNano":1693168508192851593}
    {"Type":"network","Action":"connect","Actor":{"ID":"c54920dd5074a73e28bea62007e0334d81cc040a90372be311cf16806403d350","Attributes":{"container":"4ac3bba8abd68961e627540fed81ad16d55b88e45629d7cdb792126d09b6488d","name":"bridge","type":"bridge"}},"scope":"local","time":1693168508,"timeNano":1693168508212398802}
    {"status":"start","id":"4ac3bba8abd68961e627540fed81ad16d55b88e45629d7cdb792126d09b6488d","from":"hello-world","Type":"container","Action":"start","Actor":{"ID":"4ac3bba8abd68961e627540fed81ad16d55b88e45629d7cdb792126d09b6488d","Attributes":{"image":"hello-world","name":"dreamy_goldstine"}},"scope":"local","time":1693168508,"timeNano":1693168508312969843}
    ^C

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-29 14:48:49 +02:00
Sebastiaan van Stijn 1c2cc4bbe3
info: add CDI spec directories to output
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-22 14:05:07 +02:00
Ed Morley 6e2e92d774
Update docs/command output for volume pruning
In previous versions of the Docker API, `system prune --volumes` and `volume prune`
would remove all dangling volumes. With API v1.42, this was changed so that only
anonymous volumes would be removed unless the all filter was specified.

Some of the docs were updated in #4218, however, there were a couple of places
left that didn't make the anonymous vs named volumes distinction clear.

This replaces #4079, which was bitrotted by #4218. See also #4028.

Closes #4079.

Signed-off-by: Ed Morley <501702+edmorley@users.noreply.github.com>
2023-08-12 14:22:23 +01:00
Sebastiaan van Stijn 3d0b14c3e3
vendor: github.com/docker/docker 4b19b2f4babd (25.0-dev)
full diff: dab9ffb252...4b19b2f4ba

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-08 09:41:47 +02:00
Sebastiaan van Stijn 3469beb80d
replace uses of deprecated api/types that moved to api/types/system
These types were moved to api/types/system:

- types.Info
- types.Commit
- types.PluginsInfo
- types.NetworkAddressPool
- types.Runtime
- types.SecurityOpt
- types/KeyValue
- types.DecodeSecurityOptions()

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-15 01:20:49 +02:00
Sebastiaan van Stijn 92d7a234dd
docker info: fix condition for printing debug information
The daemon collects this information regardless if "debug" is
enabled. Print the debugging information if either the daemon,
or the client has debug enabled.

We should probably improve this logic and print any of these if
set (but some special rules are needed for file-descriptors, which
may use "-1".

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-30 15:00:31 +02:00
Sebastiaan van Stijn f4bde68694
replace some basic uses of fmt.Sprintf()
Really tiny gains here, and doesn't significantly impact readability:

    BenchmarkSprintf
    BenchmarkSprintf-10    11528700     91.59 ns/op   32 B/op  1 allocs/op
    BenchmarkConcat
    BenchmarkConcat-10    100000000     11.76 ns/op    0 B/op  0 allocs/op

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-12 19:03:49 +02:00
Sebastiaan van Stijn 1ec68fabe4
cli/command/system: remove aufs from fixtures
The AuFS storage driver was deprecated and has been removed, so let's
update the test-fixtures accordingly.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-19 00:55:31 +02:00
Sebastiaan van Stijn 2fc30fd456
replace uses of client.IsErrNotFound for errdefs.IsNotFound
None of the client will return the old error-types, so there's no need
to keep the compatibility code. We can consider deprecating this function
in favor of the errdefs equivalent this.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-11 23:09:29 +02:00
Sebastiaan van Stijn 155f7d9e2b
cli/command/system: add utilities for printing
Adding some utilities to print the output, to keep the linters happier
without having to either suppress errors, or ignore them.

Perhaps we should consider adding utilities for this on the "command.Streams"
outputs.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-02 16:55:12 +02:00
Sebastiaan van Stijn 1e89037d72
cli/command/system: prettyInfo: accept Streams
No need to pass whole of DockerCLI, as all it needs is the outputs.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-02 16:54:05 +02:00
Sebastiaan van Stijn 8cfefc6ea2
cli/command/system: prettyPrintServerInfo: accept Streams
No need to pass whole of DockerCLI, as all it needs is the outputs.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-02 16:51:32 +02:00
Sebastiaan van Stijn ba7a200f0a
cli/command/system: prettyPrintClientInfo: accept Streams
No need to pass whole of DockerCLI, as all it needs is the outputs.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-02 16:50:54 +02:00
Sebastiaan van Stijn 73938cd618
cli/command/system: printSwarmInfo(): accept io.Writer
Don't require whole of DockerCLI to be passed, as all we need is a writer.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-02 16:50:29 +02:00
Sebastiaan van Stijn 2d0ea86b0a
cli/command/system: use io.Writer for printing warnings
Don't require whole of DockerCLI to be passed, as all we need is a writer.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-02 16:17:00 +02:00
Sebastiaan van Stijn be6f4cd56c
cli/command/system: prettyPrintServerInfo: refactor printing "runtimes"
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-02 16:05:52 +02:00
Sebastiaan van Stijn 1d70f7cdb4
cli/command/system: prettyPrintServerInfo: rename var that collided with import
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-02 16:01:46 +02:00
Sebastiaan van Stijn 416e55bedb
github.com/docker/cli/cli/command/system: add BenchmarkPrettyPrintInfo
goos: linux
    goarch: arm64
    pkg: github.com/docker/cli/cli/command/system
    BenchmarkPrettyPrintInfo
    BenchmarkPrettyPrintInfo-5   	  189028	      6156 ns/op	    1776 B/op	      88 allocs/op

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-02 15:49:16 +02:00
Sebastiaan van Stijn da3871fd8e
cli/command/system: printServerWarnings: use client API version from info
Set the client's API version that's used in the info, instead of requesting
it as part of printing.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-14 00:49:49 +02:00
Sebastiaan van Stijn be307c5792
cli/command/system: prettyPrintServerInfo: move out collecting username
Make this function only _print_ the info we have, and not read the username
from the credential-store.

This patch adds a Username field to the (local) `info` type, and sets it
when needed, so that prettyPrintServerInfo only has to format and print
the information, instead of calling out to the credential-store.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-14 00:25:08 +02:00
Sebastiaan van Stijn 71fde20e17
cli/command/system: prettyPrintServerInfo: simplify username
Starting with b4ca1c7368, docker login
no longer depends on info.IndexServerAddress to determine the default
registry.

The prettyPrintServerInfo() still depended on this information, which
could potentially show the wrong information.

This patch changes it to also depend on the same information as docker login
now does.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-14 00:22:47 +02:00
Sebastiaan van Stijn 375b17a312
docker info: don't print "registry" (IndexServerAddress)
The IndexServerAddress field was  as part of the initial Windows implementation
of the engine. For legal reasons, Microsoft Windows (and thus Docker images
based on Windows) were not allowed to be distributed through non-Microsoft
infrastructure. As a temporary solution, a dedicated "registry-win-tp3.docker.io"
registry was created to serve Windows images.

Currently, this field always shows "https://index.docker.io/v1/", which is
confusing, because that address is not used for the registry (only for
authentication and "v1" search).

    docker info
    ...
    Registry: https://index.docker.io/v1/

Starting with b4ca1c7368, this field is also
no longer used during authentication, and a3d56e7d06
removed the (deprecated) ElectAuthServer() which was previously used to
query it.

Given that there's currently no practical use for this information, and
it only adds "noise" (and confusion), this patch removes it from the default
output.

For now, the field is (still) available for those that want to use it;

    docker info --format '{{.IndexServerAddress}}'
    https://index.docker.io/v1/

But it won't be printed by default.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-13 14:49:14 +02:00
Sebastiaan van Stijn 8ee771114c
docker info: include Client Version and "platform name"
This patch adds additional information to the Client section of the output.
We were already outputting versions of CLI Plugins, and the Server, but not
for the Client.

Adding this information can help with bug-reports where the reporter only
provided the `docker info` output, or (e.g.) only `docker --version`. The
platform name helps identify what kind of builds the user has installed
(e.g. docker's docker-ce packages have "Docker Engine - Community" set
for this), although we should consider including "packager" information
as a more formalized field for this information.

Before this patch:

    $ docker info
    Client:
     Context:    default
     Debug Mode: false
     Plugins:
      buildx: Docker Buildx (Docker Inc.)
        Version:  v0.10.4
        Path:     /usr/libexec/docker/cli-plugins/docker-buildx
    ...

With this patch applied:

    $ docker info
    Client: Docker Engine - Community
     Version:    24.0.0-dev
     Context:    default
     Debug Mode: false
     Plugins:
      buildx: Docker Buildx (Docker Inc.)
        Version:  v0.10.4
        Path:     /usr/libexec/docker/cli-plugins/docker-buildx
    ...

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-11 18:58:41 +02:00
Sebastiaan van Stijn 3347d7b5aa
cli/command/system: add newClientVersion() utility
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-11 18:58:41 +02:00
Sebastiaan van Stijn 3124e779c9
cli/command/system: clientVersion: make all fields "omitempty"
This allows the type to be used for situations where this information is
not present, or not to be printed.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-11 18:58:41 +02:00
Sebastiaan van Stijn 9202bef4a7
cli/command/system: add platformInfo type, and fix "omitempty"
The Platform field was defined with omitempty, but would always be shown
in the JSON output, because it was never nil.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-11 18:58:39 +02:00
Sebastiaan van Stijn 5d37acddeb
cli/command/system:remove versionInfo.ServerOK() utility
It's defined on a non-exported type, and was only used in a template.
Replacing for a basic "nil" check, which should do the same.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-11 18:55:44 +02:00
Sebastiaan van Stijn 23bd746c43
fix docker version --format=json not outputting json format
The --format=json option was added for all inspect commands, but was not
implemented for "docker version". This patch implements the missing option.

Before this patch:

    docker version --format=json
    json

With this patch:

    docker version --format=json
    {"Client":{"Platform":{"Name":""},"Version":"24.0.0-dev","ApiVersion":"..."}}

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-10 14:29:14 +02:00
Sebastiaan van Stijn 80640bca72
cli/command/system: make default version template a const
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-10 14:28:02 +02:00
Sebastiaan van Stijn 46234b82e2
fix docker info --format=json not outputting json format
The --format=json option was added for all inspect commands, but was not implemented
for "docker info". This patch implements the missing option.

Before this patch:

    docker info --format=json
    json

With this patch applied:

    docker info --format=json
    {"ID":"80c2f18a-2c88-4e4a-ba69-dca0eea59835","Containers":7,"ContainersRunning":"..."}

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-10 14:26:28 +02:00
CrazyMax 4595ce588c
cmd: set double quotes as code delimiter
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-01-06 19:15:33 +01:00
Sebastiaan van Stijn a7e2c3ea1e
cli/command: add Cli.CurrentVersion() function
This internalizes constructing the Client(), which allows us to provide
fallbacks when trying to determin the current API version.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-11-28 10:49:01 +01:00
Sebastiaan van Stijn 1da95ff6aa
format code with gofumpt
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-30 11:59:11 +02:00
Sebastiaan van Stijn 4411b515f5
Merge pull request #3656 from thaJeztah/fix_info_empty_labels
info: fix output including "Labels:" if no labels were set
2022-07-19 21:09:25 +02:00
Sebastiaan van Stijn 82427d1a07
format (GoDoc) comments with Go 1.19 to prepare for go updates
Older versions of Go do not format these comments, so we can already
reformat them ahead of time to prevent gofmt linting failing once
we update to Go 1.19 or up.

Result of:

    gofmt -s -w $(find . -type f -name '*.go' | grep -v "/vendor/")

With some manual adjusting.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-07-19 19:10:16 +02:00
Sebastiaan van Stijn 80b1285fec cli: use custom annotation for aliases
Cobra allows for aliases to be defined for a command, but only allows these
to be defined at the same level (for example, `docker image ls` as alias for
`docker image list`). Our CLI has some commands that are available both as a
top-level shorthand as well as `docker <object> <verb>` subcommands. For example,
`docker ps` is a shorthand for `docker container ps` / `docker container ls`.

This patch introduces a custom "aliases" annotation that can be used to print
all available aliases for a command. While this requires these aliases to be
defined manually, in practice the list of aliases rarely changes, so maintenance
should be minimal.

As a convention, we could consider the first command in this list to be the
canonical command, so that we can use this information to add redirects in
our documentation in future.

Before this patch:

    docker images --help

    Usage:  docker images [OPTIONS] [REPOSITORY[:TAG]]

    List images

    Options:
      -a, --all             Show all images (default hides intermediate images)
      ...

With this patch:

    docker images --help

    Usage:  docker images [OPTIONS] [REPOSITORY[:TAG]]

    List images

    Aliases:
      docker image ls, docker image list, docker images

    Options:
      -a, --all             Show all images (default hides intermediate images)
      ...

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-06-28 17:32:09 +02:00
Sebastiaan van Stijn c47aa3dfac
info: fix output including "Labels:" if no labels were set
Ths prettyPrintServerInfo() was checking for the Labels property to be
nil, but didn't check for empty slices.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-06-05 14:44:08 +02:00
Sebastiaan van Stijn b9e2659a05
info: update plugin section to show installed path
This updates the pretty-print format of docker info to provide more
details on installed plugins, to help users find where a specific
plugin is installed (e.g. to update it, or to uninstall it).

Before this patch:

```bash
Client:
 Context:    desktop-linux
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc., v0.8.2)
  compose: Docker Compose (Docker Inc., v2.4.1)
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
  scan: Docker Scan (Docker Inc., v0.17.0)

Server:
...
```

With this patch applied:

```bash
docker info

Client:
 Context:    desktop-linux
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.8.2
    Path:     /usr/local/lib/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.4.1
    Path:     /usr/local/lib/docker/cli-plugins/docker-compose
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
    Version:  0.6.0
    Path:     /usr/local/lib/docker/cli-plugins/docker-sbom
  scan: Docker Scan (Docker Inc.)
    Version:  v0.17.0
    Path:     /usr/local/lib/docker/cli-plugins/docker-scan

Server:
...
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-06-01 12:46:07 +02:00
Sebastiaan van Stijn 1fafae3efc
info: remove cluster store from docker info output
This removes the cluster store information from the output of "docker info".

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-05-17 11:01:49 +02:00