configuration

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: May 25, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PredicateTypeEquals    = "equals"
	PredicateTypeNotEquals = "notEquals"
	PredicateTypeMatches   = "matches"
)
View Source
const (
	/*
	 * Basic field types
	 */
	FieldTypeString      = "string"
	FieldTypeText        = "text"
	FieldTypeExpression  = "expression"
	FieldTypeXML         = "xml"
	FieldTypeNumber      = "number"
	FieldTypeBool        = "boolean"
	FieldTypeSelect      = "select"
	FieldTypeMultiSelect = "multi-select"
	FieldTypeList        = "list"
	FieldTypeObject      = "object"
	FieldTypeTime        = "time"
	FieldTypeDate        = "date"
	FieldTypeDateTime    = "datetime"
	FieldTypeTimezone    = "timezone"
	FieldTypeDaysOfWeek  = "days-of-week"
	FieldTypeTimeRange   = "time-range"

	/*
	 * Special field types
	 */
	FieldTypeDayInYear           = "day-in-year"
	FieldTypeCron                = "cron"
	FieldTypeUser                = "user"
	FieldTypeRole                = "role"
	FieldTypeGroup               = "group"
	FieldTypeIntegrationResource = "integration-resource"
	FieldTypeAnyPredicateList    = "any-predicate-list"
	FieldTypeGitRef              = "git-ref"
	FieldTypeSecretKey           = "secret-key"
)

Variables

View Source
var AllPredicateOperators = []FieldOption{
	{
		Label: "Equals",
		Value: PredicateTypeEquals,
	},
	{
		Label: "Not Equals",
		Value: PredicateTypeNotEquals,
	},
	{
		Label: "Matches",
		Value: PredicateTypeMatches,
	},
}
View Source
var ExpressionPlaceholderRegex = regexp.MustCompile(`(?s)\{\{.*?\}\}`)

Functions

func MatchesAnyPredicate

func MatchesAnyPredicate(predicates []Predicate, value string) bool

func MatchesAnyPredicateInList added in v0.22.0

func MatchesAnyPredicateInList(predicates []Predicate, values []string) bool

MatchesAnyPredicateInList returns true if any entry in values satisfies any configured predicate. Equals and notEquals behave like MatchesAnyPredicate; matches uses full-string regex for each value so path filters align with common expectations (substring matches would false-positive on paths).

func ValidateConfiguration

func ValidateConfiguration(fields []Field, config map[string]any) error

Types

type AnyPredicateListTypeOptions

type AnyPredicateListTypeOptions struct {
	Operators []FieldOption `json:"operators"`
}

type DateTimeTypeOptions

type DateTimeTypeOptions struct {
	Format string `json:"format,omitempty"` // Expected format, e.g., "2006-01-02T15:04", "YYYY-MM-DDTHH:MM"
}

* DateTimeTypeOptions specifies format and constraints for datetime fields

type DateTypeOptions

type DateTypeOptions struct {
	Format string `json:"format,omitempty"` // Expected format, e.g., "YYYY-MM-DD", "MM/DD/YYYY"
}

* DateTypeOptions specifies format and constraints for date fields

type ExpressionTypeOptions added in v0.0.43

type ExpressionTypeOptions struct {
	MinLength *int `json:"minLength,omitempty"`
	MaxLength *int `json:"maxLength,omitempty"`
}

type Field

type Field struct {
	/*
	 * Unique name identifier for the field
	 */
	Name string `json:"name"`

	/*
	 * Human-readable label for the field (displayed in forms)
	 */
	Label string `json:"label"`

	/*
	 * Optional placeholder shown in the UI input for this field
	 */
	Placeholder string `json:"placeholder,omitempty"`

	/*
	 * Type of the field. Supported types are defined by FieldType* constants above.
	 */
	Type        string `json:"type"`
	Description string `json:"description"`
	Required    bool   `json:"required"`
	Default     any    `json:"default"`
	Togglable   bool   `json:"togglable"`

	/*
	 * Whether the field is sensitive (e.g., password, API token)
	 */
	Sensitive bool `json:"sensitive"`

	/*
	 * Type-specific options for fields.
	 * The structure depends on the field type.
	 */
	TypeOptions *TypeOptions `json:"typeOptions,omitempty"`

	/*
	 * Used for controlling when the field is visible.
	 * No visibility conditions - always visible.
	 */
	VisibilityConditions []VisibilityCondition `json:"visibilityConditions,omitempty"`

	/*
	 * Used for controlling when the field is required based on other field values.
	 * If specified, the field is only required when these conditions are met.
	 */
	RequiredConditions []RequiredCondition `json:"requiredConditions,omitempty"`
}

type FieldOption

type FieldOption struct {
	Label       string `json:"label"`
	Value       string `json:"value"`
	Description string `json:"description,omitempty"`
}

* FieldOption represents a selectable option for select / multi_select field types

type ListItemDefinition

type ListItemDefinition struct {
	Type   string  `json:"type"`
	Schema []Field `json:"schema,omitempty"`
}

* ListItemDefinition defines the structure of items in an 'list' field

type ListTypeOptions

type ListTypeOptions struct {
	ItemDefinition *ListItemDefinition `json:"itemDefinition"`
	ItemLabel      string              `json:"itemLabel,omitempty"`
	MaxItems       *int                `json:"maxItems,omitempty"`
}

* ListTypeOptions defines the structure of list items

type MultiSelectTypeOptions

type MultiSelectTypeOptions struct {
	Options       []FieldOption `json:"options"`
	UseCheckboxes bool          `json:"useCheckboxes,omitempty"`
}

* MultiSelectTypeOptions specifies options for multi_select fields

type NumberTypeOptions

type NumberTypeOptions struct {
	Min *int `json:"min,omitempty"`
	Max *int `json:"max,omitempty"`
}

* NumberTypeOptions specifies constraints for number fields

type ObjectTypeOptions

type ObjectTypeOptions struct {
	Schema []Field `json:"schema"`
}

* ObjectTypeOptions defines the schema for object fields

type ParameterRef added in v0.7.0

type ParameterRef struct {
	Name      string              `json:"name"`
	Value     *string             `json:"value"`
	ValueFrom *ParameterValueFrom `json:"valueFrom"`
}

type ParameterValueFrom added in v0.7.0

type ParameterValueFrom struct {
	Field string `json:"field"`
}

type Predicate

type Predicate struct {
	Type  string `json:"type"`
	Value string `json:"value"`
}

func (*Predicate) Matches

func (p *Predicate) Matches(value string) bool

Matches implements the default predicate semantics used by MatchesAnyPredicate. For PredicateTypeMatches, regexp.MatchString is used (substring search), which existing trigger configurations may rely on.

type RequiredCondition

type RequiredCondition struct {
	Field  string   `json:"field"`
	Values []string `json:"values"`
}

type ResourceTypeOptions

type ResourceTypeOptions struct {
	Type           string `json:"type"`
	UseNameAsValue bool   `json:"useNameAsValue,omitempty"`

	//
	// If true, render as multi-select instead of single select
	//
	Multi bool `json:"multi,omitempty"`

	//
	// Additional parameters to be sent as query parameters to the /resources endpoint.
	// They can be static or come from values of other fields.
	//
	Parameters []ParameterRef `json:"parameters,omitempty"`
}

* ResourceTypeOptions specifies which resource type to display

type SecretKeyRef added in v0.10.0

type SecretKeyRef struct {
	Secret string `json:"secret" mapstructure:"secret"`
	Key    string `json:"key" mapstructure:"key"`
}

func (SecretKeyRef) IsSet added in v0.10.0

func (r SecretKeyRef) IsSet() bool

type SelectTypeOptions

type SelectTypeOptions struct {
	Options []FieldOption `json:"options"`
}

* SelectTypeOptions specifies options for select fields

type StringTypeOptions added in v0.0.18

type StringTypeOptions struct {
	MinLength *int `json:"minLength,omitempty"`
	MaxLength *int `json:"maxLength,omitempty"`
}

* StringTypeOptions specifies constraints for string fields

type TextTypeOptions added in v0.0.18

type TextTypeOptions struct {
	MinLength *int `json:"minLength,omitempty"`
	MaxLength *int `json:"maxLength,omitempty"`
}

type TimeTypeOptions

type TimeTypeOptions struct {
	Format string `json:"format,omitempty"` // Expected format, e.g., "HH:MM", "HH:MM:SS"
}

* TimeTypeOptions specifies format and constraints for time fields

type TypeOptions

type TypeOptions struct {
	Number           *NumberTypeOptions           `json:"number,omitempty"`
	String           *StringTypeOptions           `json:"string,omitempty"`
	Text             *TextTypeOptions             `json:"text,omitempty"`
	Expression       *ExpressionTypeOptions       `json:"expression,omitempty"`
	Select           *SelectTypeOptions           `json:"select,omitempty"`
	MultiSelect      *MultiSelectTypeOptions      `json:"multiSelect,omitempty"`
	Resource         *ResourceTypeOptions         `json:"resource,omitempty"`
	List             *ListTypeOptions             `json:"list,omitempty"`
	AnyPredicateList *AnyPredicateListTypeOptions `json:"anyPredicateList,omitempty"`
	Object           *ObjectTypeOptions           `json:"object,omitempty"`
	Time             *TimeTypeOptions             `json:"time,omitempty"`
	Date             *DateTypeOptions             `json:"date,omitempty"`
	DateTime         *DateTimeTypeOptions         `json:"dateTime,omitempty"`
}

* TypeOptions contains type-specific configuration for fields.

type VisibilityCondition

type VisibilityCondition struct {
	Field  string   `json:"field"`
	Values []string `json:"values"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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