feat: replace github.com/pkg/errors to errors

Signed-off-by: haoyun <yun.hao@daocloud.io>
Co-authored-by: zounengren <zouyee1989@gmail.com>
This commit is contained in:
haoyun
2022-01-07 10:19:31 +08:00
parent 3ccd43c8f6
commit bbe46b8c43
299 changed files with 1896 additions and 1874 deletions

View File

@@ -20,6 +20,7 @@ import (
"context"
gocontext "context"
"encoding/csv"
"errors"
"fmt"
"strings"
@@ -34,7 +35,6 @@ import (
"github.com/containerd/containerd/oci"
gocni "github.com/containerd/go-cni"
specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
)

View File

@@ -21,6 +21,7 @@ package run
import (
gocontext "context"
"errors"
"fmt"
"os"
"path/filepath"
@@ -39,7 +40,6 @@ import (
"github.com/containerd/containerd/runtime/v2/runc/options"
"github.com/containerd/containerd/snapshots"
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
)
@@ -204,7 +204,7 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli
if context.Bool("net-host") {
hostname, err := os.Hostname()
if err != nil {
return nil, errors.Wrap(err, "get hostname")
return nil, fmt.Errorf("get hostname: %w", err)
}
opts = append(opts,
oci.WithHostNamespace(specs.NetworkNamespace),
@@ -417,15 +417,15 @@ func parseIDMapping(mapping string) (specs.LinuxIDMapping, error) {
}
cID, err := strconv.ParseUint(parts[0], 0, 32)
if err != nil {
return specs.LinuxIDMapping{}, errors.Wrapf(err, "invalid container id for user namespace remapping")
return specs.LinuxIDMapping{}, fmt.Errorf("invalid container id for user namespace remapping: %w", err)
}
hID, err := strconv.ParseUint(parts[1], 0, 32)
if err != nil {
return specs.LinuxIDMapping{}, errors.Wrapf(err, "invalid host id for user namespace remapping")
return specs.LinuxIDMapping{}, fmt.Errorf("invalid host id for user namespace remapping: %w", err)
}
size, err := strconv.ParseUint(parts[2], 0, 32)
if err != nil {
return specs.LinuxIDMapping{}, errors.Wrapf(err, "invalid size for user namespace remapping")
return specs.LinuxIDMapping{}, fmt.Errorf("invalid size for user namespace remapping: %w", err)
}
return specs.LinuxIDMapping{
ContainerID: uint32(cID),

View File

@@ -18,6 +18,7 @@ package run
import (
gocontext "context"
"errors"
"github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/options"
"github.com/containerd/console"
@@ -26,7 +27,6 @@ import (
"github.com/containerd/containerd/oci"
"github.com/containerd/containerd/pkg/netns"
specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
)