Documentation ¶
Index ¶
- Constants
- Variables
- func CodeRegistry() []string
- func CountErrorByClass(errs []v1beta1.ConfigSyncError) map[string]int64
- func DeepEqual(left, right MultiError) bool
- func EnablePanicOnMisuse()
- func FormatMultiLine(e error) string
- func FormatSingleLine(e error) string
- func GetSourceAnnotation(obj client.Object) string
- func HasBlockingErrors(errs MultiError) bool
- func NonBlockingErrors(errs MultiError) []v1beta1.ConfigSyncError
- func PrintResource(r client.Object) string
- func PurifyError(e error) []string
- func ToCME(m MultiError) []v1.ConfigManagementError
- func ToCSE(m MultiError) []v1beta1.ConfigSyncError
- type Error
- func APIServerError(err error, message string, resources ...client.Object) Error
- func APIServerErrorWrap(err error, resources ...client.Object) Error
- func APIServerErrorf(err error, format string, a ...interface{}) Error
- func EmptySourceError(current int, resourceType string) Error
- func EncodeDeclaredFieldError(resource client.Object, err error) Error
- func HydrationError(code string, err error) Error
- func InternalError(message string) Error
- func InternalErrorf(format string, a ...interface{}) Error
- func InternalHydrationError(err error, format string, a ...interface{}) Error
- func InternalWrap(err error) Error
- func InternalWrapf(err error, format string, a ...interface{}) Error
- func MissingResourceWrap(err error, msg string, resources ...client.Object) Error
- func MultipleSingletonsError(duplicates ...client.Object) Error
- func OSWrap(err error) Error
- func ObjectParseError(resource client.Object, err error) Error
- func PathWrapError(err error, slashPaths ...string) Error
- func ResourceWrap(err error, msg string, resources ...client.Object) Error
- func TransientError(err error) Error
- func UndocumentedError(message string) Error
- func UndocumentedErrorf(format string, a ...interface{}) Error
- func UnknownGroupKindError(gk schema.GroupKind) Error
- func UnknownObjectKindError(resource client.Object) Error
- type ErrorBuilder
- func (eb ErrorBuilder) Build() Error
- func (eb ErrorBuilder) BuildWithConflictingManagers(resource client.Object, newManager, currentManager string) ManagementConflictError
- func (eb ErrorBuilder) BuildWithPaths(paths ...id.Path) PathError
- func (eb ErrorBuilder) BuildWithResources(resources ...client.Object) ResourceError
- func (eb ErrorBuilder) Sprint(message string) ErrorBuilder
- func (eb ErrorBuilder) Sprintf(format string, a ...interface{}) ErrorBuilder
- func (eb ErrorBuilder) Wrap(toWrap error) ErrorBuilder
- type ManagementConflictError
- type MultiError
- type PathError
- type ResourceError
Constants ¶
const APIServerErrorCode = "2002"
APIServerErrorCode is the error code for a status Error originating from the kubernetes API server.
const ActionableHydrationErrorCode = "1068"
ActionableHydrationErrorCode is the error code for a user actionable Error related to the hydration process.
const EmptySourceErrorCode = "2006"
EmptySourceErrorCode is the error code for an EmptySourceError.
const EncodeDeclaredFieldErrorCode = "1067"
EncodeDeclaredFieldErrorCode is the error code for errors that happen when encoding the declared fields.
const FightErrorCode = "2005"
FightErrorCode is the error code for Config Sync fighting with other controllers.
const InsufficientPermissionErrorCode = "2013"
InsufficientPermissionErrorCode is the error code when the reconciler has insufficient permissions to manage resources.
const InternalErrorCode = "9998"
InternalErrorCode is the error code for Internal.
const InternalHydrationErrorCode = "2015"
InternalHydrationErrorCode is the error code for an internal Error related to the hydration process.
const ManagementConflictErrorCode = "1060"
ManagementConflictErrorCode is the error code for management conflict errors.
const MissingResourceErrorCode = "2011"
MissingResourceErrorCode is the error code for a MissingResourceError.
const MultipleSingletonsErrorCode = "2012"
MultipleSingletonsErrorCode is the error code for MultipleSingletonsError
const OSErrorCode = "2003"
OSErrorCode is the error code for a status Error originating from an OS-level function call.
const ObjectParseErrorCode = "1006"
ObjectParseErrorCode is the code for ObjectParseError.
const PathErrorCode = "2001"
PathErrorCode is the error code for a generic PathError.
const ResourceErrorCode = "2010"
ResourceErrorCode is the error code for a generic ResourceError.
const SourceErrorCode = "2004"
SourceErrorCode is the error code for a status Error related to the repo's source of truth.
const TransientErrorCode = "2016"
TransientErrorCode is the error code for a transient error that might be auto-resolved in the retry.
const UndocumentedErrorCode = "9999"
UndocumentedErrorCode is the error code for Undocumented.
const UnknownKindErrorCode = "1021" // Impossible to create consistent example.
UnknownKindErrorCode is the error code for UnknownObjectKindError
Variables ¶
var EmptySourceErrorBuilder = NewErrorBuilder(EmptySourceErrorCode)
EmptySourceErrorBuilder is an ErrorBuilder for errors related to the repo's source of truth.
var InsufficientPermissionErrorBuilder = NewErrorBuilder(InsufficientPermissionErrorCode).
Sprint("Insufficient permission. To fix, make sure the reconciler has sufficient permissions.")
InsufficientPermissionErrorBuilder represents an error related to insufficient permissions returned by the APIServer.
var InternalErrorBuilder = NewErrorBuilder(InternalErrorCode).Sprint("internal error")
InternalErrorBuilder allows creating complex internal errors.
var ManagementConflictErrorBuilder = NewErrorBuilder(ManagementConflictErrorCode)
ManagementConflictErrorBuilder is the builder for management conflict errors.
var ResourceErrorBuilder = NewErrorBuilder(ResourceErrorCode)
ResourceErrorBuilder almost always results from an API server call involving one or more resources.
var SourceError = NewErrorBuilder(SourceErrorCode)
SourceError is an ErrorBuilder for errors related to the repo's source of truth.
var UndocumentedErrorBuilder = NewErrorBuilder(UndocumentedErrorCode)
UndocumentedErrorBuilder builds Undocumented errors.
Functions ¶
func CodeRegistry ¶
func CodeRegistry() []string
CodeRegistry returns a sorted list of currently registered error codes.
func CountErrorByClass ¶ added in v1.15.1
func CountErrorByClass(errs []v1beta1.ConfigSyncError) map[string]int64
CountErrorByClass counts the errors by errorclass. The errorclass is a string derived from the error code. For example, the errorclass of a ConfigSyncErrow with the error code of "1323" is "1xxx".
func DeepEqual ¶
func DeepEqual(left, right MultiError) bool
DeepEqual determines whether two MultiError objects are equal. DeepEqual sorts the two MultiError objects before comparing them. Two `status.Error` objects are considered equal if they have the same code and body.
func EnablePanicOnMisuse ¶
func EnablePanicOnMisuse()
EnablePanicOnMisuse makes status.Error ensure errors are properly formatted, aren't wrapped unnecessarily, and so on. Should only be enabled in debugging and test settings, not in production.
func FormatMultiLine ¶
FormatMultiLine formats multi-errors into multi-line style Errors are joined with two new lines
func FormatSingleLine ¶
FormatSingleLine format multi-errors into single-style Each error is reformatted as single line and joined with new line
func GetSourceAnnotation ¶
GetSourceAnnotation returns the string value of the SourcePath Annotation. Returns empty string if unset or the object has no annotations.
func HasBlockingErrors ¶
func HasBlockingErrors(errs MultiError) bool
HasBlockingErrors return whether `errs` include any blocking errors.
An error is blocking if it requires the users to do something so that Config Sync can sync successfully.
func NonBlockingErrors ¶
func NonBlockingErrors(errs MultiError) []v1beta1.ConfigSyncError
NonBlockingErrors return the non-blocking errors.
func PrintResource ¶
PrintResource returns a human-readable output for the Resource.
func PurifyError ¶
PurifyError extracts unique errors, sort and return them as array of string
func ToCME ¶
func ToCME(m MultiError) []v1.ConfigManagementError
ToCME converts a MultiError to ConfigManagementError.
func ToCSE ¶
func ToCSE(m MultiError) []v1beta1.ConfigSyncError
ToCSE converts a MultiError to ConfigSyncErrors.
Types ¶
type Error ¶
type Error interface { MultiError // ToCME converts the implementor into ConfigManagementError, preserving // structured information. ToCME() v1.ConfigManagementError // ToCSE converts the implementor into ConfigSyncError, preserving structured // information. ToCSE() v1beta1.ConfigSyncError // Code is the unique identifier of the error to help users find documentation. Code() string // Body is the body of the error to be printed. Body() string // Is allows comparing error types through errors.Is. Is(target error) bool // contains filtered or unexported methods }
Error defines a Kubernetes Nomos Vet error These are GKE Config Management directory errors which are shown to the user and documented.
func APIServerError ¶
APIServerError wraps an error returned by the APIServer.
func APIServerErrorWrap ¶ added in v1.17.0
APIServerErrorWrap wraps an error returned by the APIServer with resource objects.
func APIServerErrorf ¶
APIServerErrorf wraps an error returned by the APIServer with a formatted message.
func EmptySourceError ¶
EmptySourceError returns an EmptySourceError when the specified number of resources would have be deleted.
func EncodeDeclaredFieldError ¶
EncodeDeclaredFieldError reports that an error happens when encoding the declared fields for an object.
func HydrationError ¶
HydrationError returns a hydration error.
func InternalError ¶
InternalError represents conditions that should ever happen, but that we check for so that we can control how the program terminates when these unexpected situations occur.
These errors specifically happen when the code has a bug - as long as objects are being used as their contracts require, and as long as they follow their contracts, it should not be possible to trigger these.
func InternalErrorf ¶
InternalErrorf returns an InternalError with a formatted message.
func InternalHydrationError ¶
InternalHydrationError returns an internal error related to the hydration process.
func InternalWrap ¶
InternalWrap wraps an error as an internal error.
func InternalWrapf ¶ added in v1.16.1
InternalWrapf wraps an error as an internal error with a formatted message
func MissingResourceWrap ¶
MissingResourceWrap returns a MissingResourceError wrapping the given error and Resources.
func MultipleSingletonsError ¶
MultipleSingletonsError reports that multiple singleton resources were found on the cluster.
func ObjectParseError ¶
ObjectParseError reports that an object of known type did not match its definition, and so it was read in as an *unstructured.Unstructured.
func PathWrapError ¶
PathWrapError returns a PathError wrapping an error one or more relative paths.
func ResourceWrap ¶
ResourceWrap returns a ResourceError wrapping the given error and Resources.
func TransientError ¶ added in v1.15.1
TransientError returns a transient error.
func UndocumentedError ¶
UndocumentedError returns a Undocumented with the string representation of the passed object.
func UndocumentedErrorf ¶
UndocumentedErrorf returns a Undocumented with the string representation of the passed object.
func UnknownGroupKindError ¶
UnknownGroupKindError reports that a GroupKind is not defined on the cluster, so we can't sync it.
func UnknownObjectKindError ¶
UnknownObjectKindError reports that an object declared in the repo does not have a definition in the cluster.
type ErrorBuilder ¶
type ErrorBuilder struct {
// contains filtered or unexported fields
}
ErrorBuilder constructs complex, structured error messages. Use NewErrorBuilder to register a KNV for a new code.
func NewErrorBuilder ¶
func NewErrorBuilder(code string) ErrorBuilder
NewErrorBuilder returns an ErrorBuilder that can be used to generate errors. Registers this call with the passed unique code. Panics if there is an error code collision.
func (ErrorBuilder) Build ¶
func (eb ErrorBuilder) Build() Error
Build returns the Error inside the ErrorBuilder.
func (ErrorBuilder) BuildWithConflictingManagers ¶
func (eb ErrorBuilder) BuildWithConflictingManagers(resource client.Object, newManager, currentManager string) ManagementConflictError
BuildWithConflictingManagers adds the conflicting manager and the resource declared in the repository to the Error. newManager is the manager annotation for the current remediator/reconciler. currentManager is the manager annotation in the actual resource. It is also known as conflictingManager.
func (ErrorBuilder) BuildWithPaths ¶
func (eb ErrorBuilder) BuildWithPaths(paths ...id.Path) PathError
BuildWithPaths adds paths within the repository to the Error.
func (ErrorBuilder) BuildWithResources ¶
func (eb ErrorBuilder) BuildWithResources(resources ...client.Object) ResourceError
BuildWithResources adds resources declared in the repository to the Error.
func (ErrorBuilder) Sprint ¶
func (eb ErrorBuilder) Sprint(message string) ErrorBuilder
Sprint adds a message string into the Error inside the ErrorBuilder.
func (ErrorBuilder) Sprintf ¶
func (eb ErrorBuilder) Sprintf(format string, a ...interface{}) ErrorBuilder
Sprintf adds a formatted string into the Error inside the ErrorBuilder.
func (ErrorBuilder) Wrap ¶
func (eb ErrorBuilder) Wrap(toWrap error) ErrorBuilder
Wrap adds an error into the Error inside the ErrorBuilder.
type ManagementConflictError ¶
type ManagementConflictError interface { // ConflictingManager returns the annotation value of the other conflicting manager. ConflictingManager() string // CurrentManagerError returns the error that will be surfaced to the current manager. CurrentManagerError() ManagementConflictError // ConflictingManagerError returns the error that will be surfaced to the other conflicting manager. ConflictingManagerError() ManagementConflictError Error }
ManagementConflictError indicates that the passed resource is illegally declared in multiple repositories.
func ManagementConflictErrorWrap ¶
func ManagementConflictErrorWrap(resource client.Object, newManager string) ManagementConflictError
ManagementConflictErrorWrap returns the ManagementConflictError.
type MultiError ¶
MultiError represents a collection of errors.
func Append ¶
func Append(m MultiError, err error, errs ...error) MultiError
Append adds one or more errors to an existing MultiError. If m, err, and errs are nil, returns nil.
Requires at least one error to be passed explicitly to prevent developer mistakes. There is no valid reason to call Append with exactly one argument.
If err is a MultiError, appends all contained errors.
type PathError ¶
PathError defines a status error associated with one or more path-identifiable locations in the repo.
type ResourceError ¶
ResourceError defines a status error related to one or more k8s resources.
func FightError ¶ added in v1.15.1
func FightError(frequency float64, resource client.Object) ResourceError
FightError represents when the remediator is fighting over a resource object with some other process on a Kubernetes cluster.
Source Files ¶
- api_server_error.go
- declared_field_error.go
- empty_source_error.go
- error.go
- error_builder.go
- error_impl.go
- fight_error.go
- hydration.go
- internal_error.go
- management_conflict_error.go
- message_error_impl.go
- missing_resource_error.go
- multierror.go
- multiple_singletons_error.go
- object_parse_error.go
- os_error.go
- panic_on_misuse.go
- path_error.go
- path_error_impl.go
- resource_error.go
- resource_error_impl.go
- source_error.go
- transient_error.go
- undocumented_error.go
- unknown_kind_error.go
- wrapped_error_impl.go