field

package
v0.2.73 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2025 License: Apache-2.0 Imports: 14 Imported by: 71

Documentation

Index

Constants

This section is empty.

Variables

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

	TicketingField = BoolField("ticketing", WithDescription("This must be set to enable ticketing support"), WithPersistent(true), WithExportTarget(ExportTargetNone))

	LambdaServerClientIDField = StringField("lambda-client-id", WithRequired(true), WithDescription("The oauth client id to use with the configuration endpoint"),
		WithExportTarget(ExportTargetNone))
	LambdaServerClientSecretField = StringField("lambda-client-secret", WithRequired(true), WithDescription("The oauth client secret to use with the configuration endpoint"),
		WithExportTarget(ExportTargetNone))
)
View Source
var DefaultFields = []SchemaField{
	createTicketField,
	bulkCreateTicketField,
	bulkTicketTemplatePathField,
	getTicketField,
	ListTicketSchemasField,
	provisioningField,
	TicketingField,
	c1zTmpDirField,
	clientIDField,
	clientSecretField,
	createAccountEmailField,
	createAccountLoginField,
	createAccountProfileField,
	deleteResourceField,
	deleteResourceTypeField,
	eventFeedField,
	fileField,
	grantEntitlementField,
	grantPrincipalField,
	grantPrincipalTypeField,
	logFormatField,
	revokeGrantField,
	rotateCredentialsField,
	rotateCredentialsTypeField,
	ticketIDField,
	ticketTemplatePathField,
	logLevelField,
	skipFullSync,
	otelCollectorEndpoint,
}

DefaultFields list the default fields expected in every single connector.

View Source
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,
	),
}
View Source
var LambdaServerRelationships = make([]SchemaFieldRelationship, 0)
View Source
var WrongValueTypeErr = errors.New("unable to cast any to concrete type")

Functions

func GetDefaultValue added in v0.2.68

func GetDefaultValue[T SchemaTypes](s SchemaField) (*T, error)

SchemaField can't be generic over SchemaTypes without breaking backwards compatibility :-/.

func IsFieldAmongDefaultList

func IsFieldAmongDefaultList(f SchemaField) bool

func Validate added in v0.2.3

func Validate(c Configuration, v Configurable) 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 ValidateBoolRules added in v0.2.68

func ValidateBoolRules(r *v1_conf.BoolRules, v bool, name string) error

func ValidateField added in v0.2.68

func ValidateField[T SchemaTypes](s *SchemaField, value T) (bool, error)

Go doesn't allow generic methods on a non-generic struct.

func ValidateIntRules added in v0.2.68

func ValidateIntRules(r *v1_conf.Int64Rules, vInt int, name string) error

func ValidateRepeatedStringRules added in v0.2.68

func ValidateRepeatedStringRules(r *v1_conf.RepeatedStringRules, v []string, name string) error

func ValidateStringRules added in v0.2.68

func ValidateStringRules(r *v1_conf.StringRules, v string, name string) error

func WithBool added in v0.2.68

func WithBool(f boolRuleMaker) fieldOption

func WithDefaultValue

func WithDefaultValue(value any) fieldOption

func WithDescription

func WithDescription(description string) fieldOption

func WithDisplayName added in v0.2.68

func WithDisplayName(displayName string) fieldOption

func WithExportTarget added in v0.2.68

func WithExportTarget(target ExportTarget) fieldOption

func WithHidden

func WithHidden(hidden bool) fieldOption

func WithInt added in v0.2.68

func WithInt(f intRuleMaker) fieldOption

func WithIsSecret added in v0.2.68

func WithIsSecret(value bool) fieldOption

func WithPersistent added in v0.2.32

func WithPersistent(value bool) fieldOption

func WithPlaceholder added in v0.2.68

func WithPlaceholder(value string) fieldOption

func WithRequired

func WithRequired(required bool) fieldOption

func WithRequiredInGUI added in v0.2.68

func WithRequiredInGUI(value bool) fieldOption

func WithShortHand

func WithShortHand(sh string) fieldOption

func WithString added in v0.2.68

func WithString(f stringRuleMaker) fieldOption

func WithStringSlice added in v0.2.68

func WithStringSlice(f stringSliceRuleMaker) fieldOption

func WithStructFieldName added in v0.2.71

func WithStructFieldName(name string) fieldOption

Types

type BoolRuler added in v0.2.68

type BoolRuler struct {
	// contains filtered or unexported fields
}

func NewBoolBuilder added in v0.2.68

func NewBoolBuilder(rules *v1_conf.BoolRules) *BoolRuler

func (*BoolRuler) Eq added in v0.2.68

func (b *BoolRuler) Eq(v bool) *BoolRuler

type Configurable added in v0.2.71

type Configurable interface {
	GetString(key string) string
	GetBool(key string) bool
	GetInt(key string) int
	GetStringSlice(key string) []string
}

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

func (*Configuration) Marshal added in v0.2.68

func (c *Configuration) Marshal() ([]byte, error)

func (*Configuration) MarshalJSON added in v0.2.68

func (c *Configuration) MarshalJSON() ([]byte, error)

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 ExportTarget added in v0.2.68

type ExportTarget string

ExportTarget specifies who sets the flag.

CLI: dev ops invoking the connector, as for service mode, eg flag that specifies a file path on disk
GUI: C1 tenant admin on the Web.  Inclusive of CLI.  eg service user name
Ops: C1 support dashbaord. Inclusive of CLI. eg log level
None: Only currently usable for the default fields.  Those flags are consumed by the Syncer, not the Connector.

ExportTarget is used by both dynamic conf generation and the conf schema exporting logic
const (
	ExportTargetNone    ExportTarget = "none"
	ExportTargetGUI     ExportTarget = "gui"
	ExportTargetOps     ExportTarget = "ops"
	ExportTargetCLIOnly ExportTarget = "cli"
)

type FieldRule added in v0.2.68

type FieldRule struct {
	// contains filtered or unexported fields
}

type IntRuler added in v0.2.68

type IntRuler struct {
	// contains filtered or unexported fields
}

func NewIntBuilder added in v0.2.68

func NewIntBuilder(rules *v1_conf.Int64Rules) *IntRuler

func (*IntRuler) Eq added in v0.2.68

func (b *IntRuler) Eq(value int64) *IntRuler

func (*IntRuler) Gt added in v0.2.68

func (b *IntRuler) Gt(value int64) *IntRuler

func (*IntRuler) Gte added in v0.2.68

func (b *IntRuler) Gte(value int64) *IntRuler

func (*IntRuler) In added in v0.2.68

func (b *IntRuler) In(values []int64) *IntRuler

func (*IntRuler) Lt added in v0.2.68

func (b *IntRuler) Lt(value int64) *IntRuler

func (*IntRuler) Lte added in v0.2.68

func (b *IntRuler) Lte(value int64) *IntRuler

func (*IntRuler) NotIn added in v0.2.68

func (b *IntRuler) NotIn(values []int64) *IntRuler

func (*IntRuler) ValidateEmpty added in v0.2.68

func (b *IntRuler) ValidateEmpty(value bool) *IntRuler

type Relationship

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

type SchemaField

type SchemaField struct {
	FieldName    string
	Required     bool
	DefaultValue any
	Description  string
	ExportTarget ExportTarget
	HelpURL      string

	Variant         Variant
	Rules           FieldRule
	Secret          bool
	StructFieldName string

	// Default fields - syncer side
	SyncerConfig syncerConfig

	// Config acutally ingested on the connector side - auth, regions, etc
	ConnectorConfig connectorConfig
}

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 LambdaServerFields added in v0.2.71

func LambdaServerFields() []SchemaField

func SelectField added in v0.2.68

func SelectField(name string, options []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) GetCLIShortHand added in v0.2.68

func (s SchemaField) GetCLIShortHand() string

func (SchemaField) GetDescription

func (s SchemaField) GetDescription() string

func (SchemaField) GetName

func (s SchemaField) GetName() string

func (SchemaField) IsHidden added in v0.2.68

func (s SchemaField) IsHidden() bool

func (SchemaField) IsPersistent added in v0.2.68

func (s SchemaField) IsPersistent() bool

type SchemaFieldRelationship

type SchemaFieldRelationship struct {
	Kind           Relationship
	Fields         []SchemaField
	ExpectedFields []SchemaField // Not really expected, just another field bag.
}

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.

type SchemaTypes added in v0.2.68

type SchemaTypes interface {
	~string | ~bool | ~int | ~[]string
}

type StringRuler added in v0.2.68

type StringRuler struct {
	// contains filtered or unexported fields
}

func NewStringBuilder added in v0.2.68

func NewStringBuilder(rules *v1_conf.StringRules) *StringRuler

func (*StringRuler) Contains added in v0.2.68

func (b *StringRuler) Contains(value string) *StringRuler

func (*StringRuler) Eq added in v0.2.68

func (b *StringRuler) Eq(value string) *StringRuler

func (*StringRuler) In added in v0.2.68

func (b *StringRuler) In(values []string) *StringRuler

func (*StringRuler) IsAddress added in v0.2.68

func (b *StringRuler) IsAddress() *StringRuler

func (*StringRuler) IsEmail added in v0.2.68

func (b *StringRuler) IsEmail() *StringRuler

func (*StringRuler) IsHostname added in v0.2.68

func (b *StringRuler) IsHostname() *StringRuler

func (*StringRuler) IsIP added in v0.2.68

func (b *StringRuler) IsIP() *StringRuler

func (*StringRuler) IsIpv4 added in v0.2.68

func (b *StringRuler) IsIpv4() *StringRuler

func (*StringRuler) IsIpv6 added in v0.2.68

func (b *StringRuler) IsIpv6() *StringRuler

func (*StringRuler) IsURI added in v0.2.68

func (b *StringRuler) IsURI() *StringRuler

func (*StringRuler) IsUUID added in v0.2.68

func (b *StringRuler) IsUUID() *StringRuler

func (*StringRuler) Len added in v0.2.68

func (b *StringRuler) Len(value uint64) *StringRuler

func (*StringRuler) MaxLen added in v0.2.68

func (b *StringRuler) MaxLen(value uint64) *StringRuler

func (*StringRuler) MinLen added in v0.2.68

func (b *StringRuler) MinLen(value uint64) *StringRuler

func (*StringRuler) NotContains added in v0.2.68

func (b *StringRuler) NotContains(value string) *StringRuler

func (*StringRuler) NotIn added in v0.2.68

func (b *StringRuler) NotIn(values []string) *StringRuler

func (*StringRuler) Pattern added in v0.2.68

func (b *StringRuler) Pattern(value string) *StringRuler

func (*StringRuler) Prefix added in v0.2.68

func (b *StringRuler) Prefix(value string) *StringRuler

func (*StringRuler) Suffix added in v0.2.68

func (b *StringRuler) Suffix(value string) *StringRuler

type StringSliceRuler added in v0.2.68

type StringSliceRuler struct {
	// contains filtered or unexported fields
}

func NewRepeatedStringBuilder added in v0.2.68

func NewRepeatedStringBuilder(rules *v1_conf.RepeatedStringRules) *StringSliceRuler

func (*StringSliceRuler) ItemRules added in v0.2.68

func (b *StringSliceRuler) ItemRules(f func(stringer *StringRuler)) *StringSliceRuler

func (*StringSliceRuler) MaxItems added in v0.2.68

func (b *StringSliceRuler) MaxItems(value uint64) *StringSliceRuler

func (*StringSliceRuler) MinItems added in v0.2.68

func (b *StringSliceRuler) MinItems(value uint64) *StringSliceRuler

func (*StringSliceRuler) Unique added in v0.2.68

func (b *StringSliceRuler) Unique(unique bool) *StringSliceRuler

func (*StringSliceRuler) ValidateEmpty added in v0.2.68

func (b *StringSliceRuler) ValidateEmpty(value bool) *StringSliceRuler

type Variant added in v0.2.68

type Variant string
const (
	StringVariant      Variant = "StringField"
	BoolVariant        Variant = "BoolField"
	IntVariant         Variant = "IntField"
	StringSliceVariant Variant = "StringSliceField"
)

type WebFieldType added in v0.2.68

type WebFieldType string
const (
	Text                    WebFieldType = "TEXT"
	Randomize               WebFieldType = "RANDOMIZE"
	OAuth2                  WebFieldType = "OAUTH2"
	ConnectorDerivedOptions WebFieldType = "CONNECTOR_DERIVED_OPTIONS"
	FileUpload              WebFieldType = "FILE_UPLOAD"
)

type WellKnownStrings added in v0.2.68

type WellKnownStrings string
const (
	WellKnownEmailString    WellKnownStrings = "EMAIL"
	WellKnownHostnameString WellKnownStrings = "HOSTNAME"
	WellKnownIPString       WellKnownStrings = "IP"
	WellKnownIpv4String     WellKnownStrings = "IPv4"
	WellKnownIpv6String     WellKnownStrings = "IPv6"
	WellKnownURIString      WellKnownStrings = "URI"
	WellKnownUUIDString     WellKnownStrings = "UUID"
)

Jump to

Keyboard shortcuts

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