substitutions

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2025 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// ErrorReasonCodeInvalidReferenceSub is provided when the reason
	// for a blueprint spec load error is due to one or more reference substitutions
	// being invalid.
	ErrorReasonCodeInvalidReferenceSub errors.ErrorReasonCode = "invalid_reference_substitution"
	// ErrorReasonCodeStringOrSubsInvalidType is provided when the reason
	// for a blueprint spec load error is due to a value in a source document
	// that is expected to be a string with 0 or more ${..} substitutions
	// is of a different type.
	ErrorReasonCodeStringOrSubsInvalidType errors.ErrorReasonCode = "invalid_string_or_substitution_type"
)
View Source
const (
	// JSONNodePrecedingCharCount is the number of characters that need to be accounted for
	// when determining the source start meta of a substitution interpoliation in for a string
	// in a JSON with Commas and Comments document.
	JSONNodePrecedingCharCount = 1
)

Variables

View Source
var (
	// IntLiteralPattern is the pattern for an integer
	// that can be used in a substitution.
	// Only decimal representations are supported. (As opposed to hex, octal, etc.)
	IntLiteralPattern = regexp.MustCompile(
		`^-?\d+$`,
	)

	// FloatLiteralPattern is the pattern for a floating point
	// number that can be used in a substitution.
	// Only decimal representations are supported. (As opposed to hex, octal, etc.)
	FloatLiteralPattern = regexp.MustCompile(
		`^-?\d+(\.\d+)?$`,
	)

	// BoolLiteralPattern is the pattern for a boolean
	// that can be used in a substitution.
	BoolLiteralPattern = regexp.MustCompile(
		`^(true|false)$`,
	)
)
View Source
var (
	// NamePattern is the pattern that a name/identifier
	// must match in a substitution.
	NamePattern = regexp.MustCompile(
		`^` + namePattern + `$`,
	)
	// NameStringLiteralPattern is the pattern that a name/identifier
	// must match in a substitution when it is the string literal part
	// of a object key accessor (i.e. key.v1 in "metadata.annotations[\"key.v1\"]").
	NameStringLiteralPattern = regexp.MustCompile(
		`^` + stringLiteralNamePattern + `$`,
	)
	// ResourceReferencePattern is the pattern that a resource
	// reference must match.
	//
	// Some examples that match the resource pattern are:
	// - saveOrderFunction
	//   - This will resolve the field assigned as the ID for the resource.
	// - resources.saveOrderFunction
	// - resources.saveOrderFunction.spec.functionArn
	// - resources.save_order_function.spec.endpoints[].host
	//   - Shorthand that will resolve the host of the first endpoint in the array.
	// - resources.saveOrderFunction.spec.endpoints[0].host
	// - resources.saveOrderFunction.spec.functionName
	// - resources.save-order-function.metadata.custom.apiEndpoint
	// - resources.save-order-function.metadata.displayName
	// - resources.saveOrderFunction.spec.configurations[0][1].concurrency
	// - resources.saveOrderFunction.metadata.annotations["annotationKey.v1"]
	// - resources.saveOrderFunction.spec["stateValue.v1"].value
	// - resources["save-order-function.v1"].spec.functionArn
	// - resources.s3Buckets[].spec.bucketArn
	// - resources.s3Buckets[1].spec.bucketName
	// - resources["s3-buckets.v1"][2]["spec"].bucketName
	//
	// Resources do not have to be referenced with the "resources" prefix,
	// but using the prefix is recommended to avoid ambiguity.
	// All other referenced types must be referenced with the prefix.
	ResourceReferencePattern = regexp.MustCompile(
		`^((resources` + nameAccessorPattern(0) + `)|(?P<NameWithoutNamespace>` + namePattern + `))(\[\d*\])?` +
			`(?P<Path>` + resourcePathPrefixPattern() + nameAccessorPattern(1) +
			`(` + nameAccessorPattern(2) + `|\[\d*\])*))?$`,
	)

	// VariableReferencePattern is the pattern that a variable
	// reference must match.
	//
	// Some examples that match the variable pattern are:
	// - variables.environment
	// - variables.enableFeatureV2
	// - variables.enable_feature_v3
	// - variables.function-name
	// - variables["common.app.v1.name"]
	//
	// Variables must be referenced with the "variables" prefix.
	VariableReferencePattern = regexp.MustCompile(
		`^variables` + nameAccessorPattern(0) + `$`,
	)

	// ValueReferencePattern is the pattern that a value
	// reference must match.
	//
	// Some examples that match the data source pattern are:
	// - values.buckets[].name
	// - values.secretId
	// - values["common.config.v1.name"]
	// - values.clusterConfig.endpoints[].host
	// - values.clusterConfig.nodes[1].endpoint
	//
	// Values must be referenced with the "values" prefix.
	// Values can be primitives, arrays or objects.
	ValueReferencePattern = regexp.MustCompile(
		`^values` + nameAccessorPattern(0) + `(` + nameAccessorPattern(1) + `|\[\d*\])*$`,
	)

	// DataSourceReferencePattern is the pattern that a data source
	// reference must match.
	//
	// Some examples that match the data source pattern are:
	// - datasources.network.vpc
	// - datasources.network.endpoints[]
	//   - Shorthand that will resolve the host of the first endpoint in the array.
	// - datasources.network.endpoints[0]
	// - datasources.core-infra.queueUrl
	// - datasources.coreInfra1.topics[1]
	// - datasources["core-infra.v1"].queueUrl
	// - datasources["coreInfra.v1"]["topic.v2"][0]
	//
	// Data sources must be referenced with the "datasources" prefix.
	// Data source export fields can be primitives or arrays of primitives
	// only, see the specification.
	DataSourceReferencePattern = regexp.MustCompile(
		`^datasources` + nameAccessorPattern(0) +
			`(?P<Path>` + nameAccessorPattern(1) + `(\[\d*\])?)$`,
	)

	// ChildReferencePattern is the pattern that a child blueprint
	// reference must match.
	//
	// Some examples that match the child blueprint pattern are:
	// - children.coreInfrastructure.ordersTopicId
	// - children.coreInfrastructure.cacheNodes[].host
	// - children.core-infrastructure.cacheNodes[0].host
	// - children.topics.orderTopicInfo.type
	// - children.topics.order_topic_info.arn
	// - children.topics.configurations[1]
	// - children.topics.configurations[1][2].messagesPerSecond
	// - children["core-infrastructure.v1"].cacheNodes[].host
	// - children["coreInfrastructure.v1"]["topic.v2"].arn
	//
	// Child blueprints must be referenced with the "children" prefix.
	ChildReferencePattern = regexp.MustCompile(
		`^children` + nameAccessorPattern(0) +
			`(?P<Path>(` + nameAccessorPattern(1) + `|\[\d*\])+)$`,
	)
)
View Source
var (
	// CoreSubstitutionFunctions provides a slice of all the core
	// functions that can be called in a substitution within ${..}.
	// Providers can add their own functions, this list is used as a
	// reference to provide a better user experience in giving prompts
	// to make sure the user is aware when a function is not a core function,
	// so they can check that a provider is correctly configured.
	CoreSubstitutionFunctions = []SubstitutionFunctionName{
		SubstitutionFunctionFromJSON,
		SubstitutionFunctionFromJSON_G,
		SubstitutionFunctionJSONDecode,
		SubstitutionFunctionLen,
		SubstitutionFunctionSubstr,
		SubstitutionFunctionSubstr_G,
		SubstitutionFunctionReplace,
		SubstitutionFunctionReplace_G,
		SubstitutionFunctionTrim,
		SubstitutionFunctionTrimPrefix,
		SubstitutionFunctionTrimPrefix_G,
		SubstitutionFunctionTrimSuffix,
		SubstitutionFunctionTrimSuffix_G,
		SubstitutionFunctionSplit,
		SubstitutionFunctionSplit_G,
		SubstitutionFunctionJoin,
		SubstitutionFunctionIndex,
		SubstitutionFunctionLastIndex,
		SubstitutionFunctionToUpper,
		SubstitutionFunctionToLower,
		SubstitutionFunctionHasPrefix,
		SubstitutionFunctionHasPrefix_G,
		SubstitutionFunctionHasSuffix,
		SubstitutionFunctionHasSuffix_G,
		SubstitutionFunctionContains,
		SubstitutionFunctionContains_G,
		SubstitutionFunctionList,
		SubstitutionFunctionObject,
		SubstitutionFunctionKeys,
		SubstitutionFunctionVals,
		SubstitutionFunctionMap,
		SubstitutionFunctionFilter,
		SubstitutionFunctionReduce,
		SubstitutionFunctionSort,
		SubstitutionFunctionFlatMap,
		SubstitutionFunctionCompose,
		SubstitutionFunctionPipe,
		SubstitutionFunctionGetAttr,
		SubstitutionFunctionGetElem,
		SubstitutionFunctionLink,
		SubstitutionFunctionAnd,
		SubstitutionFunctionOr,
		SubstitutionFunctionNot,
		SubstitutionFunctionEq,
		SubstitutionFunctionGT,
		SubstitutionFunctionGE,
		SubstitutionFunctionLT,
		SubstitutionFunctionLE,
		SubstitutionFunctionCWD,
		SubstitutionFunctionDateTime,
	}
)

Functions

func ContainsSubstitution

func ContainsSubstitution(str string) bool

ContainsSubstitution checks if a string contains a ${..} substitution.

func DetermineJSONSourceStartMeta

func DetermineJSONSourceStartMeta(
	node *json.Node,
	value string,
	linePositions []int,
) *source.Meta

DetermineJSONSourceStartMeta is a utility function that determines the source start meta to use as the accurate starting point for counting lines and columns for interpolated substitutions in JSON with Commas and Comments documents.

func DetermineYAMLSourceStartMeta

func DetermineYAMLSourceStartMeta(node *yaml.Node, sourceMeta *source.Meta) *source.Meta

DetermineYAMLSourceStartMeta is a utility function that determines the source start meta to use as the accurate starting point for counting lines and columns for interpolated substitutions in YAML documents.

For "literal" style blocks, "|\s*\n" must be accounted for. For "folded" style blocks, ">\s*\n" must be accounted for.

func GetYAMLNodePrecedingCharCount

func GetYAMLNodePrecedingCharCount(node *yaml.Node) int

func IsNilStringSubs

func IsNilStringSubs(stringOrSubstitutions *StringOrSubstitutions) bool

IsNilStringSubs checks if the given StringOrSubstitutions is nil or has a nil slice of values.

func PropertyPathToString

func PropertyPathToString(path []*SubstitutionPathItem) (string, error)

PropertyPathToString converts a property path to a string.

func RenderFieldPath

func RenderFieldPath(currentPath, fieldName string) string

RenderFieldPath renders a field path with the given current path and field name.

func SubChildToString

func SubChildToString(child *SubstitutionChild) (string, error)

SubChildToString produces a string representation of a substitution component that refers to a child blueprint export.

func SubElemToString

func SubElemToString(elem *SubstitutionElemReference) (string, error)

SubElemToString produces a string representation of a substitution component that refers to the current element in an input array for a resource template.

func SubResourcePropertyToString

func SubResourcePropertyToString(prop *SubstitutionResourceProperty) (string, error)

SubResourcePropertyToString produces a string representation of a substitution component that refers to a resource property.

func SubstitutionToString

func SubstitutionToString(substitutionContext string, substitution *Substitution) (string, error)

SubstitutionToString converts a representation of a substitution with the ${..} syntax to a string.

func SubstitutionsToString

func SubstitutionsToString(substitutionContext string, substitutions *StringOrSubstitutions) (string, error)

SubstitutionsToString converts a representation of a string as a sequence of string literals and interpolated substitutions to a string.

An example output of this function would be:

"GetOrderFunction-${variables.env}-${variables.version}"

Types

type ColumnAccuracy

type ColumnAccuracy int

ColumnAccuracy is an enum that describes the accuracy of column numbers in a host document that contains reference substitutions. This is used to give a hint to the user as to how accurate the column numbers are likely to be in a host document for diagnostics that will be displayed to a user.

const (
	// ColumnAccuracyExact indicates that column numbers are accurate.
	ColumnAccuracyExact ColumnAccuracy = 1
	// ColumnAccuracyApproximate indicates that column numbers are approximate.
	ColumnAccuracyApproximate ColumnAccuracy = 2
)

type LexError

type LexError struct {
	Line   int
	Column int
	// ColumnAccuracy gives a hint as to how accurate the column numbers
	// are likely to be in a host document that contains reference substitutions.
	ColumnAccuracy ColumnAccuracy
	// contains filtered or unexported fields
}

LexError is an error that is returned during failure to during lexical analysis of a reference substitution.

func (*LexError) Error

func (e *LexError) Error() string

type LexErrors

type LexErrors struct {
	ChildErrors []error
	// contains filtered or unexported fields
}

func (*LexErrors) Error

func (e *LexErrors) Error() string

type ParseError

type ParseError struct {
	Line   int
	Column int
	// ColumnAccuracy gives a hint as to how accurate the column numbers
	// are likely to be in a host document that contains reference substitutions.
	ColumnAccuracy ColumnAccuracy
	// contains filtered or unexported fields
}

ParseError is an error that is returned during failure to parse a reference substitution.

func (*ParseError) Error

func (e *ParseError) Error() string

type ParseErrors

type ParseErrors struct {
	ChildErrors []error
	// contains filtered or unexported fields
}

func (*ParseErrors) Error

func (e *ParseErrors) Error() string

type Parser

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

Parser provides an implementation of a parser for valid substitution strings (i.e. the contents of a ${..} block)

func NewParser

func NewParser(
	tokens []*token,
	parentSourceStart *source.Meta,
	outputLineInfo bool,
	ignoreParentColumn bool,
) *Parser

NewParser creates a new substitution parser.

func (*Parser) Parse

func (p *Parser) Parse() (*Substitution, error)

type ResolvedSubExprType

type ResolvedSubExprType string

ResolvedSubExprType represents a type of a resolved substitution expression defined in a blueprint. Can be one of "string", "integer", "float", "boolean", "array" or "object".

const (
	// ResolvedSubExprTypeString is for a substitution
	// expression that resolves to a string.
	ResolvedSubExprTypeString ResolvedSubExprType = "string"
	// ResolvedSubExprTypeInteger is for a substitution
	// expression that resolves to an integer.
	ResolvedSubExprTypeInteger ResolvedSubExprType = "integer"
	// ResolvedSubExprTypeFloat is for a substitution
	// expression that resolves to a float.
	ResolvedSubExprTypeFloat ResolvedSubExprType = "float"
	// ResolvedSubExprTypeBoolean is for a substitution
	// expression that resolves to a boolean.
	ResolvedSubExprTypeBoolean ResolvedSubExprType = "boolean"
	// ResolvedSubExprTypeArray is for a substitution
	// expression that resolves to an array.
	ResolvedSubExprTypeArray ResolvedSubExprType = "array"
	// ResolvedSubExprTypeObject is for a substitution
	// expression that resolves to an object.
	ResolvedSubExprTypeObject ResolvedSubExprType = "object"
	// ResolvedSubExprTypeFunction is for a substitution
	// expression that resolves to a function.
	ResolvedSubExprTypeFunction ResolvedSubExprType = "function"
	// ResolvedSubExprTypeAny is for a substitution
	// expression that resolves to any type.
	ResolvedSubExprTypeAny ResolvedSubExprType = "any"
)

type StringOrSubstitution

type StringOrSubstitution struct {
	StringValue       *string
	SubstitutionValue *Substitution
	SourceMeta        *source.Meta
}

StringOrSubstitution represents a value that can be either a string or a substitution represented as ${..} from user input.

func ParseSubstitutionValues

func ParseSubstitutionValues(
	substitutionContext, value string,
	parentSourceMeta *source.Meta,
	outputLineInfo bool,
	ignoreParentColumn bool,
	parentContextPrecedingCharCount int,
) ([]*StringOrSubstitution, error)

ParseSubstitutionValues parses a string that can contain interpolated references.

type StringOrSubstitutions

type StringOrSubstitutions struct {
	Values []*StringOrSubstitution
	// SourceMeta is the source metadata for the string or substitutions,
	// this is optional and may or may not be set depending on the context
	// and the source blueprint.
	SourceMeta *source.Meta
}

StringOrSubstitutions represents a value that represents a string interpolated with substitutions.

func (*StringOrSubstitutions) FromJSONNode

func (s *StringOrSubstitutions) FromJSONNode(
	node *json.Node,
	linePositions []int,
	parentPath string,
) error

FromJSONNode fufils the interface of the core.JSONNodeExtractable that allows for including location information in the source meta for JSON with Commas and Comments source documents.

func (*StringOrSubstitutions) MarshalJSON

func (v *StringOrSubstitutions) MarshalJSON() ([]byte, error)

MarshalJSON fulfils the json.Marshaler interface to marshal a blueprint string or substitutions value into a string representation.

func (*StringOrSubstitutions) MarshalYAML

func (s *StringOrSubstitutions) MarshalYAML() (any, error)

MarshalYAML fulfils the yaml.Marshaler interface to marshal a blueprint string or substitutions value into a string representation.

func (*StringOrSubstitutions) UnmarshalJSON

func (s *StringOrSubstitutions) UnmarshalJSON(data []byte) error

UnmarshalJSON fulfils the json.Unmarshaler interface to unmarshal a string that could contain interpolated references.

func (*StringOrSubstitutions) UnmarshalYAML

func (s *StringOrSubstitutions) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML fulfils the yaml.Unmarshaler interface to unmarshal a string that could contain interpolated references.

type Substitution

type Substitution struct {
	Function           *SubstitutionFunctionExpr
	Variable           *SubstitutionVariable
	ValueReference     *SubstitutionValueReference
	ElemReference      *SubstitutionElemReference
	ElemIndexReference *SubstitutionElemIndexReference
	DataSourceProperty *SubstitutionDataSourceProperty
	ResourceProperty   *SubstitutionResourceProperty
	Child              *SubstitutionChild
	StringValue        *string
	IntValue           *int64
	FloatValue         *float64
	BoolValue          *bool
	SourceMeta         *source.Meta
}

Substitution is a representation of a placeholder provided with the ${..} syntax.

func ParseSubstitution

func ParseSubstitution(
	substitutionContext string,
	substitutionInput string,
	parentSourceStart *source.Meta,
	outputLineInfo bool,
	ignoreParentColumn bool,
) (*Substitution, error)

ParseSubstitution parses a string that represents a substitution that is the contents of an interpolated "${..}" block.

type SubstitutionChild

type SubstitutionChild struct {
	ChildName  string
	Path       []*SubstitutionPathItem
	SourceMeta *source.Meta
}

type SubstitutionDataSourceProperty

type SubstitutionDataSourceProperty struct {
	DataSourceName    string
	FieldName         string
	PrimitiveArrIndex *int64
	SourceMeta        *source.Meta
}

type SubstitutionElemIndexReference

type SubstitutionElemIndexReference struct {
	SourceMeta *source.Meta
}

type SubstitutionElemReference

type SubstitutionElemReference struct {
	Path       []*SubstitutionPathItem
	SourceMeta *source.Meta
}

type SubstitutionFunctionArg

type SubstitutionFunctionArg struct {
	Name       string
	Value      *Substitution
	SourceMeta *source.Meta
}

type SubstitutionFunctionExpr

type SubstitutionFunctionExpr struct {
	FunctionName SubstitutionFunctionName
	Arguments    []*SubstitutionFunctionArg
	// Path for values accessed from the function result
	// when the return value is an array or object.
	Path       []*SubstitutionPathItem
	SourceMeta *source.Meta
}

type SubstitutionFunctionName

type SubstitutionFunctionName string

SubstitutionFunctionName is a type alias reserved for names of functions that can be called in a substitution.

const (
	// SubstitutionFunctionFromJSON is a function that is used to extract values
	// from a serialised JSON string.
	SubstitutionFunctionFromJSON SubstitutionFunctionName = "fromjson"

	// SubstitutionFunctionFromJSON_G is a higher-order function that creates a function
	// that is used to extract values from a serialised JSON string.
	// Example:
	// ${map(variables.cacheClusterConfigDefs, fromjson_g("host"))}
	SubstitutionFunctionFromJSON_G SubstitutionFunctionName = "fromjson_g"

	// SubstitutionFunctionJSONDecode is a function that is used to decode a serialised json string
	// into an array or mapping.
	SubstitutionFunctionJSONDecode SubstitutionFunctionName = "jsondecode"

	// SubstitutionFunctionLen is a function that is used to get the length of a string, array
	// or mapping.
	SubstitutionFunctionLen SubstitutionFunctionName = "len"

	// SubstitutionFunctionSubstr is a function that is used to get a substring of a given string.
	SubstitutionFunctionSubstr SubstitutionFunctionName = "substr"

	// SubstitutionFunctionSubstr_G is a higher-order function that creates a function
	// that is used to get a substring from a given string.
	// Example:
	// ${map(variables.cacheClusterConfig.hosts, substr_g(0, 3))}
	SubstitutionFunctionSubstr_G SubstitutionFunctionName = "substr_g"

	// Replace is a function that is used to replace all occurrences
	// of a given string with another string.
	SubstitutionFunctionReplace SubstitutionFunctionName = "replace"

	// SubstitutionFunctionReplace_G is a higher-order function that creates a function
	// that is used to replace all occurences of a given string with another string.
	// Example:
	// ${map(variables.cacheClusterConfig.hosts, replace_g("http://", "https://"))}
	SubstitutionFunctionReplace_G SubstitutionFunctionName = "replace_g"

	// SubstitutionFunctionTrim is a function that is used to remove all leading and trailing whitespace
	// from a given string.
	SubstitutionFunctionTrim SubstitutionFunctionName = "trim"

	// SubstitutionFunctionTrimPrefix is a function that is used to remove a prefix from a string.
	SubstitutionFunctionTrimPrefix SubstitutionFunctionName = "trimprefix"

	// SubstitutionFunctionTrimPrefix_G is a higher-order function that creates a function
	// that is used to remove a prefix from a string.
	// Example:
	// ${map(variables,cacheClusterConfig.hosts, trimprefix_g("http://"))}
	SubstitutionFunctionTrimPrefix_G SubstitutionFunctionName = "trimprefix_g"

	// SubstitutionFunctionTrimSuffix is a function that is used to remove a suffix from a string.
	SubstitutionFunctionTrimSuffix SubstitutionFunctionName = "trimsuffix"

	// SubstitutionFunctionTrimSuffix_G is a higher-order function that creates a function
	// that is used to remove a suffix from a string.
	// Example:
	// ${map(variables.cacheClusterConfig.hosts, trimsuffix_g("/config"))}
	SubstitutionFunctionTrimSuffix_G SubstitutionFunctionName = "trimsuffix_g"

	// SubstitutionFunctionSplit is a function that is used to split a string
	// into an array of strings based on a delimiter.
	SubstitutionFunctionSplit SubstitutionFunctionName = "split"

	// SubstitutionFunctionSplit_G is a higher-order function that creates a function
	// that is used to split a string into an array of strings based on a delimiter.
	// Example:
	// ${flatmap(variables.cacheClusterConfig.multiClusterHosts, split_g(","))}
	SubstitutionFunctionSplit_G SubstitutionFunctionName = "split_g"

	// SubstitutionFunctionJoin is a function that is used to join an array of strings
	// into a single string with a delimiter.
	SubstitutionFunctionJoin SubstitutionFunctionName = "join"

	// SubstitutionFunctionIndex is a function that is used to get the
	// first index of a substring in a given string.
	SubstitutionFunctionIndex SubstitutionFunctionName = "index"

	// SubstitutionFunctionLastIndex is a function that is used to get the
	// last index of a substring in a given string.
	SubstitutionFunctionLastIndex SubstitutionFunctionName = "last_index"

	// SubstitutionFunctionToUpper is a function that converts all characters
	// of a string to upper case.
	SubstitutionFunctionToUpper SubstitutionFunctionName = "to_upper"

	// SubstitutionFunctionToLower is a function that converts all characters
	// of a string to lower case.
	SubstitutionFunctionToLower SubstitutionFunctionName = "to_lower"

	// SubstitutionFunctionHasPrefix is a function that checks if a string
	// starts with a given substring.
	SubstitutionFunctionHasPrefix SubstitutionFunctionName = "has_prefix"

	// SubstitutionFunctionHasPrefix_G is a higher-order function that creates a function
	// that is used to check if a string starts with a given substring.
	// Example:
	// ${filter(
	// 	variables.cacheClusterConfig.hosts,
	// 	has_prefix_g("http://")
	// )}
	SubstitutionFunctionHasPrefix_G SubstitutionFunctionName = "has_prefix_g"

	// SubstitutionFunctionHasSuffix is a function that checks if a string
	// ends with a given substring.
	SubstitutionFunctionHasSuffix SubstitutionFunctionName = "has_suffix"

	// SubstitutionFunctionHasSuffix_G is a higher-order function that creates a function
	// that is used to check if a string ends with a given substring.
	// Example:
	// ${filter(
	// 	variables.cacheClusterConfig.hosts,
	// 	has_suffix_g("/config")
	// )}
	SubstitutionFunctionHasSuffix_G SubstitutionFunctionName = "has_suffix_g"

	// SubstitutionFunctionContains is a function that checks if a string
	// contains a given substring or an array contains a given element.
	SubstitutionFunctionContains SubstitutionFunctionName = "contains"

	// SubstitutionFunctionContains_G is a higher-order function that creates a function
	// that is used to check if a string contains a given substring
	// or an array contains a given element.
	// Example:
	// ${filter(
	// 	variables.cacheClusterConfig.hosts,
	// 	contains_g("celerityframework.com")
	// )}
	SubstitutionFunctionContains_G SubstitutionFunctionName = "contains_g"

	// SubstitutionFunctionList is a function that creates an array
	// from variadic arguments of the same type.
	SubstitutionFunctionList SubstitutionFunctionName = "list"

	// SubstitutionFunctionObject is a function that creates an object
	// from variadic named arguments.
	SubstitutionFunctionObject SubstitutionFunctionName = "object"

	// SubstitutionFunctionKeys is a function that produces an array of keys
	// from a mapping or attribute names from an object.
	SubstitutionFunctionKeys SubstitutionFunctionName = "keys"

	// SubstitutionFunctionVals is a function that produces an array of values
	// from a mapping.
	SubstitutionFunctionVals SubstitutionFunctionName = "vals"

	// SubstitutionFunctionMap is a function that maps a list of values
	// to a new list of values using a function.
	SubstitutionFunctionMap SubstitutionFunctionName = "map"

	// SubstitutionFunctionFilter is a function that filters a list of values
	// based on a predicate function.
	SubstitutionFunctionFilter SubstitutionFunctionName = "filter"

	// SubstitutionFunctionReduce is a function that reduces a list of values
	// to a single value using a function.
	SubstitutionFunctionReduce SubstitutionFunctionName = "reduce"

	// SubstitutionFunctionSort is a function that sorts a list of values
	// to a single value using a comparison function.
	SubstitutionFunctionSort SubstitutionFunctionName = "sort"

	// SubstitutionFunctionFlatMap is a function that maps a list of values
	// using a function and flattens the result.
	SubstitutionFunctionFlatMap SubstitutionFunctionName = "flatmap"

	// SubstitutionFunctionCompose is a higher-order function that combines
	// N functions into a single function, where the output of one function
	// is passed in as the input of the previous function. The call order of the function
	// is from right to left.
	SubstitutionFunctionCompose SubstitutionFunctionName = "compose"

	// SubstitutionFunctionPipe is a higher-order function that combines
	// N functions into a single function, where the output of one function
	// is passed in as the input of the next function. The call order of the function
	// is from left to right.
	SubstitutionFunctionPipe SubstitutionFunctionName = "pipe"

	// SubstitutionFunctionGetAttr is a higher-order function that returns
	// a function that extracts a named attribute from an object or a mapping.
	// This is useful in situations where you want to map an array of objects to an array
	// of values of a specific attribute such as IDs.
	SubstitutionFunctionGetAttr SubstitutionFunctionName = "getattr"

	// SubstitutionFunctionGetElem is a higher-order function that returns
	// a function that extracts an element from an array.
	// This is useful when you want to map a two-dimensional array to an array
	// of values of a specific element.
	SubstitutionFunctionGetElem SubstitutionFunctionName = "getelem"

	// SubstitutionFunctionLink is a function that is used to retrieve the state
	// of a link between two resources in the current blueprint.
	SubstitutionFunctionLink SubstitutionFunctionName = "link"

	// SubstitutionFunctionAnd is a function that is used to perform a logical AND
	// operation on two boolean values.
	SubstitutionFunctionAnd SubstitutionFunctionName = "and"

	// SubstitutionFunctionOr is a function that is used to perform a logical OR
	// operation on two boolean values.
	SubstitutionFunctionOr SubstitutionFunctionName = "or"

	// SubstitutionFunctionNot is a function that is used to perform a negation
	// on a boolean value.
	SubstitutionFunctionNot SubstitutionFunctionName = "not"

	// SubstitutionFunctionEq is a function that is used to perform an equality
	// comparison on two values.
	SubstitutionFunctionEq SubstitutionFunctionName = "eq"

	// substitutionFunctionGT is a function that is used to perform a greater than
	// comparison on two values.
	SubstitutionFunctionGT SubstitutionFunctionName = "gt"

	// SubstitutionFunctionGE is a function that is used to perform a greater than
	// or equal to comparison on two values.
	SubstitutionFunctionGE SubstitutionFunctionName = "ge"

	// SubstitutionFunctionLT is a function that is used to perform a less than
	// comparison on two values.
	SubstitutionFunctionLT SubstitutionFunctionName = "lt"

	// SubstitutionFunctionLE is a function that is used to perform a less than
	// or equal to comparison on two values.
	SubstitutionFunctionLE SubstitutionFunctionName = "le"

	// SubstituionFunctionCWD is a function that is used to get the current working
	// directory of the user executing or validating a blueprint.
	SubstitutionFunctionCWD SubstitutionFunctionName = "cwd"

	// SubstitutionFunctionDateTime is a function that is used to get the current
	// date and time in a specific format.
	SubstitutionFunctionDateTime SubstitutionFunctionName = "datetime"
)

type SubstitutionPathItem

type SubstitutionPathItem struct {
	FieldName  string
	ArrayIndex *int64
}

type SubstitutionResourceProperty

type SubstitutionResourceProperty struct {
	ResourceName              string
	ResourceEachTemplateIndex *int64
	Path                      []*SubstitutionPathItem
	SourceMeta                *source.Meta
}

type SubstitutionValueReference

type SubstitutionValueReference struct {
	ValueName  string
	Path       []*SubstitutionPathItem
	SourceMeta *source.Meta
}

type SubstitutionVariable

type SubstitutionVariable struct {
	VariableName string
	SourceMeta   *source.Meta
}

Jump to

Keyboard shortcuts

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