Without breaking API compatibility, this patch allows us to know whether
a returned `cli/StatusError` was caused by a context cancellation or
not, which we can use to provide a nicer UX and not print the Go
"context canceled" error message if this is the cause.
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
Users have trouble understanding the different login paths on the CLI.
The default login is performed through an OAuth flow with the option to
fallback to a username and PAT login using the docker login -u <username>
option.
This patch improves the text around docker login, indicating:
- The username is shown when already authenticated
- Steps the user can take to switch user accounts are printed when
authenticated in an info.
- When not authenticated, the OAuth login flow explains the fallback
clearly to the user in an info.
- The password prompt now explicitly states that it accepts a PAT in an
info.
Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
- Use stdlib multi-errors instead of creating our own
- use apiClient instead of client for the API client to
prevent shadowing imports.
- use dockerCLI with Go's standard camelCase casing.
- rewrite runServiceScale to return warnings, instead of printing them
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
- Use stdlib multi-errors instead of creating our own
- use apiClient instead of client for the API client to
prevent shadowing imports.
- use dockerCLI with Go's standard camelCase casing.
- rename runSecretRemove to runRemove to align with other commands
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
- pass through the manifest-store, instead of the CLI as a whole
- handle context cancellation
- rename `runRm` to `runRemove` to align with other commands
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Use stdlib multi-errors instead of creating our own; also
touch-up one error and some minor cleanups.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
- use apiClient instead of client for the API client to
prevent shadowing imports.
- use dockerCLI with Go's standard camelCase casing.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
- use apiClient instead of client for the API client to
prevent shadowing imports.
- use dockerCLI with Go's standard camelCase casing.
- suppress some errors to make my IDE and linters happier
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
- use apiClient instead of client for the API client to
prevent shadowing imports.
- use dockerCLI with Go's standard camelCase casing.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Tasks with a service filter will result in the daemon performing a lookup
of the full service ID, then updating the provided filter with the actual
ID: 96ded2a1ba/daemon/cluster/tasks.go (L15-L30)
The `getService()` helper has a fast-path for situations where the given
filter is a full ID, before falling back to fuzzy-logic to search filters
by service name or prefix, which would return an error if the result is
ambiguous;
96ded2a1ba/daemon/cluster/helpers.go (L62-L81)
The loop executed here calls `client.ServiceInspectWithRaw()` to get info
of the service, and that method is ultimately calling the exact same
`getService()` helper on the daemon side, which means that we don't need
to repeat the work; we can use the `Service.ID` resolved from that call,
and use it to apply as filter for listing the tasks.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Use intermediate vars, so that the replicatedJobProgressUpdater can
be created in one go intead of setting some fields after the fact.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This check was redundant, because `errors.Join` already checks if the
list of errors is either empty, or only contains `nil` errors, as can
be seen in [this example][1];
package main
import (
"errors"
"testing"
)
func TestMultiErr(t *testing.T) {
var errs []error
if err := errors.Join(errs...); err != nil {
t.Fatal(err)
}
errs = append(errs, nil, nil, nil)
t.Logf("errs contains %d elements", len(errs))
if err := errors.Join(errs...); err != nil {
t.Fatal(err)
}
errs = append(errs, errors.New("with an error"))
if err := errors.Join(errs...); err == nil {
t.Fatal("expected an error")
}
}
[1]: https://go.dev/play/p/iSuGP81eght
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
commit 71ebbb81ae replaced the use of the
custom "cli.Errors" type for stdlib's errors.Join, however it made a
mistake by calling errors.Join for each error occurred, which "nests"
each error instead of putting each error at the same level.
Thanks to Paweł Gronowski for spotting this on the [pull request][1]
[1]: 71ebbb81ae (r1810257735)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
- assert unhandled error
- reset command-args to prevent test failing when running from pre-compiled test-binary
- use a const and a slightly more unique name for the volume-name
- discard stdout/stderr output
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
- assert unhandled error
- use sub-tests
- add test-case for conflicting options (both flag and name)
- reset command-args to prevent test failing when running from pre-compiled test-binary
- use a const and a slightly more unique name for the volume-name
- discard stdout/stderr output
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This was the only command for which we set the "example" field; while
we could consider doing this for other commands, we need to look what's
best w.r.t. duplicating the information maintained in markdown.
Also remove the intermediate variable used for the long description,
as this was also the only location where we used one.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
- use Println to print newline instead of custom format
- suppress some errors to make my IDE and linters happier
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
- use Println to print newline instead of custom format
- use apiClient instead of client for the API client to
prevent shadowing imports.
- use dockerCLI with Go's standard camelCase casing.
- suppress some errors to make my IDE and linters happier
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
- use Println to print newline instead of custom format
- use dockerCLI with Go's standard camelCase casing.
- suppress some errors to make my IDE and linters happier
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
- use Println to print newline instead of custom format
- use dockerCLI with Go's standard camelCase casing.
- suppress some errors to make my IDE and linters happier
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
- use Println to print newline instead of custom format
- use apiClient instead of client for the API client to
prevent shadowing imports.
- use dockerCLI with Go's standard camelCase casing.
- suppress some errors to make my IDE and linters happier
- fix some tests to work with "go test -update"
- rewrite TestSwarmInit to use sub-tests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
- use Println to print newline instead of custom format
- use dockerCLI with Go's standard camelCase casing.
- suppress some errors to make my IDE and linters happier
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
- use Println to print newline instead of custom format
- use apiClient instead of client for the API client to
prevent shadowing imports.
- use dockerCLI with Go's standard camelCase casing.
- suppress some errors to make my IDE and linters happier
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
- use Println to print newline instead of custom format
- use dockerCLI with Go's standard camelCase casing.
- suppress some errors to make my IDE and linters happier
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>