Documentation
¶
Index ¶
- Constants
- func GoValueToMappingNode(value interface{}) *core.MappingNode
- func MappingNodeToGoValue(node *core.MappingNode) interface{}
- func NewFunctionCallContext(stack function.Stack, registry provider.FunctionRegistry, ...) provider.FunctionCallContext
- type ChildExportFieldInfo
- type Registries
- type ResolveDataSourceTargetInfo
- type ResolveExportTargetInfo
- type ResolveForStage
- type ResolveInDataSourceResult
- type ResolveInExportResult
- type ResolveInIncludeResult
- type ResolveInMappingNodeResult
- type ResolveInResourceResult
- type ResolveInValueResult
- type ResolveIncludeTargetInfo
- type ResolveMappingNodeTargetInfo
- type ResolveResourceTargetInfo
- type ResolveResult
- type ResolveTargetInfo
- type ResolveValueTargetInfo
- type ResolvedExport
- type ResolvedInclude
- type ResolvedValue
- type SubstitutionResolver
Constants ¶
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 interface{}) *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) interface{}
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
}
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
}
ResolveInIncludeResult contains a resolved include and a list of full property paths that must be resolved during deployment.
type ResolveInMappingNodeResult ¶
type ResolveInMappingNodeResult struct {
ResolvedMappingNode *bpcore.MappingNode
ResolveOnDeploy []string
}
ResolveInMappingNodeResult contains a resolved mapping node and a list of full property paths that must be resolved during deployment.
type ResolveInResourceResult ¶
type ResolveInResourceResult struct {
ResolvedResource *provider.ResolvedResource
ResolveOnDeploy []string
}
ResolveInResourceResult contains a resolved resource and a list of full property paths that must be resolved during deployment.
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
}
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 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"`
}
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.
ResolveResourceEach(
ctx context.Context,
resourceName string,
resource *schema.Resource,
resolveFor ResolveForStage,
) ([]*bpcore.MappingNode, 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[[]*bpcore.MappingNode], childExportFieldCache *bpcore.Cache[*ChildExportFieldInfo], spec speccore.BlueprintSpec, params bpcore.BlueprintParams, ) SubstitutionResolver
NewDefaultSubstitutionResolver creates a new default implementation of a substitution resolver.