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:
@@ -18,8 +18,8 @@ package container
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||
)
|
||||
|
||||
@@ -85,5 +85,5 @@ func (c *Metadata) UnmarshalJSON(data []byte) error {
|
||||
*c = Metadata(versioned.Metadata)
|
||||
return nil
|
||||
}
|
||||
return errors.Errorf("unsupported version: %q", versioned.Version)
|
||||
return fmt.Errorf("unsupported version: %q", versioned.Version)
|
||||
}
|
||||
|
||||
@@ -18,12 +18,13 @@ package container
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
|
||||
"github.com/containerd/continuity"
|
||||
"github.com/pkg/errors"
|
||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||
)
|
||||
|
||||
@@ -165,11 +166,11 @@ type StatusStorage interface {
|
||||
func StoreStatus(root, id string, status Status) (StatusStorage, error) {
|
||||
data, err := status.encode()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to encode status")
|
||||
return nil, fmt.Errorf("failed to encode status: %w", err)
|
||||
}
|
||||
path := filepath.Join(root, "status")
|
||||
if err := continuity.AtomicWriteFile(path, data, 0600); err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to checkpoint status to %q", path)
|
||||
return nil, fmt.Errorf("failed to checkpoint status to %q: %w", path, err)
|
||||
}
|
||||
return &statusStorage{
|
||||
path: path,
|
||||
@@ -183,11 +184,11 @@ func LoadStatus(root, id string) (Status, error) {
|
||||
path := filepath.Join(root, "status")
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return Status{}, errors.Wrapf(err, "failed to read status from %q", path)
|
||||
return Status{}, fmt.Errorf("failed to read status from %q: %w", path, err)
|
||||
}
|
||||
var status Status
|
||||
if err := status.decode(data); err != nil {
|
||||
return Status{}, errors.Wrapf(err, "failed to decode status %q", data)
|
||||
return Status{}, fmt.Errorf("failed to decode status %q: %w", data, err)
|
||||
}
|
||||
return status, nil
|
||||
}
|
||||
@@ -215,10 +216,10 @@ func (s *statusStorage) UpdateSync(u UpdateFunc) error {
|
||||
}
|
||||
data, err := newStatus.encode()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to encode status")
|
||||
return fmt.Errorf("failed to encode status: %w", err)
|
||||
}
|
||||
if err := continuity.AtomicWriteFile(s.path, data, 0600); err != nil {
|
||||
return errors.Wrapf(err, "failed to checkpoint status to %q", s.path)
|
||||
return fmt.Errorf("failed to checkpoint status to %q: %w", s.path, err)
|
||||
}
|
||||
s.status = newStatus
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user