Skip to content

Commit b774e75

Browse files
committed
cli/command/system: use stdlib errors
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 9ba1314 commit b774e75

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

cli/command/system/dial_stdio.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ package system
22

33
import (
44
"context"
5+
"errors"
6+
"fmt"
57
"io"
68
"os"
79

810
"github.com/docker/cli/cli"
911
"github.com/docker/cli/cli/command"
10-
"github.com/pkg/errors"
1112
"github.com/sirupsen/logrus"
1213
"github.com/spf13/cobra"
1314
)
@@ -35,7 +36,7 @@ func runDialStdio(ctx context.Context, dockerCli command.Cli) error {
3536
dialer := dockerCli.Client().Dialer()
3637
conn, err := dialer(ctx)
3738
if err != nil {
38-
return errors.Wrap(err, "failed to open the raw stream connection")
39+
return fmt.Errorf("failed to open the raw stream connection: %w", err)
3940
}
4041
defer conn.Close()
4142

@@ -81,7 +82,7 @@ func copier(to halfWriteCloser, from halfReadCloser, debugDescription string) er
8182
}
8283
}()
8384
if _, err := io.Copy(to, from); err != nil {
84-
return errors.Wrapf(err, "error while Copy (%s)", debugDescription)
85+
return fmt.Errorf("error while Copy (%s): %w", debugDescription, err)
8586
}
8687
return nil
8788
}

cli/command/system/inspect.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
flagsHelper "github.com/docker/cli/cli/flags"
1818
"github.com/moby/moby/api/types/image"
1919
"github.com/moby/moby/client"
20-
"github.com/pkg/errors"
2120
"github.com/spf13/cobra"
2221
"github.com/spf13/pflag"
2322
)
@@ -99,7 +98,7 @@ func runInspect(ctx context.Context, dockerCli command.Cli, opts inspectOptions)
9998
typePlugin, typeSecret, typeService, typeTask, typeVolume:
10099
elementSearcher = inspectAll(ctx, dockerCli, opts.size, opts.objectType)
101100
default:
102-
return errors.Errorf(`unknown type: %q: must be one of "%s"`, opts.objectType, strings.Join(allTypes, `", "`))
101+
return fmt.Errorf(`unknown type: %q: must be one of "%s"`, opts.objectType, strings.Join(allTypes, `", "`))
103102
}
104103
return inspect.Inspect(dockerCli.Out(), opts.ids, opts.format, elementSearcher)
105104
}
@@ -273,7 +272,7 @@ func inspectAll(ctx context.Context, dockerCLI command.Cli, getSize bool, typeCo
273272
}
274273
return v, raw, err
275274
}
276-
return nil, nil, errors.Errorf("error: no such object: %s", ref)
275+
return nil, nil, fmt.Errorf("error: no such object: %s", ref)
277276
}
278277
}
279278

cli/command/system/version.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package system
22

33
import (
44
"context"
5+
"fmt"
56
"io"
67
"runtime"
78
"sort"
@@ -18,7 +19,6 @@ import (
1819
"github.com/docker/cli/templates"
1920
"github.com/moby/moby/api/types"
2021
"github.com/moby/moby/client"
21-
"github.com/pkg/errors"
2222
"github.com/spf13/cobra"
2323
"github.com/tonistiigi/go-rosetta"
2424
)
@@ -212,7 +212,7 @@ func newVersionTemplate(templateFormat string) (*template.Template, error) {
212212
}
213213
tmpl, err := templates.New("version").Funcs(template.FuncMap{"getDetailsOrder": getDetailsOrder}).Parse(templateFormat)
214214
if err != nil {
215-
return nil, errors.Wrap(err, "template parsing error")
215+
return nil, fmt.Errorf("template parsing error: %w", err)
216216
}
217217
return tmpl, nil
218218
}

0 commit comments

Comments
 (0)