1 /* 2 Copyright 2020 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package errors 18 19 import ( 20 "errors" 21 22 "google.golang.org/grpc/codes" 23 "google.golang.org/grpc/status" 24 ) 25 26 var ( 27 // ErrRegistryUnavailable - Get http error on the PullImage RPC call. 28 ErrRegistryUnavailable = errors.New("RegistryUnavailable") 29 30 // ErrSignatureValidationFailed - Unable to validate the image signature on the PullImage RPC call. 31 ErrSignatureValidationFailed = errors.New("SignatureValidationFailed") 32 33 // ErrRROUnsupported - Unable to enforce recursive readonly mounts 34 ErrRROUnsupported = errors.New("RROUnsupported") 35 ) 36 37 // IsNotFound returns a boolean indicating whether the error 38 // is grpc not found error. 39 // See https://github.com/grpc/grpc/blob/master/doc/statuscodes.md 40 // for a list of grpc status codes. 41 func IsNotFound(err error) bool { 42 s, ok := status.FromError(err) 43 if !ok { 44 return ok 45 } 46 if s.Code() == codes.NotFound { 47 return true 48 } 49 50 return false 51 } 52