github.com/operator-framework/operator-lifecycle-manager@v0.30.0/pkg/controller/errors/errors.go (about) 1 package errors 2 3 import "fmt" 4 5 // MultipleExistingCRDOwnersError is an error that denotes multiple owners of a CRD exist 6 // simultaneously in the same namespace 7 type MultipleExistingCRDOwnersError struct { 8 CSVNames []string 9 CRDName string 10 Namespace string 11 } 12 13 type UnadoptableError struct { 14 resourceNamespace string 15 resourceName string 16 } 17 18 func (err UnadoptableError) Error() string { 19 if err.resourceNamespace == "" { 20 return fmt.Sprintf("%s is unadoptable", err.resourceName) 21 } 22 return fmt.Sprintf("%s/%s is unadoptable", err.resourceNamespace, err.resourceName) 23 } 24 25 func NewUnadoptableError(resourceNamespace, resourceName string) UnadoptableError { 26 return UnadoptableError{resourceNamespace, resourceName} 27 } 28 29 func (m MultipleExistingCRDOwnersError) Error() string { 30 return fmt.Sprintf("Existing CSVs %v in namespace %s all claim to own CRD %s", m.CSVNames, m.Namespace, m.CRDName) 31 } 32 33 func NewMultipleExistingCRDOwnersError(csvNames []string, crdName string, namespace string) MultipleExistingCRDOwnersError { 34 return MultipleExistingCRDOwnersError{ 35 CSVNames: csvNames, 36 CRDName: crdName, 37 Namespace: namespace, 38 } 39 } 40 41 func IsMultipleExistingCRDOwnersError(err error) bool { 42 switch err.(type) { 43 case MultipleExistingCRDOwnersError: 44 return true 45 } 46 47 return false 48 } 49 50 type FatalError struct { 51 error 52 } 53 54 func NewFatalError(err error) FatalError { 55 return FatalError{err} 56 } 57 func IsFatal(err error) bool { 58 switch err.(type) { 59 case FatalError: 60 return true 61 } 62 return false 63 } 64 65 // GroupVersionKindNotFoundError occurs when we can't find an API via discovery 66 type GroupVersionKindNotFoundError struct { 67 Group string 68 Version string 69 Kind string 70 } 71 72 func (g GroupVersionKindNotFoundError) Error() string { 73 return fmt.Sprintf("Unable to find GVK in discovery: %s %s %s", g.Group, g.Version, g.Kind) 74 }