subengine

package
v0.57.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 19 Imported by: 4 modules, 8 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// ErrorReasonCodeInvalidResolvedSubValue
	// is provided when the reason for an error
	// during deployment or change staging is due to
	// an substitution value that resolves to an invalid type.
	// For example, a substitution value that resolves to a
	// complex object or array when a type that can be cheaply converted
	// to a string is expected.
	ErrorReasonCodeInvalidResolvedSubValue errors.ErrorReasonCode = "invalid_resolved_sub_value"
	// ErrorReasonCodeInvalidSubstitutionValue
	// is provided when the reason for an error
	// during deployment or change staging is due to
	// an empty substitution value.
	ErrorReasonCodeEmptySubstitution errors.ErrorReasonCode = "empty_substitution"
	// ErrorReasonCodeMissingVariable
	// is provided when the reason for an error
	// during deployment or change staging is due to
	// a missing variable referenced in a substitution.
	ErrorReasonCodeMissingVariable errors.ErrorReasonCode = "missing_variable"
	// ErrorReasonCodeMissingValue
	// is provided when the reason for an error
	// during deployment or change staging is due to
	// a missing value referenced in a substitution.
	ErrorReasonCodeMissingValue errors.ErrorReasonCode = "missing_value"
	// ErrorReasonCodeMissingDataSource
	// is provided when the reason for an error
	// during deployment or change staging is due to
	// a missing data source referenced in a substitution.
	ErrorReasonCodeMissingDataSource errors.ErrorReasonCode = "missing_data_source"
	// ErrorReasonCodeEmptyDataSourceData
	// is provided when the reason for an error
	// during deployment or change staging is due to
	// the result of fetching data from a data source being empty.
	ErrorReasonCodeEmptyDataSourceData errors.ErrorReasonCode = "empty_data_source_data"
	// ErrorReasonCodeMissingDataSourceProp
	// is provided when the reason for an error
	// during deployment or change staging is due to
	// a missing property in the data fetched for a
	// data source referenced in a substitution.
	ErrorReasonCodeMissingDataSourceProp errors.ErrorReasonCode = "missing_data_source_prop"
	// ErrorReasonCodeDataSourcePropNotArray
	// is provided when the reason for an error
	// during deployment or change staging is due to
	// a property in the data fetched for a data source
	// referenced in a substitution not being an array.
	ErrorReasonCodeDataSourcePropNotArray errors.ErrorReasonCode = "data_source_prop_not_array"
	// ErrorReasonCodeDataSourcePropArrayIndexOutOfBounds
	// is provided when the reason for an error
	// during deployment or change staging is due to
	// an index being out of bounds for an array property
	// in the data fetched for a data source referenced in a substitution.
	ErrorReasonCodeDataSourcePropArrayIndexOutOfBounds errors.ErrorReasonCode = "data_source_prop_array_index_out_of_bounds"
	// ErrorReasonCodeResourceNotResolved
	// is provided when the reason for an error
	// during deployment or change staging is due to
	// a resource not being resolved before use.
	ErrorReasonCodeResourceNotResolved errors.ErrorReasonCode = "resource_not_resolved"
	// ErrorReasonCodeResourceEachIndexOutOfBounds
	// is provided when the reason for an error
	// during deployment or change staging is due to
	// an index being out of bounds for a resource template
	// that is being used in a resource definition that is made a template
	// by the use of the `each` property.
	ErrorReasonCodeResourceEachIndexOutOfBounds errors.ErrorReasonCode = "resource_each_index_out_of_bounds"
	// ErrorReasonCodeResourceEachEmpty
	// is provided when the reason for an error
	// during deployment or change staging is due to
	// the `each` property of a resource template yielding an empty list.
	ErrorReasonCodeResourceEachEmpty errors.ErrorReasonCode = "resource_each_empty"
	// ErrorReasonCodeResourceEachInvalidType
	// is provided when the reason for an error
	// during deployment or change staging is due to
	// the `each` property of a resource template yielding a value
	// that is not an array.
	ErrorReasonCodeResourceEachInvalidType errors.ErrorReasonCode = "resource_each_invalid_type"
	// ErrorReasonCodeMissingFunction
	// is provided when the reason for an error
	// during deployment or change staging is due to
	// a missing function in the registry.
	ErrorReasonCodeMissingFunction errors.ErrorReasonCode = "missing_function"
	// ErrorReasonCodeEmptyPositionalFunctionArgument
	// is provided when the reason for an error
	// during deployment or change staging is due to
	// an empty value being provided for a positional argument
	// in a function call.
	ErrorReasonCodeEmptyPositionalFunctionArgument errors.ErrorReasonCode = "empty_positional_function_argument"
	// ErrorReasonCodeEmptyNamedFunctionArgument
	// is provided when the reason for an error
	// during deployment or change staging is due to
	// an empty value being provided for a named argument
	// in a function call.
	ErrorReasonCodeEmptyNamedFunctionArgument errors.ErrorReasonCode = "empty_named_function_argument"
	// ErrorReasonCodeEmptyFunctionOutput
	// is provided when the reason for an error
	// during deployment or change staging is due to
	// a function call returning an empty output.
	ErrorReasonCodeEmptyFunctionOutput errors.ErrorReasonCode = "empty_function_output"
	// ErrorReasonCodeHigherOrderFunctionNotSupported
	// is provided when the reason for an error
	// during deployment or change staging is due to
	// a higher order function being used in a context where
	// it is not supported.
	ErrorReasonCodeHigherOrderFunctionNotSupported errors.ErrorReasonCode = "higher_order_function_not_supported"
	// ErrorReasonCodeResourceMissing
	// is provided when the reason for an error
	// during deployment or change staging is due to
	// a referenced resource not being present in the blueprint.
	ErrorReasonCodeResourceMissing errors.ErrorReasonCode = "resource_missing"
	// ErrorReasonCodeResourceSpecDefinitionMissing
	// is provided when the reason for an error
	// during deployment or change staging is due to
	// a missing spec definition for a resource.
	ErrorReasonCodeResourceSpecDefinitionMissing errors.ErrorReasonCode = "resource_spec_definition_missing"
	// ErrorReasonCodeInvalidResourceSpecDefinition
	// is provided when the reason for an error
	// during deployment or change staging is due to
	// an invalid spec definition for a resource.
	ErrorReasonCodeInvalidResourceSpecDefinition errors.ErrorReasonCode = "invalid_resource_spec_definition"
	// ErrorReasonCodeInvalidResourceSpecProperty
	// is provided when the reason for an error
	// during deployment or change staging is due to
	// an unsupported property being referenced for a resource.
	ErrorReasonCodeInvalidResourceSpecProperty errors.ErrorReasonCode = "invalid_resource_spec_property"
	// ErrorReasonCodeMissingResourceSpecProperty
	// is provided when the reason for an error
	// during deployment or change staging is due to
	// a missing property being referenced for a resource.
	ErrorReasonCodeMissingResourceSpecProperty errors.ErrorReasonCode = "missing_resource_spec_property"
	// ErrorReasonCodeInvalidResourceMetadataProperty
	// is provided when the reason for an error
	// during deployment or change staging is due to
	// an unsupported property being referenced for the metadata
	// of a resource.
	ErrorReasonCodeInvalidResourceMetadataProperty errors.ErrorReasonCode = "invalid_resource_metadata_property"
	// ErrorReasonCodeMissingResourceMetadataProperty
	// is provided when the reason for an error
	// during deployment or change staging is due to
	// a missing property being referenced for the metadata
	// of a resource.
	ErrorReasonCodeMissingResourceMetadataProperty errors.ErrorReasonCode = "missing_resource_metadata_property"
	// ErrorReasonCodeInvalidResourceMetadataNotSet
	// is provided when the reason for an error
	// during deployment or change staging is due to
	// a metadata property being referenced for a resource
	// that does not have any metadata set.
	ErrorReasonCodeInvalidResourceMetadataNotSet errors.ErrorReasonCode = "invalid_resource_metadata_not_set"
	// ErrorReasonCodeEmptyChildPath
	// is provided when the reason for an error
	// during deployment or change staging is due to
	// an empty child export path being provided for a child reference.
	ErrorReasonCodeEmptyChildPath errors.ErrorReasonCode = "empty_child_path"
	// ErrorReasonCodeMissingChildExport
	// is provided when the reason for an error
	// during deployment or change staging is due to
	// a missing export in a child reference.
	ErrorReasonCodeMissingChildExport errors.ErrorReasonCode = "missing_child_export"
	// ErrorReasonCodeMissingChildExportProperty
	// is provided when the reason for an error
	// during deployment or change staging is due to
	// a missing property in the export data for a child reference.
	ErrorReasonCodeMissingChildExportProperty errors.ErrorReasonCode = "missing_child_export_property"
	// ErrorReasonCodeDisallowedElementType
	// is provided when the reason for an error
	// during deployment or change staging is due to
	// a referenced element type not beig a supported dependency for a given property.
	// For example, a resource being used as a dependency for the `each` property
	// of another resource.
	ErrorReasonCodeDisallowedElementType errors.ErrorReasonCode = "disallowed_element_type"
	// ErrorReasonCodeResourceNotTemplate
	// is provided when the reason for an error
	// during deployment or change staging is due to
	// a resource not being a template when a reference to one of
	// "elem" or "i" is used in a substitution.
	ErrorReasonCodeResourceNotTemplate errors.ErrorReasonCode = "resource_not_template"
	// ErrorReasonCodeMissingResourceTemplateInputElements
	// is provided when the reason for an error
	// during deployment or change staging is due to
	// missing input elements for a resource template.
	// This error is expected to be returned when the stage changing process
	// is unable to resolve the list of input elements provided in the `each` property
	// for a resource template.
	ErrorReasonCodeMissingResourceTemplateInputElements errors.ErrorReasonCode = "missing_resource_template_input_elements"
	// ErrorReasonCodeMissingCurrentElementProperty
	// is provided when the reason for an error
	// during deployment or change staging is due to
	// a missing property in the current element reference.
	ErrorReasonCodeMissingCurrentElementProperty errors.ErrorReasonCode = "missing_current_element_property"
)

Variables

This section is empty.

Functions

func GoValueToMappingNode

func GoValueToMappingNode(value any) *core.MappingNode

GoValueToMappingNode converts a Go value to a mapping node to be used in resolving substitutions for values returned by function calls. This uses reflection for the conversion process, reflection is generally slow but is the only way to effectively convert Go values to mapping nodes. There shouldn't be noticeable impact on performance unless very large, complex structures are being converted or a blueprint contains 100s of function calls.

func MappingNodeToGoValue

func MappingNodeToGoValue(node *core.MappingNode) any

MappingNodeToGoValue converts a mapping node to a Go value to be used as arguments for function calls as functions expect Go values as arguments.

func NewFunctionCallContext

func NewFunctionCallContext(
	stack function.Stack,
	registry provider.FunctionRegistry,
	params bpcore.BlueprintParams,
	location *source.Meta,
) provider.FunctionCallContext

NewFunctionCallContext creates a new call context that can be passed into function plugin calls and can be used to generate a function call arguments service that function plugins can call to retrieve arguments from.

Types

type ChildExportFieldInfo

type ChildExportFieldInfo struct {
	Value           *bpcore.MappingNode
	Removed         bool
	ResolveOnDeploy bool
	// Sensitive carries the child's own answer for the export, so that a parent field
	// reading it is marked. A child resolves against its own record, so this is the only
	// thing the parent has to go on.
	Sensitive bool
}

ExportFieldInfo contains information about an exported field from a child blueprint that is used in resolving references to child blueprint exports.

type Registries

type Registries struct {
	FuncRegistry       provider.FunctionRegistry
	ResourceRegistry   resourcehelpers.Registry
	DataSourceRegistry provider.DataSourceRegistry
}

type ResolveDataSourceTargetInfo

type ResolveDataSourceTargetInfo struct {
	ResolveFor        ResolveForStage
	PartiallyResolved *provider.ResolvedDataSource
}

ResolveDataSourceTargetInfo contains information about the target of a substitution that is being resolved in a data source.

type ResolveExportTargetInfo

type ResolveExportTargetInfo struct {
	ResolveFor        ResolveForStage
	PartiallyResolved *ResolvedExport
}

ResolveExportTargetInfo contains information about the target of a substitution that is being resolved in a blueprint export.

type ResolveForStage

type ResolveForStage string

ResolveForStage is an enum that indicates the stage at which a substitution is being resolved for.

const (
	// ResolveForChangeStaging indicates that the substitution is being resolved for staging changes.
	ResolveForChangeStaging ResolveForStage = "change_staging"
	// ResolveForDeployment indicates that the substitution is being resolved for deploying a blueprint.
	ResolveForDeployment ResolveForStage = "deployment"
)

type ResolveInDataSourceResult

type ResolveInDataSourceResult struct {
	ResolvedDataSource *provider.ResolvedDataSource
	ResolveOnDeploy    []string
}

ResolveInDataSourceResult contains a resolved data source and a list of full property paths that must be resolved during deployment.

type ResolveInExportResult

type ResolveInExportResult struct {
	ResolvedExport  *ResolvedExport
	ResolveOnDeploy []string
}

ResolveInExportResult contains a resolved export and a list of full property paths that must be resolved during deployment.

type ResolveInIncludeResult

type ResolveInIncludeResult struct {
	ResolvedInclude *ResolvedInclude
	ResolveOnDeploy []string
	// SensitivePaths holds the property paths a secret reached, including the variables
	// passed down to the child blueprint, and the values and data sources resolved on the way.
	SensitivePaths []string
}

ResolveInIncludeResult contains a resolved include, a list of full property paths that must be resolved during deployment and the property paths a secret reached while resolving.

type ResolveInMappingNodeResult

type ResolveInMappingNodeResult struct {
	ResolvedMappingNode *bpcore.MappingNode
	ResolveOnDeploy     []string
	// SensitivePaths holds the property paths a secret reached, rooted at the element the
	// node was resolved for, so "metadata.auditKey" for blueprint-wide metadata.
	SensitivePaths []string
}

ResolveInMappingNodeResult contains a resolved mapping node, a list of full property paths that must be resolved during deployment and the property paths a secret reached while resolving.

type ResolveInResourceResult

type ResolveInResourceResult struct {
	ResolvedResource *provider.ResolvedResource
	ResolveOnDeploy  []string
	// SensitivePaths holds the property paths a secret reached that are not the resource's
	// own spec. This includes its description, condition and metadata, and the values and data sources
	// resolved on the way. The spec's own paths are on the resolved resource, so that they
	// travel with it.
	SensitivePaths []string
}

ResolveInResourceResult contains a resolved resource, a list of full property paths that must be resolved during deployment and the property paths a secret reached while resolving that the resolved resource does not already carry.

type ResolveInValueResult

type ResolveInValueResult struct {
	ResolvedValue   *ResolvedValue
	ResolveOnDeploy []string
}

ResolveInValueResult contains a resolved value and a list of full property paths that must be resolved during deployment.

type ResolveIncludeTargetInfo

type ResolveIncludeTargetInfo struct {
	ResolveFor        ResolveForStage
	PartiallyResolved *ResolvedInclude
}

ResolveIncludeTargetInfo contains information about the target of a substitution that is being resolved in a child blueprint include.

type ResolveMappingNodeTargetInfo

type ResolveMappingNodeTargetInfo struct {
	ResolveFor        ResolveForStage
	PartiallyResolved *bpcore.MappingNode
}

ResolveMappingNodeTargetInfo contains information about the target of a substitution that is being resolved in a mapping node.

type ResolveResourceTargetInfo

type ResolveResourceTargetInfo struct {
	ResolveFor        ResolveForStage
	PartiallyResolved *provider.ResolvedResource
}

ResolveTargetInfo contains information about the target of a substitution that is being resolved in a resource.

type ResolveResult

type ResolveResult struct {
	Resolved        *bpcore.MappingNode
	ResolveOnDeploy []string
	// SensitivePaths holds the property paths a secret reached, which for a single
	// substitution is the property it was resolved into along with anything resolved on the way.
	SensitivePaths []string
}

ResolveResult contains a resolved mapping node and a list of full property paths that must be resolved during deployment.

type ResolveTargetInfo

type ResolveTargetInfo struct {
	ResolveFor        ResolveForStage
	PartiallyResolved interface{}
}

ResolveTargetInfo contains information about the target of a substitution that is being resolved in a context outside of regular substitution resolution.

type ResolveValueTargetInfo

type ResolveValueTargetInfo struct {
	ResolveFor        ResolveForStage
	PartiallyResolved *ResolvedValue
}

ResolveValueTargetInfo contains information about the target of a substitution that is being resolved in a value.

type ResolvedExport

type ResolvedExport struct {
	Type        *schema.ExportTypeWrapper `json:"type"`
	Field       *core.ScalarValue         `json:"field"`
	Description *core.MappingNode         `json:"description,omitempty"`
}

ResolvedExport provides a version of an export for which all ${..} substitutions have been applied.

type ResolvedInclude

type ResolvedInclude struct {
	Path        *core.MappingNode `json:"path"`
	Variables   *core.MappingNode `json:"variables,omitempty"`
	Metadata    *core.MappingNode `json:"metadata,omitempty"`
	Description *core.MappingNode `json:"description,omitempty"`
}

ResolvedInclude provides a version of a child blueprint include for which all ${..} substitutions have been applied.

This is NOT to be confused with a resolved child blueprint which is the result of resolving a child blueprint include using an implementation of the `includes.ChildResolver` interface.

type ResolvedResourceTemplateInput added in v0.55.0

type ResolvedResourceTemplateInput struct {
	// Items holds one item per resource the template expands into, in the order the `each`
	// expression yielded them.
	Items []*bpcore.MappingNode
	// Sensitive is true when a secret reached the `each` expression, and applies to the
	// whole list. A single expression can mix sources, as `${list(variables.plain,
	// variables.secret)}` does, so this marks more items than the secret reached: the
	// record keys on element property paths and has no notion of an item, so there is
	// nothing finer to record against. Marking too much is the safe direction for a secret.
	//
	// Cached with the items because the expanded resources resolve separately, and an
	// `${elem...}` reference in one of them has nothing else to consult.
	Sensitive bool
}

ResolvedResourceTemplateInput holds the items a resource template expands over, along with whether a secret reached the `each` expression that produced them.

type ResolvedValue

type ResolvedValue struct {
	Type        *schema.ValueTypeWrapper `json:"type"`
	Value       *core.MappingNode        `json:"value"`
	Description *core.MappingNode        `json:"description,omitempty"`
	Secret      *core.ScalarValue        `json:"secret"`
	// SensitivePaths holds the paths within this value that a secret reached, rooted at
	// "value", so "value.password" for a field of an object value.
	//
	// Carried on the value because resolution memoises values. A value that declares nothing
	// but interpolates a secret would otherwise mark only the field whose reference resolved
	// it, with every later reference served from the cache and will allow for leaking secrets
	// used in fields that won't be marked.
	SensitivePaths []string `json:"sensitivePaths,omitempty"`
}

ResolvedValue provides a version of a value for which all ${..} substitutions have been applied.

type SubstitutionResolver

type SubstitutionResolver interface {
	// ResolveInResource resolves substitutions in a resource.
	ResolveInResource(
		ctx context.Context,
		resourceName string,
		resource *schema.Resource,
		resolveTargetInfo *ResolveResourceTargetInfo,
	) (*ResolveInResourceResult, error)
	// ResolveResourceEach resolves the substitution in the `each` property of a resource
	// that is expected to resolve to a list of items that will be mapped to a planned and
	// eventually deployed resource. The result also reports whether a secret reached the
	// `each` expression, which callers must cache with the items so that `${elem...}`
	// references in the expanded resources can be marked.
	ResolveResourceEach(
		ctx context.Context,
		resourceName string,
		resource *schema.Resource,
		resolveFor ResolveForStage,
	) (*ResolvedResourceTemplateInput, error)
	// ResolveInDataSource resolves substitutions in a data source.
	ResolveInDataSource(
		ctx context.Context,
		dataSourceName string,
		dataSource *schema.DataSource,
		resolveTargetInfo *ResolveDataSourceTargetInfo,
	) (*ResolveInDataSourceResult, error)
	// ResolveInMappingNode resolves substitutions in a mapping node, primarily used
	// for the top-level blueprint metadata.
	ResolveInMappingNode(
		ctx context.Context,
		currentElementName string,
		mappingNode *bpcore.MappingNode,
		resolveTargetInfo *ResolveMappingNodeTargetInfo,
	) (*ResolveInMappingNodeResult, error)
	// ResolveInValue resolves substitutions in a value.
	ResolveInValue(
		ctx context.Context,
		valueName string,
		value *schema.Value,
		resolveTargetInfo *ResolveValueTargetInfo,
	) (*ResolveInValueResult, error)
	// ResolveInInclude resolves substitutions in an include.
	ResolveInInclude(
		ctx context.Context,
		includeName string,
		include *schema.Include,
		resolveTargetInfo *ResolveIncludeTargetInfo,
	) (*ResolveInIncludeResult, error)
	// ResolveInExport resolves substitutions in an export.
	ResolveInExport(
		ctx context.Context,
		exportName string,
		export *schema.Export,
		resolveTargetInfo *ResolveExportTargetInfo,
	) (*ResolveInExportResult, error)
	// ResolveSubstitution resolves a substitution value from a string or a substitution
	// in a provided context.
	// This is to be used to resolve values outside the regular substitution resolution context
	// (e.g. resolving a reference to a resource property in an export).
	ResolveSubstitution(
		ctx context.Context,
		value *substitutions.StringOrSubstitution,
		inElementName string,
		inElementProperty string,
		resolveTargetInfo *ResolveTargetInfo,
	) (*ResolveResult, error)
}

SubstitutionResolver is an interface that provides functionality to resolve substitutions in components of a blueprint. Resolving involves taking a parsed representation of a substitution, resolving referenced values and executing functions to produce a final output.

func NewDefaultSubstitutionResolver

func NewDefaultSubstitutionResolver(
	registries *Registries,
	stateContainer state.Container,

	resourceCache *bpcore.Cache[*provider.ResolvedResource],

	resourceTemplateInputElemCache *bpcore.Cache[*ResolvedResourceTemplateInput],

	childExportFieldCache *bpcore.Cache[*ChildExportFieldInfo],
	spec speccore.BlueprintSpec,
	params bpcore.BlueprintParams,
) SubstitutionResolver

NewDefaultSubstitutionResolver creates a new default implementation of a substitution resolver.

Jump to

Keyboard shortcuts

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