Documentation
¶
Overview ¶
Package errors contains useful functionality for conversion errors
Index ¶
- Constants
- Variables
- func AsAPIError(err error) error
- func AsStatusCode(err error) int
- func AsStatusError(response *resty.Response, grs ...schema.GroupResource) error
- func ConvertKnativeFieldErrorToErrorList(err *apis.FieldError) field.ErrorList
- func ConvertKnativeFieldErrorToInternalError(err *apis.FieldError) *field.Error
- func ConvertResponseError(ctx context.Context, response *http.Response, err error, ...) error
- func ConvertToPluginK8StatusError(ctx context.Context, response *http.Response, err error, ...) error
- func GVKToGVR(gvk schema.GroupVersionKind) (gr schema.GroupVersionResource)
- func HandleError(req *restful.Request, resp *restful.Response, err error)
- func IsCredentialNotProvided(err error) bool
- func IsDefaultStorageClassNotFound(err error) bool
- func IsFileNotFound(err error) bool
- func IsGitRevisionNotFound(err error) bool
- func IsTemporaryError(err error) bool
- func IsToolServiceUnavailable(err error) bool
- func IsUnauthorized(err error) bool
- func NewCredentialNotProvided(message string) error
- func NewDefaultStorageClassNotFound(message string) error
- func NewFileNotFound(message string) error
- func NewGitRevisionNotFound(message string) error
- func Reason(err error) (exist bool, reason metav1.StatusReason)
- type TemporaryError
Constants ¶
const ( // StatusReasonCredentialNotProvided indicate that credential not provided StatusReasonCredentialNotProvided metav1.StatusReason = "CredentialNotProvided" //nolint:gosec StatusReasonUnauthorized metav1.StatusReason = "Unauthorized" // StatusReasonFileNotFound indicate that requested file not found StatusReasonFileNotFound metav1.StatusReason = "FileNotFound" // StatusReasonGitRevisionNotFound indicate that requested git revision not found StatusReasonGitRevisionNotFound metav1.StatusReason = "GitRevisionNotFound" StatusReasonToolServiceUnavailable metav1.StatusReason = "ToolServiceUnavailable" // StatusReasonStorageClassNotFound indicate that default storage class not found StatusReasonStorageClassNotFound metav1.StatusReason = "DefaultStorageClassNotFound" )
Variables ¶
var ErrNilPointer = errors.New("nil pointer")
ErrNilPointer indicates nil pointer, avoid panic. Although unlikely just in case
var RESTAPIGroupResource = schema.GroupResource{Group: "katanomi.dev", Resource: "API"}
RESTAPIGroupResource fake GroupResource to use errors api
var RESTClientGroupResource = schema.GroupResource{Group: "katanomi.dev", Resource: "RESTfulClient"}
RESTClientGroupResource fake GroupResource to use errors api
Functions ¶
func AsAPIError ¶
AsAPIError returns an error as a apimachinary api error
func AsStatusCode ¶
AsStatusCode returns the code from a errors.APIStatus, if not compatible will return InternalServerError
func AsStatusError ¶
func AsStatusError(response *resty.Response, grs ...schema.GroupResource) error
AsStatusError transform resty response to status error
func ConvertKnativeFieldErrorToErrorList ¶
func ConvertKnativeFieldErrorToErrorList(err *apis.FieldError) field.ErrorList
func ConvertKnativeFieldErrorToInternalError ¶
func ConvertKnativeFieldErrorToInternalError(err *apis.FieldError) *field.Error
func ConvertResponseError ¶ added in v0.3.0
func ConvertResponseError(ctx context.Context, response *http.Response, err error, gvk schema.GroupVersionKind, names ...string) error
ConvertResponseError converts a http response and an error into a kubernetes api error ctx is the basic context, response is the response object from tool sdk, err is the returned error gvk is the GroupVersionKind object with type meta for the object names supports one optional name to be given and will be attributed as the resource name in the returned error
func ConvertToPluginK8StatusError ¶ added in v0.8.0
func ConvertToPluginK8StatusError(ctx context.Context, response *http.Response, err error, gvk schema.GroupVersionKind, names ...string) error
ConvertToPluginK8StatusError converts a http response from plugin and an error into a kubernetes api error if the error is a kubernetes api error return it directly if the error is a common error then convert it to toolServiceUnavailable or Unauthorized error ctx is the basic context, response is the response object from tool sdk, err is the returned error names supports one optional name to be given and will be attributed as the resource name in the returned error
func GVKToGVR ¶ added in v0.7.0
func GVKToGVR(gvk schema.GroupVersionKind) (gr schema.GroupVersionResource)
GVKToGVR convert schema GroupVersionKind to GroupVersionResource Warning: this function just for show error info
func HandleError ¶
func HandleError(req *restful.Request, resp *restful.Response, err error)
HandleError handles error in requests
func IsCredentialNotProvided ¶ added in v0.8.0
IsCredentialNotProvided judge if the error is CredentialNotProvided
func IsDefaultStorageClassNotFound ¶ added in v0.10.0
IsDefaultStorageClassNotFound judge if the error is DefaultStorageClassNotFound
func IsFileNotFound ¶ added in v0.8.0
IsFileNotFound judge if the error is FileNotFound
func IsGitRevisionNotFound ¶ added in v0.8.0
IsGitRevisionNotFound judge if the error is GitRevisionNotFound
func IsTemporaryError ¶
IsTemporaryError this will check against a list of know non-temporary related errors like 403-Forbidden etc all others will be considered to be temporary
func IsToolServiceUnavailable ¶ added in v0.8.0
IsToolServiceUnavailable judge if the error is ToolServiceUnavailable
func IsUnauthorized ¶ added in v0.8.0
IsUnauthorized judge if the error is Unauthorized
func NewCredentialNotProvided ¶ added in v0.8.0
NewCredentialNotProvided init a CredentialNotProvided k8s api error
func NewDefaultStorageClassNotFound ¶ added in v0.10.0
NewDefaultStorageClassNotFound init a GitRevisionNotFound k8s api error
func NewFileNotFound ¶ added in v0.8.0
NewFileNotFound init a FileNotFound k8s api error
func NewGitRevisionNotFound ¶ added in v0.8.0
NewGitRevisionNotFound init a GitRevisionNotFound k8s api error
Types ¶
type TemporaryError ¶
TemporaryError is an error and has a Temporary function