Documentation
¶
Index ¶
- Constants
- Variables
- func Description(description string) error
- func DisplayName(displayName string) error
- func Email(email string) error
- func ForControlCharacters(s string) error
- func Identifier(identifier string) error
- func IsPathTooDeep(path string, isSpace bool) bool
- func Password(pw string) error
- func Path(path string, isSpace bool, identifierCheck SpaceIdentifier) error
- func PathDepth(path string, isSpace bool) error
- func PrincipalUIDDefault(uid string) error
- func RepoIdentifierDefault(identifier string) error
- func ServiceAccountParent(parentType enum.ParentResourceType, parentID int64) error
- func SpaceIdentifierDefault(identifier string, isRoot bool) error
- func TokenLifetime(lifetime *time.Duration, optional bool) error
- type PrincipalUID
- type RepoIdentifier
- type SpaceIdentifier
- type ValidationError
Constants ¶
const (
MaxIdentifierLength = 100
)
Variables ¶
var ( ErrDisplayNameLength = &ValidationError{ fmt.Sprintf("DisplayName has to be between %d and %d in length.", minDisplayNameLength, maxDisplayNameLength), } ErrDescriptionTooLong = &ValidationError{ fmt.Sprintf("Description can be at most %d in length.", maxDescriptionLength), } ErrIdentifierLength = &ValidationError{ fmt.Sprintf( "Identifier has to be between %d and %d in length.", minIdentifierLength, MaxIdentifierLength, ), } ErrIdentifierRegex = &ValidationError{ "Identifier can only contain the following characters [a-zA-Z0-9-_.].", } ErrEmailLen = &ValidationError{ fmt.Sprintf("Email address has to be within %d and %d characters", minEmailLength, maxEmailLength), } ErrInvalidCharacters = &ValidationError{"Input contains invalid characters."} ErrIllegalRootSpaceIdentifier = &ValidationError{ fmt.Sprintf("The following identifiers are not allowed for a root space: %v", illegalRootSpaceIdentifiers), } ErrIllegalRepoSpaceIdentifierSuffix = &ValidationError{ fmt.Sprintf("Space and repository identifiers cannot end with %q.", illegalRepoSpaceIdentifierSuffix), } ErrIllegalPrincipalUID = &ValidationError{ fmt.Sprintf("Principal UID is not allowed to be %q.", types.AnonymousPrincipalUID), } )
var ( ErrPathEmpty = &ValidationError{ "Path can't be empty.", } ErrPathInvalidDepth = &ValidationError{ fmt.Sprintf("A path can have at most %d segments (%d for spaces).", maxPathSegments, maxPathSegmentsForSpace), } ErrEmptyPathSegment = &ValidationError{ "Empty segments are not allowed.", } ErrPathCantBeginOrEndWithSeparator = &ValidationError{ fmt.Sprintf("Path can't start or end with the separator ('%s').", types.PathSeparator), } )
var ( ErrServiceAccountParentTypeIsInvalid = &ValidationError{ "Provided parent type is invalid.", } ErrServiceAccountParentIDInvalid = &ValidationError{ "ParentID required - Global service accounts are not supported.", } )
var ( ErrTokenLifeTimeOutOfBounds = &ValidationError{ "The life time of a token has to be between 1 day and 365 days.", } ErrTokenLifeTimeRequired = &ValidationError{ "The life time of a token is required.", } )
var (
ErrAny = &ValidationError{}
)
var ( // ErrPasswordLength is returned when the password // is outside of the allowed length. ErrPasswordLength = &ValidationError{ fmt.Sprintf("Password has to be within %d and %d characters", minPasswordLength, maxPasswordLength), } )
var WireSet = wire.NewSet( ProvidePrincipalUIDCheck, ProvideSpaceIdentifierCheck, ProvideRepoIdentifierCheck, )
WireSet provides a wire set for this package.
Functions ¶
func Description ¶
Description checks the provided description and returns an error if it isn't valid.
func DisplayName ¶
DisplayName checks the provided display name and returns an error if it isn't valid.
func ForControlCharacters ¶
ForControlCharacters ensures that there are no control characters in the provided string.
func Identifier ¶
Identifier checks the provided identifier and returns an error if it isn't valid.
func IsPathTooDeep ¶
IsPathTooDeep Checks if the provided path is too long. NOTE: A repository path can be one deeper than a space path (as otherwise the space would be useless).
func Path ¶
func Path(path string, isSpace bool, identifierCheck SpaceIdentifier) error
Path checks the provided path and returns an error in it isn't valid.
func PrincipalUIDDefault ¶
PrincipalUIDDefault performs the default Principal UID check.
func RepoIdentifierDefault ¶
RepoIdentifierDefault performs the default Identifier check and also blocks illegal repo identifiers.
func ServiceAccountParent ¶
func ServiceAccountParent(parentType enum.ParentResourceType, parentID int64) error
ServiceAccountParent verifies the remaining fields of a service account that aren't inhereted from principal.
func SpaceIdentifierDefault ¶
SpaceIdentifierDefault performs the default Identifier check and also blocks illegal root space Identifiers.
Types ¶
type PrincipalUID ¶
PrincipalUID is an abstraction of a validation method that verifies principal UIDs. NOTE: Enables support for different principal UID formats.
func ProvidePrincipalUIDCheck ¶
func ProvidePrincipalUIDCheck() PrincipalUID
type RepoIdentifier ¶
func ProvideRepoIdentifierCheck ¶
func ProvideRepoIdentifierCheck() RepoIdentifier
type SpaceIdentifier ¶
SpaceIdentifier is an abstraction of a validation method that returns true iff the Identifier is valid to be used in a resource path for repo/space. NOTE: Enables support for different path formats.
func ProvideSpaceIdentifierCheck ¶
func ProvideSpaceIdentifierCheck() SpaceIdentifier
type ValidationError ¶
type ValidationError struct {
// contains filtered or unexported fields
}
ValidationError is error returned for any validation errors. WARNING: This error will be printed to the user as is!
func NewValidationError ¶
func NewValidationError(msg string) *ValidationError
func NewValidationErrorf ¶
func NewValidationErrorf(format string, args ...interface{}) *ValidationError
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
func (*ValidationError) Is ¶
func (e *ValidationError) Is(target error) bool