Skip to content

Commit

Permalink
cmd/containerd-shim-runhcs-v1/delete: stop using pkg/errors
Browse files Browse the repository at this point in the history
There is no need to wrap errors from os package, as they already contain
extra information such as filename and which operation has failed.

Signed-off-by: Kir Kolyshkin <[email protected]>
  • Loading branch information
kolyshkin committed Oct 9, 2024
1 parent e78ef44 commit 3bd12f1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cmd/containerd-shim-runhcs-v1/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ package main

import (
"context"
"errors"
"fmt"
"os"
"path/filepath"
"time"

task "github.com/containerd/containerd/api/runtime/task/v2"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
"google.golang.org/protobuf/proto"
Expand All @@ -27,7 +27,7 @@ import (
func limitedRead(filePath string, readLimitBytes int64) ([]byte, error) {
f, err := os.Open(filePath)
if err != nil {
return nil, errors.Wrapf(err, "limited read failed to open file: %s", filePath)
return nil, err
}
defer f.Close()
if fi, err := f.Stat(); err == nil {
Expand All @@ -37,11 +37,11 @@ func limitedRead(filePath string, readLimitBytes int64) ([]byte, error) {
buf := make([]byte, readLimitBytes)
_, err := f.Read(buf)
if err != nil {
return []byte{}, errors.Wrapf(err, "limited read failed during file read: %s", filePath)
return nil, err
}
return buf, nil
}
return []byte{}, errors.Wrapf(err, "limited read failed during file stat: %s", filePath)
return nil, err
}

var deleteCommand = cli.Command{
Expand Down

0 comments on commit 3bd12f1

Please sign in to comment.