1
0
mirror of https://github.com/docker/cli.git synced 2026-01-06 05:41:44 +03:00

cli/command/system: use stdlib errors

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2025-09-08 20:24:17 +02:00
parent 9ba1314d3a
commit b774e75931
3 changed files with 8 additions and 8 deletions

View File

@@ -2,12 +2,13 @@ package system
import (
"context"
"errors"
"fmt"
"io"
"os"
"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
@@ -35,7 +36,7 @@ func runDialStdio(ctx context.Context, dockerCli command.Cli) error {
dialer := dockerCli.Client().Dialer()
conn, err := dialer(ctx)
if err != nil {
return errors.Wrap(err, "failed to open the raw stream connection")
return fmt.Errorf("failed to open the raw stream connection: %w", err)
}
defer conn.Close()
@@ -81,7 +82,7 @@ func copier(to halfWriteCloser, from halfReadCloser, debugDescription string) er
}
}()
if _, err := io.Copy(to, from); err != nil {
return errors.Wrapf(err, "error while Copy (%s)", debugDescription)
return fmt.Errorf("error while Copy (%s): %w", debugDescription, err)
}
return nil
}

View File

@@ -17,7 +17,6 @@ import (
flagsHelper "github.com/docker/cli/cli/flags"
"github.com/moby/moby/api/types/image"
"github.com/moby/moby/client"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
@@ -99,7 +98,7 @@ func runInspect(ctx context.Context, dockerCli command.Cli, opts inspectOptions)
typePlugin, typeSecret, typeService, typeTask, typeVolume:
elementSearcher = inspectAll(ctx, dockerCli, opts.size, opts.objectType)
default:
return errors.Errorf(`unknown type: %q: must be one of "%s"`, opts.objectType, strings.Join(allTypes, `", "`))
return fmt.Errorf(`unknown type: %q: must be one of "%s"`, opts.objectType, strings.Join(allTypes, `", "`))
}
return inspect.Inspect(dockerCli.Out(), opts.ids, opts.format, elementSearcher)
}
@@ -273,7 +272,7 @@ func inspectAll(ctx context.Context, dockerCLI command.Cli, getSize bool, typeCo
}
return v, raw, err
}
return nil, nil, errors.Errorf("error: no such object: %s", ref)
return nil, nil, fmt.Errorf("error: no such object: %s", ref)
}
}

View File

@@ -2,6 +2,7 @@ package system
import (
"context"
"fmt"
"io"
"runtime"
"sort"
@@ -18,7 +19,6 @@ import (
"github.com/docker/cli/templates"
"github.com/moby/moby/api/types"
"github.com/moby/moby/client"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/tonistiigi/go-rosetta"
)
@@ -212,7 +212,7 @@ func newVersionTemplate(templateFormat string) (*template.Template, error) {
}
tmpl, err := templates.New("version").Funcs(template.FuncMap{"getDetailsOrder": getDetailsOrder}).Parse(templateFormat)
if err != nil {
return nil, errors.Wrap(err, "template parsing error")
return nil, fmt.Errorf("template parsing error: %w", err)
}
return tmpl, nil
}