field

package
v0.2.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2024 License: Apache-2.0 Imports: 6 Imported by: 27

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ListTicketSchemasField = BoolField("list-ticket-schemas", WithHidden(true), WithDescription("List ticket schemas"))

	TicketingField = BoolField("ticketing", WithDescription("This must be set to enable ticketing support"))
)
View Source
var DefaultFields = []SchemaField{
	createTicketField,
	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.

View Source
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 required fields are mutually exclusive
  • repeated fields (by name) are defined
  • if sets of fields are mutually exclusive and required together at the same time
  • if fields depend on themselves

func WithDefaultValue

func WithDefaultValue(value any) fieldOption

func WithDescription

func WithDescription(description string) fieldOption

func WithHidden

func WithHidden(hidden 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 (*ErrConfigurationMissingFields) Push added in v0.2.3

func (e *ErrConfigurationMissingFields) Push(err error)

type Relationship

type Relationship int
const (
	RequiredTogether Relationship = iota + 1
	MutuallyExclusive
	AtLeastOne
	Dependents
)

type SchemaField

type SchemaField struct {
	FieldName    string
	FieldType    reflect.Kind
	CLIShortHand string
	Required     bool
	Hidden       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

func FieldsDependentOn added in v0.2.10

func FieldsDependentOn(dependent []SchemaField, expected []SchemaField) SchemaFieldRelationship

func FieldsMutuallyExclusive

func FieldsMutuallyExclusive(fields ...SchemaField) SchemaFieldRelationship

func FieldsRequiredTogether

func FieldsRequiredTogether(fields ...SchemaField) SchemaFieldRelationship

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL