api

package
v0.0.0-...-8a73590 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package api implements the data types and messages exchanged by the ConfigHub function executor and its clients, in Go.

Index

Constants

View Source
const (
	// Basic scalar types
	DataTypeNone   = DataType("")
	DataTypeString = DataType("string")
	DataTypeInt    = DataType("int")
	DataTypeBool   = DataType("bool")
	DataTypeEnum   = DataType("enum")

	// Additional Storage types
	DataTypeUUID          = DataType("uuid")
	DataTypeTime          = DataType("time")
	DataTypeStringMap     = DataType("map[string]string")
	DataTypeStringBoolMap = DataType("map[string]bool")
	DataTypeUUIDArray     = DataType("[]uuid")
	DataTypeUUIDStringMap = DataType("map[uuid]string")

	// Structured data types
	DataTypeAttributeValueList   = DataType("AttributeValueList")
	DataTypePatchMap             = DataType("PatchMap")
	DataTypeResourceMutationList = DataType("ResourceMutationList")
	DataTypeResourceList         = DataType("ResourceList")

	// Configuration format types
	DataTypeJSON       = DataType("JSON")
	DataTypeYAML       = DataType("YAML")
	DataTypeProperties = DataType("Properties")
	DataTypeTOML       = DataType("TOML")
	DataTypeINI        = DataType("INI")
	DataTypeEnv        = DataType("Env")
	DataTypeHCL        = DataType("HCL")
	DataTypeCEL        = DataType("CEL")
)
View Source
const (
	OutputTypeValidationResult     = OutputType("ValidationResult")
	OutputTypeValidationResultList = OutputType("ValidationResultList")
	OutputTypeAttributeValueList   = OutputType("AttributeValueList")
	OutputTypeResourceInfoList     = OutputType("ResourceInfoList")
	OutputTypeResourceList         = OutputType("ResourceList")
	OutputTypePatchMap             = OutputType("PatchMap")
	OutputTypeCustomJSON           = OutputType("JSON")
	OutputTypeYAML                 = OutputType("YAML")
	OutputTypeOpaque               = OutputType("Opaque")
	OutputTypeResourceMutationList = OutputType("ResourceMutationList")
)
View Source
const (
	ResourceCategoryInvalid     = ResourceCategory("Invalid")
	ResourceCategoryResource    = ResourceCategory("Resource")
	ResourceCategoryDyanmicData = ResourceCategory("DynamicData")
	ResourceCategoryAppConfig   = ResourceCategory("AppConfig")
)
View Source
const (
	AttributeNameNone                    = AttributeName("")
	AttributeNameGeneral                 = AttributeName("attribute-value")
	AttributeNameNeededValue             = AttributeName("needed-value")
	AttributeNameProvidedValue           = AttributeName("provided-value")
	AttributeNameResourceName            = AttributeName("resource-name")
	AttributeNameContainerName           = AttributeName("container-name")
	AttributeNameContainerImage          = AttributeName("container-image")
	AttributeNameContainerImages         = AttributeName("container-images")
	AttributeNameContainerRepositoryURI  = AttributeName("container-repository-uri")
	AttributeNameContainerImageReference = AttributeName("container-image-reference")
	AttributeNameHostname                = AttributeName("hostname")
	AttributeNameDomain                  = AttributeName("domain")
	AttributeNameSubdomain               = AttributeName("subdomain")
	AttributeNameDetail                  = AttributeName("detail")
	AttributeNameDefaultName             = AttributeName("default-name")
)
View Source
const (
	FunctionTypePathVisitor = FunctionType("PathVisitor")
	FunctionTypeCustom      = FunctionType("Custom")
)
View Source
const (
	EvaluatorTemplate = "template"
	EvaluatorCEL      = "cel"
)
View Source
const AttributeNamePrefixRegexpString = "^[A-Za-z0-9]([\\-_A-Za-z0-9]{0,127})?"

Valid attribute names. By convention we use kabob-case to match cub's convention.

View Source
const (
	EmbeddedAccessorRegexp = "Regexp"
)
View Source
const FunctionNamePrefixRegexpString = "^[A-Za-z0-9]([\\-_A-Za-z0-9]{0,127})?"

Valid function names. By convention we use kabob-case to match cub's convention.

View Source
const MaxConfigDataLength = 64 * 1024 * 1024 // 64MB
View Source
const MaxFilterLength = 8192
View Source
const MaxFunctionErrorMessageLength = 1024
View Source
const MaxFunctionNameLength = 128
View Source
const MaxFunctionNumberOfErrors = 1024
View Source
const MaxFunctionOutputLength = 64 * 1024 * 1024 // 64MB
View Source
const MaxNumFunctionArguments = 32
View Source
const MaxResourceTypeLength = 128
View Source
const (
	ResourceTypeAny = ResourceType("*")
)

Variables

View Source
var (
	ValidationResultTrue  = ValidationResult{Passed: true}
	ValidationResultFalse = ValidationResult{Passed: false}
)
View Source
var (
	LogicalOperatorRegexp = regexp.MustCompile(logicalOperatorRegexpString)

	// Exported Literal patterns
	BooleanLiteralRegexp      = regexp.MustCompile(booleanLiteralRegexpString)
	IntegerLiteralRegexp      = regexp.MustCompile(integerLiteralRegexpString)
	SafeStringCharsOnlyRegexp = regexp.MustCompile("^" + safeStringCharsRegexpString + "$")
	StringLiteralRegexp       = regexp.MustCompile(stringLiteralRegexpString)
)
View Source
var ImportSupportedOperators = []string{"=", "!=", "IN", "NOT IN"}

Import-specific operator support

Functions

func CombineOutputs

func CombineOutputs(
	functionName string,
	instance string,
	newOutputType OutputType,
	outputs map[OutputType]any,
	newOutput any,
	functionInvocationIndex int,
	messages []string,
) (map[OutputType]any, []string)

func DataTypeIsSerializedAsString

func DataTypeIsSerializedAsString(dataType DataType) bool

All types except int and bool are always serialized as strings

func EvaluateExpression

func EvaluateExpression(expr *RelationalExpression, leftValue any, rightValue any, customComparators []CustomStringComparator) (bool, error)

EvaluateExpression evaluates a relational expression against a value of any type Returns (matched, error) where error indicates type conversion failure

func GetLogicalOperator

func GetLogicalOperator(decodedQueryString string) (string, string)

func IsSupportedToolchain

func IsSupportedToolchain(toolchain workerapi.ToolchainType) bool

func NoMutations

func NoMutations(mutations ResourceMutationList) bool

func OffsetMutations

func OffsetMutations(mutations ResourceMutationList, offset int64)

func ParseInClause

func ParseInClause(decodedQueryString string) (string, string, error)

ParseInClause parses an IN clause like "('value1', 'value2', 'value3')" Exported for use by internal packages

func ParseInClauseValues

func ParseInClauseValues(literal string) []string

ParseInClauseValues parses values from IN/NOT IN clauses like "('value1', 'value2')" Exported for use by internal packages

func ParseWhereFilterForImport

func ParseWhereFilterForImport(queryString string) ([]ImportFilter, ImportOptions, error)

ParseWhereFilterForImport parses a where-filter query string into ImportFilters and ImportOptions This is the public API version that can be used in tests and other public packages

func SkipWhitespace

func SkipWhitespace(decodedQueryString string) string

SkipWhitespace skips whitespace characters with optional limit

func SkipWhitespaceWithLimit

func SkipWhitespaceWithLimit(decodedQueryString string, limit int) string

SkipWhitespaceWithLimit skips whitespace characters with a character limit limit of -1 means no limit, 0 means no whitespace allowed, positive values set max chars

func UnmarshalOutput

func UnmarshalOutput(outputBytes []byte, outputType OutputType) (any, error)

func ValidateImportOperator

func ValidateImportOperator(operator string) error

ValidateImportOperator validates that an operator is supported for import queries

Types

type AttributeDetails

type AttributeDetails struct {
	GetterInvocation  *FunctionInvocation  `json:",omitempty"` // used for matching
	SetterInvocations []FunctionInvocation `json:",omitempty"` // used for matching
	Description       string               `json:",omitempty"` // documentation

}

AttributeDetails provides the getter and (potentially multiple) setter functions for the resource attribute, and other information.

type AttributeIdentifier

type AttributeIdentifier struct {
	ResourceInfo
	Path        ResolvedPath `swaggertype:"string"`
	InLiveState bool         `json:",omitempty"`
}

An AttributeIdentifier identifies the resource type and name and resolved path of the resource attribute.

type AttributeInfo

type AttributeInfo struct {
	AttributeIdentifier
	AttributeMetadata
}

AttributeInfo conveys both the identifying information about a resource attribute and its metadata.

type AttributeMetadata

type AttributeMetadata struct {
	AttributeName AttributeName     `json:",omitempty" swaggertype:"string"`
	DataType      DataType          `swaggertype:"string"`
	Info          *AttributeDetails `json:",omitempty"`
}

AttributeMetadata specifies the AttributeName, DataType, and other details, such as corresponding getter and setter functions for the attribute.

type AttributeName

type AttributeName string

AttributeName represents the category name of an attribute used for getter and setter functions, and for matching Provided values to Needed values. There are some well known attribute names that are used across resource/configuration providers, and some that are specific to each provider. The well known ones are specified here. For functions that use the path registry, they identify sets of related resource paths.

func AttributeNameForResourceType

func AttributeNameForResourceType(resourceType ResourceType) AttributeName

type AttributeNameToResourceTypeToPathToVisitorInfoType

type AttributeNameToResourceTypeToPathToVisitorInfoType map[AttributeName]ResourceTypeToPathToVisitorInfoType

AttributeNameToResourceTypeToPathToVisitorInfoType associates paths of resource types with an attribute attribute class for traversal/visitation by functions.

type AttributeValue

type AttributeValue struct {
	AttributeInfo
	Value   any
	Comment string `json:",omitempty"`
	Index   int    // index of the function invocation corresponding to the result
}

AttributeValue provides the value of an attribute in addition to information about the attribute.

type AttributeValueList

type AttributeValueList []AttributeValue

type CustomStringComparator

type CustomStringComparator interface {
	// MatchesPath returns true if this comparator should handle the given path
	MatchesPath(path string) bool
	// Evaluate performs the comparison of a value and literal and returns the result
	Evaluate(expr *RelationalExpression, value string) (bool, error)
}

CustomStringComparator allows injecting custom string comparison logic for specific path patterns

type DataType

type DataType string

DataType represents the data type of a function parameter or configuration attribute. The data type can be a scalar type (string, int, bool), a structured format (JSON, YAML), or a well known structured data type (e.g., AttributeValueList).

func ParseLiteral

func ParseLiteral(decodedQueryString string) (string, string, DataType, error)

type EmbeddedAccessorType

type EmbeddedAccessorType string

EmbeddedAccessorType specifies the type of format the embedded accessor can marshal and unmarshal in order to access embedded attributes.

type FunctionArgument

type FunctionArgument struct {
	ParameterName string `` /* 133-byte string literal not displayed */
	Value         any    `description:"Argument value; must be a Scalar type, currently string, int, or bool"`
	// DataType is not needed here because it's in the function signature
	Evaluator string `json:",omitempty" description:"Evaluate the provided Value with the specified Evaluator; supported values: template, cel"`
}

FunctionArgument specifies the value of an argument in a function invocation and, optionally, its corresponding parameter name. If the parameter name is not specified for any argument, all of the arguments are expected to be passed in the same order as in the parameter list.

type FunctionContext

type FunctionContext struct {
	// ToolchainType is the ToolchainType of the configuration data and function handlers.
	ToolchainType workerapi.ToolchainType

	// UnitDisplayName is the display name of the configuration Unit.
	UnitDisplayName string

	// UnitSlug is the Slug of the configuration Unit.
	UnitSlug string

	// UnitID is the unique id of the configuration Unit.
	UnitID uuid.UUID

	// UnitLabels contains the labels of the configuration Unit.
	UnitLabels map[string]string

	// UnitAnnotations contains the annotations of the configuration Unit.
	UnitAnnotations map[string]string

	// SpaceID is the id of the Space of the configuration Unit.
	SpaceID uuid.UUID

	// SpaceSlug is the Slug of the Space of the configuration Unit.
	SpaceSlug string

	// OrganizationID is the id of the Organization of the configuration Unit.
	OrganizationID uuid.UUID

	// TargetID of the configuration Unit to determine the target where the function is executed.
	// This field is optional.
	TargetID uuid.UUID

	// BridgeWorkerID is the id of the BridgeWorker that executes the function.
	// This field is optional.
	// If not present, the function is executed by the Internal Function Executor.
	BridgeWorkerID uuid.UUID

	// RevisionID is the unique id of the configuration Revision.
	RevisionID uuid.UUID

	// RevisionNum is the current/previous HeadRevisionNum of the configuration Unit.
	RevisionNum int64

	// New is true if the configuration has never been applied (or has been destroyed).
	New bool

	// PreviousContentHash contains the crc32.ChecksumIEEE of the previous copy of the data,
	// for determining whether it has been changed since it was last written.
	PreviousContentHash RevisionHash

	// Usernames of users that have approved this revision of the configuration data.
	ApprovedBy []string
}

The FunctionContext contains metadata about the configuration Unit provided as input to a function invocation sequence.

func (*FunctionContext) InstanceString

func (fc *FunctionContext) InstanceString() string

InstanceString returns a string that uniquely identifies the configuration Unit and, if present, the RevisionID.

type FunctionIDs

type FunctionIDs struct {
	OrganizationID uuid.UUID `description:"ID of the Unit's Organization"`
	SpaceID        uuid.UUID `description:"ID of the Unit's Space"`
	UnitID         uuid.UUID `description:"ID of the Unit the configuration data is associated with"`
	RevisionID     uuid.UUID `description:"ID of the Revision the configuration data is associated with"`
}

FunctionIDs contains the IDs related to a function invocation.

type FunctionInvocation

type FunctionInvocation struct {
	FunctionName string             `description:"Function name"`
	Arguments    []FunctionArgument `description:"Function arguments"`
}

FunctionInvocation specifies the name of the function to invoke and the arguments to pass to the function. The function name must uniquely identify the function within its resource/configuration provider on its executor instance.

type FunctionInvocationList

type FunctionInvocationList []FunctionInvocation

type FunctionInvocationRequest

type FunctionInvocationRequest struct {
	FunctionContext
	ConfigData          []byte                 `swaggertype:"string" format:"byte" description:"Configuration data of the Unit to operate on"`
	LiveState           []byte                 `` /* 169-byte string literal not displayed */
	NumFilters          int                    `description:"Number of validating functions to treat as filters: stop, but don't report errors"`
	StopOnError         bool                   `description:"If true, stop executing functions on the first error"`
	FunctionInvocations FunctionInvocationList `description:"List of functions to invoke and their arguments"`
}

A FunctionInvocationRequest contains the configuration data of a configuration Unit, the function context for that configuration Unit, a sequence of functions to invoke and their arguments, and various options for the invocation.

type FunctionInvocationResponse

type FunctionInvocationResponse struct {
	FunctionIDs
	FunctionInvocationSuccessResponse
	Success       bool     `description:"True if all functions executed successfully"`
	ErrorMessages []string `description:"Error messages from function execution; will be empty if Success is true"`
}

A FunctionInvocationResponse is returned by the function executor in response to a FunctionInvocationRequest. It contains the potentially modified configuration data, any output produced by read-only and/or validation functions, whether the function sequence executed successfully, and any error messages returned. Output of compatible OutputTypes is combined, and otherwise the first output is returned. For instance, multiple AttributeValueLists will be appended together, and multiple ResourceInfoLists will be appended together.

type FunctionInvocationSuccessResponse

type FunctionInvocationSuccessResponse struct {
	ConfigData []byte                `swaggertype:"string" format:"byte" description:"The resulting configuration data, potentially mutated"`
	Outputs    map[OutputType][]byte `description:"Map of output types to their corresponding output data as embedded JSON"`
	Mutations  ResourceMutationList  `description:"List of mutations in the same order as the resources in ConfigData"`
	Mutators   []int                 `description:"List of function invocation indices that resulted in mutations"`
}

FunctionInvocationSuccessResponse contains the data returned from a successful function invocation.

type FunctionOutput

type FunctionOutput struct {
	ResultName  string     `description:"Name of the result in kabob-case"`
	Description string     `description:"Description of the result"`
	OutputType  OutputType `swaggertype:"string" description:"Data type of the JSON embedded in the output"`
}

FunctionOutput specifies the name and description of the result and its OutputType.

type FunctionParameter

type FunctionParameter struct {
	ParameterName string   `description:"Name of the parameter in kabob-case"`
	Description   string   `description:"Description of the parameter"`
	Required      bool     `description:"Whether the parameter is required"`
	DataType      DataType `swaggertype:"string" description:"Data type of the parameter"`
	Example       string   `json:",omitempty" description:"Example value"`
	ValueConstraints
}

FunctionParameter specifies the parameter name, description, required vs optional, data type, and example.

type FunctionSignature

type FunctionSignature struct {
	FunctionName          string              `description:"Name of the function in kabob-case"`
	Parameters            []FunctionParameter `description:"Function parameters, in order"`
	RequiredParameters    int                 `description:"Number of required parameters"`
	VarArgs               bool                `description:"Last parameter may be repeated"`
	OutputInfo            *FunctionOutput     `description:"Output description"`
	Mutating              bool                `description:"May change the configuration data"`
	Validating            bool                `description:"Returns ValidationResult"`
	Hermetic              bool                `description:"Does not call other systems"`
	Idempotent            bool                `description:"Will return the same result if invoked again"`
	Description           string              `description:"Description of the function"`
	FunctionType          FunctionType        `swaggertype:"string" description:"Implementation pattern of the function: PathVisitor or Custom"`
	AttributeName         AttributeName       `json:",omitempty" swaggertype:"string" description:"Attribute corresponding to registered paths, if a path visitor; optional"`
	AffectedResourceTypes []ResourceType      `json:",omitempty" description:"Resource types the function applies to; * if all"`
}

FunctionSignature specifies the parameter names and values, required and optional parameters, OutputType, kind of function (mutating/readonly or validating), and description of the function.

type FunctionType

type FunctionType string

FunctionType represents the function's implementation pattern, if a common pattern. The type is Custom if it doesn't fit a common pattern.

type ImportFilter

type ImportFilter struct {
	// Type specifies the filter type (namespace, label, resource_type, etc.)
	Type string `json:",omitempty"`

	// Operator specifies how to apply the filter (include, exclude, equals, contains, matches)
	Operator string `json:",omitempty"`

	// Values specifies the filter values
	Values []string `json:",omitempty"`
}

ImportFilter

type ImportOptions

type ImportOptions map[string]interface{}

ImportOptions represents extensible import configuration

type MutationInfo

type MutationInfo struct {
	MutationType MutationType `` /* 133-byte string literal not displayed */
	Index        int64        `description:"Function index or sequence number corresponding to the change"`
	Predicate    bool         `description:"Used to decide how to use the mututation"`
	Value        string       `description:"Removed configuration data if MutationType is Delete and otherwise the new data"`
}

type MutationMap

type MutationMap map[ResolvedPath]MutationInfo

type MutationMapEntry

type MutationMapEntry struct {
	Path         ResolvedPath
	MutationInfo *MutationInfo
}

type MutationType

type MutationType string

Mutation Type is the type of mutation performed on the associated configuration element.

const (
	// No mutations at the level.
	MutationTypeNone MutationType = "None"
	// Add new configuration at the level.
	MutationTypeAdd MutationType = "Add"
	// Update part of the configuration at the level.
	MutationTypeUpdate MutationType = "Update"
	// Replace all of the configuration at the level (equivalent of Delete + Add).
	MutationTypeReplace MutationType = "Replace"
	// Delete the configuration at the level.
	MutationTypeDelete MutationType = "Delete"
)

type OutputType

type OutputType string

OutputType represents the type of output produced by a function. It is either a well known structured type (e.g., AttributeValueList), a structured format (JSON), or Opaque (unparsed).

type PatchMap

PatchList is a list of patches applied to specified resources.

type PathToVisitorInfoType

type PathToVisitorInfoType map[UnresolvedPath]*PathVisitorInfo

PathToVisitorInfoType associates attribute metadata with a resource path.

type PathVisitorInfo

type PathVisitorInfo struct {
	Path                   UnresolvedPath            `swaggertype:"string"`                   // unresolved path pattern
	ResolvedPath           ResolvedPath              `json:",omitempty" swaggertype:"string"` // specific resolved path
	AttributeName          AttributeName             `swaggertype:"string"`                   // AttributeName for the path
	DataType               DataType                  `swaggertype:"string"`                   // DataType of the attribute at the path
	Info                   *AttributeDetails         `json:",omitempty"`                      // additional attribute details
	TypeExceptions         map[ResourceType]struct{} `json:",omitempty"`                      // resource types to skip
	EmbeddedAccessorType   EmbeddedAccessorType      `json:",omitempty" swaggertype:"string"` // embedded accessor to use, if any
	EmbeddedAccessorConfig string                    `json:",omitempty"`                      // configuration of the embedded accessor, if any
}

PathVisitorInfo specifies the information needed by a visitor function to traverse the specified attributes within the registered resource types. The type is serializable as JSON for dynamic configuration and discovery.

type RelationalExpression

type RelationalExpression struct {
	Path               string // The path of the left operand, which must be an attribute. During evaluation this is used to trigger custom evaluators.
	Operator           string
	Literal            string
	DataType           DataType
	IsLengthExpression bool // True if this is a LEN(attribute) expression
}

type ResolvedPath

type ResolvedPath string

ResolvedPath represents a concrete specific dot-separated path within a structured document (JSON, YAML document, etc.). Array indices are represented as integers within the path. A Kubernetes example is: "spec.template.spec.containers.0.image".

type Resource

type Resource struct {
	ResourceInfo
	ResourceBody string `json:",omitempty" description:"Full configuration data of the resource"`
}

Resource contains the ResourceName, ResourceType, ResourceCategory, and Body for a configuration Element within a configuration Unit.

type ResourceCategory

type ResourceCategory string

ResourceCategory represents the category of syntactic construct represented. Each configuration toolchain defines its own set of valid resource categories, but there are some common categories, such as Resource and AppConfig.

type ResourceCategoryType

type ResourceCategoryType struct {
	ResourceCategory ResourceCategory
	ResourceType     ResourceType
}

ResourceCategoryType is a tuple containing the ResourceCategory and ResourceType.

type ResourceInfo

type ResourceInfo struct {
	ResourceName             ResourceName     `` /* 324-byte string literal not displayed */
	ResourceNameWithoutScope ResourceName     `` /* 270-byte string literal not displayed */
	ResourceType             ResourceType     `` /* 217-byte string literal not displayed */
	ResourceCategory         ResourceCategory `` /* 247-byte string literal not displayed */
}

ResourceInfo contains the ResourceName, ResourceNameWithoutScope, ResourceType, and ResourceCategory for a configuration Element within a configuration Unit.

type ResourceInfoList

type ResourceInfoList []ResourceInfo

type ResourceList

type ResourceList []Resource

type ResourceMutation

type ResourceMutation struct {
	Resource             ResourceInfo              `description:"Identifiers of the resource to which the mutations correspond"`
	ResourceMutationInfo MutationInfo              `description:"Resource-level mutation information, such as for Add, Delete, or Replace"`
	PathMutationMap      MutationMap               `description:"Path-level mutation information; more deeply nested paths override values represented at higher levels"`
	Aliases              map[ResourceName]struct{} `json:",omitempty" description:"Names (with scopes, if any) used in current and prior revisions of this resource"`
	AliasesWithoutScopes map[ResourceName]struct{} `json:",omitempty" description:"Names without scopes used in current and prior revisions of this resource"`
}

type ResourceMutationList

type ResourceMutationList []ResourceMutation

func AddMutations

func AddMutations(mutations, newMutations ResourceMutationList) ResourceMutationList

AddMutations merges newMutations into (existing) mutations and returns the result.

type ResourceName

type ResourceName string

ResourceName represents a fully qualified resource name of a resource for a specific resource provider.

type ResourcePatch

type ResourcePatch struct {
	Patches yamlpatch.Patch
}

type ResourceType

type ResourceType string

ResourceType represents a fully qualified resource type of a resource provider. Each resource provider defines its own set of valid resource types.

type ResourceTypeAndName

type ResourceTypeAndName string

func ResourceTypeAndNameFromResourceInfo

func ResourceTypeAndNameFromResourceInfo(resourceInfo ResourceInfo) ResourceTypeAndName

TODO: Add ResourceCategory

type ResourceTypeToPathToVisitorInfoType

type ResourceTypeToPathToVisitorInfoType map[ResourceType]PathToVisitorInfoType

ResourceTypeToPathToVisitorInfoType associates attribute path information with applicable resource types.

type RevisionHash

type RevisionHash int32

RevisionHash represents a crc32.ChecksumIEEE of configuration data. In Go, conversion of uint32 to int32 doesn't lose information. The 32 bits are retained. We use int32 because a number of languages and systems don't handle unsigned integers.

func HashConfigData

func HashConfigData(data []byte) RevisionHash

type Scalar

type Scalar interface {
	~string | ~int | ~bool
}

type UnresolvedPath

type UnresolvedPath string

UnresolvedPath represents a dot-separated path pattern within a structured document (JSON, YAML document, etc.). In addition to literal map keys and array indices, the following segment patterns are supported:

  • .?mapKey:parameterName=value. represents an associative match within an array based on the value of the `mapKey` attribute of a child of the array. This is common, for instance, in Kubernetes. It is replaced with the matched array index. The `parameterName` is the name of the getter or setter parameter that corresponds to the segment.

  • .*?mapKey:parameterName. represents a wildcard match within an array or map where the value of the `mapKey` attribute of a child is recorded for the named parameter of the getter or setter for the attribute.

  • .*@:parameterName. represents a wildcard match within a map where the value of the map key for that segment is recorded for the named parameter of the getter or setter for the attribute.

  • .*. represents a wildcard for an array or map without recording any values for getter or setter parameters.

type ValidationResult

type ValidationResult struct {
	Passed           bool               // true if valid, false otherwise
	Index            int                // index of the function invocation corresponding to the result
	Details          []string           `json:",omitempty"` // optional list of failure details
	FailedAttributes AttributeValueList `json:",omitempty"` // optional list of failed attributes; preferred over Details
}

ValidationResult specifies whether a single validation function or sequence of validation functions passed for the given configuration Unit.

type ValidationResultList

type ValidationResultList []ValidationResult

type ValueConstraints

type ValueConstraints struct {
	Regexp     string   `json:",omitempty" description:"Regular expression matching valid values; applies to string parameters"`
	Min        *int     `json:",omitempty" description:"Minimum allowed value; applies to int parameters"`
	Max        *int     `json:",omitempty" description:"Maximum allowed value; applies to int parameters"`
	EnumValues []string `json:",omitempty" description:"List of valid enum values; applies to enum parameters"`
}

ValueConstraints specifies constraints on a parameter's value.

type VisitorRelationalExpression

type VisitorRelationalExpression struct {
	RelationalExpression
	// Fields for split path feature used by function visitors
	VisitorPath string // Left side of .| for visitor
	SubPath     string // Right side of .| for property check
	IsSplitPath bool   // Whether this uses the .|syntax
}

VisitorRelationalExpression extends RelationalExpression with visitor-specific fields

func ParseAndValidateBinaryExpression

func ParseAndValidateBinaryExpression(decodedQueryString string) (string, *VisitorRelationalExpression, error)

func ParseAndValidateWhereFilter

func ParseAndValidateWhereFilter(queryString string) ([]*VisitorRelationalExpression, error)

func ParseAndValidateWhereFilterForImport

func ParseAndValidateWhereFilterForImport(queryString string) ([]*VisitorRelationalExpression, error)

ParseAndValidateWhereFilterForImport parses a where filter specifically for import context

type YAMLPayload

type YAMLPayload struct {
	Payload string
}

Jump to

Keyboard shortcuts

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