Documentation ¶
Index ¶
- Variables
- func IsFieldAmongDefaultList(f SchemaField) bool
- func Validate(c Configuration, v *viper.Viper) error
- func WithDefaultValue(value any) fieldOption
- func WithDescription(description string) fieldOption
- func WithHidden(hidden bool) fieldOption
- func WithPersistent(value bool) fieldOption
- func WithRequired(required bool) fieldOption
- func WithShortHand(sh string) fieldOption
- type Configuration
- type ErrConfigurationMissingFields
- type Relationship
- type SchemaField
- func BoolField(name string, optional ...fieldOption) SchemaField
- func EnsureDefaultFieldsExists(originalFields []SchemaField) []SchemaField
- func IntField(name string, optional ...fieldOption) SchemaField
- func StringField(name string, optional ...fieldOption) SchemaField
- func StringSliceField(name string, optional ...fieldOption) SchemaField
- func (s SchemaField) Bool() (bool, error)
- func (s SchemaField) GetDescription() string
- func (s SchemaField) GetName() string
- func (s SchemaField) GetType() reflect.Kind
- func (s SchemaField) Int() (int, error)
- func (s SchemaField) String() (string, error)
- func (s SchemaField) StringSlice() ([]string, error)
- type SchemaFieldRelationship
- func EnsureDefaultRelationships(original []SchemaFieldRelationship) []SchemaFieldRelationship
- func FieldsAtLeastOneUsed(fields ...SchemaField) SchemaFieldRelationship
- func FieldsDependentOn(fields []SchemaField, required []SchemaField) SchemaFieldRelationship
- func FieldsMutuallyExclusive(fields ...SchemaField) SchemaFieldRelationship
- func FieldsRequiredTogether(fields ...SchemaField) SchemaFieldRelationship
Constants ¶
This section is empty.
Variables ¶
var ( ListTicketSchemasField = BoolField("list-ticket-schemas", WithHidden(true), WithDescription("List ticket schemas"), WithPersistent(true)) TicketingField = BoolField("ticketing", WithDescription("This must be set to enable ticketing support"), WithPersistent(true)) )
var DefaultFields = []SchemaField{ createTicketField, bulkCreateTicketField, bulkTicketTemplatePathField, getTicketField, ListTicketSchemasField, provisioningField, TicketingField, c1zTmpDirField, clientIDField, clientSecretField, createAccountEmailField, createAccountLoginField, deleteResourceField, deleteResourceTypeField, eventFeedField, fileField, grantEntitlementField, grantPrincipalField, grantPrincipalTypeField, logFormatField, revokeGrantField, rotateCredentialsField, rotateCredentialsTypeField, ticketIDField, ticketTemplatePathField, logLevelField, skipFullSync, }
DefaultFields list the default fields expected in every single connector.
var DefaultRelationships = []SchemaFieldRelationship{ FieldsRequiredTogether(grantEntitlementField, grantPrincipalField), FieldsRequiredTogether(clientIDField, clientSecretField), FieldsRequiredTogether(createTicketField, ticketTemplatePathField), FieldsRequiredTogether(bulkCreateTicketField, bulkTicketTemplatePathField), FieldsRequiredTogether(getTicketField, ticketIDField), FieldsMutuallyExclusive( grantEntitlementField, revokeGrantField, createAccountLoginField, deleteResourceField, rotateCredentialsField, eventFeedField, createTicketField, getTicketField, ListTicketSchemasField, bulkCreateTicketField, ), FieldsMutuallyExclusive( grantEntitlementField, revokeGrantField, createAccountEmailField, deleteResourceTypeField, rotateCredentialsTypeField, eventFeedField, ListTicketSchemasField, ), }
var WrongValueTypeErr = errors.New("unable to cast any to concrete type")
Functions ¶
func IsFieldAmongDefaultList ¶
func IsFieldAmongDefaultList(f SchemaField) bool
func Validate ¶ added in v0.2.3
func Validate(c Configuration, v *viper.Viper) error
Validate perform validation of field requirement and constraints relationships after the configuration is read. We don't check the following:
- if sets of fields are mutually exclusive and required together at the same time
func WithDefaultValue ¶
func WithDefaultValue(value any) fieldOption
func WithDescription ¶
func WithDescription(description string) fieldOption
func WithHidden ¶
func WithHidden(hidden bool) fieldOption
func WithPersistent ¶ added in v0.2.32
func WithPersistent(value bool) fieldOption
func WithRequired ¶
func WithRequired(required bool) fieldOption
func WithShortHand ¶
func WithShortHand(sh string) fieldOption
Types ¶
type Configuration ¶ added in v0.2.3
type Configuration struct { Fields []SchemaField Constraints []SchemaFieldRelationship }
func NewConfiguration ¶ added in v0.2.3
func NewConfiguration(fields []SchemaField, constraints ...SchemaFieldRelationship) Configuration
type ErrConfigurationMissingFields ¶ added in v0.2.3
type ErrConfigurationMissingFields struct {
// contains filtered or unexported fields
}
func (*ErrConfigurationMissingFields) Error ¶ added in v0.2.3
func (e *ErrConfigurationMissingFields) Error() string
func (*ErrConfigurationMissingFields) Push ¶ added in v0.2.3
func (e *ErrConfigurationMissingFields) Push(err error)
type Relationship ¶
type Relationship int
const ( Invalid Relationship = iota RequiredTogether MutuallyExclusive AtLeastOne Dependents )
type SchemaField ¶
type SchemaField struct { FieldName string FieldType reflect.Kind CLIShortHand string Required bool Hidden bool Persistent bool Description string DefaultValue any }
func BoolField ¶
func BoolField(name string, optional ...fieldOption) SchemaField
func EnsureDefaultFieldsExists ¶
func EnsureDefaultFieldsExists(originalFields []SchemaField) []SchemaField
func IntField ¶
func IntField(name string, optional ...fieldOption) SchemaField
func StringField ¶
func StringField(name string, optional ...fieldOption) SchemaField
func StringSliceField ¶ added in v0.2.13
func StringSliceField(name string, optional ...fieldOption) SchemaField
func (SchemaField) Bool ¶
func (s SchemaField) Bool() (bool, error)
Bool returns the default value as a boolean.
func (SchemaField) GetDescription ¶
func (s SchemaField) GetDescription() string
func (SchemaField) GetName ¶
func (s SchemaField) GetName() string
func (SchemaField) GetType ¶
func (s SchemaField) GetType() reflect.Kind
func (SchemaField) Int ¶
func (s SchemaField) Int() (int, error)
Int returns the default value as a integer.
func (SchemaField) String ¶
func (s SchemaField) String() (string, error)
String returns the default value as a string.
func (SchemaField) StringSlice ¶ added in v0.2.13
func (s SchemaField) StringSlice() ([]string, error)
StringSlice returns the default value as a string array.
type SchemaFieldRelationship ¶
type SchemaFieldRelationship struct { Kind Relationship Fields []SchemaField ExpectedFields []SchemaField }
func EnsureDefaultRelationships ¶
func EnsureDefaultRelationships(original []SchemaFieldRelationship) []SchemaFieldRelationship
func FieldsAtLeastOneUsed ¶ added in v0.2.4
func FieldsAtLeastOneUsed(fields ...SchemaField) SchemaFieldRelationship
FieldsAtLeastOneUsed - the provided fields are valid if and only if at least one field is present.
func FieldsDependentOn ¶ added in v0.2.10
func FieldsDependentOn(fields []SchemaField, required []SchemaField) SchemaFieldRelationship
FieldsDependentOn - the provided fields are valid if and only if every field in `required` are also present.
func FieldsMutuallyExclusive ¶
func FieldsMutuallyExclusive(fields ...SchemaField) SchemaFieldRelationship
FieldsMutuallyExclusive - the provided fields are valid if and only if at most one field is present.
func FieldsRequiredTogether ¶
func FieldsRequiredTogether(fields ...SchemaField) SchemaFieldRelationship
FieldsRequiredTogether - the provided fields are valid if and only if every provided field is present.