mirror of
https://github.com/replicatedhq/troubleshoot.git
synced 2026-04-15 07:16:34 +00:00
27 lines
612 B
Go
27 lines
612 B
Go
package collect
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
type RBACError struct {
|
|
DisplayName string
|
|
Namespace string
|
|
Resource string
|
|
Verb string
|
|
}
|
|
|
|
func (e RBACError) Error() string {
|
|
if e.Namespace == "" {
|
|
return fmt.Sprintf("cannot collect %s: action %q is not allowed on resource %q at the cluster scope", e.DisplayName, e.Verb, e.Resource)
|
|
}
|
|
return fmt.Sprintf("cannot collect %s: action %q is not allowed on resource %q in the %q namespace", e.DisplayName, e.Verb, e.Resource, e.Namespace)
|
|
}
|
|
|
|
func IsRBACError(err error) bool {
|
|
_, ok := errors.Cause(err).(RBACError)
|
|
return ok
|
|
}
|