switch usage directly to errdefs.(ErrAlreadyExists and ErrNotFound)

Signed-off-by: Zou Nengren <zouyee1989@gmail.com>
This commit is contained in:
zounengren
2021-09-24 18:26:58 +08:00
parent 45e0e5a77e
commit fcffe0c83a
19 changed files with 87 additions and 91 deletions

View File

@@ -19,14 +19,14 @@ package server
import (
"encoding/json"
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/log"
imagestore "github.com/containerd/containerd/pkg/cri/store/image"
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
"github.com/containerd/containerd/pkg/cri/store"
imagestore "github.com/containerd/containerd/pkg/cri/store/image"
)
// ImageStatus returns the status of the image, returns nil if the image isn't present.
@@ -35,7 +35,7 @@ import (
func (c *criService) ImageStatus(ctx context.Context, r *runtime.ImageStatusRequest) (*runtime.ImageStatusResponse, error) {
image, err := c.localResolve(r.GetImage().GetImage())
if err != nil {
if err == store.ErrNotExist {
if errdefs.IsNotFound(err) {
// return empty without error when image not found.
return &runtime.ImageStatusResponse{}, nil
}