Commit Graph

10174 Commits

Author SHA1 Message Date
Harald Albers 6f439ea4a4
Add completion for `--link`
Signed-off-by: Harald Albers <github@albersweb.de>
(cherry picked from commit e513454244)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-14 17:00:47 +01:00
Harald Albers 7e35be13ea
Add completion for `--ipc`
Signed-off-by: Harald Albers <github@albersweb.de>
(cherry picked from commit c555327f0b)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-14 17:00:47 +01:00
Harald Albers f9ccc50304
Add completion for `--attach`
Signed-off-by: Harald Albers <github@albersweb.de>
(cherry picked from commit b598ec8cdb)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-14 17:00:47 +01:00
Harald Albers 38e37778b0
Share the container completions
Signed-off-by: Harald Albers <github@albersweb.de>
(cherry picked from commit 761d76750c)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-14 17:00:47 +01:00
Sebastiaan van Stijn fd53fe7f47
Merge pull request #5613 from thaJeztah/27.x_backport_bump_golangci_lint
[27.x backport] bump golangci-lint to v1.61.0 and cleanup config
2024-11-14 16:48:41 +01:00
Laura Brehm 929e861812
Merge pull request #5614 from thaJeztah/27.x_backport_completion-events--filter 2024-11-14 15:42:28 +00:00
Harald Albers 8caf347188
Add tests for completions that call the API
Some small adjustments for this branch due to some times being renamed
in master;

    63.76 cli/command/system/cmd.go:1: : # github.com/docker/cli/cli/command/system [github.com/docker/cli/cli/command/system.test]
    63.76 cli/command/system/client_test.go:22:79: undefined: container.Summary
    63.76 cli/command/system/client_test.go:38:103: undefined: container.Summary
    63.76 cli/command/system/client_test.go:42:21: undefined: container.Summary
    63.76 cli/command/system/completion_test.go:30:86: undefined: container.Summary
    63.76 cli/command/system/completion_test.go:31:25: undefined: container.Summary
    63.76 cli/command/system/completion_test.go:42:86: undefined: container.Summary (typecheck)

Signed-off-by: Harald Albers <github@albersweb.de>
(cherry picked from commit e1c5180dba)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-14 14:55:02 +01:00
Harald Albers 9e7d01bfb3
Add completion for `events --filter`
Signed-off-by: Harald Albers <github@albersweb.de>
(cherry picked from commit d4f4cf1418)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-14 14:53:54 +01:00
Sebastiaan van Stijn 8be6bec27d
Merge pull request #5611 from thaJeztah/27.x_backport_login_minor_refactor
[27.x backport] cli/command: PromptUserForCredentials: assorted minor improvements and (linting) fixes
2024-11-14 14:51:17 +01:00
Sebastiaan van Stijn d515955b62
Merge pull request #5616 from thaJeztah/27.x_backport_bump_compose_buildx
[27.x backport] Dockerfile: update buildx to v0.18.0, compose to v2.30.3
2024-11-14 14:42:31 +01:00
Sebastiaan van Stijn d5b327258f
Merge pull request #5612 from thaJeztah/27.x_backport_docs
[27.x backport] assorted docs updates
2024-11-14 10:42:14 +01:00
Sebastiaan van Stijn 9128f7b2d5
Dockerfile: update compose to v2.30.3
Update the compose cli plugin used in the dev-container

full diff: https://github.com/docker/compose/compare/v2.29.7...v2.30.3

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 3dd7621240)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-14 10:37:44 +01:00
Sebastiaan van Stijn 0529d64f7f
Dockerfile: update buildx to v0.18.0
Update the buildx cli plugin used in the dev-container

full diff: https://github.com/docker/buildx/compare/0.17.1..0.18.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 4242cda826)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-14 10:37:44 +01:00
Sebastiaan van Stijn 2958a27e0f
Merge pull request #5610 from thaJeztah/27.x_backport_moby_deps
[27.x backport] dependency updates for moby/moby
2024-11-14 10:27:53 +01:00
Sebastiaan van Stijn 8fe93724a3
bump golangci-lint to v1.61.0
Also updating a linter that was deprecated;

    The linter 'exportloopref' is deprecated (since v1.60.2) due to: Since Go1.22 (loopvar) this linter is no longer relevant. Replaced by copyloopvar.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 9af049c618)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-14 09:44:37 +01:00
Sebastiaan van Stijn df7113d7eb
[27.x] cli: fix non-constant format string in call to errors.Errorf (govet)
cli/required.go:17:24: printf: non-constant format string in call to github.com/docker/cli/vendor/github.com/pkg/errors.Errorf (govet)
     		return errors.Errorf("\n" + strings.TrimRight(cmd.UsageString(), "\n"))
     		                     ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-14 09:42:49 +01:00
Sebastiaan van Stijn 35122a0692
golangci-lint: update comment, and disable "exclude-dirs-use-default"
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 745629bd55)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-13 23:40:37 +01:00
Sebastiaan van Stijn 1890ea0762
golangci-lint: move gosec excludes to linters-settings
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 7451339ab0)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-13 23:40:37 +01:00
Sebastiaan van Stijn 7a906196ed
golangci-lint: enable G204, add #nosec comments instead
There's only 3 locations where it's hit, so putting #gosec ignore comments
in those locations.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 020f3a7ad9)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-13 23:40:37 +01:00
David Karlsson 2734299993
docs: update example redis tags from 3.0.x to 7.4.x
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
(cherry picked from commit 172f340112)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-13 23:37:40 +01:00
Noah Silas 9d5a2a6b66
docs: Correct `run` exit code 126 description
The command to run inside the container is `/etc`. The semicolon is a
statement terminator, which ends the command `docker run busybox /etc`,
while `echo $?` prints the exit code of that full docker command.

Having this mistake could confuse someone who thinks that `/etc; echo
$?` is all run inside the container, which wouldn't help the reader
understand the exit code of the `docker run` command itself.

Signed-off-by: Noah Silas <noah@hustle.com>
(cherry picked from commit 0c999fe95b)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-13 23:37:10 +01:00
Paul Rogalski 0dd07f0bfd
docs: Link supported Go duration strings
Signed-off-by: Paul Rogalski <mail@paul-rogalski.de>
(cherry picked from commit c70b2165a9)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-13 23:36:58 +01:00
Sebastiaan van Stijn 168a4bdc05
cli/command: PromptUserForCredentials: suppress unhandled errors
Keep the linters (and my IDE) happy; these errors should be safe to ignore.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 4b7a1e4613)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-13 23:32:41 +01:00
Sebastiaan van Stijn ddeb7eb4ed
cli/command: PromptUserForCredentials: use consts for all hints
This message resulted in code-lines that were too long; move it to a
const together with the other hint. While at it, also suppress unhandled
error, and touch-up the code-comment.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 378a3d7d36)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-13 23:32:41 +01:00
Sebastiaan van Stijn da3a1c3027
cli/command: PromptUserForCredentials: print error on terminal restore fail
If restoring the terminal state fails, "echo" no longer works, which means
that anything the user types is no longer shown. The login itself may already
have succeeded, so we should not fail the command, but it's good to inform
the user that this happened, which may give them a clue why things no longer
work as they expect them to work.

With this patch:

    docker login -u yourname
    Password:
    Error: failed to restore terminal state to echo input: something bad happened

    Login Succeeded

We should consider printing instructions how  to restore this manually (other
than restarting the shell). e.g., 'run stty echo' when in a Linux or macOS shell,
but PowerShell and CMD.exe may need different instructions.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 3d8b49523d)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-13 23:32:41 +01:00
Sebastiaan van Stijn 1377310110
cli/command: PromptUserForCredentials: always trim password
we don't support empty passwords; when prompting the user for a password,
we already trim the result, but we didn't do the same for a password that's
passed through stdin or through the `-p` / `--password` flag.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit a21a5f4243)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-13 23:32:41 +01:00
Sebastiaan van Stijn 78dbcca264
cli/command: PromptUserForCredentials: move trimming where it's used
- move trimming defaultUsername inside the if-branch, as it's the only
  location where the result of the trimmed username is use.
- do the reverse for trimming argUser, because the result of trimming
  argUser is used outside of the if-branch (not just for the condition).
  putting it inside the condition makes it easy to assume the result is
  only used locally.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit eda78e9cdc)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-13 23:32:41 +01:00
Sebastiaan van Stijn 97c25b7574
cli/command: PromptUserForCredentials: move "post" check for empty name
move the "post" check for username being empty inside the branch
that's handling the username, as it's the only branch where username
is mutated after checking if it's empty.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 581cf36bd4)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-13 23:32:41 +01:00
Sebastiaan van Stijn 05455f8505
cli/command: PromptUserForCredentials: inline isDefaultRegistry
remove isDefaultRegistry and inline it where it's used; the code-comment
already outlines what we're looking for, so the intermediate var didn't
add much currently.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit a55cfe5f82)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-13 23:32:40 +01:00
Sebastiaan van Stijn d23ab524c3
cli/command: PromptUserForCredentials: remove named output variables
This function has multiple conditional branches, which makes it harder
to see at a glance whether authConfig may be partially populated. This
patch instead returns a fresh instance for error returns to prevent any
confusion.

It also removes the named output variables, as they're now no longer used,
and the returned types should already be descriptive enough to understand
what's returned.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 3a8485085d)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-13 23:32:40 +01:00
Sebastiaan van Stijn 46844b4f1d
vendor: github.com/klauspost/compress v1.17.11
full diff: https://github.com/klauspost/compress/compare/v1.17.9...v1.17.11

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit e3942d46a0)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-13 23:01:16 +01:00
Sebastiaan van Stijn 3f28d05292
vendor: google.golang.org/protobuf v1.35.1
full diff: https://github.com/protocolbuffers/protobuf-go/compare/v1.34.1...v1.35.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 1bba009944)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-13 23:00:49 +01:00
Sebastiaan van Stijn 2521abdb1b
vendor: golang.org/x/sys v0.26.0
full diff: https://github.com/golang/sys/compare/v0.25.0...v0.26.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 02b92c699d)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-13 22:59:20 +01:00
Sebastiaan van Stijn eb986ae71b
Merge pull request #5603 from dvdksn/bp_5600
[27.x backport] docs: change link to desktop docs
2024-11-07 13:57:54 +01:00
Sebastiaan van Stijn f39012209b
Merge pull request #5602 from vvoland/update-go-27.x
[27.x] update to go1.22.9
2024-11-07 13:54:26 +01:00
aevesdocker e15a979e3d docs: change link to desktop docs
Signed-off-by: aevesdocker <allie.sadler@docker.com>
(cherry picked from commit 1440f9f8cf)
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
2024-11-07 13:29:04 +01:00
Paweł Gronowski 35c87e326c
update to go1.22.9
- https://github.com/golang/go/issues?q=milestone%3AGo1.22.9+label%3ACherryPickApproved
- full diff: https://github.com/golang/go/compare/go1.22.8...go1.22.9

go1.22.9 (released 2024-11-06) includes fixes to the linker. See the
[Go 1.22.9 milestone](https://github.com/golang/go/issues?q=milestone%3AGo1.22.9+label%3ACherryPickApproved)
for details.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-11-07 13:23:41 +01:00
Sebastiaan van Stijn f4f328b84b
Merge pull request #5588 from vvoland/5586-27.x
[27.x backport] Buffer 'docker stats' text to avoid terminal flickering
2024-10-31 22:07:21 +01:00
Giedrius Jonikas 470ab05503
Buffer 'docker stats' text to avoid terminal flickering
This change reduces the flickering of the terminal when
running `docker stats` by buffering the formatted stats
text and printing it in one write.

Should also consume less CPU as we now only have to issue
a single syscall to write the stats text to the terminal.

Signed-off-by: Giedrius Jonikas <giedriusj1@gmail.com>
(cherry picked from commit 0b16070ae6)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-10-31 14:29:38 +01:00
Laura Brehm 968506fd0f
Merge pull request #5569 from thaJeztah/27.x_backport_login_idempotent 2024-10-22 16:18:18 +01:00
Sebastiaan van Stijn 6736be779a
cli/config/credentials: add test for save being idempotent
Test case for d3f6867e4d

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 3c78069240)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-22 12:23:27 +02:00
Sebastiaan van Stijn 720da3c65a
cil/config/credentials: remove newStore() test-utility
This function was names slightly confusing, as it returns a fakeStore,
and it didn't do any constructing, so didn't provide value above just
constructing the type.

I'm planning to add more functionality to the fakeStore, but don't want
to maintain a full-fledged constructor for all of that, so let's remove
this utility.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 0dd6f7f1b3)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-22 12:15:34 +02:00
Sebastiaan van Stijn 05c860e866
Merge pull request #5548 from thaJeztah/27.x_backport_plugin_better_error
[27.x backport] cli/command/plugins: use errors.Join instead of custom cli.Errors, and deprecate cli.Errors
2024-10-22 10:42:38 +02:00
Sebastiaan van Stijn 365e7a5a4e
cli/config/credentials: skip saving config-file if credentials didn't change
Before this change, the config-file was always updated, even if there
were no changes to save. This could cause issues when the config-file
already had credentials set and was read-only for the current user.

For example, on NixOS, this poses a problem because `config.json` is a
symlink to a write-protected file;

    $ readlink ~/.docker/config.json
    /home/username/.config/sops-nix/secrets/ghcr_auth

    $ readlink -f ~/.docker/config.json
    /run/user/1000/secrets.d/28/ghcr_auth

Which causes `docker login` to fail, even if no changes were to be made;

    Error saving credentials: rename /home/derek/.docker/config.json2180380217 /home/username/.config/sops-nix/secrets/ghcr_auth: invalid cross-device link

This patch updates the code to only update the config file if changes
were detected. It there's nothing to save, it skips updating the file,
as well as skips printing the warning about credentials being stored
insecurely.

With this patch applied:

    $ docker login -u yourname
    Password:

    WARNING! Your credentials are stored unencrypted in '/root/.docker/config.json'.
    Configure a credential helper to remove this warning. See
    https://docs.docker.com/go/credential-store/

    Login Succeeded

    $ docker login -u yourname
    Password:
    Login Succeeded

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit d3f6867e4d)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-22 00:21:18 +02:00
Sebastiaan van Stijn 79113a3db5
Merge pull request #5564 from austinvazquez/cherry-pick-35d7b1a7a6426080f44e044b6564cee990b35eab-to-27.x
[27.x backport] cli/command/container: set empty args in tests and discard output
2024-10-21 23:21:51 +02:00
Sebastiaan van Stijn df7e6e5c5f
cli/command/container: TestWaitExitOrRemoved use subtests
=== RUN   TestWaitExitOrRemoved
    === RUN   TestWaitExitOrRemoved/normal-container
    === RUN   TestWaitExitOrRemoved/give-me-exit-code-42
    === RUN   TestWaitExitOrRemoved/i-want-a-wait-error
    time="2024-10-13T18:48:14+02:00" level=error msg="Error waiting for container: removal failed"
    === RUN   TestWaitExitOrRemoved/non-existent-container-id
    time="2024-10-13T18:48:14+02:00" level=error msg="error waiting for container: no such container: non-existent-container-id"
    --- PASS: TestWaitExitOrRemoved (0.00s)
        --- PASS: TestWaitExitOrRemoved/normal-container (0.00s)
        --- PASS: TestWaitExitOrRemoved/give-me-exit-code-42 (0.00s)
        --- PASS: TestWaitExitOrRemoved/i-want-a-wait-error (0.00s)
        --- PASS: TestWaitExitOrRemoved/non-existent-container-id (0.00s)
    PASS

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 35d7b1a7a6)
Signed-off-by: Austin Vazquez <macedonv@amazon.com>
2024-10-21 15:53:20 +00:00
Sebastiaan van Stijn 254b966b0d
cli/command/container: set empty args in tests and discard output
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>
(cherry picked from commit 3b38dc67be)
Signed-off-by: Austin Vazquez <macedonv@amazon.com>
2024-10-21 15:53:09 +00:00
Laura Brehm 220033dd80
Merge pull request #5552 from thaJeztah/27.x_backport_fix_ConfigureAuth_deprecation 2024-10-21 16:42:49 +01:00
Sebastiaan van Stijn dd013610c6
Merge pull request #5563 from vvoland/5554-27.x
[27.x backport] Fix bash completion for `events --filter daemon=`
2024-10-21 11:37:57 +02:00
Harald Albers dc36908ec5
Fix bash completion for `events --filter daemon=`
Signed-off-by: Harald Albers <github@albersweb.de>
(cherry picked from commit 3f7b156c85)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-10-21 11:12:35 +02:00