kubernetes: github.com/erikstmartin/kubernetes/pkg/api/errors Index | Files | Directories

package errors

import "github.com/erikstmartin/kubernetes/pkg/api/errors"

Package errors provides detailed error types for api field validation.


Package Files

doc.go errors.go validation.go

func FromObject Uses

func FromObject(obj runtime.Object) error

FromObject generates an statusError from an api.Status, if that is the type of obj; otherwise, returns an error created by fmt.Errorf.

func IsAlreadyExists Uses

func IsAlreadyExists(err error) bool

IsAlreadyExists determines if the err is an error which indicates that a specified resource already exists.

func IsBadRequest Uses

func IsBadRequest(err error) bool

IsBadRequest determines if err is an error which indicates that the request is invalid.

func IsConflict Uses

func IsConflict(err error) bool

IsConflict determines if the err is an error which indicates the provided update conflicts.

func IsInvalid Uses

func IsInvalid(err error) bool

IsInvalid determines if the err is an error which indicates the provided resource is not valid.

func IsNotFound Uses

func IsNotFound(err error) bool

IsNotFound returns true if the specified error was created by NewNotFoundErr.

func NewAlreadyExists Uses

func NewAlreadyExists(kind, name string) error

NewAlreadyExists returns an error indicating the item requested exists by that identifier.

func NewBadRequest Uses

func NewBadRequest(reason string) error

NewBadRequest creates an error that indicates that the request is invalid and can not be processed.

func NewConflict Uses

func NewConflict(kind, name string, err error) error

NewConflict returns an error indicating the item can't be updated as provided.

func NewInvalid Uses

func NewInvalid(kind, name string, errs ValidationErrorList) error

NewInvalid returns an error indicating the item is invalid and cannot be processed.

func NewNotFound Uses

func NewNotFound(kind, name string) error

NewNotFound returns a new error which indicates that the resource of the kind and the name was not found.

func ValueOf Uses

func ValueOf(t ValidationErrorType) string

type ValidationError Uses

type ValidationError struct {
    Type     ValidationErrorType
    Field    string
    BadValue interface{}

ValidationError is an implementation of the 'error' interface, which represents an error of validation.

func NewFieldDuplicate Uses

func NewFieldDuplicate(field string, value interface{}) ValidationError

NewFieldDuplicate returns a ValidationError indicating "duplicate value"

func NewFieldForbidden Uses

func NewFieldForbidden(field string, value interface{}) ValidationError

NewFieldForbidden returns a ValidationError indicating "forbidden"

func NewFieldInvalid Uses

func NewFieldInvalid(field string, value interface{}) ValidationError

NewFieldInvalid returns a ValidationError indicating "invalid value"

func NewFieldNotFound Uses

func NewFieldNotFound(field string, value interface{}) ValidationError

NewFieldNotFound returns a ValidationError indicating "value not found"

func NewFieldNotSupported Uses

func NewFieldNotSupported(field string, value interface{}) ValidationError

NewFieldNotSupported returns a ValidationError indicating "unsupported value"

func NewFieldRequired Uses

func NewFieldRequired(field string, value interface{}) ValidationError

NewFieldRequired returns a ValidationError indicating "value required"

func (ValidationError) Error Uses

func (v ValidationError) Error() string

type ValidationErrorList Uses

type ValidationErrorList util.ErrorList

ValidationErrorList is a collection of ValidationErrors. This does not implement the error interface to avoid confusion where an empty ValidationErrorList would still be an error (non-nil). To produce a single error instance from a ValidationErrorList, use the ToError() method, which will return nil for an empty ValidationErrorList.

func (ValidationErrorList) Prefix Uses

func (list ValidationErrorList) Prefix(prefix string) ValidationErrorList

Prefix adds a prefix to the Field of every ValidationError in the list. Returns the list for convenience.

func (ValidationErrorList) PrefixIndex Uses

func (list ValidationErrorList) PrefixIndex(index int) ValidationErrorList

PrefixIndex adds an index to the Field of every ValidationError in the list. Returns the list for convenience.

func (ValidationErrorList) ToError Uses

func (list ValidationErrorList) ToError() error

ToError converts a ValidationErrorList into a "normal" error, or nil if the list is empty.

type ValidationErrorType Uses

type ValidationErrorType string

ValidationErrorType is a machine readable value providing more detail about why a field is invalid. These values are expected to match 1-1 with CauseType in api/types.go.

const (
    // ValidationErrorTypeNotFound is used to report failure to find a requested value
    // (e.g. looking up an ID).
    ValidationErrorTypeNotFound ValidationErrorType = "FieldValueNotFound"
    // ValidationErrorTypeRequired is used to report required values that are not
    // provided (e.g. empty strings, null values, or empty arrays).
    ValidationErrorTypeRequired ValidationErrorType = "FieldValueRequired"
    // ValidationErrorTypeDuplicate is used to report collisions of values that must be
    // unique (e.g. unique IDs).
    ValidationErrorTypeDuplicate ValidationErrorType = "FieldValueDuplicate"
    // ValidationErrorTypeInvalid is used to report malformed values (e.g. failed regex
    // match).
    ValidationErrorTypeInvalid ValidationErrorType = "FieldValueInvalid"
    // ValidationErrorTypeNotSupported is used to report valid (as per formatting rules)
    // values that can not be handled (e.g. an enumerated string).
    ValidationErrorTypeNotSupported ValidationErrorType = "FieldValueNotSupported"
    // ValidationErrorTypeForbidden is used to report valid (as per formatting rules)
    // values which would be accepted by some api instances, but which would invoke behavior
    // not permitted by this api instance (such as due to stricter security policy).
    ValidationErrorTypeForbidden ValidationErrorType = "FieldValueForbidden"

TODO: These values are duplicated in api/types.go, but there's a circular dep. Fix it.


etcdPackage etcd provides conversion of etcd errors to API errors.

Package errors imports 7 packages (graph). Updated 2018-04-10. Refresh now. Tools for package owners.