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:
@@ -20,6 +20,7 @@ import (
|
||||
"bufio"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -37,7 +38,6 @@ import (
|
||||
v1 "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/opencontainers/runc/libcontainer/user"
|
||||
"github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// SpecOpts sets spec specific information to a newly generated OCI spec
|
||||
@@ -138,7 +138,7 @@ func WithSpecFromBytes(p []byte) SpecOpts {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
|
||||
*s = Spec{} // make sure spec is cleared.
|
||||
if err := json.Unmarshal(p, s); err != nil {
|
||||
return errors.Wrapf(err, "decoding spec config file failed, current supported OCI runtime-spec : v%s", specs.Version)
|
||||
return fmt.Errorf("decoding spec config file failed, current supported OCI runtime-spec : v%s: %w", specs.Version, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -149,7 +149,7 @@ func WithSpecFromFile(filename string) SpecOpts {
|
||||
return func(ctx context.Context, c Client, container *containers.Container, s *Spec) error {
|
||||
p, err := os.ReadFile(filename)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "cannot load spec config file")
|
||||
return fmt.Errorf("cannot load spec config file: %w", err)
|
||||
}
|
||||
return WithSpecFromBytes(p)(ctx, c, container, s)
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ package oci
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/containerd/containerd/containers"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// WithAllCurrentCapabilities propagates the effective capabilities of the caller process to the container process.
|
||||
|
||||
@@ -18,10 +18,10 @@ package oci
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/containerd/containerd/containers"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// WithWindowsCPUCount sets the `Windows.Resources.CPU.Count` section to the
|
||||
|
||||
@@ -20,12 +20,13 @@
|
||||
package oci
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/containerd/containerd/pkg/userns"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
@@ -47,7 +48,7 @@ func HostDevices() ([]specs.LinuxDevice, error) {
|
||||
func getDevices(path, containerPath string) ([]specs.LinuxDevice, error) {
|
||||
stat, err := os.Stat(path)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "error stating device path")
|
||||
return nil, fmt.Errorf("error stating device path: %w", err)
|
||||
}
|
||||
|
||||
if !stat.IsDir() {
|
||||
|
||||
Reference in New Issue
Block a user