Documentation
¶
Index ¶
- Constants
- Variables
- func AsBadInputError(err error, target **BadInputError) bool
- func AsLinkUpdateIntermediaryResourcesError(err error, target **LinkUpdateIntermediaryResourcesError) bool
- func AsLinkUpdateResourceAError(err error, target **LinkUpdateResourceAError) bool
- func AsLinkUpdateResourceBError(err error, target **LinkUpdateResourceBError) bool
- func AsResourceDeployError(err error, target **ResourceDeployError) bool
- func AsResourceDestroyError(err error, target **ResourceDestroyError) bool
- func AsRetryableError(err error, target **RetryableError) bool
- func CalculateRetryWaitTimeMS(retryPolicy *RetryPolicy, currentRetryAttempt int) int
- func ErrUnknownResourceDefSchemaType(specType ResourceDefinitionsSchemaType, resourceType string) error
- func ExtractProviderFromItemType(itemType string) string
- func IsLinkImplementationNotFoundError(err error) bool
- func IsRetryableError(err error) bool
- type BadInputError
- type Changes
- type Context
- type CustomVariableType
- type CustomVariableTypeGetDescriptionInput
- type CustomVariableTypeGetDescriptionOutput
- type CustomVariableTypeGetExamplesInput
- type CustomVariableTypeGetExamplesOutput
- type CustomVariableTypeGetTypeInput
- type CustomVariableTypeGetTypeOutput
- type CustomVariableTypeOption
- type CustomVariableTypeOptionsInput
- type CustomVariableTypeOptionsOutput
- type CustomVariableTypeRegistry
- type DataSource
- type DataSourceFetchInput
- type DataSourceFetchOutput
- type DataSourceFilterSchema
- type DataSourceFilterSearchValueType
- type DataSourceGetExamplesInput
- type DataSourceGetExamplesOutput
- type DataSourceGetFilterFieldsInput
- type DataSourceGetFilterFieldsOutput
- type DataSourceGetSpecDefinitionInput
- type DataSourceGetSpecDefinitionOutput
- type DataSourceGetTypeDescriptionInput
- type DataSourceGetTypeDescriptionOutput
- type DataSourceGetTypeInput
- type DataSourceGetTypeOutput
- type DataSourceRegistry
- type DataSourceSpecDefinition
- type DataSourceSpecSchema
- type DataSourceSpecSchemaType
- type DataSourceValidateInput
- type DataSourceValidateOutput
- type ErrorFailureReasons
- type FieldChange
- type Function
- type FunctionCallArguments
- type FunctionCallContext
- type FunctionCallInput
- type FunctionCallOutput
- type FunctionGetDefinitionInput
- type FunctionGetDefinitionOutput
- type FunctionRegistry
- type FunctionRuntimeInfo
- type Link
- type LinkAnnotationDefinition
- type LinkChanges
- type LinkContext
- type LinkGetAnnotationDefinitionsInput
- type LinkGetAnnotationDefinitionsOutput
- type LinkGetKindInput
- type LinkGetKindOutput
- type LinkGetPriorityResourceInput
- type LinkGetPriorityResourceOutput
- type LinkGetTypeDescriptionInput
- type LinkGetTypeDescriptionOutput
- type LinkGetTypeInput
- type LinkGetTypeOutput
- type LinkKind
- type LinkPriorityResource
- type LinkRegistry
- type LinkStageChangesInput
- type LinkStageChangesOutput
- type LinkUpdateIntermediaryResourcesError
- type LinkUpdateIntermediaryResourcesInput
- type LinkUpdateIntermediaryResourcesOutput
- type LinkUpdateResourceAError
- type LinkUpdateResourceBError
- type LinkUpdateResourceInput
- type LinkUpdateResourceOutput
- type LinkUpdateType
- type Provider
- type ResolvedDataSource
- type ResolvedDataSourceFieldExport
- type ResolvedDataSourceFilter
- type ResolvedDataSourceFilterSearch
- type ResolvedDataSourceFilters
- type ResolvedDataSourceMetadata
- type ResolvedResource
- type ResolvedResourceCondition
- type ResolvedResourceMetadata
- type Resource
- type ResourceCanLinkToInput
- type ResourceCanLinkToOutput
- type ResourceDefinitionsSchema
- type ResourceDefinitionsSchemaType
- type ResourceDeployError
- type ResourceDeployInput
- type ResourceDeployOutput
- type ResourceDeployService
- type ResourceDeployServiceInput
- type ResourceDestroyError
- type ResourceDestroyInput
- type ResourceGetExamplesInput
- type ResourceGetExamplesOutput
- type ResourceGetExternalStateInput
- type ResourceGetExternalStateOutput
- type ResourceGetSpecDefinitionInput
- type ResourceGetSpecDefinitionOutput
- type ResourceGetTypeDescriptionInput
- type ResourceGetTypeDescriptionOutput
- type ResourceGetTypeInput
- type ResourceGetTypeOutput
- type ResourceHasStabilisedInput
- type ResourceHasStabilisedOutput
- type ResourceInfo
- type ResourceIsCommonTerminalInput
- type ResourceIsCommonTerminalOutput
- type ResourceSpecDefinition
- type ResourceStabilisedDependenciesInput
- type ResourceStabilisedDependenciesOutput
- type ResourceValidateInput
- type ResourceValidateOutput
- type RetryContext
- type RetryPolicy
- type RetryableError
Constants ¶
const ( // ErrorReasonCodeItemTypeProviderNotFound is provided when the // reason for a blueprint spec load error is due to // there being no provider for a specific resource or data source // type. ErrorReasonCodeItemTypeProviderNotFound errors.ErrorReasonCode = "provider_not_found" // ErrorReasonCodeProviderDataSourceTypeNotFound is provided when the // reason for a blueprint spec load error is due to // the data source provider missing an implementation for a // specific data source type. ErrorReasonCodeProviderDataSourceTypeNotFound errors.ErrorReasonCode = "data_source_type_not_found" // ErrorReasonCodeFunctionNotFound is provided when the // reason for a blueprint spec load error is due to // the function not being found in any of the configured providers. ErrorReasonCodeFunctionNotFound errors.ErrorReasonCode = "function_not_found" // ErrorReasonCodeProviderFunctionNotFound is provided when the // reason for a blueprint spec load error is due to // the function not being found in a specific provider. ErrorReasonCodeProviderFunctionNotFound errors.ErrorReasonCode = "provider_function_not_found" // ErrorReasonCodeFunctionAlreadyProvided is provided when the // reason for a blueprint spec load error is due to // the same function being provided by multiple providers. ErrorReasonCodeFunctionAlreadyProvided errors.ErrorReasonCode = "function_already_provided" // ErrorReasonCodeInvalidResourceSpecDefinition is provided when the // reason for a blueprint spec load error is due to // an unknown resource spec schema type being used in the schema definition. ErrorReasonCodeInvalidResourceSpecDefinition errors.ErrorReasonCode = "invalid_resource_spec_def" // ErrorReasonCodeCustomVariableTypeNotFound is provided when the // reason for a blueprint spec load error is due to // the custom variable type not being found in a specific provider. ErrorReasonCodeProviderCustomVariableTypeNotFound errors.ErrorReasonCode = "custom_variable_type_not_found" // ErrorReasonCodeLinkImplementationNotFound is provided when the // reason for a blueprint spec load error is due to // the link implementation not being found for a specific resource type pair. ErrorReasonCodeLinkImplementationNotFound errors.ErrorReasonCode = "link_implementation_not_found" )
Variables ¶
var DefaultRetryPolicy = &RetryPolicy{ MaxRetries: 5, FirstRetryDelay: 2, MaxDelay: 300, BackoffFactor: 2, Jitter: true, }
DefaultRetryPolicy is the default retry policy that can be used when a provider does not provide a custom retry policy.
Functions ¶
func AsBadInputError ¶
func AsBadInputError(err error, target **BadInputError) bool
AsBadInputError returns true if the error is a bad input error and assigns the error to the target.
func AsLinkUpdateIntermediaryResourcesError ¶
func AsLinkUpdateIntermediaryResourcesError( err error, target **LinkUpdateIntermediaryResourcesError, ) bool
AsLinkUpdateIntermediaryResourcesError returns true if the error is a link update intermediary resources error and assigns the error to the target.
func AsLinkUpdateResourceAError ¶
func AsLinkUpdateResourceAError(err error, target **LinkUpdateResourceAError) bool
AsLinkUpdateResourceAError returns true if the error is a link update resource A error and assigns the error to the target.
func AsLinkUpdateResourceBError ¶
func AsLinkUpdateResourceBError(err error, target **LinkUpdateResourceBError) bool
AsLinkUpdateResourceBError returns true if the error is a link update resource B error and assigns the error to the target.
func AsResourceDeployError ¶
func AsResourceDeployError(err error, target **ResourceDeployError) bool
AsResourceDeployError returns true if the error is a resource deploy error and assigns the error to the target.
func AsResourceDestroyError ¶
func AsResourceDestroyError(err error, target **ResourceDestroyError) bool
AsResourceDestroyError returns true if the error is a resource destroy error and assigns the error to the target.
func AsRetryableError ¶
func AsRetryableError(err error, target **RetryableError) bool
AsRetryableError returns true if the error is a retryable error. Whether or not there will be another retry depends on the retry policy configured for the provider or globally. This will assign the error to the target.
func CalculateRetryWaitTimeMS ¶
func CalculateRetryWaitTimeMS( retryPolicy *RetryPolicy, currentRetryAttempt int, ) int
CalculateRetryWaitTimeMS calculates the wait time in milliseconds between retries based on a provided retry policy and current retry attempt.
func ErrUnknownResourceDefSchemaType ¶
func ErrUnknownResourceDefSchemaType( specType ResourceDefinitionsSchemaType, resourceType string, ) error
ErrUnknownResourceDefSchemaType is returned when the schema definition for a resource type contains an unknown resource definition schema type.
func ExtractProviderFromItemType ¶
ExtractProviderFromItemType extracts the provider namespace from a resource type or data source type.
func IsLinkImplementationNotFoundError ¶
IsLinkImplementationNotFoundError returns true if an error is for the case when a link implementation is not found in the registered providers.
func IsRetryableError ¶
IsRetryableError returns true if the error is a retryable error. Whether or not there will be another retry depends on the retry policy configured for the provider or globally.
Types ¶
type BadInputError ¶
type BadInputError struct {
// The underlying error for that describes the bad input.
ChildError error
FailureReasons []string
}
BadInputError is an error that indicates an error due to unexpected user input. This is primarily used to allow the framework to distinguish between unexpected errors and errors that are due to user input. This should be used by provider plugin implementations when the error is due to user input that can not be recovered from, applications built on top of the blueprint framework should ensure that this distinction is relayed to the user in a meaningful way.
func (*BadInputError) Error ¶
func (e *BadInputError) Error() string
func (*BadInputError) GetFailureReasons ¶
func (e *BadInputError) GetFailureReasons() []string
type Changes ¶
type Changes struct {
// AppliedResourceInfo provides a new version of the spec
// and schema for which variable substitution has been applied
// so the deploy phase has everything it needs to deploy the resource.
AppliedResourceInfo ResourceInfo `json:"appliedResourceInfo"`
MustRecreate bool `json:"mustRecreate"`
ModifiedFields []FieldChange `json:"modifiedFields"`
NewFields []FieldChange `json:"newFields"`
RemovedFields []string `json:"removedFields"`
UnchangedFields []string `json:"unchangedFields"`
// ComputedFields holds a list of field paths that are computed
// at deploy time. This is primarily useful to give fast access to
// information about which fields are computed without having to inspect
// the spec schema in link implementations.
ComputedFields []string `json:"computedFields"`
// FieldChangesKnownOnDeploy holds a list of field names
// for which changes will be known when the host blueprint is deployed.
FieldChangesKnownOnDeploy []string `json:"fieldChangesKnownOnDeploy"`
// ConditionKnownOnDeploy specifies whether the condition
// for the resource will be known when the host blueprint is deployed.
// When a condition makes use of items in the blueprint that are not resolved
// until deployment, whether the resource will be deployed or not
// cannot be known during the change staging phase.
ConditionKnownOnDeploy bool `json:"conditionKnownOnDeploy"`
// NewOutboundLinks holds a mapping of the linked to resource name
// to the link changes representing the new links that will be created.
NewOutboundLinks map[string]LinkChanges `json:"newOutboundLinks"`
// OutboundLinkChanges holds a mapping
// of the linked to resource name to any changes
// that will be made to existing links.
// The key is of the form `{resourceA}::{resoureB}`
OutboundLinkChanges map[string]LinkChanges `json:"outboundLinkChanges"`
// RemovedOutboundLinks holds a list of link identifiers
// that will be removed.
// The form of the link identifier is `{resourceA}::{resoureB}`
RemovedOutboundLinks []string `json:"removedOutboundLinks"`
}
Changes provides a set of modified fields along with a version of the resource schema (includes metadata labels and annotations) and spec that has already had all it's variables substituted.
type Context ¶
type Context interface {
// ProviderConfigVariable retrieves a configuration value that was loaded
// for the current provider.
ProviderConfigVariable(name string) (*core.ScalarValue, bool)
// ProviderConfigVariables retrieves all the configuration values that were loaded
// for the current provider.
// This is useful to export all the configuration values to be sent to plugins
// that are running in a different process.
ProviderConfigVariables() map[string]*core.ScalarValue
// ContextVariable retrieves a context-wide variable
// for the current environment, this differs from values extracted
// from context.Context, as these context variables are specific
// to the components that implement the interfaces of the blueprint library
// and can be shared between processes over a network or similar.
ContextVariable(name string) (*core.ScalarValue, bool)
// ContextVariables retrieves all the context-wide variables
// for the current environment.
// This is useful to export all the context-wide variables to be sent to plugins
// that are running in a different process.
ContextVariables() map[string]*core.ScalarValue
}
Context provides access to information about the current provider and environment that a provider plugin is running in. This is not to be confused with the conventional Go context.Context used for setting deadlines, cancelling requests and storing request-scoped values in a Go program.
func NewProviderContextFromLinkContext ¶
func NewProviderContextFromLinkContext( linkCtx LinkContext, providerNamespace string, ) Context
NewProviderContextFromLinkContext creates a new provider context from a link context for the current environment. This is primarily useful for link plugin implementations that need to manage intermediary resource deployment by hooking into the `ResourceDeployService` to deploy resources registered with the blueprint framework host application.
func NewProviderContextFromParams ¶
func NewProviderContextFromParams( providerNamespace string, blueprintParams core.BlueprintParams, ) Context
NewProviderContextFromParams creates a new provider context from a set of blueprint parameters for the current environment. The provider context will then be passed into provider plugins to allow them to access configuration values and context variables.
type CustomVariableType ¶
type CustomVariableType interface {
// GetType deals with retrieving the namespaced type for a custom variable type.
GetType(ctx context.Context, input *CustomVariableTypeGetTypeInput) (*CustomVariableTypeGetTypeOutput, error)
// GetDescription deals with retrieving the description for a custom variable type in a blueprint spec
// that can be used for documentation and tooling.
// Markdown and plain text formats are supported.
GetDescription(ctx context.Context, input *CustomVariableTypeGetDescriptionInput) (*CustomVariableTypeGetDescriptionOutput, error)
// Options loads a set of fixed possible values available
// for the custom variable type.
// In the returned options, each one is keyed by a label, essentially
// behaving as a runtime enum.
Options(ctx context.Context, input *CustomVariableTypeOptionsInput) (*CustomVariableTypeOptionsOutput, error)
// GetExamples loads a set of examples for how to use the custom
// variable type in a blueprint.
GetExamples(ctx context.Context, input *CustomVariableTypeGetExamplesInput) (*CustomVariableTypeGetExamplesOutput, error)
}
CustomVariableType provides the interface for a custom variable type that provides convenience variable types with a (usually large) fixed set of possible values. A custom variable type should not be used for dynamically sourced values external to a blueprint, data sources exist for that purpose. All custom variable type values must be of the same primitive type.
type CustomVariableTypeGetDescriptionInput ¶
type CustomVariableTypeGetDescriptionInput struct {
ProviderContext Context
}
CustomVariableTypeGetDescriptionInput provides the input required to retrieve a description for a custom variable type.
type CustomVariableTypeGetDescriptionOutput ¶
type CustomVariableTypeGetDescriptionOutput struct {
MarkdownDescription string
PlainTextDescription string
// A short summary of the custom variable type that can be formatted
// in markdown, this is useful for listing custom variable types in documentation.
MarkdownSummary string
// A short summary of the custom variable type in plain text,
// this is useful for listing custom variable types in documentation.
PlainTextSummary string
}
CustomVariableTypeGetDescriptionOutput provides the output from retrieving the description for a custom variable type.
type CustomVariableTypeGetExamplesInput ¶
type CustomVariableTypeGetExamplesInput struct {
ProviderContext Context
}
CustomVariableTypeGetExamplesInput provides the input required to retrieve examples for a custom variable type.
type CustomVariableTypeGetExamplesOutput ¶
type CustomVariableTypeGetExamplesOutput struct {
PlainTextExamples []string
MarkdownExamples []string
}
CustomVariableTypeGetExamplesOutput provides the output from retrieving examples for a custom variable type.
type CustomVariableTypeGetTypeInput ¶
type CustomVariableTypeGetTypeInput struct {
ProviderContext Context
}
CustomVariableTypeGetTypeInput provides the input required to retrieve the namespaced type for a custom variable type.
type CustomVariableTypeGetTypeOutput ¶
type CustomVariableTypeGetTypeOutput struct {
Type string
// A human-readable label for the custom variable type.
Label string
}
CustomVariableTypeGetTypeOutput provides the output from retrieving the namespaced type for a custom variable type.
type CustomVariableTypeOption ¶
type CustomVariableTypeOption struct {
// The value of the option.
Value *core.ScalarValue
// A human-readable label for the option.
Label string
// A human-readable plain text description for the option.
Description string
// A human-readable description for the option
// that can be formatted in markdown.
MarkdownDescription string
}
type CustomVariableTypeOptionsInput ¶
type CustomVariableTypeOptionsInput struct {
ProviderContext Context
}
CustomVariableTypeOptionsInput provides the input required to load the fixed set of possible values for a custom variable type.
type CustomVariableTypeOptionsOutput ¶
type CustomVariableTypeOptionsOutput struct {
Options map[string]*CustomVariableTypeOption
}
CustomVariableTypeOptionsOutput provides the output from loading the fixed set of possible values for a custom variable type.
type CustomVariableTypeRegistry ¶
type CustomVariableTypeRegistry interface {
// GetDescription returns the description of a custom variable type
// in the registry.
GetDescription(
ctx context.Context,
customVariableType string,
input *CustomVariableTypeGetDescriptionInput,
) (*CustomVariableTypeGetDescriptionOutput, error)
// HasCustomVariableType checks if a custom variable type is available in the registry.
HasCustomVariableType(ctx context.Context, customVariableType string) (bool, error)
// ListCustomVariableTypes retrieves a list of all the custom variable types avaiable
// in the registry.
ListCustomVariableTypes(ctx context.Context) ([]string, error)
}
CustomVariableTypeRegistry provides a way to get information about custom variable type plugins across multiple providers.
func NewCustomVariableTypeRegistry ¶
func NewCustomVariableTypeRegistry(providers map[string]Provider) CustomVariableTypeRegistry
NewCustomVariableTypeRegistry creates a new CustomVariableTypeRegistry from a map of providers, matching against providers based on the data source type prefix.
type DataSource ¶
type DataSource interface {
// GetType deals with retrieving the namespaced type for a data source in a blueprint.
GetType(ctx context.Context, input *DataSourceGetTypeInput) (*DataSourceGetTypeOutput, error)
// GetTypeDescription deals with retrieving the description for a data source type in a blueprint spec
// that can be used for documentation and tooling.
// Markdown and plain text formats are supported.
GetTypeDescription(ctx context.Context, input *DataSourceGetTypeDescriptionInput) (*DataSourceGetTypeDescriptionOutput, error)
// CustomValidate provides support for custom validation that goes beyond
// the spec schema validation provided by the data source's spec definition.
CustomValidate(ctx context.Context, input *DataSourceValidateInput) (*DataSourceValidateOutput, error)
// GetSpecDefinition retrieves the spec definition for a data source.
// This definition specifies all the fields that can be exported from a data source
// to be used in a blueprint.
// This is the first line of validation for a data source in a blueprint and is also
// useful for validating references to a data source instance
// in a blueprint and for providing definitions for docs and tooling.
GetSpecDefinition(ctx context.Context, input *DataSourceGetSpecDefinitionInput) (*DataSourceGetSpecDefinitionOutput, error)
// GetFilterFields provides the fields that can be used in a filter for a data source.
GetFilterFields(ctx context.Context, input *DataSourceGetFilterFieldsInput) (*DataSourceGetFilterFieldsOutput, error)
// Fetch deals with loading the data from the upstream data source
// and returning the exported fields defined in the spec.
Fetch(ctx context.Context, input *DataSourceFetchInput) (*DataSourceFetchOutput, error)
// GetExamples deals with retrieving a list examples for a data source type in a blueprint spec
// that can be used for documentation and tooling.
// Markdown and plain text formats are supported.
GetExamples(ctx context.Context, input *DataSourceGetExamplesInput) (*DataSourceGetExamplesOutput, error)
}
DataSource provides the interface for a data source that a provider can contain which provides data that can be used by all other resources in the same spec.
type DataSourceFetchInput ¶
type DataSourceFetchInput struct {
// DataSourceWithResolvedSubs holds a version of a data source for which all ${..}
// substitutions have been applied.
DataSourceWithResolvedSubs *ResolvedDataSource
ProviderContext Context
}
DataSourceFetchInput provides the input required to fetch data from an upstream data source.
type DataSourceFetchOutput ¶
type DataSourceFetchOutput struct {
Data map[string]*core.MappingNode
}
DataSourceFetchOutput provides the output from fetching data from an upstream data source which includes the exported fields defined in the spec.
type DataSourceFilterSchema ¶ added in v0.22.0
type DataSourceFilterSchema struct {
// Type holds the type of the data source filter field.
Type DataSourceFilterSearchValueType
// Description holds a human-readable description for the data source spec
// without any formatting.
Description string
// FormattedDescription holds a human-readable description for the data source spec
// that is formatted with markdown.
FormattedDescription string
// A list of supported operators for the filter field, this will be used
// for validation and documentation to ensure that only operators
// supported by a specific data source filter are used.
SupportedOperators []schema.DataSourceFilterOperator
// A list of other filter fields that this filter field conflicts with.
// For example, when an external resource can have multiple unique identifiers,
// you will usually want to ensure that only one of them is used in a filter
// at a time, so you can specify the conflicting filter fields here.
ConflictsWith []string
}
DataSourceFilterSchema provides a schema that can be used to validate a data source filter field.
type DataSourceFilterSearchValueType ¶ added in v0.22.0
type DataSourceFilterSearchValueType string
DataSourceFilterSearchValueType holds the type of a data source filter search value.
const ( // DataSourceFilterSearchValueTypeString is for a string search value. DataSourceFilterSearchValueTypeString DataSourceFilterSearchValueType = "string" // DataSourceFilterSearchValueTypeInteger is for an integer search value. DataSourceFilterSearchValueTypeInteger DataSourceFilterSearchValueType = "integer" // DataSourceFilterSearchValueTypeFloat is for a float search value. DataSourceFilterSearchValueTypeFloat DataSourceFilterSearchValueType = "float" // DataSourceFilterSearchValueTypeBoolean is for a boolean search value. DataSourceFilterSearchValueTypeBoolean DataSourceFilterSearchValueType = "boolean" )
type DataSourceGetExamplesInput ¶
type DataSourceGetExamplesInput struct {
ProviderContext Context
}
DataSourceGetExamplesInput provides the input data needed for a data source to retrieve examples for a resoudata sourcerce type in a blueprint spec.
type DataSourceGetExamplesOutput ¶
DataSourceGetExamplesOutput provides the output data from retrieving examples for a data source type in a blueprint spec.
type DataSourceGetFilterFieldsInput ¶
type DataSourceGetFilterFieldsInput struct {
ProviderContext Context
}
DataSourceGetFilterFieldsOutput provides the output from retrieving the fields that can be used in a filter for a data source.
type DataSourceGetFilterFieldsOutput ¶
type DataSourceGetFilterFieldsOutput struct {
// A map of filter field names to a definition that includes descriptions
// and a schema for the filter field used for documentation and validation.
FilterFields map[string]*DataSourceFilterSchema
}
DataSourceGetFilterFieldsOutput provides the output from retrieving the fields that can be used in a filter for a data source.
type DataSourceGetSpecDefinitionInput ¶
type DataSourceGetSpecDefinitionInput struct {
ProviderContext Context
}
DataSourceGetSpecDefinitionInput provides the input data needed for a data source to provide a spec definition.
type DataSourceGetSpecDefinitionOutput ¶
type DataSourceGetSpecDefinitionOutput struct {
SpecDefinition *DataSourceSpecDefinition
}
DataSourceGetSpecDefinitionOutput provides the output data from providing a spec definition for a data source.
type DataSourceGetTypeDescriptionInput ¶
type DataSourceGetTypeDescriptionInput struct {
ProviderContext Context
}
DataSourceGetTypeDescriptionInput provides the input data needed for a data source to retrieve a description of the type of a data source in a blueprint spec.
type DataSourceGetTypeDescriptionOutput ¶
type DataSourceGetTypeDescriptionOutput struct {
MarkdownDescription string
PlainTextDescription string
// A short summary of the data source type that can be formatted
// in markdown, this is useful for listing data source types in documentation.
MarkdownSummary string
// A short summary of the data source type in plain text,
// this is useful for listing data source types in documentation.
PlainTextSummary string
}
DataSourceGetTypeDescriptionOutput provides the output data from retrieving a description of the type of a data source in a blueprint spec.
type DataSourceGetTypeInput ¶
type DataSourceGetTypeInput struct {
ProviderContext Context
}
DataSourceGetTypeInput provides the input required to retrieve the namespaced type for a data source in a blueprint.
type DataSourceGetTypeOutput ¶
type DataSourceGetTypeOutput struct {
Type string
// A human-readable label for the data source type.
Label string
}
DataSourceGetTypeOutput provides the output from retrieving the namespaced type for a data source in a blueprint.
type DataSourceRegistry ¶
type DataSourceRegistry interface {
// GetSpecDefinition returns the definition of a data source spec
// in the registry that includes allowed parameters and return types.
GetSpecDefinition(
ctx context.Context,
dataSourceType string,
input *DataSourceGetSpecDefinitionInput,
) (*DataSourceGetSpecDefinitionOutput, error)
// GetFilterFields returns the fields that can be used in a filter for a data source.
GetFilterFields(
ctx context.Context,
dataSourceType string,
input *DataSourceGetFilterFieldsInput,
) (*DataSourceGetFilterFieldsOutput, error)
// GetTypeDescription returns the description of a data source type
// in the registry.
GetTypeDescription(
ctx context.Context,
dataSourceType string,
input *DataSourceGetTypeDescriptionInput,
) (*DataSourceGetTypeDescriptionOutput, error)
// HasDataSourceType checks if a data source type is available in the registry.
HasDataSourceType(ctx context.Context, dataSourceType string) (bool, error)
// ListDataSourceTypes retrieves a list of all the data source types avaiable
// in the registry.
ListDataSourceTypes(ctx context.Context) ([]string, error)
// CustomValidate allows for custom validation of a data source of a given type.
CustomValidate(
ctx context.Context,
dataSourceType string,
input *DataSourceValidateInput,
) (*DataSourceValidateOutput, error)
// Fetch retrieves the data from a data source using the provider
// of the given type.
Fetch(
ctx context.Context,
dataSourceType string,
input *DataSourceFetchInput,
) (*DataSourceFetchOutput, error)
}
DataSourceRegistry provides a way to retrieve data source plugins across multiple providers for tasks such as data source exports validation.
func NewDataSourceRegistry ¶
func NewDataSourceRegistry( providers map[string]Provider, clock core.Clock, logger core.Logger, ) DataSourceRegistry
NewDataSourceRegistry creates a new DataSourceRegistry from a map of providers, matching against providers based on the data source type prefix.
type DataSourceSpecDefinition ¶
type DataSourceSpecDefinition struct {
// Fields holds a mapping of schemas for
// fields that can be exported from a data source.
// Unlike resource specs, data source specs are restricted
// in that they only support primitives or arrays of primitives.
Fields map[string]*DataSourceSpecSchema
}
DataSourceSpecDefinition provides a definition for a data source spec that can be used for validation, docs and tooling.
type DataSourceSpecSchema ¶
type DataSourceSpecSchema struct {
// Type holds the type of the data source spec.
Type DataSourceSpecSchemaType
// Label holds a human-readable label for the data source spec.
Label string
// Description holds a human-readable description for the data source spec
// without any formatting.
Description string
// FormattedDescription holds a human-readable description for the data source spec
// that is formatted with markdown.
FormattedDescription string
// Items holds the schema for the items in a data source spec schema array.
// Items are expected to be of a primitive type, if an array type is provided here,
// an error will occur.
Items *DataSourceSpecSchema
// Nullable specifies whether the data source spec schema can be null.
// This essentially means that the data source implementation can provide
// a null value for the field.
Nullable bool
}
DataSourceSpecSchema provides a schema that can be used to validate a data source spec.
type DataSourceSpecSchemaType ¶
type DataSourceSpecSchemaType string
DataSourceSpecSchemaType holds the type of a data source schema.
const ( // DataSourceSpecTypeString is for a schema string. DataSourceSpecTypeString DataSourceSpecSchemaType = "string" // DataSourceSpecTypeInteger is for a schema integer. DataSourceSpecTypeInteger DataSourceSpecSchemaType = "integer" // DataSourceSpecTypeFloat is for a schema float. DataSourceSpecTypeFloat DataSourceSpecSchemaType = "float" // DataSourceSpecTypeBoolean is for a schema boolean. DataSourceSpecTypeBoolean DataSourceSpecSchemaType = "boolean" // DataSourceSpecTypeArray is for a schema array. DataSourceSpecTypeArray DataSourceSpecSchemaType = "array" )
type DataSourceValidateInput ¶
type DataSourceValidateInput struct {
SchemaDataSource *schema.DataSource
ProviderContext Context
}
DataSourceValidateInput provides the input required to validate a data source definition in a blueprint.
type DataSourceValidateOutput ¶
type DataSourceValidateOutput struct {
Diagnostics []*core.Diagnostic
}
DataSourceValidateOutput provides the output from validating a data source which includes a list of diagnostics that detail issues with the data source.
type ErrorFailureReasons ¶
type ErrorFailureReasons interface {
GetFailureReasons() []string
}
ErrorFailureReasons is an interface that should be implemented by errors that provide a list of failure reasons.
type FieldChange ¶
type FieldChange struct {
FieldPath string `json:"fieldPath"`
PrevValue *core.MappingNode `json:"prevValue"`
NewValue *core.MappingNode `json:"newValue"`
// MustRecreate is a flag that indicates whether the resource or link
// containing the field must be recreated in order to apply the change.
MustRecreate bool `json:"mustRecreate"`
}
FieldChange represents a change in a field value of a resource or link that is used in change staging.
type Function ¶
type Function interface {
// GetDefinition returns the definition of the function
// that includes allowed parameters and return types.
// This would usually be called during initialisation of a provider
// to pre-fetch function definitions and cache them to validate
// the returned values from plugin function calls.
GetDefinition(ctx context.Context, input *FunctionGetDefinitionInput) (*FunctionGetDefinitionOutput, error)
// Call is the function that is called when a function is used in a blueprint.
// Tools built on top of the framework should provide custom error types
// that can be used to distinguish logical function call errors from other
// errors that may occur during a function call.
Call(ctx context.Context, input *FunctionCallInput) (*FunctionCallOutput, error)
}
Function is the interface for an implementation of a function that can be used in a blueprint "${..}" substitution.
type FunctionCallArguments ¶
type FunctionCallArguments interface {
// Get retrieves the argument at the given position.
Get(ctx context.Context, position int) (any, error)
// GetVar writes the argument at the given position to the
// provided target.
GetVar(ctx context.Context, position int, target any) error
// GetMultipleVars writes the arguments to the provided targets
// in the order they were passed to the function.
GetMultipleVars(ctx context.Context, targets ...any) error
// Export captures the arguments for the current context
// as a slice of any that can be serialised and transported
// across process boundaries.
Export(ctx context.Context) ([]any, error)
}
FunctionCallArguments provides a way to fetch the arguments passed to a function call.
type FunctionCallContext ¶
type FunctionCallContext interface {
// Registry retrieves the function registry that can be used to
// call other functions from within a function.
// This would be akin to importing functions from a module
// to be called in a typical programming language.
Registry() FunctionRegistry
// Params retrieves the current context blueprint params
// treated like global data from the perspective of function
// implementations.
Params() core.BlueprintParams
// NewCallArgs creates a new instance of FunctionCallArguments
// to be passed into a function call.
NewCallArgs(args ...any) FunctionCallArguments
// CallStackSnapshot provides a snapshot of the current call stack
// to be used in error messages.
CallStackSnapshot() []*function.Call
// CurrentLocation provides the current location in the blueprint
// where the function is being called.
// This can be used to associate a function call with a specific
// location in the source blueprint, this can and often will yield
// nil in situations where the location is not available.
CurrentLocation() *source.Meta
}
FunctionCallContext provides useful context for functions that allow access to "global" blueprint params and the ability to call other functions loaded into the provider. Functions should not be able to directly access state, values from state should be resolved before calling a function.
type FunctionCallInput ¶
type FunctionCallInput struct {
Arguments FunctionCallArguments
CallContext FunctionCallContext
}
FunctionCallInput provides the input data needed for a substitution function to be called.
type FunctionCallOutput ¶
type FunctionCallOutput struct {
ResponseData any
FunctionInfo FunctionRuntimeInfo
}
FunctionCallOutput provides the output data from a substitution function call.
type FunctionGetDefinitionInput ¶
type FunctionGetDefinitionInput struct {
Params core.BlueprintParams
}
FunctionGetDefinitionInput provides the input data for retrieving the definition of a function.
type FunctionGetDefinitionOutput ¶
type FunctionGetDefinitionOutput struct {
Definition *function.Definition
}
FunctionGetDefinitionOutput provides the output data for retrieving the definition of a function.
type FunctionRegistry ¶
type FunctionRegistry interface {
// ForCallContext creates a light-weight copy of the registry
// with a call stack that is specific to the current call context
// (i.e. a ${..} substitution).
ForCallContext(stack function.Stack) FunctionRegistry
// Call allows calling a function in the registry by name.
Call(ctx context.Context, functionName string, input *FunctionCallInput) (*FunctionCallOutput, error)
// GetDefinition returns the definition of a function
// in the registry that includes allowed parameters and return types.
GetDefinition(
ctx context.Context,
functionName string,
input *FunctionGetDefinitionInput,
) (*FunctionGetDefinitionOutput, error)
// HasFunction checks if a function is available in the registry.
HasFunction(ctx context.Context, functionName string) (bool, error)
// ListFunctions retrieves a list of all the functions avaiable
// in the registry.
ListFunctions(ctx context.Context) ([]string, error)
}
FunctionRegistry provides a way to retrieve function plugins to call from other functions. Instead of returning a function directly, a registry allows calling functions through the registry as a proxy to allow for adding calls to a stack along with other context-specific enhancements that may be needed.
func NewFunctionRegistry ¶
func NewFunctionRegistry( providers map[string]Provider, ) FunctionRegistry
NewFunctionRegistry creates a new FunctionRegistry from a map of providers, matching against providers based on the the list of functions that a provider exposes.
type FunctionRuntimeInfo ¶
type FunctionRuntimeInfo struct {
FunctionName string
PartialArgs []any
// Specify the offset of the arguments in the partial arguments.
// This should be rarely be used, but in the case where the captured
// arguments to be "partially applied" are not the first arguments
// in the function signature, this can be used to specify the offset
// of the arguments in the partial arguments list.
ArgsOffset int
}
FunctionRuntimeInfo provides information about a function to be passed between functions. The blueprint function framework is designed to work across process boundaries so an actual function in memory can not be passed around, Instead, a function runtime info is used, this contains the function name to be called and pre-configured arguments that can be used when the function is eventually called.
Higher-order functions can only use named functions for the return value as the function name is used to look up the function definition and combine the pre-configured arguments with the arguments passed to the function.
type Link ¶
type Link interface {
// StageChanges must detail the changes that will be made when a deployment of the loaded blueprint
// for the link between two resources.
// Unlike resources, links do not map to a specification for a single deployable unit,
// so link implementations must specify the changes that will be made across multiple resources.
StageChanges(
ctx context.Context,
input *LinkStageChangesInput,
) (*LinkStageChangesOutput, error)
// UpdateResourceA deals with applying the changes to the first of the two linked resources
// for the creation or removal of a link between two resources.
// The value of the `LinkData` field returned in the output will be combined
// with the LinkData output from updating resource B and intermediary resources
// to form the final LinkData that will be persisted in the state of the blueprint instance.
// Parameters are passed into UpdateResourceA for extra context, blueprint variables will have already
// been substituted at this stage and must be used instead of the passed in params argument
// to ensure consistency between the staged changes that are reviewed and the deployment itself.
UpdateResourceA(ctx context.Context, input *LinkUpdateResourceInput) (*LinkUpdateResourceOutput, error)
// UpdateResourceB deals with applying the changes to the second of the two linked resources
// for the creation or removal of a link between two resources.
// The value of the `LinkData` field returned in the output will be combined
// with the LinkData output from updating resource A and intermediary resources
// to form the final LinkData that will be persisted in the state of the blueprint instance.
// Parameters are passed into UpdateResourceB for extra context, blueprint variables will have already
// been substituted at this stage and must be used instead of the passed in params argument
// to ensure consistency between the staged changes that are reviewed and the deployment itself.
UpdateResourceB(ctx context.Context, input *LinkUpdateResourceInput) (*LinkUpdateResourceOutput, error)
// UpdateIntermediaryResources deals with creating, updating or deleting intermediary resources
// that are required for the link between two resources.
// This is called for both the creation and removal of a link between two resources.
// The value of the `LinkData` field returned in the output will be combined
// with the LinkData output from updating resource A and B
// to form the final LinkData that will be persisted in the state of the blueprint instance.
// Parameters are passed into UpdateIntermediaryResources for extra context, blueprint variables will have already
// been substituted at this stage and must be used instead of the passed in params argument
// to ensure consistency between the staged changes that are reviewed and the deployment itself.
UpdateIntermediaryResources(
ctx context.Context,
input *LinkUpdateIntermediaryResourcesInput,
) (*LinkUpdateIntermediaryResourcesOutput, error)
// GetPriorityResource retrieves the resource in the relationship
// that must be deployed first. This will be empty for links where one resource does not
// need to be deployed before the other.
GetPriorityResource(ctx context.Context, input *LinkGetPriorityResourceInput) (*LinkGetPriorityResourceOutput, error)
// GetType deals with retrieving the type of the link in relation to the two resource
// types it provides a relationship between.
GetType(ctx context.Context, input *LinkGetTypeInput) (*LinkGetTypeOutput, error)
// GetTypeDescription deals with retrieving the description for a link type in a blueprint spec
// that can be used for documentation and tooling.
// Markdown and plain text formats are supported.
GetTypeDescription(ctx context.Context, input *LinkGetTypeDescriptionInput) (*LinkGetTypeDescriptionOutput, error)
// GetAnnotationDefinitions retrieves the annotation definitions for the link type.
// Annotations provide a way to fine tune the behaviour of a link in a blueprint spec
// in the linked resource metadata sections.
GetAnnotationDefinitions(ctx context.Context, input *LinkGetAnnotationDefinitionsInput) (*LinkGetAnnotationDefinitionsOutput, error)
// GetKind tells us whether the link is a "hard" or "soft" link.
// A hard link is where the priority resource type must be created first.
// A soft link is where it does not matter which resource type in the relationship
// is created first.
GetKind(ctx context.Context, input *LinkGetKindInput) (*LinkGetKindOutput, error)
}
Link provides the interface for the implementation of a link between two resources.
type LinkAnnotationDefinition ¶
type LinkAnnotationDefinition struct {
Name string `json:"name"`
Label string `json:"label"`
Type core.ScalarType `json:"type"`
Description string `json:"description"`
DefaultValue *core.ScalarValue `json:"defaultValue,omitempty"`
AllowedValues []*core.ScalarValue `json:"allowedValues,omitempty"`
Examples []*core.ScalarValue `json:"examples,omitempty"`
Required bool `json:"required"`
// ValidateFunc is a custom validation function that allows for validation
// of annotation values when provided as literals.
// When substitutions are used as annotation values (e.g. `${variables.myVar}`),
// the validation function will not be called, as the value will not be resolved
// to a concrete value at the validation stage.
// The function should return a slice of diagnostics, where if at least one diagnostic
// has a level of Error, overall validation will fail.
ValidateFunc func(
key string,
annotationValue *core.ScalarValue,
) []*core.Diagnostic `json:"-"`
}
LinkAnnotationDefinition provides a way to define annotations for a link type. Annotations that have dynamic keys should use the `<resourceName>` syntax in the key name, e.g. "aws.lambda.dynamodb.<tableName>.accessType". The value that "<resourceName>" represents must be the name of a resource that is linked to the resource type where the annotation is defined. Schema validation will match based on the pattern for dynamic keys. Only a single "<resourceName>" placeholder is allowed for a dynamic annotation key. Dynamic keys are used to target specific resources when there are multiple resources of the same type linked to the resource where the annotation is defined. Default values are ignored for link annotation field definitions that have dynamic field names, the default value should be defined in an equivalent annotation that is not targeted at a specific resource name (e.g. "aws.lambda.dynamodb.accessType").
type LinkChanges ¶
type LinkChanges struct {
ModifiedFields []*FieldChange `json:"modifiedFields"`
NewFields []*FieldChange `json:"newFields"`
RemovedFields []string `json:"removedFields"`
UnchangedFields []string `json:"unchangedFields"`
// FieldChangesKnownOnDeploy holds a list of field names
// for which changes will be known when the host blueprint is deployed.
FieldChangesKnownOnDeploy []string `json:"fieldChangesKnownOnDeploy"`
}
LinkChanges provides a set of modified fields for a link between two resources. The link field changes represent a set of changes that will be made to the resources in the link relationship, these changes should be modelled as per the structure of the linkData that is persisted in the state of a blueprint instance. The linkData model should be organised by the resource type with a structure that is a close approximation of the actual changes that will be made to each resource during deployment in the upstream provider.
type LinkContext ¶
type LinkContext interface {
// ProviderConfigVariable retrieves a configuration value that was loaded
// for the specified provider.
ProviderConfigVariable(providerNamespace string, varName string) (*core.ScalarValue, bool)
// ProviderConfigVariables retrieves all configuration values that were loaded
// for the specified provider.
ProviderConfigVariables(providerNamespace string) map[string]*core.ScalarValue
// AllProviderConfigVariables retrieves all configuration values that were loaded
// for all providers.
AllProviderConfigVariables() map[string]map[string]*core.ScalarValue
// ContextVariable retrieves a context-wide variable
// for the current environment, this differs from values extracted
// from context.Context, as these context variables are specific
// to the components that implement the interfaces of the blueprint library
// and can be shared between processes over a network or similar.
ContextVariable(name string) (*core.ScalarValue, bool)
// ContextVariables returns all context variables
// for the current environment.
ContextVariables() map[string]*core.ScalarValue
}
LinkContext provides access to information about providers and configuration in the current environment. Links can live in intermediary provider plugins that can represent a link between resources in different providers, for this reason, the LinkContext provides access to configuration for all providers loaded into the current environment.
func NewLinkContextFromParams ¶
func NewLinkContextFromParams( blueprintParams core.BlueprintParams, ) LinkContext
NewLinkContextFromParams creates a new link context from a set of blueprint parameters for the current environment. The link context will then be passed into provider link plugins to allow them to access configuration values and context variables.
type LinkGetAnnotationDefinitionsInput ¶
type LinkGetAnnotationDefinitionsInput struct {
LinkContext LinkContext
}
LinkGetAnnotationDefinitionsInput provides the input for retrieving the annotation definitions for the link type.
type LinkGetAnnotationDefinitionsOutput ¶
type LinkGetAnnotationDefinitionsOutput struct {
// A mapping of annotation names prefixed by resource type that
// can be used to fine tune the behaviour of a link in a blueprint spec.
// The format should be as follows:
// {resourceType}::{annotationName} -> LinkAnnotationDefinition
// e.g. "aws/lambda/function::aws.lambda.dynamodb.accessType" -> LinkAnnotationDefinition
AnnotationDefinitions map[string]*LinkAnnotationDefinition
}
LinkGetAnnotationDefinitionsOutput provides the output for retrieving the annotation definitions for the link type.
type LinkGetKindInput ¶
type LinkGetKindInput struct {
LinkContext LinkContext
}
LinkGetKindInput provides the input for retrieving the kind of link.
type LinkGetKindOutput ¶
type LinkGetKindOutput struct {
Kind LinkKind
}
LinkGetKindOutput provides the output for retrieving the kind of link.
type LinkGetPriorityResourceInput ¶
type LinkGetPriorityResourceInput struct {
LinkContext LinkContext
}
LinkGetPriorityResourceInput provides the input for retrieving the priority resource type in a link relationship.
type LinkGetPriorityResourceOutput ¶
type LinkGetPriorityResourceOutput struct {
PriorityResource LinkPriorityResource
PriorityResourceType string
}
LinkPriorityResourceOutput provides the output for retrieving the priority resource in a link relationship.
type LinkGetTypeDescriptionInput ¶
type LinkGetTypeDescriptionInput struct {
LinkContext LinkContext
}
LinkGetTypeDescriptionInput provides the input for retrieving the description of a link type in a blueprint spec.
type LinkGetTypeDescriptionOutput ¶
type LinkGetTypeDescriptionOutput struct {
MarkdownDescription string
PlainTextDescription string
// A short summary of the link type that can be formatted
// in markdown, this is useful for listing link types in documentation.
MarkdownSummary string
// A short summary of the link type in plain text,
// this is useful for listing link types in documentation.
PlainTextSummary string
}
LinkGetTypeDescriptionOutput provides the output for retrieving the description of a link type in a blueprint spec.
type LinkGetTypeInput ¶
type LinkGetTypeInput struct {
LinkContext LinkContext
}
LinkGetTypeOutput provides the output for retrieving the type of link with respect to the two resource types it provides a relationship between.
type LinkGetTypeOutput ¶
type LinkGetTypeOutput struct {
Type string
}
LinkGetTypeOutput provides the output for retrieving the type of link with respect to the two resource types it provides a relationship between.
type LinkKind ¶
type LinkKind string
LinkKind provides a way to categorise links to help determine the order in which resources need to be deployed when a blueprint instance is being deployed.
const ( // LinkKindHard is the type of link where the priority resource type // must be created before the other resource type in the relationship. LinkKindHard LinkKind = "hard" // LinkKindSoft is the type of link where it does not matter // which of the two resource types in the relationship is created // first. LinkKindSoft LinkKind = "soft" )
type LinkPriorityResource ¶
type LinkPriorityResource int
LinkPriorityResource holds the type of resource that must be deployed first in a link relationship.
const ( // LinkPriorityResourceNone is used when there is no priority resource in the link relationship. LinkPriorityResourceNone LinkPriorityResource = iota // LinkPriorityResourceA is used when the priority resource is the first resource in the link relationship. LinkPriorityResourceA // LinkPriorityResourceB is used when the priority resource is the second resource in the link relationship. LinkPriorityResourceB )
type LinkRegistry ¶
type LinkRegistry interface {
// Link retrieves a link plugin to handle a link between two resource types
// in a blueprint from one of the registered providers.
Link(ctx context.Context, resourceTypeA string, resourceTypeB string) (Link, error)
// Provider retrieves the provider that implements the link between two resource types.
Provider(resourceTypeA string, resourceTypeB string) (Provider, error)
}
LinkRegistry provides an interface for a registry of link implementations that span multiple providers.
func NewLinkRegistry ¶
func NewLinkRegistry( providers map[string]Provider, ) LinkRegistry
NewLinkRegistry creates a new LinkRegistry from a map of providers, each provider will be checked for a given link implementation on the first request to retrieve a link for a given resource type pair. As links are not tied to the providers of each of the resource types in the link, a trial-and-error approach is used to find the correct provider for a link.
type LinkStageChangesInput ¶
type LinkStageChangesInput struct {
ResourceAChanges *Changes
ResourceBChanges *Changes
CurrentLinkState *state.LinkState
LinkContext LinkContext
}
LinkStageChangesInput provides the input required to stage changes for a link between two resources.
type LinkStageChangesOutput ¶
type LinkStageChangesOutput struct {
Changes *LinkChanges
}
LinkStageChangesOutput provides the output from staging changes for a link between two resources.
type LinkUpdateIntermediaryResourcesError ¶
LinkUpdateIntermediaryResourcesError is an error that indicates a failure to update intermediary resources in a link relationship.
func (*LinkUpdateIntermediaryResourcesError) Error ¶
func (e *LinkUpdateIntermediaryResourcesError) Error() string
func (*LinkUpdateIntermediaryResourcesError) GetFailureReasons ¶
func (e *LinkUpdateIntermediaryResourcesError) GetFailureReasons() []string
type LinkUpdateIntermediaryResourcesInput ¶
type LinkUpdateIntermediaryResourcesInput struct {
ResourceAInfo *ResourceInfo
ResourceBInfo *ResourceInfo
Changes *LinkChanges
// Additional user-defined blueprint instance name
// that can be used in ID/unique name generation and for debugging.
InstanceName string
LinkUpdateType LinkUpdateType
LinkContext LinkContext
// ResourceDeployService allows a link implementation to hook into
// the framework's existing mechanism to manage resource deployments,
// this is useful as it allows link implementations to use the same
// resources used in blueprints.
ResourceDeployService ResourceDeployService
}
LinkUpdateIntermediaryResourcesInput provides the input required to update intermediary resources in a link relationship.
type LinkUpdateIntermediaryResourcesOutput ¶
type LinkUpdateIntermediaryResourcesOutput struct {
IntermediaryResourceStates []*state.LinkIntermediaryResourceState
LinkData *core.MappingNode
}
type LinkUpdateResourceAError ¶
LinkUpdateResourceAError is an error that indicates a failure to update resource A in a link relationship.
func (*LinkUpdateResourceAError) Error ¶
func (e *LinkUpdateResourceAError) Error() string
func (*LinkUpdateResourceAError) GetFailureReasons ¶
func (e *LinkUpdateResourceAError) GetFailureReasons() []string
type LinkUpdateResourceBError ¶
LinkUpdateResourceBError is an error that indicates a failure to update resource B in a link relationship.
func (*LinkUpdateResourceBError) Error ¶
func (e *LinkUpdateResourceBError) Error() string
func (*LinkUpdateResourceBError) GetFailureReasons ¶
func (e *LinkUpdateResourceBError) GetFailureReasons() []string
type LinkUpdateResourceInput ¶
type LinkUpdateResourceInput struct {
Changes *LinkChanges
ResourceInfo *ResourceInfo
OtherResourceInfo *ResourceInfo
// Additional user-defined blueprint instance name
// that can be used in ID/unique name generation and for debugging.
InstanceName string
LinkUpdateType LinkUpdateType
LinkContext LinkContext
}
LinkUpdateResourceInput provides the input required to update a resource in a link relationship with data that will contribute to "activating" or "de-activating" the link.
type LinkUpdateResourceOutput ¶
type LinkUpdateResourceOutput struct {
LinkData *core.MappingNode
}
LinkUpdateResourceOutput provides the output from updating a resource in a link relationship.
type LinkUpdateType ¶
type LinkUpdateType int
LinkUpdateType represents the type of update that is being carried out for a link between two resources.
const ( // LinkUpdateTypeCreate is used when a link is being created. LinkUpdateTypeCreate LinkUpdateType = iota // LinkUpdateTypeDestroy is used when a link is being destroyed. LinkUpdateTypeDestroy // LinkUpdateTypeUpdate is used when a link is being updated. LinkUpdateTypeUpdate )
type Provider ¶
type Provider interface {
// Namespace retrieves the resource type prefix that is used as the namespace
// for all resource types in the provider.
// (e.g. "aws" for AWS resources such as "aws/lambda/function")
Namespace(ctx context.Context) (string, error)
// ConfigDefinition retrieves a detailed definition of the
// configuration that is required for the provider.
ConfigDefinition(ctx context.Context) (*core.ConfigDefinition, error)
// Resource retrieves a resource plugin to handle a resource in a blueprint for
// a given resource type.
Resource(ctx context.Context, resourceType string) (Resource, error)
// DataSource retrieves a data source plugin to handle a data source in a blueprint
// for a given data source type.
DataSource(ctx context.Context, dataSourceType string) (DataSource, error)
// Link retrieves a link plugin to handle a link between two resource types
// in a blueprint.
Link(ctx context.Context, resourceTypeA string, resourceTypeB string) (Link, error)
// CustomVariableType retrieves a custom variable type plugin to handle validating
// convenience variable types with a (usually large) fixed set of possible values.
// These custom variable types should not be used for dynamically sourced values
// external to a blueprint, data sources exist for that purpose.
CustomVariableType(ctx context.Context, customVariableType string) (CustomVariableType, error)
// Function retrieves a function plugin that provides custom pure functions for blueprint
// substitutions "${..}".
// Functions are global and which providers are to be used for which functions
// should be configured during initialisation of an application using the framework.
// The core functions that are defined in the blueprint specification can not be overridden
// by a provider.
Function(ctx context.Context, functionName string) (Function, error)
// ListResourceTypes retrieves a list of all the resource types that are provided by the
// provider. This is primarily used in tools and documentation to provide a list of
// available resource types.
ListResourceTypes(ctx context.Context) ([]string, error)
// ListLinkTypes retrieves a list of all the link types that are provided by the
// provider. This is primarily used in tools and documentation to provide a list of
// available link types.
ListLinkTypes(ctx context.Context) ([]string, error)
// ListDataSourceTypes retrieves a list of all the data source types that are provided by the
// provider. This is primarily used in tools and documentation to provide a list of
// available data source types.
ListDataSourceTypes(ctx context.Context) ([]string, error)
// ListCustomVariableTypes retrieves a list of all the custom variable types that are provided by the
// provider. This is primarily used in tools and documentation to provide a list of
// available custom variable types.
ListCustomVariableTypes(ctx context.Context) ([]string, error)
// ListFunctions retrieves a list of all the function names that are provided by the
// provider. This is primarily used to assign the correct provider to a function
// as functions are globally named. When multiple providers provide the same function,
// an error should be reported during initialisation.
ListFunctions(ctx context.Context) ([]string, error)
// RetryPolicy retrieves the retry policy that should be used for the provider
// for resource, link and data source operations.
// The retry policy will be applied for resources when deploying, updating and removing
// resources, for links when creating and removing links and for data sources when
// querying the upstream data source.
// The retry behaviour only kicks in when the provider resource, data source or link
// implementation returns an error of type `provider.RetryableError`,
// in which case the retry policy will be applied.
// A retry policy is optional and if not provided, a default retry policy
// provided by the host tool will be used.
RetryPolicy(ctx context.Context) (*RetryPolicy, error)
}
Provider is the interface for an implementation of a provider of a set of resource and data source types that can be used in a blueprint. An example of a provider could be a cloud provider such as AWS or Google Cloud.
When we have links between resources of different providers, a new provider implementation should be implemented to act as a bridge between the two providers the linked resources belong to.
type ResolvedDataSource ¶
type ResolvedDataSource struct {
Type *schema.DataSourceTypeWrapper `json:"type"`
DataSourceMetadata *ResolvedDataSourceMetadata `json:"metadata"`
Filter *ResolvedDataSourceFilters `json:"filter"`
Exports map[string]*ResolvedDataSourceFieldExport `json:"exports"`
Description *core.MappingNode `json:"description,omitempty"`
}
ResolvedDataSource is a data source for which all ${..} substitutions have been applied.
type ResolvedDataSourceFieldExport ¶
type ResolvedDataSourceFieldExport struct {
Type *schema.DataSourceFieldTypeWrapper `json:"type"`
AliasFor *core.ScalarValue `json:"aliasFor,omitempty"`
Description *core.MappingNode `json:"description,omitempty"`
}
ResolvedDataSourceFieldExport provides a field export for which all ${..} substitutions have been applied.
type ResolvedDataSourceFilter ¶
type ResolvedDataSourceFilter struct {
Field *core.ScalarValue `json:"field"`
Operator *schema.DataSourceFilterOperatorWrapper `json:"operator"`
Search *ResolvedDataSourceFilterSearch `json:"search"`
}
ResolvedDataSourceFilter provides a filter for which all ${..} substitutions have been applied.
type ResolvedDataSourceFilterSearch ¶
type ResolvedDataSourceFilterSearch struct {
Values []*core.MappingNode
}
ResolvedDataSourceFilterSearch provides a search for which all ${..} substitutions have been applied.
func (*ResolvedDataSourceFilterSearch) MarshalJSON ¶
func (s *ResolvedDataSourceFilterSearch) MarshalJSON() ([]byte, error)
func (*ResolvedDataSourceFilterSearch) UnmarshalJSON ¶
func (s *ResolvedDataSourceFilterSearch) UnmarshalJSON(data []byte) error
type ResolvedDataSourceFilters ¶ added in v0.19.0
type ResolvedDataSourceFilters struct {
Filters []*ResolvedDataSourceFilter `json:"filters"`
}
ResolvedDataSourceFilters provides a list of filters for which all ${..} substitutions have been applied.
func (*ResolvedDataSourceFilters) MarshalJSON ¶ added in v0.19.0
func (s *ResolvedDataSourceFilters) MarshalJSON() ([]byte, error)
func (*ResolvedDataSourceFilters) UnmarshalJSON ¶ added in v0.19.0
func (s *ResolvedDataSourceFilters) UnmarshalJSON(data []byte) error
type ResolvedDataSourceMetadata ¶
type ResolvedDataSourceMetadata struct {
DisplayName *core.MappingNode `json:"displayName"`
Annotations *core.MappingNode `json:"annotations,omitempty"`
Custom *core.MappingNode `json:"custom,omitempty"`
}
ResolvedDataSourceMetadata provides metadata for which all ${..} substitutions have been applied.
type ResolvedResource ¶
type ResolvedResource struct {
Type *schema.ResourceTypeWrapper `json:"type"`
Description *core.MappingNode `json:"description,omitempty"`
Metadata *ResolvedResourceMetadata `json:"metadata,omitempty"`
Condition *ResolvedResourceCondition `json:"condition,omitempty"`
LinkSelector *schema.LinkSelector `json:"linkSelector,omitempty"`
Spec *core.MappingNode `json:"spec"`
}
ResolvedResource provides a version of a resource for which all ${..} substitutions have been applied. Mapping nodes replace StringOrSubstitutions from the blueprint schema representation of the resource.
type ResolvedResourceCondition ¶
type ResolvedResourceCondition struct {
// A list of conditions that must all be true.
And []*ResolvedResourceCondition `json:"and,omitempty"`
// A list of conditions where at least one must be true.
Or []*ResolvedResourceCondition `json:"or,omitempty"`
// A condition that will be negated.
Not *ResolvedResourceCondition `json:"not,omitempty"`
// A condition expression that is expected
// to be a substitution that resolves to a boolean.
StringValue *core.MappingNode `json:"-"`
}
ResolvedResourceCondition provides a resolved version of the condition for a resource where all substitutions have been applied.
func (*ResolvedResourceCondition) MarshalJSON ¶
func (c *ResolvedResourceCondition) MarshalJSON() ([]byte, error)
func (*ResolvedResourceCondition) UnmarshalJSON ¶
func (c *ResolvedResourceCondition) UnmarshalJSON(data []byte) error
type ResolvedResourceMetadata ¶
type ResolvedResourceMetadata struct {
DisplayName *core.MappingNode `json:"displayName,omitempty"`
Annotations *core.MappingNode `json:"annotations,omitempty"`
Labels *schema.StringMap `json:"labels,omitempty"`
Custom *core.MappingNode `json:"custom,omitempty"`
}
ResolvedResourceMetadata provides a resolved version of the metadata for a resource where all substitutions have been applied.
type Resource ¶
type Resource interface {
// CustomValidate provides support for custom validation that goes beyond
// the spec schema validation provided by the resource's spec definition.
CustomValidate(ctx context.Context, input *ResourceValidateInput) (*ResourceValidateOutput, error)
// GetSpecDefinition retrieves the spec definition for a resource,
// this is the first line of validation for a resource in a blueprint and is also
// useful for validating references to a resource instance
// in a blueprint and for providing definitions for docs and tooling.
// The spec defines both the schema for the resource spec fields that can be defined
// by users in a blueprint and computed fields that are derived from the deployed
// resource in the external provider (e.g. Lambda ARN in AWS).
GetSpecDefinition(ctx context.Context, input *ResourceGetSpecDefinitionInput) (*ResourceGetSpecDefinitionOutput, error)
// CanLinkTo specifices the list of resource types the current resource type
// can link to.
CanLinkTo(ctx context.Context, input *ResourceCanLinkToInput) (*ResourceCanLinkToOutput, error)
// GetStabilisedDependencies retrieves a list of resource types that must be stabilised
// before the current resource can be deployed when another resource of one of the specified types
// is a dependency of the current resource in a blueprint.
GetStabilisedDependencies(ctx context.Context, input *ResourceStabilisedDependenciesInput) (*ResourceStabilisedDependenciesOutput, error)
// IsCommonTerminal specifies whether this resource is expected to have a common use-case
// as a terminal resource that does not link out to other resources.
// This is useful for providing useful warnings to users about their blueprints
// without overloading them with warnings for all resources that don't have any outbound
// links that could have.
IsCommonTerminal(ctx context.Context, input *ResourceIsCommonTerminalInput) (*ResourceIsCommonTerminalOutput, error)
// GetType deals with retrieving the namespaced type for a resource in a blueprint spec.
GetType(ctx context.Context, input *ResourceGetTypeInput) (*ResourceGetTypeOutput, error)
// GetTypeDescription deals with retrieving the description for a resource type in a blueprint spec
// that can be used for documentation and tooling.
// Markdown and plain text formats are supported.
GetTypeDescription(ctx context.Context, input *ResourceGetTypeDescriptionInput) (*ResourceGetTypeDescriptionOutput, error)
// GetExamples deals with retrieving a list of examples for a resource type in a blueprint spec
// that can be used for documentation and tooling.
// Markdown and plain text formats are supported.
GetExamples(ctx context.Context, input *ResourceGetExamplesInput) (*ResourceGetExamplesOutput, error)
// Deploy deals with deploying a resource with the upstream resource provider.
// The behaviour of deploy is to create or update the resource configuration and return the resource
// spec state once the configuration has been created or updated.
// Deploy should not wait for the resource to be in a stable state before returning,
// the framework will call the HasStabilised method periodically when waiting for a resource
// to stabilise.
// Parameters are passed into Deploy for extra context, blueprint variables will have already
// been substituted at this stage and must be used instead of the passed in params argument
// to ensure consistency between the staged changes that are reviewed and the deployment itself.
Deploy(ctx context.Context, input *ResourceDeployInput) (*ResourceDeployOutput, error)
// HasStabilised deals with checking if a resource has stabilised after being deployed.
// This is important for resources that require a stable state before other resources can be deployed.
// This is only used when creating or updating a resource, not when destroying a resource.
HasStabilised(ctx context.Context, input *ResourceHasStabilisedInput) (*ResourceHasStabilisedOutput, error)
// GetExternalState deals with getting the state of the resource from the resource provider.
// (e.g. AWS or Google Cloud)
GetExternalState(ctx context.Context, input *ResourceGetExternalStateInput) (*ResourceGetExternalStateOutput, error)
// Destroy deals with destroying a resource instance if its current
// state is successfully deployed or cleaning up a corrupt or partially deployed
// resource instance.
// The resource instance should be completely removed from the external provider
// as a result of this operation; this is essential for when
// another element to be removed from a blueprint
// requires a resource to be completely removed from the external provider.
// There is no "config complete" equivalent for destroying a resource and
// "HasStabilised" is designed to be used for resources being created or
// updated.
Destroy(ctx context.Context, input *ResourceDestroyInput) error
}
Resource provides the interface for a resource that a provider can contain which includes logic for validating, transforming, linking and deploying a resource.
type ResourceCanLinkToInput ¶
type ResourceCanLinkToInput struct {
ProviderContext Context
}
ResourceCanLinkToInput provides the input data needed for a resource to determine what types of resources it can link to.
type ResourceCanLinkToOutput ¶
type ResourceCanLinkToOutput struct {
CanLinkTo []string
}
ResourceCanLinkToOutput provides the output data from determining what types of resources a given resource can link to.
type ResourceDefinitionsSchema ¶
type ResourceDefinitionsSchema struct {
// Type holds the type of the resource definition.
Type ResourceDefinitionsSchemaType
// Label holds a human-readable label for the resource definition.
Label string
// Description holds a human-readable description for the resource definition
// without any formatting.
Description string
// FormattedDescription holds a human-readable description for the resource definition
// that is formatted with markdown.
FormattedDescription string
// Attributes holds a mapping of the attribute types for a resource definition
// schema object.
Attributes map[string]*ResourceDefinitionsSchema
// Items holds the schema for the items in a resource definition schema array.
Items *ResourceDefinitionsSchema
// MapValues holds the schema for the values in a resource definition schema map.
// Keys are always strings.
MapValues *ResourceDefinitionsSchema
// OneOf holds a list of possible schemas for a resource definition item.
// This is to be used with the "union" type.
OneOf []*ResourceDefinitionsSchema
// Required holds a list of required attributes for a resource definition schema object.
Required []string
// Nullable specifies whether the resource definition schema can be null.
Nullable bool
// AllowedValues holds a list of allowed values for a resource definition schema.
// This is useful for enum-like values and can be used with the "string",
// "integer" and "float" types.
// Unions and enums are mutually exclusive, when designing your schemas,
// you should use either unions for type constraints or allowed values for
// value constraints.
// In the validation implementation, the allowed values constraint will only be applied
// for values that contain ${..} substitutions, warnings will be produced when the value
// contains substitutions as there is no way to know the final value during the validation phase.
// Allowed values take precedence over other value constrants such as minimum, maximum and pattern.
AllowedValues []*core.MappingNode
// Minimum holds the minimum value that can be used for an element in a resource spec that uses
// this schema.
// This is only used for "integer" and "float" types.
// This constraint can not be forced when ${..} substitutions are used in a value,
// warnings will be produced when the value contains substitutions
// as there is no way to know the final value during the validation phase.
// Allowed values will take precedence over this constraint.
Minimum *core.ScalarValue
// Maximum holds the maximum value that can be used for an element in a resource spec that uses
// this schema.
// This is only used for "integer" and "float" types.
// This constraint can not be forced when ${..} substitutions are used in a value,
// warnings will be produced when the value contains substitutions
// as there is no way to know the final value during the validation phase.
// Allowed values will take precedence over this constraint.
Maximum *core.ScalarValue
// MinLength can provide a minimum length for a string value,
// minimum amount of items in an array or minimum number of keys in a map.
// This is only used for "string", "array" and "map" types.
//
// For strings, this constraint represents the minimum number of characters (runes)
// in the string and not the number of bytes.
//
// This constraint can not be forced when ${..} substitutions are used in a string value,
// warnings will be produced when a string value contains substitutions
// as there is no way to know the final value during the validation phase.
// 0 means that there is no minimum length constraint.
// Allowed values will take precedence over this constraint for values of type "string".
MinLength int
// MaxLength can provide a maximum length for a string value,
// maximum amount of items in an array or maximum number of keys in a map.
// This is only used for "string", "array" and "map" types.
//
// For strings, this constraint represents the maximum number of characters (runes)
// in the string and not the number of bytes.
//
// This constraint can not be forced when ${..} substitutions are used in a string value,
// warnings will be produced when the vstring alue contains substitutions
// as there is no way to know the final value during the validation phase.
// 0 means that there is no maximum length constraint.
// Allowed values will take precedence over this constraint for values of type "string".
MaxLength int
// Pattern holds a regular expression pattern that can be used to validate
// a string value in a resource spec that uses this schema.
// This is only used for "string" types.
// The pattern must be a valid Go regular expression, see: https://pkg.go.dev/regexp/syntax.
// Allowed values will take precedence over this constraint.
Pattern string
// ValidateFunc is a custom validation function that can be used to validate
// a resource spec value that uses this schema.
// This function will be called during the validation phase of a resource
// and can be used to perform additional validation that is not covered
// by the schema definition.
// This can also be useful for targeted conditional validation based on other
// known values in the resource as defined in the source blueprint document.
// The function should return a list of diagnostics that will be used to
// report validation errors and warnings, validation will fail if at least one
// diagnostic is of level `core.DiagnosticLevelError`.
//
// All first-class validation properties such as `AllowedValues`, `Minimum`, `Maximum`,
// `MinLength`, `MaxLength` and `Pattern` will be applied before the custom validation function
// is called, so the custom validation function should not be used to validate
// and will only be called if a non-nil value is provided for the value and the value
// is known at the validation stage.
// This will not be called for computed values or fields that contain ${..} substitutions
// as the value is not known at the initial validation stage.
ValidateFunc func(
path string,
value *core.MappingNode,
resource *schema.Resource,
) []*core.Diagnostic
// Default holds the default value for a resource spec schema,
// this will be populated in the `Resource.Spec.*` mapping node
// if the resource spec is missing a value
// for a specific attribute or item in the spec.
// The default value will not be used if the attribute value in a given resource spec is nil
// and the schema is nullable, a nil pointer should not be used
// for an empty value, pointers should be set when you want to explicitly
// set a value to nil.
// The default value will not be used for computed values in a resource spec.
Default *core.MappingNode
// Examples holds a list of examples for the resource definition element.
// Examples are useful for documentation and tooling.
Examples []*core.MappingNode
// Computed specifies whether the value is computed by the provider
// and should not be set by the user.
// Computed values are expected to be populated by resource implementations
// in a provider in the deployment process.
Computed bool
// MustRecreate specifies whether the resource must be recreated
// if a change to the field is detected in the resource state.
// This is only used for user-provided values, it will be ignored
// for computed values.
MustRecreate bool
}
ResourceDefinitionsSchema provides a schema that can be used to validate a resource spec or output state.
type ResourceDefinitionsSchemaType ¶
type ResourceDefinitionsSchemaType string
ResourceDefinitionsSchemaType holds the type of a resource schema.
const ( // ResourceDefinitionsSchemaTypeString is for a schema string. ResourceDefinitionsSchemaTypeString ResourceDefinitionsSchemaType = "string" // ResourceDefinitionsSchemaTypeInteger is for a schema integer. ResourceDefinitionsSchemaTypeInteger ResourceDefinitionsSchemaType = "integer" // ResourceDefinitionsSchemaTypeFloat is for a schema float. ResourceDefinitionsSchemaTypeFloat ResourceDefinitionsSchemaType = "float" // ResourceDefinitionsSchemaTypeBoolean is for a schema boolean. ResourceDefinitionsSchemaTypeBoolean ResourceDefinitionsSchemaType = "boolean" // ResourceDefinitionsSchemaTypeMap is for a schema map. ResourceDefinitionsSchemaTypeMap ResourceDefinitionsSchemaType = "map" // ResourceDefinitionsSchemaTypeObject is for a schema object. ResourceDefinitionsSchemaTypeObject ResourceDefinitionsSchemaType = "object" // ResourceDefinitionsSchemaTypeArray is for a schema array. ResourceDefinitionsSchemaTypeArray ResourceDefinitionsSchemaType = "array" // ResourceDefinitionsSchemaTypeUnion is for an element that can be one of // multiple schemas. ResourceDefinitionsSchemaTypeUnion ResourceDefinitionsSchemaType = "union" )
type ResourceDeployError ¶
ResourceDeployError is an error that indicates a failure to deploy a resource. This is a part of the API for provider resources that should be returned when a resource fails to deploy, this will cause the operation to fail and the state of the resource will be marked as failed with the failure reasons provided. This should only be used for errors that can not be retried, the RetryableError should be used for transient errors that can be retried.
func (*ResourceDeployError) Error ¶
func (e *ResourceDeployError) Error() string
func (*ResourceDeployError) GetFailureReasons ¶
func (e *ResourceDeployError) GetFailureReasons() []string
type ResourceDeployInput ¶
type ResourceDeployInput struct {
InstanceID string
// Additional user-defined blueprint instance name
// that can be used in ID/unique name generation and for debugging.
InstanceName string
ResourceID string
Changes *Changes
ProviderContext Context
}
ResourceDeployInput provides the input data needed for a resource to be deployed.
type ResourceDeployOutput ¶
type ResourceDeployOutput struct {
// ComputedFieldValues holds a mapping of computed field paths
// to their values.
// Examples of computed fields are the ARN of an AWS Lambda function
// or the ID of a Google Cloud Storage bucket.
// Some examples of valid computed field paths are:
// - `spec.arn`
// - `spec.id`
// - `spec.arns[0]`
// - `spec.identifiers["id.v1"]`
// - `spec["identifiers.1"].arn`
//
// The computed fields will be injected into the final resource state that
// will be persisted as a part of the blueprint instance state.
ComputedFieldValues map[string]*core.MappingNode
}
ResourceDeployOutput provides the output data from deploying a resource. This should contain any computed fields that are known after the resource has been deployed.
type ResourceDeployService ¶
type ResourceDeployService interface {
// Deploy deals with the deployment of a resource of a given type.
// Callers can specify whether or not to wait for the resource to stabilise
// before returning.
Deploy(
ctx context.Context,
resourceType string,
input *ResourceDeployServiceInput,
) (*ResourceDeployOutput, error)
// Destroy deals with the destruction of a resource of a given type.
Destroy(
ctx context.Context,
resourceType string,
input *ResourceDestroyInput,
) error
}
ResourceDeployService is an interface for a service that deploys resources. This is a subset of a resource registry that enables the deployment of resources in limited contexts that don't need the full functionality of a resource registry or a resource plugin implementation.
type ResourceDeployServiceInput ¶
type ResourceDeployServiceInput struct {
// DeployInput is the input for the resource deployment that is passed into the `Deploy`
// method of a `provider.Resource` implementation.
DeployInput *ResourceDeployInput
// WaitUntilStable specifies whether or not to
// wait for the resource to stabilise before returning.
WaitUntilStable bool
}
ResourceDeployServiceInput is the input for the Deploy method of the ResourceDeployService that enhances the ResourceDeployInput with a flag to allow the caller to specify whether or not to wait for the resource to stabilise before returning.
type ResourceDestroyError ¶
ResourceDestroyError is an error that indicates a failure to destroy a resource. This is a part of the API for provider resources that should be returned when an attempt to remove a resource fails, this will cause the operation to fail and the state of the resource will be marked as failed with the failure reasons provided. This should only be used for errors that can not be retried, the RetryableError should be used for transient errors that can be retried.
func (*ResourceDestroyError) Error ¶
func (e *ResourceDestroyError) Error() string
func (*ResourceDestroyError) GetFailureReasons ¶
func (e *ResourceDestroyError) GetFailureReasons() []string
type ResourceDestroyInput ¶
type ResourceDestroyInput struct {
InstanceID string
// Additional user-defined blueprint instance name
// that can be used in ID/unique name generation and for debugging.
InstanceName string
ResourceID string
ResourceState *state.ResourceState
ProviderContext Context
}
ResourceDestroyInput provides the input data needed to delete a resource.
type ResourceGetExamplesInput ¶
type ResourceGetExamplesInput struct {
ProviderContext Context
}
ResourceGetExamplesInput provides the input data needed for a resource to retrieve examples for a resource type in a blueprint spec.
type ResourceGetExamplesOutput ¶
ResourceGetExamplesOutput provides the output data from retrieving examples for a resource type in a blueprint spec.
type ResourceGetExternalStateInput ¶
type ResourceGetExternalStateInput struct {
InstanceID string
// Additional user-defined blueprint instance name
// that can be used in ID/unique name generation and for debugging.
InstanceName string
ResourceID string
CurrentResourceSpec *core.MappingNode
CurrentResourceMetadata *state.ResourceMetadataState
ProviderContext Context
}
ResourceGetExternalStateInput provides the input data needed for a resource to get the external state of a resource.
type ResourceGetExternalStateOutput ¶
type ResourceGetExternalStateOutput struct {
ResourceSpecState *core.MappingNode
}
ResourceGetExternalStateOutput provides the output data from retrieving the external state of a resource.
type ResourceGetSpecDefinitionInput ¶
type ResourceGetSpecDefinitionInput struct {
ProviderContext Context
}
ResourceGetSpecDefinitionInput provides the input data needed for a resource to provide a spec definition.
type ResourceGetSpecDefinitionOutput ¶
type ResourceGetSpecDefinitionOutput struct {
SpecDefinition *ResourceSpecDefinition
}
ResourceGetSpecDefinitionOutput provides the output data from providing a spec definition for a resource.
type ResourceGetTypeDescriptionInput ¶
type ResourceGetTypeDescriptionInput struct {
ProviderContext Context
}
ResourceGetTypeDescriptionInput provides the input data needed for a resource to retrieve a description of the type of a resource in a blueprint spec.
type ResourceGetTypeDescriptionOutput ¶
type ResourceGetTypeDescriptionOutput struct {
MarkdownDescription string
PlainTextDescription string
// A short summary of the resource type that can be formatted
// in markdown, this is useful for listing resource types in documentation.
MarkdownSummary string
// A short summary of the resource type in plain text,
// this is useful for listing resource types in documentation.
PlainTextSummary string
}
ResourceGetTypeDescriptionOutput provides the output data from retrieving a description of the type of a resource in a blueprint spec.
type ResourceGetTypeInput ¶
type ResourceGetTypeInput struct {
ProviderContext Context
}
ResourceGetTypeInput provides the input data needed for a resource to determine the type of a resource in a blueprint spec.
type ResourceGetTypeOutput ¶
type ResourceGetTypeOutput struct {
Type string
// A human-readable label for the resource type.
Label string
}
ResourceGetTypeOutput provides the output data from determining the type of a resource in a blueprint spec.
type ResourceHasStabilisedInput ¶
type ResourceHasStabilisedInput struct {
InstanceID string
// Additional user-defined blueprint instance name
// that can be used in ID/unique name generation and for debugging.
InstanceName string
ResourceID string
ResourceSpec *core.MappingNode
ResourceMetadata *state.ResourceMetadataState
ProviderContext Context
}
ResourceHasStabilisedInput provides the input data needed for a resource to determine if it has stabilised after being deployed.
type ResourceHasStabilisedOutput ¶
type ResourceHasStabilisedOutput struct {
Stabilised bool
}
ResourceHasStabilisedOutput provides the output data from determining if a resource has stabilised after being deployed.
type ResourceInfo ¶
type ResourceInfo struct {
// ResourceID holds the ID of a resource when in the context
// of a blueprint instance when deploying or staging changes.
// Sometimes staging changes is independent of an instance and is used to compare
// two versions of a blueprint in which
// case the resource ID will be empty.
ResourceID string `json:"resourceId"`
// ResourceName holds the name of the resource in the blueprint spec.
// This is useful for new resources that do not have any current resource state.
ResourceName string `json:"resourceName"`
// InstanceID holds the ID of the blueprint instance
// that the current resource belongs to.
// This could be empty if the resource is being staged
// for an initial deployment.
InstanceID string `json:"instanceId"`
// CurrentResourceState holds the current state of the resource
// for which changes are being staged.
// The ResourceInfo struct is passed into resource implementation plugins
// for deployment.
// A resource implementation should be guarded from the details of where
// the state is stored and how it is retrieved,
// the state should be provided to resource plugins by the blueprint
// engine.
// If this is a nil pointer, it means that the resource is new and does not have
// a current state.
CurrentResourceState *state.ResourceState `json:"currentResourceState"`
// ResourceWithResolvedSubs holds a version of a resource for which all ${..}
// substitutions have been applied.
ResourceWithResolvedSubs *ResolvedResource `json:"resourceWithResolvedSubs"`
}
ResourceInfo provides all the information needed for a resource including the blueprint schema data with annotations, labels and the spec as a core mapping node.
type ResourceIsCommonTerminalInput ¶
type ResourceIsCommonTerminalInput struct {
ProviderContext Context
}
ResourceIsCommonTerminalInput provides the input data needed for a resource to determine if it is a common terminal resource.
type ResourceIsCommonTerminalOutput ¶
type ResourceIsCommonTerminalOutput struct {
IsCommonTerminal bool
}
ResourceIsCommonTerminalOutput provides the output data from determining if a resource is a common terminal resource.
type ResourceSpecDefinition ¶
type ResourceSpecDefinition struct {
// Schema holds the schema for the resource
// specification.
Schema *ResourceDefinitionsSchema
// IDField holds the name of the field in the resource spec
// that holds the ID of the resource.
// This is used to resolve references to a resource in a blueprint
// where only the name of the resource is specified.
// For example, references such as `resources.processOrderFunction` or `processOrderFunction`
// should resolve to the ID of the resource in the blueprint.
// The ID field must be a top-level property of the resource spec schema.
IDField string
}
ResourceSpecDefinition provides a definition for a resource spec that is used for state management, validation, docs and tooling.
type ResourceStabilisedDependenciesInput ¶
type ResourceStabilisedDependenciesInput struct {
ProviderContext Context
}
ResourceStabilisedDependenciesInput provides the input data needed for a resource to determine what resource types must be stabilised before the current resource can be deployed.
type ResourceStabilisedDependenciesOutput ¶
type ResourceStabilisedDependenciesOutput struct {
StabilisedDependencies []string
}
ResourceStabilisedDependenciesOutput provides the output data from determining what resource types must be stabilised before the current resource can be deployed.
type ResourceValidateInput ¶
ResourceValidateParams provides the input data needed for a resource to be validated.
type ResourceValidateOutput ¶
type ResourceValidateOutput struct {
Diagnostics []*core.Diagnostic
}
ResourceValidateOutput provides the output data from validating a resource which includes a list of diagnostics that detail issues with the resource.
type RetryContext ¶
type RetryContext struct {
Attempt int
ExceededMaxRetries bool
Policy *RetryPolicy
AttemptDurations []float64
AttemptStartTime time.Time
}
RetryContext contains information to be used for retrying operations such as resource deployment, data source fetching, etc.
func CreateRetryContext ¶
func CreateRetryContext(policy *RetryPolicy) *RetryContext
CreateRetryContext creates a new retry context with state for the initial attempt with the provided retry policy.
func RetryContextWithNextAttempt ¶
func RetryContextWithNextAttempt( retryCtx *RetryContext, currentAttemptDuration time.Duration, ) *RetryContext
RetryContextWithNextAttempt creates a new retry context with state for the next retry attempt based on the provided retry context.
func RetryContextWithStartTime ¶
func RetryContextWithStartTime(retryCtx *RetryContext, startTime time.Time) *RetryContext
RetryContextWithStartTime creates a new retry context with the provided start time for the current attempt.
type RetryPolicy ¶
type RetryPolicy struct {
// MaxRetries is the maximum number of retries that should be attempted
// for a resource, link or data source operation.
// If MaxRetries is 0, no retries should be attempted.
MaxRetries int `json:"maxRetries"`
// FirstRetryDelay is the delay in seconds that should be used before the first retry
// attempt.
// Fractional seconds are supported.
FirstRetryDelay float64 `json:"firstRetryDelay"`
// MaxDelay represents the maximum interval in seconds to wait between retries.
// If -1 is provided, no maximum delay is enforced.
// Fractional seconds are supported.
MaxDelay float64 `json:"maxDelay"`
// BackoffFactor is the factor that should be used to calculate the backoff
// time between retries.
// This AWS blog post from 2015 provides a good insight into how exponential backoff works:
// https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/
BackoffFactor float64 `json:"backoffFactor"`
// Jitter is a boolean value that determines whether to apply jitter to the retry interval.
// This AWS blog post from 2015 provides a good insight into how jitter works:
// https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/
Jitter bool `json:"jitter"`
}
RetryPolicy defines the retry policy that should be used for the provider for resource, link and data source operations.
type RetryableError ¶
type RetryableError struct {
// The underlying error for the action that can be retried.
ChildError error
}
RetryableError is an error that indicates a transient error that can be retried. This is a part of the API for provider resources, data sources and custom variable types. When a retryable error is returned from a provider resource, data source or custom variable type. The operation is retried after a delay based on a configured backoff/retry strategy that is configured globally or at the provider level, the framework/host tool will provide some reasonable defaults.
The message in ChildError will be used as the failure reason persisted in the state when in the context of a resource deployment.
func (*RetryableError) Error ¶
func (e *RetryableError) Error() string