Commit Graph

2270 Commits

Author SHA1 Message Date
Harald Albers 39cd60b6eb Disable file completion for `--network-alias`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-10-28 22:48:37 +00:00
Harald Albers b3703fa109 Disable file completion for `--name`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-10-28 22:48:37 +00:00
Harald Albers 31f1f43b1b Disable file completion for `--mount`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-10-28 22:48:37 +00:00
Harald Albers 0135d7ed2b Disable file completion for `--memory*`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-10-28 22:48:37 +00:00
Harald Albers e27ff3b202 Disable file completion for `--mac-address`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-10-28 22:48:37 +00:00
Harald Albers 6a801bcd40 Disable file completion for `--log-*`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-10-28 22:48:37 +00:00
Harald Albers 93af729f53 Disable file completion for `--link-local-ip`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-10-28 22:48:37 +00:00
Harald Albers 0e4b312b90 Add completion for `--link`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-10-28 22:48:37 +00:00
Harald Albers 846439cdc4 Disable file completion for `--label`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-10-28 22:48:37 +00:00
Harald Albers 33d870adb7 Disable file completion for `--kernel-memory`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-10-28 22:48:37 +00:00
Harald Albers 77fd7d7a16 Disable file completion for `--isolation`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-10-28 22:48:37 +00:00
Harald Albers b9c7f6c67e Add completion for `--ipc`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-10-28 22:48:37 +00:00
Harald Albers 784ad51c67 Disable file completion for `--ip6*`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-10-28 22:48:37 +00:00
Harald Albers e08a00701b Disable file completion for `--hostname`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-10-28 22:48:37 +00:00
Harald Albers 3ab5af735a Disable file completion for `--health-*`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-10-28 22:48:37 +00:00
Harald Albers d963cfc964 Disable file completion for `--group-add`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-10-28 22:48:37 +00:00
Harald Albers a5aa7c9037 Disable file completion for `--gpus`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-10-28 22:48:37 +00:00
Harald Albers 6aba94e6dd Disable file completion for `--expose`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-10-28 22:48:37 +00:00
Harald Albers 9906847f54 Disable file completion for `--entrypoint`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-10-28 22:48:37 +00:00
Harald Albers 85ab1210ab Disable file completion for `--domainname`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-10-28 22:48:37 +00:00
Harald Albers 14038a915d Disable file completion for `--dns*`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-10-28 22:48:37 +00:00
Harald Albers 285d0e32be Disable file completion for `--device-*`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-10-28 22:48:37 +00:00
Harald Albers 4450f48f07 Disable file completion for `--cpu*`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-10-28 22:48:37 +00:00
Harald Albers 00e3b7cdcc Add completion for `--cgroupns`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-10-28 22:48:37 +00:00
Harald Albers fe1db01af1 Disable file completion for `--cgroup-parent`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-10-28 22:48:37 +00:00
Harald Albers 75d80775ce Disable file completion for `--blkio-weight*`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-10-28 22:48:37 +00:00
Harald Albers 55d4192c3a Add completion for `--attach`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-10-28 22:48:37 +00:00
Harald Albers 98d5b0389d Disable file completion for `--annotation`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-10-28 22:48:37 +00:00
Harald Albers d9766a3c65 Disable file completion for `--add-host`
Signed-off-by: Harald Albers <github@albersweb.de>
2024-10-28 22:48:37 +00:00
Harald Albers cc981e30ba Share the container completions
Signed-off-by: Harald Albers <github@albersweb.de>
2024-10-28 22:48:37 +00:00
Sebastiaan van Stijn 61baf2a3d9
Merge pull request #5570 from thaJeztah/credentials_coverage
cli/config/credentials: add test for save being idempotent
2024-10-22 16:36:58 +02:00
Sebastiaan van Stijn c34b80bc65
Merge pull request #5567 from thaJeztah/config_fix_err
cli/config: improve error when failing to parse config file
2024-10-22 14:05:45 +02:00
Sebastiaan van Stijn 3c78069240
cli/config/credentials: add test for save being idempotent
Test case for d3f6867e4d

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-22 12:22:54 +02:00
Sebastiaan van Stijn 0dd6f7f1b3
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>
2024-10-22 10:58:29 +02:00
Sebastiaan van Stijn 5f4b14950e
cli: remove deprecated Errors type
The Errors type was deprecated in d3bafa5f3e,
which has been included in the 27.4.0 release.

This patch removes the type, as there are no external consumers.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-22 10:43:24 +02:00
Sebastiaan van Stijn 1aab64dd90
Merge pull request #5547 from thaJeztah/plugin_better_error
cli/command/plugins: use errors.Join instead of custom cli.Errors, and deprecate cli.Errors
2024-10-22 10:42:26 +02:00
Sebastiaan van Stijn 0ab0eca8bd
Merge pull request #5550 from thaJeztah/login_minor_refactor
cli/command: PromptUserForCredentials: assorted minor improvements and (linting) fixes
2024-10-21 23:23:06 +02:00
Sebastiaan van Stijn d96f8b7f91
cli/config: improve error when failing to parse config file
The format had a stray colon and space included. While fixing that, also
updating the error message to clarify the error happened while parsing
the file (not so much "loading" it).

Before:

    WARNING: Error loading config file: /root/.docker/config.json: : json: cannot unmarshal bool into Go struct field ConfigFile.features of type string

After:

    WARNING: Error parsing config file (/root/.docker/config.json): json: cannot unmarshal bool into Go struct field ConfigFile.features of type string

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-21 18:26:02 +02:00
Sebastiaan van Stijn abb8e9b78a
Merge pull request #5546 from thaJeztah/hints_coverage
cli/hints: add tests
2024-10-21 18:08:28 +02:00
Laura Brehm 7029147458
Merge pull request #5557 from thaJeztah/minor_linting_issues 2024-10-21 17:00:40 +01:00
Paweł Gronowski d2b87a0a3b
Merge pull request #5553 from thaJeztah/login_idempotent
cli/config/credentials: skip saving config-file if credentials didn't change
2024-10-21 15:23:26 +02:00
Sebastiaan van Stijn d3f6867e4d
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>
2024-10-21 00:19:52 +02:00
Sebastiaan van Stijn 6b9083776f
cli/command: AddPlatformFlag: suppress unhandled error
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-20 17:51:36 +02:00
Sebastiaan van Stijn fb61156b05
cli/command/registry: fix minor linting issues
- fix camelCase naming of verifyLoginOptions
- suppress unhandled errors that can be ignored

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-20 17:51:12 +02:00
Sebastiaan van Stijn 4b7a1e4613
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>
2024-10-19 13:24:19 +02:00
Sebastiaan van Stijn 378a3d7d36
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>
2024-10-19 13:23:29 +02:00
Sebastiaan van Stijn 54e3685bcd
cli/command: ConfigureAuth: fix deprecation comment
Deprecation comments must have an empty line before them, otherwise tools
and linters may not recognise them. While fixing this, also updated the
reference to PromptUserForCredentials to be a docs-link to make it clickable.

Updates 6e4818e7d6.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-19 13:05:31 +02:00
Sebastiaan van Stijn 3d8b49523d
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>
2024-10-19 12:49:44 +02:00
Sebastiaan van Stijn a21a5f4243
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>
2024-10-19 12:10:46 +02:00
Sebastiaan van Stijn eda78e9cdc
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>
2024-10-19 12:07:51 +02:00