Commit Graph

1475 Commits

Author SHA1 Message Date
Paweł Gronowski fe7afb700f
cli/container: Don't ignore error when parsing volume spec
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-07-12 09:45:55 +02:00
Sebastiaan van Stijn df04aca5d2
Merge pull request #4405 from cpuguy83/health_start_interval
Add support for health start interval
2023-07-07 18:15:10 +02:00
Brian Goff 986879c071 Add flags to container/service for health start interval
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2023-07-06 19:05:34 +00:00
Evan Lezar dad225d1e2 Support CDI devices in --device flag
Signed-off-by: Evan Lezar <elezar@nvidia.com>
2023-07-04 14:52:46 +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 27bae1172a
Merge pull request #4366 from thaJeztah/remove_deprecated_context_stubs
cli/command/context: remove deprecated k8s / orchestrator option-stubs
2023-06-28 14:42:18 +02:00
Sebastiaan van Stijn 79ff64f06d
cli/command/context: don't use pkg/homedir in test
I'm considering deprecating the "Key()" utility, as it was only
used in tests.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-26 13:35:42 +02:00
Sebastiaan van Stijn 085d5c2816
Merge pull request #4343 from thaJeztah/cleanup_sprintf
replace some basic uses of fmt.Sprintf(), and minor refactor
2023-06-21 11:49:50 +02:00
Sebastiaan van Stijn c96484a114
Merge pull request #4346 from thaJeztah/build_errors
build: error if Dockerfile name is passed with Dockerfile from stdin
2023-06-21 11:48:12 +02:00
Sebastiaan van Stijn 2133d0446a
cli/command/context: remove deprecated k8s / orchestrator option-stubs
support for kubernetes contexts was deprecated in docker 20.10 through
b639ea8b89, 0793f96394,
and 1d37fb3027, and removed altoghether in
23.0 through 193ede9b12.

This patch removes the remaining stubs for options that were deprecated
and no longer used.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-21 11:39:04 +02:00
Sebastiaan van Stijn 3c99d229d9
Merge pull request #4363 from thaJeztah/cleanup_useragent
cli/command: newAPIClientFromEndpoint: use WithUserAgent
2023-06-21 11:38:55 +02:00
Sebastiaan van Stijn 2d06cfcde6
cli/command: newAPIClientFromEndpoint: use WithUserAgent
More things to be done after this, to allow passing a custom user-agent,
but let's start with just using this utility.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-20 15:01:41 +02:00
Sebastiaan van Stijn 8181aa8879
cli/command/context: don't pass CLI if we only need context-store
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-20 13:39:02 +02:00
Sebastiaan van Stijn c2535aa467
build: error if Dockerfile name is passed with Dockerfile from stdin
When passing a Dockerfile through stdin, it's not possible to specify the
name of the Dockerfile (using the `-f` option). When building with BuildKit
enabled, an error is already produced for this case, but the classic builder
silently ignored it.

This patch adds an error for this situation:

    echo -e 'FROM busybox' | DOCKER_BUILDKIT=0 docker build -f some.Dockerfile -
    DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
    BuildKit is currently disabled; enable it by removing the DOCKER_BUILDKIT=0
    environment-variable.

    unable to prepare context: ambiguous Dockerfile source: both stdin and flag correspond to Dockerfiles

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-13 14:03:03 +02:00
Sebastiaan van Stijn 77dd05caad
cli/command/image: remove errStdinConflict
This error was only used in a single location, so no need to define a
package-level variable for this.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-13 13:47:56 +02:00
Sebastiaan van Stijn 7d723e2ba7
Merge pull request #4337 from thaJeztah/dont_mutate_configfile
cli/command/container: don't mutate ConfigFile.DetachKeys
2023-06-12 21:37:37 +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 9e481e09e0
Merge pull request #4226 from laurazard/fix-connhelper-docker-example
ssh: fix error on commandconn close, add ping and default timeout
2023-06-09 22:56:16 +02:00
Laura Brehm a5ebe2282a
commandconn: don't return error if command closed successfully
---
commandconn: fix race on `Close()`

During normal operation, if a `Read()` or `Write()` call results
in an EOF, we call `onEOF()` to handle the terminating command,
and store it's exit value.

However, if a Read/Write call was blocked while `Close()` is called
the in/out pipes are immediately closed which causes an EOF to be
returned. Here, we shouldn't call `onEOF()`, since the reason why
we got an EOF is because we're already terminating the connection.
This also prevents a race between two calls to the commands `Wait()`,
in the `Close()` call and `onEOF()`

---
Add CLI init timeout to SSH connections

---
connhelper: add 30s ssh default dialer timeout

(same as non-ssh dialer)

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2023-06-09 11:24:19 +02:00
Sebastiaan van Stijn 2331e4d521
cli/command/container: don't mutate ConfigFile.DetachKeys
This code was introduced in 15aa2a663b,
but from those changes, it appears that overwriting the config value was
merely out of convenience, and that struct being used as an intermediate.

While changing the config here should be mostly ephemeral, and not written
back to the config-file, let's be clear on intent, and not mutatte the config
as part of this code.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-08 16:54:41 +02:00
Sebastiaan van Stijn 23e26f40fe
cli/command/container: createContainer(): return container-ID
This function returned the whole response, but we already handled the
warnings included in the response as part of the function. All consumers
of this function only used the container-ID, so let's simplify and return
just that (it's a non-exported func, so we can change the signature again
if we really need it).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-08 16:54:41 +02:00
Sebastiaan van Stijn c2c6fbe23c
cli/command/container: TestCreateContainerImagePullPolicy: use sub-tests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-08 16:54:41 +02:00
Sebastiaan van Stijn 0c5adb2e98
cli/command/container: attach: rename var that collided with import
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-08 16:54:22 +02:00
Sebastiaan van Stijn 5251d37481
cli/command: add EnvOverrideContext const for "DOCKER_CONTEXT"
Add a const for the name of the environment-variable we accept, so
that we can document its purpose in code.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-02 14:20:53 +02:00
Sebastiaan van Stijn 0692d762ac
cli/command: fix GoDoc referencing wrong const
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-01 21:42:30 +02:00
Sebastiaan van Stijn 4cf04988ae
remove uses of golang.org/x/sys/execabs
the "golang.org/x/sys/execabs" package was introduced to address a security
issue on Windows, and changing the default behavior of os/exec was considered
a breaking change. go1.19 applied the behavior that was previously implemented
in the execabs package;

from the release notes: https://go.dev/doc/go1.19#os-exec-path

> Command and LookPath no longer allow results from a PATH search to be found
> relative to the current directory. This removes a common source of security
> problems but may also break existing programs that depend on using, say,
> exec.Command("prog") to run a binary named prog (or, on Windows, prog.exe)
> in the current directory. See the os/exec package documentation for information
> about how best to update such programs.
>
> On Windows, Command and LookPath now respect the NoDefaultCurrentDirectoryInExePath
> environment variable, making it possible to disable the default implicit search
> of “.” in PATH lookups on Windows systems.

With those changes, we no longer need to use the execabs package, and we can
switch back to os/exec.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-26 02:03:45 +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 8794455dc3
Merge pull request #4250 from thaJeztah/tininits
tini nits
2023-05-16 18:13:24 +01:00
Sebastiaan van Stijn 10bade23e1
Merge pull request #4261 from thaJeztah/remove_old_buildtags
remove pre-go1.17 build-tags
2023-05-16 18:12:50 +01:00
Sebastiaan van Stijn 0f78de7ab0
Merge pull request #4280 from thaJeztah/remove_deprecated_EncodeAuthToBase64
cli/command: remove deprecated EncodeAuthToBase64
2023-05-16 18:12:02 +01:00
Sebastiaan van Stijn 3d9905f3d6
Merge pull request #4279 from thaJeztah/remove_deprecated_stack_stubs
cli/command/stack: remove deprecated RunDeploy, RunPS, RunRemove, GetServices
2023-05-16 18:11:41 +01: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 537b88dab9
cli/command: don't use legacy "notfound" error-type in tests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-11 23:09:12 +02:00
Sebastiaan van Stijn ff7111ae21
cli/command: remove deprecated EncodeAuthToBase64
This function was deprecated in b87ed34351,
which is part of the v24.0 release, so we can remove it from master.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-09 22:39:22 +02:00
Sebastiaan van Stijn d3ac801275
cli/command/stack: remove deprecated RunDeploy, RunPS, RunRemove, GetServices
These were deprecated in f08252c10a, which
is part of the v24.0 release, so we can remove these on master.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-09 22:32:21 +02:00
Sebastiaan van Stijn 8fc956ce77
Merge pull request #4244 from thaJeztah/update_engine_next
vendor: github.com/docker/docker github.com/docker/docker v24.0.0-rc.1.0.20230505222407-8d9a40a82034 (v24.0.0-rc.2)
2023-05-06 01:32:38 +02:00
Sebastiaan van Stijn 9f15ba0d13
Merge pull request #4156 from AkihiroSuda/docker-run-annotation
cli/command/container: implement `docker run --annotation`
2023-05-06 00:49:15 +02:00
Sebastiaan van Stijn 4f97f55999
vendor: github.com/docker/docker v24.0.0-rc.1.0.20230505222407-8d9a40a82034
This will be v24.0.0-rc.2

full diff: https://github.com/docker/docker/compare/v24.0.0-rc.1...8d9a40a820349860405e142249c55215aa4da8e3

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-06 00:34:34 +02:00
Sebastiaan van Stijn 2ae223038c
remove pre-go1.17 build-tags
Removed pre-go1.17 build-tags with go fix;

    go mod init
    go fix -mod=readonly ./...
    rm go.mod

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-05 18:23:03 +02:00
Sebastiaan van Stijn 2b7bfb3994
cli/command/image/build: GetContextFromReader: rename var that collided
This var collided with the `archive/tar` import.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-03 17:02:12 +02:00
Sebastiaan van Stijn ab17029c63
cli/command/container: hijackedIOStreamer: explicitly ignore err
Make the linters and IDEs happier

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-05-03 17:01:08 +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 bd2c26328f
vendor: github.com/docker/docker v24.0.0-rc.1
full diff: https://github.com/docker/docker/compare/v24.0.0-beta.2...v24.0.0-rc.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-28 17:56:17 +02:00
Sebastiaan van Stijn f02301ab5d
remove uses of deprecated VirtualSize field
The VirtualSize field is deprecated and the upcoming API version v1.44
will no longer propagate the field. See:
1261fe69a3,

Given that in docker 1.10 and up (API v1.22), the VirtualSize and Size
fields contain the same value, and the "df" endpoint was not supported
until API v1.25, we can "safely" use Size instead; see:

- 4ae7176ffb
- 4352da7803

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-28 14:58:53 +02:00
Sebastiaan van Stijn 59b07b7253
Merge pull request #4045 from vvoland/test-e2e-arm64-fixes
test/e2e: Fix running `test-e2e` on non-amd64 platforms
2023-04-27 11:41:43 +02:00
Paweł Gronowski ec5504a83f
test/e2e: Use "frozen" tag to reference test images
This makes it possible to update the image loaded for e2e tests without
modifying all tests that use them.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-04-27 10:57:57 +02:00
Sebastiaan van Stijn 019657a986
Merge pull request #4174 from thaJeztah/remove_deprecated_streams
cli/command: remove deprecated Stream types
2023-04-26 13:10:21 +02:00
Sebastiaan van Stijn 04bf047a2c
Merge pull request #4205 from thaJeztah/info_dont_depend_on_IndexServerAddress
cli/command/system: prettyPrintServerInfo: don't depend on IndexServerAddress and credential-store
2023-04-26 13:07:01 +02:00
Sebastiaan van Stijn c180202cea
cli/command: remove deprecated Stream types
These were deprecated in eb0ba4f8d5, which
was part of docker 19.03, so users should have had a chance to migrate.

This removes InStream, OutStream, NewInStream and NewOutStream

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-25 11:07:45 +02:00
Sebastiaan van Stijn 0dec5d20a2
volumes: prune: add --all / -a option
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-20 23:31:47 +02:00
Paweł Gronowski ff7f76af7a
Handle empty DOCKER_BUILDKIT like unset
This fixes the cli erroring out if the variable is set to an empty
value.

```
$ export DOCKER_BUILDKIT=
$ docker version
DOCKER_BUILDKIT environment variable expects boolean value: strconv.ParseBool: parsing "": invalid syntax
```

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-04-19 14:17:01 +02:00
Akihiro Suda 88be16cb5b
cli/command/container: implement `docker run --annotation`
For moby/moby PR 45025 (Docker v24, API v1.43).

`docker run --annotation foo=bar` is similar to `podman run --annotation foo=bar`,
however, unlike Podman, Docker implementation also accepts an annotation with an empty value.
(`docker run --annotation foo`)

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2023-04-14 12:59:12 +09: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 fcd3bca1e7
Merge pull request #4204 from thaJeztah/docker_info_remove_registry
docker info: don't print "registry" (IndexServerAddress)
2023-04-13 20:23:15 +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 b87ed34351
cli/command: deprecate EncodeAuthToBase64
Deprecate this function in favor of the implementation in the API types,
considering that to be the canonical implementation.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-13 14:29:59 +02:00
Sebastiaan van Stijn c25115e968
Merge pull request #4190 from thaJeztah/command_auth_cleanups
cli/command: some cleanups / refactoring, and fixes related to auth
2023-04-13 14:23:26 +02:00
Sebastiaan van Stijn 6416d810dc
Merge pull request #3666 from thaJeztah/ps_always_accept_quiet
docker ps: always use --quiet, also combined with --format
2023-04-13 13:53:39 +02:00
Sebastiaan van Stijn 5d856a5d91
cli/command/container: pullImage: use DisplayJSONMessagesToStream utility
This utility provides the same logic as was implemented here (and using it
aligns with the "docker pull" equivalent).

Also added a TODO to replace this function with the regular "docker pull"
code.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-12 21:17:16 +02:00
Sebastiaan van Stijn b9b98aee5d
cli/command/container/create: pullImage(): use RetrieveAuthTokenFromImage
replace the local code with RetrieveAuthTokenFromImage, which does exactly the same;
623356001f/cli/command/registry.go (L163-L188)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-12 21:17:15 +02:00
Sebastiaan van Stijn a27acd62b3
cli/command/container/create: pullImage() remove intermediate vars
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-12 21:17:15 +02:00
Sebastiaan van Stijn e0b47cc2cc
cli/command/image: imagePullPrivileged: remove intermediate variables
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-12 21:17:15 +02:00
Sebastiaan van Stijn 372bb56ade
cli/command: replace EncodeAuthToBase64 for registry.EncodeAuthConfig
Replace uses of this function in favor of the implementation in the
API types, so that we have a single, canonical implementation.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-12 21:17:15 +02:00
Sebastiaan van Stijn 534bfc2301
cli/command/registry: remove intermediate var that collided
This also simplifies the code a bit.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-12 21:17:14 +02:00
Sebastiaan van Stijn 5e76d41bf6
cli/command: ConfigureAuth: fix links to related tickets
Also adds a TODO to verify if this special handling is still needed.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-12 21:17:14 +02:00
Sebastiaan van Stijn 68d791e56d
cli/command: ConfigureAuth: trim whitespace both for username and password
changes readInput() to trim whitespace. The existing code tried to be
conservative and only trimmed whitespace for username (not for password).
Passwords with leading/trailing whitespace would be _very_ unlikely, and
trimming whitespace is generally accepted.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-12 21:17:14 +02:00
Sebastiaan van Stijn d0ec8fa5cf
cli/command: ConfigureAuth: fix terminal state not being restored on error
ConfigureAuth used the readInput() utility to read the username and password.
However, this utility did not return errors it encountered, but instead did
an os.Exit(1). A result of this was that the terminal was not restored if
an error happened. When reading the password, the terminal is configured to
disable echo (i.e. characters are not printed), and failing to restore
the previous state means that the terminal is now "non-functional".

This patch:

- changes readInput() to return errors it encounters
- uses a defer() to restore terminal state

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-12 21:17:14 +02:00
Sebastiaan van Stijn c697659678
Merge pull request #4180 from thaJeztah/docker_info_version
docker info: include Client Version and "platform name"
2023-04-12 12:42:55 +02:00
Sebastiaan van Stijn 5bd359132b
cli/command: fix documentation for ResolveAuthConfig
This function no longer uses the /info endpoint to resolve the registry
to use. The documentation for this function was still referring to
the (once used) special registry for Windows images, which is no longer
in use, so update the docs to reflect reality :)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-12 10:23:47 +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
Sebastiaan van Stijn 1aaa179d9d
cli/command/formatter: export JSONFormat const
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-10 14:26:07 +02:00
Sebastiaan van Stijn 37e02ff211
docker ps: print warning if both --format and --quiet are set
Of both "--quiet" and "--format" are set, --quiet takes precedence. This
patch adds a warning to inform the user that their custom format is not
used:

    docker ps --format='{{.Image}}'
    ubuntu:22.04
    alpine

    docker ps --format='{{.Image}}' --quiet
    WARNING: Ignoring custom format, because both --format and --quiet are set.
    40111f61d5c5
    482efdf39fac

The warning is printed on STDERR, so can be redirected:

    docker ps --format='{{.Image}}' --quiet 2> /dev/null
    40111f61d5c5
    482efdf39fac

The warning is only shown if the format is set using the "--format" option.
No warning is shown if a custom format is set through the CLI configuration
file:

    mkdir -p ~/.docker/
    echo '{"psFormat": "{{.Image}}"}' > ~/.docker/config.json

    docker ps
    ubuntu:22.04
    alpine

    docker ps --quiet
    40111f61d5c5
    482efdf39fac

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-10 01:17:48 +02:00
Sebastiaan van Stijn f522905595
docker ps: always use --quiet, also combined with --format
Previously, the formatter would ignore the quiet option if a custom format
was passed; this situation was handled in runPs(), where custom formats
would only be applied if the quiet option was not set, but only if the
format was set in the CLI's config.

This patch updates NewContainerFormat() to do the same, even if a `--format`
was passed on the command-line.

This is a change in behavior, so may need some discussion; possible alternatives;

- produce an error if both `--format` and `--quiet` are passed
- print a warning if both are passed (but use the logic from this patch)

Before this patch:

```console
docker ps --format '{{.Image}}'
ubuntu:22.04
alpine

docker ps --format '{{.Image}}' --quiet
ubuntu:22.04
alpine

mkdir -p ~/.docker/
echo '{"psFormat": "{{.Image}}"}' > ~/.docker/config.json

docker ps
ubuntu:22.04
alpine

docker ps --quiet
ubuntu:22.04
alpine
```

With this patch applied:

```console
docker ps --format '{{.Image}}'
ubuntu:22.04
alpine

docker ps --format '{{.Image}}' --quiet
40111f61d5c5
482efdf39fac

mkdir -p ~/.docker/
echo '{"psFormat": "{{.Image}}"}' > ~/.docker/config.json

docker ps
ubuntu:22.04
alpine

docker ps --quiet
40111f61d5c5
482efdf39fac
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-10 01:12:00 +02:00
Sebastiaan van Stijn f36e4b0949
cli/command/container: rename vars that collided
- containerConfig collided with the containerConfig type
- warning collided with the warning const

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-10 00:32:51 +02:00
Sebastiaan van Stijn daf99dd308
Merge pull request #3972 from thaJeztah/embed_streams
cli/command: embed "Streams" interface in "Cli"
2023-04-09 12:49:56 +02:00
Sebastiaan van Stijn 9ce269fb83
Merge pull request #4146 from thaJeztah/remove_deprecated_bits
remove various deprecated types and functions
2023-04-03 14:49:26 +02:00
Sebastiaan van Stijn 3405eb1f41
cli/command/formatter: remove deprecated KubernetesEndpoint
This was deprecated in 467e650d4c, which
is part of docker 23.0, so users should have had a chance to migrate.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-01 20:36:01 +02:00
Sebastiaan van Stijn 817897f891
cli/command: fix deprecation comments for Stream types
These were deprecated in 6c400a9c2009bba9376ad61ab59c04c1ad675871 (docker 19.03),
but the "Deprecated:" comments were missing a newline before them.

While most IDEs will detect such comments as "deprecated", pkg.go.dev and linters
will ignore them, which may result in users not being aware of them being deprecated.

This patch;

- Fixes the "Deprecated:" comments.
- Changes the var aliases to functions, which is slightly more boilerplating,
  but makes sure the functions are documented as "function", instead of shown
  in the "variables" section on pkg.go.dev.
- Adds some punctuation and adds "doc links", which allows readers to navigate
  to related content on pkg.go.dev.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-01 18:28:35 +02:00
Sebastiaan van Stijn 8e6ac62d53
Merge pull request #4137 from cpuguy83/fix_cp_no_tty
Improve docker cp progress output
2023-03-31 21:06:26 +02:00
Brian Goff eb392ff4ce cp: Do not block transfer on writing to terminal
This moves all the terminal writing to a goroutine that updates the
terminal periodically.
In our MITM copier we just use an atomic to add to the total number of
bytes read/written, the goroutine reads the total and updates the
terminal as needed.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2023-03-30 20:15:16 +00:00
Sebastiaan van Stijn 7189716d5a
replace uses of deprecated api/types.AuthConfig
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-03-30 19:57:16 +02:00
Sebastiaan van Stijn bfa79fd75a
vendor: github.com/docker/docker master (v24.0.0-dev)
- updates VolumeList() calls for docker/docker master
- update fakeClient signature, and suppress err output in tests

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-03-30 19:56:28 +02:00
Sebastiaan van Stijn 607f290f65
cli/command/volume: remove name for unused arg (revive)
cli/command/volume/prune_test.go:113:22: unused-parameter: parameter 'args' seems to be unused, consider removing or renaming it as _ (revive)
    func simplePruneFunc(args filters.Args) (types.VolumesPruneReport, error) {
                         ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-03-30 17:22:09 +02:00