Skip to content

Commit

Permalink
fix: Added not found errors to classifier (#166)
Browse files Browse the repository at this point in the history
* fix: Added `not found` errors to classifier

* Update client/errors.go

Co-authored-by: Erez Rokah <[email protected]>

* message adjusted

* Update client/errors.go

Co-authored-by: Erez Rokah <[email protected]>

Co-authored-by: Erez Rokah <[email protected]>
  • Loading branch information
amanenk and erezrokah committed Jun 13, 2022
1 parent 6faeea5 commit 44479e9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion plugins/k8s/client/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ func ErrorClassifier(_ schema.ClientMeta, resourceName string, err error) diag.D
func classifyError(err error, fallbackType diag.Type, opts ...diag.BaseErrorOption) diag.Diagnostics {
ie := errors.Unwrap(err)
if se, ok := ie.(k8s.APIStatus); ok {
if se.Status().Code == 403 {
switch se.Status().Code {
case 403:
return diag.FromError(ie, diag.ACCESS, diag.WithSeverity(diag.WARNING), diag.WithDetails(se.Status().Details.String()))
case 404:
return diag.FromError(ie, diag.RESOLVING, diag.WithSeverity(diag.IGNORE), diag.WithDetails("Current version of k8s might not support the requested resource. Consider upgrading k8s to the latest version"))
}
}
return diag.Diagnostics{diag.NewBaseError(err, fallbackType, opts...)}
Expand Down

0 comments on commit 44479e9

Please sign in to comment.