core

package
v0.24.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// BlueprintInstanceIDKey is the key used to store the blueprint instance ID
	// in the context for a blueprint execution.
	BlueprintInstanceIDKey = ContextKey("blueprintInstanceID")
)
View Source
const MappingNodeMaxTraverseDepth = 20

MappingNodeMaxTraverseDepth is the maximum depth allowed to traverse a mapping node tree during validation and when resolving substitutions. This also applies to the depth of a schema definition for a resource spec.

Variables

This section is empty.

Functions

func BlueprintInstanceIDFromContext

func BlueprintInstanceIDFromContext(ctx context.Context) (string, error)

BlueprintInstanceIDFromContext retrieves the current blueprint instance ID from the context passed through when loading and carrying out an action for a blueprint.

func BoolMapValue

func BoolMapValue(value *MappingNode) map[string]bool

BoolMapValue extracts a map of string to bool values from a MappingNode.

func BoolSliceValue

func BoolSliceValue(value *MappingNode) []bool

BoolSliceValue extracts a slice of booleans from a MappingNode.

func BoolValue

func BoolValue(value *MappingNode) bool

BoolValue extracts the boolean value from a MappingNode. This will return false if the value is nil or the given mapping node contains another type of value.

func BoolValueFromScalar

func BoolValueFromScalar(scalar *ScalarValue) bool

BoolValueFromScalar extracts a Go bool from a bool scalar value. If the scalar is nil, false is returned.

func ChildElementID

func ChildElementID(childName string) string

ChildElementID generates an element ID for a child blueprint that is used primarily for resolving substitutions.

func CreateJSONNodePath

func CreateJSONNodePath(key string, parentPath string, parentIsRoot bool) string

CreateJSONNodePath creates a JSON node path from the given key and parent path.

func CreatePatternForDynamicFieldName

func CreatePatternForDynamicFieldName(fieldDefName string, maxPlaceholders int) string

CreatePatternForDynamicFieldName creates a regex pattern for a given field definition name that contains one or more "<placeholder>" sub-strings. This is intended to be used for plugin config field definitions and link annotation definitions. Set maxPlaceholders to a value of -1 to allow for any number of placeholders to be captured.

func DataSourceElementID

func DataSourceElementID(dataSourceName string) string

DataSourceElementID generates an element ID for a data source that is used primarily for resolving substitutions.

func ElementPropertyPath

func ElementPropertyPath(elementID string, propertyName string) string

ElementPropertyPath generates a property path for a given element ID and property name.

func ExpandedResourceName

func ExpandedResourceName(resourceTemplateName string, index int) string

ExpandedResourceName generates a resource name with an index appended to it for resources expanded from a resource template.

func ExportElementID

func ExportElementID(dataSourceName string) string

ExportElementID generates an element ID for a blueprint export that is used primarily for resolving substitutions.

func Flatten

func Flatten[Item any](array [][]Item) []Item

Flatten returns a flattened 2D array of the given type.

func FloatMapValue

func FloatMapValue(value *MappingNode) map[string]float64

FloatMapValue extracts a map of string to float values from a MappingNode.

func FloatSliceValue

func FloatSliceValue(value *MappingNode) []float64

FloatSliceValue extracts a slice of floats from a MappingNode.

func FloatValue

func FloatValue(value *MappingNode) float64

FloatValue extracts the float value from a MappingNode. This will return 0.0 if the value is nil or the given mapping node contains another type of value.

func FloatValueFromScalar

func FloatValueFromScalar(scalar *ScalarValue) float64

FloatValueFromScalar extracts a Go float64 from a float64 scalar value. If the scalar is nil, 0.0 is returned.

func FractionalMilliseconds

func FractionalMilliseconds(duration time.Duration) float64

FractionalMilliseconds returns the fractional milliseconds of a given duration.

func InjectPathValue

func InjectPathValue(
	path string,
	value *MappingNode,
	injectInto *MappingNode,
	maxTraverseDepth int,
) error

InjectPathValue injects a value into a MappingNode using a path. This will return an error if the provided path is invalid or if the path is not reachable in the given node. Structures such as an arrays and field mappings will be created if they do not exist in the injectInto node and the path is valid.

A path supports the following acessors:

- "." for fields - "[\"<field>\"]" for fields with special characters - "[<index>]" for array items

"$" represents the root of the path and must always be the first character in the path.

Example:

core.InjectPathValue("$[\"cluster.v1\"].config.endpoints[0]", value, injectInto, 3)

func IntMapValue

func IntMapValue(value *MappingNode) map[string]int

IntMapValue extracts a map of string to int values from a MappingNode.

func IntSliceValue

func IntSliceValue(value *MappingNode) []int

IntSliceValue extracts a slice of integers from a MappingNode.

func IntValue

func IntValue(value *MappingNode) int

IntValue extracts the integer value from a MappingNode. This will return 0 if the value is nil or the given mapping node contains another type of value.

func IntValueFromScalar

func IntValueFromScalar(scalar *ScalarValue) int

IntValueFromScalar extracts a Go int from an int scalar value. If the scalar is nil, 0 is returned.

func IsArrayMappingNode

func IsArrayMappingNode(node *MappingNode) bool

IsArrayMappingNode returns true if the mapping node is an array/slice of items.

func IsDynamicFieldName

func IsDynamicFieldName(fieldDefName string) bool

IsDynamicFieldName checks if a given field definition name contains one or more "<placeholder>" sub-strings. This is intended to be used for plugin config field definitions and link annotation definitions.

func IsInScalarList

func IsInScalarList(value *ScalarValue, list []*ScalarValue) bool

IsInScalarList checks if a given scalar value is in a list of scalar values.

func IsNilMappingNode

func IsNilMappingNode(node *MappingNode) bool

IsNilMappingNode returns true if the mapping node is nil or has no content.

func IsObjectMappingNode

func IsObjectMappingNode(node *MappingNode) bool

IsObjectMappingNode returns true if the mapping node is an object or map of fields.

func IsScalarBool

func IsScalarBool(scalar *ScalarValue) bool

IsScalarBool checks if a scalar value is a bool.

func IsScalarFloat

func IsScalarFloat(scalar *ScalarValue) bool

IsScalarFloat checks if a scalar value is a float.

func IsScalarInt

func IsScalarInt(scalar *ScalarValue) bool

IsScalarInt checks if a scalar value is an int.

func IsScalarMappingNode

func IsScalarMappingNode(node *MappingNode) bool

IsScalarMappingNode returns true if the mapping node is a scalar value.

func IsScalarNil

func IsScalarNil(scalar *ScalarValue) bool

IsScalarNil checks if a scalar value is nil or has no value.

func IsScalarString

func IsScalarString(scalar *ScalarValue) bool

IsScalarString checks if a scalar value is a string.

func IsStringWithSubsMappingNode added in v0.24.0

func IsStringWithSubsMappingNode(node *MappingNode) bool

IsStringWithSubsMappingNode returns true if the mapping node is a string with substitutions.

func LinePositionsFromSource

func LinePositionsFromSource(source string) []int

LinePositionsFromSource returns the line positions of the source string. It returns a slice of integers representing the start positions of each line. This will always include a line ending even if the source string does not end with a newline character to be able to obtain the length of the last line in the source string.

func LinkType

func LinkType(resourceTypeA string, resourceTypeB string) string

LinkType generates a link type identifier for a given pair of resource types in the given order. (e.g. "aws/lambda/function::aws/dynamodb/table").

func LogicalLinkName

func LogicalLinkName(resourceAName string, resourceBName string) string

LogicalLinkName generates a logical link name for a given pair of resource names in the given order. (e.g. "resourceA::resourceB").

func MappingNodeEqual

func MappingNodeEqual(nodeA, nodeB *MappingNode) bool

MappingNodeEqual returns true if the mapping nodes are equal. This will carry out a deep comparison for mapping nodes that represent maps/objects and arrays.

func PopulateDefaultConfigValues

func PopulateDefaultConfigValues(
	config map[string]*ScalarValue,
	configDefinition *ConfigDefinition,
) (map[string]*ScalarValue, error)

PopulateDefaultConfigValues populates the default values for the given configuration based on the provided config definition. This is used to ensure that the default values are set for the configuration before it is used.

func ResourceElementID

func ResourceElementID(resourceName string) string

ResourceElementID generates an element ID for a resource that is used primarily for resolving substitutions.

func ScalarMappingNodeEqual

func ScalarMappingNodeEqual(nodeA, nodeB *MappingNode) bool

ScalarMappingNodeEqual returns true if the scalar values of two mapping nodes are equal.

func StringMapValue

func StringMapValue(value *MappingNode) map[string]string

StringMapValue extracts a map of string to string values from a MappingNode.

func StringSliceValue

func StringSliceValue(value *MappingNode) []string

StringSliceValue extracts a slice of strings from a MappingNode.

func StringValue

func StringValue(value *MappingNode) string

StringValue extracts the string value from a MappingNode.

func StringValueFromScalar

func StringValueFromScalar(scalar *ScalarValue) string

StringValueFromScalar extracts a Go string from a string scalar value. If the scalar is nil, an empty string is returned.

func Sum

func Sum(numbers []float64) float64

Sum calculates the sum of a list of numbers.

func ToLogicalChildName

func ToLogicalChildName(childElementID string) string

ToLogicalChildName converts a child element ID to a logical child name (e.g. "children.child1" -> "child1").

func ToLogicalResourceName

func ToLogicalResourceName(resourceElementID string) string

ToLogicalResourceName converts a resource element ID to a logical resource name (e.g. "resources.resource1" -> "resource1").

func UnpackValueFromJSONMapNode

func UnpackValueFromJSONMapNode(
	nodeMap map[string]json.Node,
	key string,
	target JSONNodeExtractable,
	linePositions []int,
	parentPath string,
	parentIsRoot bool,
	required bool,
) error

UnpackValueFromJSONMapNode unpacks a value from a JSON map node into the target struct.

func UnpackValuesFromJSONMapNode

func UnpackValuesFromJSONMapNode[Target JSONNodeExtractable](
	nodeMap map[string]json.Node,
	key string,
	target *[]Target,
	linePositions []int,
	parentPath string,
	parentIsRoot bool,
	required bool,
) error

UnpackValuesFromJSONMapNode unpacks a slice of values from a JSON map node into the target slice.

func ValueElementID

func ValueElementID(valueName string) string

ValueElementID generates an element ID for a value that is used primarily for resolving substitutions.

func VariableElementID

func VariableElementID(variableName string) string

VariableElementID generates an element ID for a variable that is used primarily for resolving substitutions.

func YAMLNodeToPosInfo

func YAMLNodeToPosInfo(node *yaml.Node) source.PositionInfo

YAMLNodeToPosInfo returns a source.PositionInfo for a YAML node. This is used to provide position information for errors that are shared between YAML and JWCC parsers.

Types

type BlueprintParams

type BlueprintParams interface {
	// ProviderConfig retrieves the config for the provider
	// with the given namespace in the form a map of key-value pairs.
	// It's up to the caller to validate the provider config at runtime.
	ProviderConfig(namespace string) map[string]*ScalarValue
	// AllProvidersConfig retrieves the config for all providers
	// in the form of a map of key-value pairs.
	AllProvidersConfig() map[string]map[string]*ScalarValue
	// TransformerConfig retrieves the config for the transformer
	// with the given namespace in the form a map of key-value pairs.
	// It's up to the caller to validate the transformer config at runtime.
	TransformerConfig(namespace string) map[string]*ScalarValue
	// AllTransformersConfig retrieves the config for all transformers
	// in the form of a map of key-value pairs.
	AllTransformersConfig() map[string]map[string]*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.
	ContextVariable(name string) *ScalarValue
	// AllContextVariables returns all context variables
	// for the current environment.
	// This is useful for exporting all context variables
	// to a provider or transformer plugin running
	// in a separate process.
	AllContextVariables() map[string]*ScalarValue
	// BlueprintVariable retrieves a variable value
	// specific to a blueprint that will ultimately substitute
	// variable placeholders in a blueprint.
	BlueprintVariable(name string) *ScalarValue
	// AllBlueprintVariables returns all blueprint variables
	// for the current environment.
	// This is useful for exporting all blueprint variables
	// to a provider or transformer plugin running
	// in a separate process.
	AllBlueprintVariables() map[string]*ScalarValue
	// WithBlueprintVariables returns a new BlueprintParams
	// with the given variables added to the blueprint variables.
	// If keepExisting is true, the existing blueprint variables
	// will be kept, otherwise they will not be included in the new
	// BlueprintParams.
	//
	// This is useful for creating a new set of parameters for child
	// blueprints that need to inherit context variables and provider config
	// from the parent but require their own set of blueprint variables as
	// defined in an "include" block of the parent blueprint.
	WithBlueprintVariables(vars map[string]*ScalarValue, keepExisting bool) BlueprintParams
	// WithContextVariables returns a new BlueprintParams
	// with the given variables added to the context variables.
	// If keepExisting is true, the existing context variables
	// will be kept, otherwise they will not be included in the new
	// BlueprintParams.
	WithContextVariables(vars map[string]*ScalarValue, keepExisting bool) BlueprintParams
}

BlueprintParams represents a service that contains a mixture config for a resource provider, general context variables and variables for the blueprint.

func NewDefaultParams

func NewDefaultParams(
	providerConfig map[string]map[string]*ScalarValue,
	transformerConfig map[string]map[string]*ScalarValue,
	contextVariables map[string]*ScalarValue,
	blueprintVariables map[string]*ScalarValue,
) BlueprintParams

NewParams creates a new Params instance with the supplied provider configuration, context variables and blueprint variables.

type Cache

type Cache[Data any] struct {
	// contains filtered or unexported fields
}

Cache provides an implementation of a cache that can be used across go routines. This is a thread safe cache to be used by internal components of the blueprint framework, not to be confused with the `cache.BlueprintCache` interface which is utility interface on which applications can build their own blueprint caching implementations.

func NewCache

func NewCache[Data any]() *Cache[Data]

NewCache provides a thread safe cache that can be used across go routines.

func (*Cache[Data]) Delete

func (c *Cache[Data]) Delete(key string)

Delete an item from the cache.

func (*Cache[Data]) Get

func (c *Cache[Data]) Get(key string) (Data, bool)

Get an item from the cache.

func (*Cache[Data]) Set

func (c *Cache[Data]) Set(key string, data Data)

Set an item in the cache.

type Clock

type Clock interface {
	// Now returns the current time.
	Now() time.Time
	// Since returns the time elapsed since a given time.
	Since(time.Time) time.Duration
}

Clock is an interface that provides the current time and a way to measure time elapsed since a given time.

type ConfigDefinition

type ConfigDefinition struct {
	Fields                map[string]*ConfigFieldDefinition `json:"fields"`
	AllowAdditionalFields bool                              `json:"allowAdditionalFields"`
}

ConfigDefinition contains a detailed definition (schema) of the configuration required for a provider or transformer plugin. Fields that have dynamic keys should use the `<placeholder>` syntax in the key name, e.g. "aws.config.regionKMSKeys.<region>". The value that "<placeholder>" represents must be a string that matches the pattern [A-Za-z0-9\-_]+. Schema validation will match based on the pattern for dynamic keys. Dynamic keys are often useful to emulate nested dynamic map or array structures in provider and transformer configuration. Default values are ignored for config field definitions that have dynamic field names.

type ConfigFieldDefinition

type ConfigFieldDefinition struct {
	Type        ScalarType `json:"type"`
	Label       string     `json:"label"`
	Description string     `json:"description"`
	// Set to true if the config field should be a secret,
	// An application such as the deploy engine
	// will ensure that the value of this field
	// does not appear in logs.
	Secret bool `json:"secret"`
	// If the name of this field represents a config value template
	// (e.g. "aws.config.regionKMSKeys.<region>"),
	// the default value will not be used and is ignored in validation.
	DefaultValue  *ScalarValue   `json:"defaultValue,omitempty"`
	AllowedValues []*ScalarValue `json:"allowedValues,omitempty"`
	Examples      []*ScalarValue `json:"examples,omitempty"`
	Required      bool           `json:"required"`
	// ValidateFunc is a function that can be used to validate an individual
	// config field value. This function takes a key and a value
	// along with the entire plugin configuration for the current provider
	// or transformer plugin.
	// It should return a list of diagnostics where validation will fail
	// if there are one or more diagnostics at an error level.
	ValidateFunc func(
		key string,
		value *ScalarValue,
		pluginConfig PluginConfig,
	) []*Diagnostic `json:"-"`
}

ConfigFieldDefinition represents a field in a configuration definition for a provider or transformer plugin.

type ContextKey

type ContextKey string

ContextKey provides a unique key type for blueprint execution context values.

func (ContextKey) String

func (c ContextKey) String() string

type Diagnostic

type Diagnostic struct {
	// The level of this diagnostic.
	Level DiagnosticLevel `json:"level"`
	// The message of this diagnostic.
	Message string `json:"message"`
	// An optional text range in the source blueprint
	// that the diagnostic applies to.
	Range *DiagnosticRange `json:"range,omitempty"`
}

Diagnostic provides error, warning or informational diagnostic for a blueprint. Blueprint validation will not use this for errors, but instead return an error, tools that use the blueprint framework can transform these errors into diagnostics, see the Blueprint Language Server or the Deploy Engine for examples.

func ValidateConfigDefinition

func ValidateConfigDefinition(
	pluginName string,
	pluginType string,
	config map[string]*ScalarValue,
	configDefinition *ConfigDefinition,
) ([]*Diagnostic, error)

ValidateConfigDefinition checks provider and transformer configuration against a given config definition schema. This is intended to be used before change staging, deploy and destroy actions for an instance of a blueprint. This validation supports dynamic field names that match a config field name that contains one or more "<placeholder>" strings. The value that "<placeholder>" represents must be a string that matches the pattern [A-Za-z0-9\-_]+. For example, a config field name of "aws.config.regionKMSKeys.<region>" would match a config field name of "aws.config.regionKMSKeys.us-east-1" and "aws.config.regionKMSKeys.us-west-2". When a field definition with a dynamic name is required, it means that at least one config value that matches the pattern must be present. Default values are ignored for config field definitions that have dynamic field names. This returns an error for any unexpected errors and will return a list of diagnostics for any validation errors and warnings.

type DiagnosticLevel

type DiagnosticLevel int

DiagnosticLevel provides the level of a diagnostic.

const (
	// DiagnosticLevelError should be used for diagnostics that point out
	// errors in a blueprint.
	// This is not solely used as a source of errors, this should be combined
	// with unpacking a returned error to produce a set of error diagnostics
	// for tools that report diagnostics. (e.g. language servers)
	DiagnosticLevelError DiagnosticLevel = 1
	// DiagnosticLevelWarning should be used for diagnostics that point out
	// potential issues that may occur when executing a blueprint.
	DiagnosticLevelWarning DiagnosticLevel = 2
	// DiagnosticLevelInfo should be used for diagnostics that provide
	// informational messages about the blueprint that are worth noting
	// but do not indicate issues that may occur when executing a blueprint.
	DiagnosticLevelInfo DiagnosticLevel = 3
)

type DiagnosticRange

type DiagnosticRange struct {
	Start *source.Meta `json:"start,omitempty"`
	End   *source.Meta `json:"end,omitempty"`
	// When the diagnostic is concerning contents of a ${..} substitution,
	// depending on the context, the column may not be accurate,
	// this gives you the option to ignore approximate columns in contexts
	// where they are likely to cause confusion for the end-user.
	// (e.g. language server diagnostics for a code editor)
	ColumnAccuracy *substitutions.ColumnAccuracy `json:"columnAccuracy,omitempty"`
}

DiagnosticRange provides a range in the source blueprint that a diagnostic applies to. This will only be used for source formats that allow position tracking of parsed nodes (i.e. YAML source documents).

func DiagnosticRangeFromSourceMeta added in v0.18.0

func DiagnosticRangeFromSourceMeta(
	start *source.Meta,
	nextLocation *source.Meta,
) *DiagnosticRange

DiagnosticRangeFromSourceMeta creates a diagnostic range to be used with validation based on the position of an element in the source blueprint document.

type EmptyIDGenerator

type EmptyIDGenerator struct{}

EmptyIDGenerator is an ID generator that produces empty strings.

func (*EmptyIDGenerator) GenerateID

func (e *EmptyIDGenerator) GenerateID() (string, error)

GenerateID generates an empty string.

type Error

type Error struct {
	ReasonCode ErrorCoreReasonCode
	Err        error
	// The line in the source blueprint file
	// where the error occurred.
	// This will be nil if the error is not related
	// to a specific line in the blueprint file
	// or the source format is JSON.
	SourceLine *int
	// The column on a line in the source blueprint file
	// where the error occurred.
	// This will be nil if the error is not related
	// to a specific line/column in the blueprint file
	// or the source format is JSON.
	SourceColumn *int
}

Error represents an error due to an issue with a core data type (mapping or scalar) in a blueprint.

func (*Error) Error

func (e *Error) Error() string

type ErrorCoreReasonCode

type ErrorCoreReasonCode string
const (
	// ErrorCoreReasonCodeInvalidMappingNode is provided
	// when a mapping node can not be parsed from a serialised blueprint.
	ErrorCoreReasonCodeInvalidMappingNode ErrorCoreReasonCode = "invalid_mapping_node"
	// ErrorCoreReasonCodeMissingMappingNode is provided
	// when a mapping node is missing a value in a serialised blueprint.
	ErrorCoreReasonCodeMissingMappingNode ErrorCoreReasonCode = "missing_mapping_node"
	// ErrorCoreReasonCodeMustBeScalar is an error that is returned
	// when a value that is expected to be a blueprint scalar is not a scalar value.
	ErrorCoreReasonCodeMustBeScalar ErrorCoreReasonCode = "must_be_scalar"
)
const (
	// ErrInvalidMappingPath is used when a path to access a value
	// in a MappingNode is invalid.
	ErrInvalidMappingPath ErrorCoreReasonCode = "invalid_mapping_path"
)

type IDGenerator

type IDGenerator interface {
	GenerateID() (string, error)
}

IDGenerator is an interface for generating globally unique IDs. ID generators are used in the deployment process of a blueprint container, if the state container should be responsible for assigning IDs, then you can choose to use an ID generator that produces an empty string.

func NewEmptyIDGenerator

func NewEmptyIDGenerator() IDGenerator

NewEmptyIDGenerator creates a new generator that produces empty strings. This is useful when the state container should be responsible for assigning IDs.

func NewNanoIDGenerator

func NewNanoIDGenerator() IDGenerator

NewNanoIDGenerator creates a new generator that produces nano IDs.

func NewUUIDGenerator

func NewUUIDGenerator() IDGenerator

NewNanoIDGenerator creates a new generator that produces v4 UUIDs.

type InstanceStatus

type InstanceStatus int

InstanceStatus is used to represent the current state of a blueprint instance.

const (
	// InstanceStatusPreparing is used when a blueprint
	// instance is being prepared to be deployed, updated
	// or destroyed.
	InstanceStatusPreparing InstanceStatus = iota
	// InstanceStatusDeploying is used when
	// an initial blueprint deployment is currently in progress.
	InstanceStatusDeploying
	// InstanceStatusDeployed is used when
	// a blueprint instance has been deployed
	// successfully.
	InstanceStatusDeployed
	// InstanceStatusDeployFailed is used when
	// the first deployment of a blueprint instance failed.
	InstanceStatusDeployFailed
	// InstanceStatusDeployRollingBack is used when
	// a blueprint instance deployment has failed
	// and is being rolled back to a previous state.
	InstanceStatusDeployRollingBack
	// InstanceStatusDeployRollbackFailed is used when
	// a blueprint instance deployment has failed
	// and the rollback process has also failed.
	InstanceStatusDeployRollbackFailed
	// InstanceStatusDeployRollbackComplete is used when
	// a blueprint instance deployment has been successfully rolled back
	// to a previous state.
	InstanceStatusDeployRollbackComplete
	// InstanceStatusDestroying is used when
	// all the resources defined in a blueprint
	// are in the process of being destroyed
	// for a given instance.
	InstanceStatusDestroying
	// InstanceStatusDestroyed is used when
	// all resources defined in a blueprint have been destroyed
	// for a given instance.
	InstanceStatusDestroyed
	// InstanceStatusDestroyFailed is used when
	// the destruction of all resources in a blueprint fails.
	InstanceStatusDestroyFailed
	// InstanceStatusDestroyRollingBack is used when
	// a blueprint instance removal has failed
	// and is being rolled back to a previous state.
	InstanceStatusDestroyRollingBack
	// InstanceStatusDestroyRollbackFailed is used when
	// a blueprint instance removal has failed
	// and the rollback process has also failed.
	InstanceStatusDestroyRollbackFailed
	// InstanceStatusDeployRollbackComplete is used when
	// a blueprint instance removal has been successfully rolled back
	// to a previous state.
	InstanceStatusDestroyRollbackComplete
	// InstanceStatusUpdating is used when
	// a blueprint instance is being updated.
	InstanceStatusUpdating
	// InstanceStatusUpdated is used when a blueprint
	// instance has been sucessfully updated.
	InstanceStatusUpdated
	// InstanceStatusUpdateFailed is used when a blueprint
	// instance has failed to update.
	InstanceStatusUpdateFailed
	// InstanceStatusUpdateRollingBack is used when
	// a blueprint instance update has failed
	// and is being rolled back to a previous state.
	InstanceStatusUpdateRollingBack
	// InstanceStatusUpdateRollbackFailed is used when
	// a blueprint instance update has failed
	// and the rollback process has also failed.
	InstanceStatusUpdateRollbackFailed
	// InstanceStatusUpdateRollbackComplete is used when
	// a blueprint instance update has been successfully rolled back
	// to a previous state.
	InstanceStatusUpdateRollbackComplete
	// InstanceStatusNotDeployed is used when
	// a blueprint instance has not had its first deployment.
	// This is useful for persisting a skeleton for an instance
	// before the first deployment of a new blueprint instance.
	InstanceStatusNotDeployed
)

type JSONNodeExtractable

type JSONNodeExtractable interface {
	// FromJSONNode populates the struct from a JSON node.
	// The linePositions parameter is a slice of integers
	// that represents the line offsets in the entire source
	// document.
	// The parentPath parameter is a string that represents the path
	// to the parent node in the JSON document that is used
	// to provide extra context for errors.
	FromJSONNode(node *json.Node, linePositions []int, parentPath string) error
}

JSONNodeExtractable is an interface that allows a struct to be populated from a JSON node with offsets.

type LinkStatus

type LinkStatus int

LinkStatus is used to represent the current state of a link in a blueprint instance.

const (
	// LinkStatusUnknown is used when we can't
	// determine an accurate status for a link.
	LinkStatusUnknown LinkStatus = iota
	// LinkStatusCreating is used when
	// an initial link deployment is currently in progress.
	LinkStatusCreating
	// LinkStatusCreated is used when
	// a link has been deployed
	// successfully.
	LinkStatusCreated
	// LinkStatusCreateFailed is used when
	// the first creation of a link failed.
	LinkStatusCreateFailed
	// LinkStatusCreateRollingBack is used when
	// another change in the same blueprint has failed
	// and the creation of the current link is being rolled back.
	LinkStatusCreateRollingBack
	// LinkStatusCreateRollbackFailed is used when
	// another element change in the same blueprint has failed
	// and the creation of the current link could not be rolled back.
	LinkStatusCreateRollbackFailed
	// LinkStatusCreateRollbackComplete is used when
	// another change in the same blueprint has failed
	// and the creation of the current link has been rolled back.
	LinkStatusCreateRollbackComplete
	// LinkStatusDestroying is used when
	// a link is in the process of being destroyed.
	LinkStatusDestroying
	// LinkStatusDestroyed is used when
	// a link has been destroyed.
	LinkStatusDestroyed
	// LinkStatusDestroyFailed is used when
	// the destruction of a link fails.
	LinkStatusDestroyFailed
	// LinkStatusDestroyRollingBack is used when
	// another change in the same blueprint has failed
	// and the removal of the current link is being rolled back.
	LinkStatusDestroyRollingBack
	// LinkStatusDestroyRollbackFailed is used when
	// another resource change in the same blueprint has failed
	// and the removal of the current link could not be rolled back.
	LinkStatusDestroyRollbackFailed
	// LinkStatusDestroyRollbackComplete is used when
	// another change in the same blueprint has failed
	// and the removal of the current link has been rolled back.
	LinkStatusDestroyRollbackComplete
	// LinkStatusUpdating is used when
	// a link is being updated.
	LinkStatusUpdating
	// LinkStatusUpdated is used when a link
	// has been sucessfully updated.
	LinkStatusUpdated
	// LinkStatusUpdateFailed is used when a link
	// has failed to update.
	LinkStatusUpdateFailed
	// LinkStatusUpdateRollingBack is used when
	// another change in the same blueprint has failed
	// and the latest changes made to
	// the current link are being rolled back.
	LinkStatusUpdateRollingBack
	// LinkStatusUpdateRollbackFailed is used when
	// another resource change in the same blueprint has failed
	// and the latest changes made to
	// the current link could not be rolled back.
	LinkStatusUpdateRollbackFailed
	// LinkStatusUpdateRollbackComplete is used when
	// another change in the same blueprint has failed
	// and the latest changes made to
	// the current link have been rolled back.
	LinkStatusUpdateRollbackComplete
)

type LogField

type LogField struct {
	Type      LogFieldType
	Key       string
	String    string
	Integer   int64
	Float     float64
	Bool      bool
	Err       error
	Interface interface{}
}

LogField represents a key-value pair that can be used to add additional context to a log message. This supports log fields that are strings, integers, floats, booleans, errors or arrays of the above types. Nested structures are not supported, but can be flattened into a a set of top-level fields or serialised into a string that can be included as a single field.

func BoolLogField

func BoolLogField(key string, value bool) LogField

BoolLogField creates a new log field with a boolean value that can be used to add additional context to a log message.

func BoolsLogField

func BoolsLogField(key string, values []bool) LogField

BoolsLogField creates a new log field with an array of boolean values that can be used to add additional context to a log message.

func ErrorLogField

func ErrorLogField(key string, value error) LogField

ErrorLogField creates a new log field with an error value that can be used to add additional context to a log message.

func ErrorsLogField

func ErrorsLogField(key string, values []error) LogField

ErrorsLogField creates a new log field with an array of error values that can be used to add additional context to a log message.

func FloatLogField

func FloatLogField(key string, value float64) LogField

FloatLogField creates a new log field with a float value that can be used to add additional context to a log message.

func FloatsLogField

func FloatsLogField(key string, values []float64) LogField

FloatsLogField creates a new log field with an array of float values that can be used to add additional context to a log message.

func IntegerLogField

func IntegerLogField(key string, value int64) LogField

IntegerLogField creates a new log field with an integer value that can be used to add additional context to a log message.

func IntegersLogField

func IntegersLogField(key string, values []int64) LogField

IntegersLogField creates a new log field with an array of integer values that can be used to add additional context to a log message.

func StringLogField

func StringLogField(key, value string) LogField

StringLogField creates a new log field with a string value that can be used to add additional context to a log message.

func StringsLogField

func StringsLogField(key string, values []string) LogField

StringsLogField creates a new log field with an array of string values that can be used to add additional context to a log message.

type LogFieldType

type LogFieldType int

LogFieldType represents the type of a log field that is used to determine which value to use when serialising the field to a log message.

const (
	// StringLogFieldType represents a log field with a string value.
	StringLogFieldType LogFieldType = iota
	// IntegerLogFieldType represents a log field with an integer value.
	IntegerLogFieldType
	// FloatLogFieldType represents a log field with a float value.
	FloatLogFieldType
	// BoolLogFieldType represents a log field with a boolean value.
	BoolLogFieldType
	// ErrorLogFieldType represents a log field with an error value.
	ErrorLogFieldType
	// StringsLogFieldType represents a log field with an array of string values.
	StringsLogFieldType
	// IntegersLogFieldType represents a log field with an array of integer values.
	IntegersLogFieldType
	// FloatsLogFieldType represents a log field with an array of float values.
	FloatsLogFieldType
	// BoolsLogFieldType represents a log field with an array of boolean values.
	BoolsLogFieldType
	// ErrorsLogFieldType represents a log field with an array of error values.
	ErrorsLogFieldType
)

type Logger

type Logger interface {
	// Info logs a message at the info level.
	// This message includes any fields passed into the log call,
	// as well as any fields that have been added to the logger.
	Info(msg string, fields ...LogField)
	// Debug logs a message at the debug level.
	// This message includes any fields passed into the log call,
	// as well as any fields that have been added to the logger.
	Debug(msg string, fields ...LogField)
	// Warn logs a message at the warn level.
	// This message includes any fields passed into the log call,
	// as well as any fields that have been added to the logger.
	Warn(msg string, fields ...LogField)
	// Error logs a message at the error level.
	// This message includes any fields passed into the log call,
	// as well as any fields that have been added to the logger.
	Error(msg string, fields ...LogField)
	// Fatal logs a message at the fatal level.
	// This message includes any fields passed into the log call,
	// as well as any fields that have been added to the logger.
	// After logging the message, the application will exit with
	// a non-zero exit code.
	Fatal(msg string, fields ...LogField)
	// WithFields returns a new logger enrich with the specified
	// fields that will be included in all log messages for the
	// returned logger.
	WithFields(fields ...LogField) Logger
	// Named returns a new logger with the specified name that will
	// be included in all log messages for the returned logger.
	// Multiple nested names will be join with a period.
	// Names are useful as they can be used to filter logs to only surface
	// logs from a specific section of functionality.
	// (e.g. "parent" -> "child" -> "grandchild" would be "parent.child.grandchild")
	Named(name string) Logger
}

Logger provides a common interface for logging used throughout the blueprint framework and layers built on top of it.

func NewLoggerFromZap

func NewLoggerFromZap(zapLogger *zap.Logger) Logger

NewLoggerFromZap creates a new instance of a blueprint framework logger that is backed by a zap logger.

func NewNopLogger

func NewNopLogger() Logger

NewNopLogger creates a new instance of the no-op logger that will do nothing when log messages are sent to it.

type MappingNode

type MappingNode struct {
	// Scalar represents a scalar value in a mapping node.
	// This could be an integer, string, boolean or a floating point number.
	Scalar *ScalarValue
	// Fields represents a map of field names to child mapping nodes.
	Fields map[string]*MappingNode
	// Items represents a slice of child mapping nodes.
	Items []*MappingNode
	// StringWithSubstitutions is a slice of strings and substitutions
	// where substitutions are a representation of placeholders for variables,
	// resource properties, data source properties and child blueprint properties
	// or function calls contained within ${..}.
	StringWithSubstitutions *substitutions.StringOrSubstitutions
	// SourceMeta is the source metadata for the mapping node,
	// this is optional and may or may not be set depending on the context
	// and the source blueprint.
	SourceMeta *source.Meta
	// FieldsSourceMeta is a map of field names to source metadata
	// used to store the source location of fields in the original source.
	// This is optional and may or may not be set depending on the context
	// and the source blueprint.
	FieldsSourceMeta map[string]*source.Meta
}

MappingNode provides a tree structure for user-defined resource specs or metadata mappings.

This is used to allow creators of resource providers to define custom specifications while supporting ${..} placeholder substitution as a first class member of the primary representation of the spec. The initial intention was to allow the definition of custom native structs for resource specs, but this was abandoned in favour of a structure that will make placeholder substitution easier to deal with for the framework.

This is also used to provide a tree structure for metadata mappings to facilitate substitutions at all levels of nesting in user-provided metadata.

A mapping node can be used to store data for resources, links and data sources along with storing the output of a ${..} substitution.

func CopyMappingNode

func CopyMappingNode(node *MappingNode) *MappingNode

CopyMappingNode produces a deep copy of the provided mapping node. This does not copy StringWithSubstitutions, this should only be used for mapping nodes for which all values have been resolved and substituted.

func GetPathValue

func GetPathValue(path string, node *MappingNode, maxTraverseDepth int) (*MappingNode, error)

GetPathValue retrieves a value from a MappingNode using a path. This will return an error if the provided path is invalid and will return a nil MappingNode if the path does not exist in the given node.

A path supports the following acessors:

- "." for fields - "[\"<field>\"]" for fields with special characters - "[<index>]" for array items

"$" represents the root of the path and must always be the first character in the path.

Example:

core.GetPathValue("$[\"cluster.v1\"].config.endpoints[0]", node, 3)

func MappingNodeFromBool

func MappingNodeFromBool(value bool) *MappingNode

MappingNodeFromBool creates a MappingNode from a boolean value.

func MappingNodeFromBoolMap

func MappingNodeFromBoolMap(values map[string]bool) *MappingNode

MappingNodeFromBoolMap creates a MappingNode from a map of string keys to boolean values.

func MappingNodeFromBoolSlice

func MappingNodeFromBoolSlice(values []bool) *MappingNode

MappingNodeFromBoolSlice creates a MappingNode from a slice of booleans.

func MappingNodeFromFloat

func MappingNodeFromFloat(value float64) *MappingNode

MappingNodeFromFloat creates a MappingNode from a float value.

func MappingNodeFromFloatMap

func MappingNodeFromFloatMap(values map[string]float64) *MappingNode

MappingNodeFromFloatMap creates a MappingNode from a map of string keys to float values.

func MappingNodeFromFloatSlice

func MappingNodeFromFloatSlice(values []float64) *MappingNode

MappingNodeFromFloatSlice creates a MappingNode from a slice of floats.

func MappingNodeFromInt

func MappingNodeFromInt(value int) *MappingNode

MappingNodeFromInt creates a MappingNode from an integer value.

func MappingNodeFromIntMap

func MappingNodeFromIntMap(values map[string]int64) *MappingNode

MappingNodeFromIntMap creates a MappingNode from a map of string keys to integer values.

func MappingNodeFromIntSlice

func MappingNodeFromIntSlice(values []int64) *MappingNode

MappingNodeFromIntSlice creates a MappingNode from a slice of integers.

func MappingNodeFromString

func MappingNodeFromString(value string) *MappingNode

MappingNodeFromString creates a MappingNode from a string value.

func MappingNodeFromStringMap

func MappingNodeFromStringMap(values map[string]string) *MappingNode

MappingNodeFromStringMap creates a MappingNode from a map of string keys to string values.

func MappingNodeFromStringSlice

func MappingNodeFromStringSlice(values []string) *MappingNode

MappingNodeFromStringSlice creates a MappingNode from a slice of strings.

func MergeMaps

func MergeMaps(nodes ...*MappingNode) *MappingNode

MergeMaps merges multiple mapping nodes that represent a map of fields to values into a single mapping node.

func ParseScalarMappingNode

func ParseScalarMappingNode(source string) *MappingNode

ParseScalarMappingNode parses a scalar mapping node (string, boolean, integer, or float) from a source string.

func (*MappingNode) FromJSONNode

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

func (*MappingNode) MarshalJSON

func (m *MappingNode) MarshalJSON() ([]byte, error)

MarshalJSON fulfils the json.Marshaler interface to marshal a blueprint mapping node into a JSON representation.

func (*MappingNode) MarshalYAML

func (m *MappingNode) MarshalYAML() (any, error)

MarshalYAML fulfils the yaml.Marshaler interface to marshal a mapping node into a YAML representation.

func (*MappingNode) UnmarshalJSON

func (m *MappingNode) UnmarshalJSON(data []byte) error

UnmarshalJSON fulfils the json.Unmarshaler interface to unmarshal a serialised blueprint mapping node.

func (*MappingNode) UnmarshalYAML

func (m *MappingNode) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML fulfils the yaml.Unmarshaler interface to unmarshal a YAML representation into a mapping node.

type MappingPathError

type MappingPathError struct {
	ReasonCode ErrorCoreReasonCode
	Path       string
	Err        error
}

Error represents an error due to an issue with a path to access a value from a MappingNode.

func (*MappingPathError) Error

func (e *MappingPathError) Error() string

type NanoIDGenerator

type NanoIDGenerator struct{}

NanoIDGenerator is an ID generator that produces nano IDs.

func (*NanoIDGenerator) GenerateID

func (n *NanoIDGenerator) GenerateID() (string, error)

GenerateID generates a NanoID.

type NopLogger

type NopLogger struct{}

NopLogger is an implementation of the core.Logger interface that does nothing when log messages are sent to it.

func (*NopLogger) Debug

func (l *NopLogger) Debug(msg string, fields ...LogField)

func (*NopLogger) Error

func (l *NopLogger) Error(msg string, fields ...LogField)

func (*NopLogger) Fatal

func (l *NopLogger) Fatal(msg string, fields ...LogField)

func (*NopLogger) Info

func (l *NopLogger) Info(msg string, fields ...LogField)

func (*NopLogger) Named

func (l *NopLogger) Named(name string) Logger

func (*NopLogger) Warn

func (l *NopLogger) Warn(msg string, fields ...LogField)

func (*NopLogger) WithFields

func (l *NopLogger) WithFields(fields ...LogField) Logger

type ParamsImpl

type ParamsImpl struct {
	ProviderConf       map[string]map[string]*ScalarValue
	TransformerConf    map[string]map[string]*ScalarValue
	ContextVariables   map[string]*ScalarValue
	BlueprintVariables map[string]*ScalarValue
}

ParamsImpl provides an implementation of the blueprint core.BlueprintParams interface to supply parameters when loading blueprint source files.

func (*ParamsImpl) AllBlueprintVariables

func (p *ParamsImpl) AllBlueprintVariables() map[string]*ScalarValue

func (*ParamsImpl) AllContextVariables

func (p *ParamsImpl) AllContextVariables() map[string]*ScalarValue

func (*ParamsImpl) AllProvidersConfig

func (p *ParamsImpl) AllProvidersConfig() map[string]map[string]*ScalarValue

func (*ParamsImpl) AllTransformersConfig

func (p *ParamsImpl) AllTransformersConfig() map[string]map[string]*ScalarValue

func (*ParamsImpl) BlueprintVariable

func (p *ParamsImpl) BlueprintVariable(name string) *ScalarValue

func (*ParamsImpl) ContextVariable

func (p *ParamsImpl) ContextVariable(name string) *ScalarValue

func (*ParamsImpl) ProviderConfig

func (p *ParamsImpl) ProviderConfig(namespace string) map[string]*ScalarValue

func (*ParamsImpl) TransformerConfig

func (p *ParamsImpl) TransformerConfig(namespace string) map[string]*ScalarValue

func (*ParamsImpl) WithBlueprintVariables

func (b *ParamsImpl) WithBlueprintVariables(
	vars map[string]*ScalarValue,
	keepExisting bool,
) BlueprintParams

func (*ParamsImpl) WithContextVariables

func (b *ParamsImpl) WithContextVariables(
	vars map[string]*ScalarValue,
	keepExisting bool,
) BlueprintParams

type PluginConfig

type PluginConfig map[string]*ScalarValue

PluginConfig is a convenience type that wraps a map of string keys to scalar values holding the configuration for a provider or transformer plugin. This enhances a map to allow for convenience methods such as retrieving all config values under a specific prefix or deriving a slice or map from a key prefix.

func (PluginConfig) Get

func (c PluginConfig) Get(key string) (*ScalarValue, bool)

Get retrieves a configuration value by its key. It returns the value and a boolean indicating whether the key exists in the config.

func (PluginConfig) GetAllWithMapPrefix

func (c PluginConfig) GetAllWithMapPrefix(prefix string) PluginConfig

GetAllWithMapPrefix returns a subset of the PluginConfig that contains all keys that match the pattern "<prefix>.<string>". This is useful for retrieving configuration values that represent a map of objects or lists.

func (PluginConfig) GetAllWithPrefix

func (c PluginConfig) GetAllWithPrefix(prefix string) PluginConfig

GetAllWithPrefix returns a subset of the PluginConfig that contains all keys that start with the specified prefix.

func (PluginConfig) GetAllWithSlicePrefix

func (c PluginConfig) GetAllWithSlicePrefix(prefix string) (PluginConfig, []string)

GetAllWithSlicePrefix returns a subset of the PluginConfig that contains all keys that match the pattern "<prefix>.<integer>". This is useful for retrieving configuration values that represent a list of objects or lists. For example, if the prefix is "aws.config.regionKMSKeys", it will return all values with a key that match the pattern "^aws\.config\.regionKMSKeys\.[0-9]+\.?.*". The second return value is a slice of the keys in order based on the matching index.

func (PluginConfig) MapFromPrefix

func (c PluginConfig) MapFromPrefix(prefix string) PluginConfig

MapFromPrefix returns a map of all configuration values that start with the specified prefix where the prefix is followed by ".<string>". For example, if the prefix is "aws.config.regionKMSKeys", it will return all values with a key that match the pattern "^aws\.config\.regionKMSKeys\.[A-Za-z0-9\-_]+$".

func (PluginConfig) SliceFromPrefix

func (c PluginConfig) SliceFromPrefix(prefix string) []*ScalarValue

SliceFromPrefix returns a slice of all configuration values that start with the specified prefix where the prefix is followed by ".<integer>". For example, if the prefix is "aws.config.regionKMSKeys", it will return all values with a key that match the pattern "^aws\.config\.regionKMSKeys\.[0-9]+$". This only works for keys that represent a list of scalar values, not for nested maps or lists, for nested structures, you can use GetAllWithSlicePrefix to retrieve a subset of config values with a specific array prefix.

type PreciseLinkStatus

type PreciseLinkStatus int

PreciseLinkStatus is used to represent a more precise current state of a link in a blueprint instance.

const (
	// PreciseLinkStatusUnknown is used when we can't
	// determine an accurate status for a link.
	PreciseLinkStatusUnknown PreciseLinkStatus = iota
	// PreciseLinkStatusUpdatingResourceA is used when
	// the configuration for a link is being applied to resource A
	// in the link.
	PreciseLinkStatusUpdatingResourceA
	// PreciseLinkStatusResourceAUpdated is used when
	// the configuration for a link has been applied to resource A
	// in the link.
	PreciseLinkStatusResourceAUpdated
	// PreciseLinkStatusResourceAUpdateFailed is used when
	// the configuration for a link has failed to be applied to resource A
	// in the link.
	PreciseLinkStatusResourceAUpdateFailed
	// PreciseLinkStatusResourceAUpdateRollingBack is used when
	// another change in the same blueprint has failed
	// and the current link for which resource A was successfully
	// updated is being rolled back.
	PreciseLinkStatusResourceAUpdateRollingBack
	// PreciseLinkStatusResourceAUpdateRollbackFailed is used when
	// another change in the same blueprint has failed
	// and the current link for which resource A was successfully
	// updated failed to be rolled back.
	PreciseLinkStatusResourceAUpdateRollbackFailed
	// PreciseLinkStatusResourceAUpdateRollbackComplete is used when
	// another change in the same blueprint has failed
	// and the current link for which resource A was succsefully updated
	// has been rolled back.
	PreciseLinkStatusResourceAUpdateRollbackComplete
	// PreciseLinkStatusUpdatingResourceB is used when
	// the configuration for a link is being applied to resource B
	// in the link.
	PreciseLinkStatusUpdatingResourceB
	// PreciseLinkStatusResourceBUpdated is used when
	// the configuration for a link has been applied to resource B
	// in the link.
	PreciseLinkStatusResourceBUpdated
	// PreciseLinkStatusResourceBUpdateFailed is used when
	// the configuration for a link has failed to be applied to resource B
	// in the link.
	PreciseLinkStatusResourceBUpdateFailed
	// PreciseLinkStatusResourceBUpdateRollingBack is used when
	// another change in the same blueprint has failed
	// and the current link for which resource B was successfully
	// updated is being rolled back.
	PreciseLinkStatusResourceBUpdateRollingBack
	// PreciseLinkStatusResourceBUpdateRollbackFailed is used when
	// another change in the same blueprint has failed
	// and the current link for which resource B was successfully
	// updated failed to be rolled back.
	PreciseLinkStatusResourceBUpdateRollbackFailed
	// PreciseLinkStatusResourceBUpdateRollbackComplete is used when
	// another change in the same blueprint has failed
	// and the current link for which resource B was succsefully updated
	// has been rolled back.
	PreciseLinkStatusResourceBUpdateRollbackComplete
	// PreciseLinkStatusUpdatingIntermediaryResources is used when
	// intermediary resources are being created, updated or destroyed.
	// This status is a high level indication of progress,
	// the status of each intermediary resource should be checked
	// to determine the exact state of each intermediary resource
	// in the link.
	PreciseLinkStatusUpdatingIntermediaryResources
	// PreciseLinkStatusIntermediaryResourcesUpdated is used when
	// all intermediary resources have been successfully updated,
	// created or destroyed.
	PreciseLinkStatusIntermediaryResourcesUpdated
	// PreciseLinkStatusIntermediaryResourceUpdateFailed is used when
	// an intermediary resource has failed to be updated, created or destroyed.
	PreciseLinkStatusIntermediaryResourceUpdateFailed
	// PreciseLinkStatusIntermediaryResourceUpdateRollingBack is used when
	// another change in the same blueprint has failed
	// and the current link for which intermediary resources were successfully
	// updated is being rolled back.
	PreciseLinkStatusIntermediaryResourceUpdateRollingBack
	// PreciseLinkStatusIntermediaryResourceUpdateRollbackFailed is used when
	// another change in the same blueprint has failed
	// and the current link for which intermediary resources were successfully
	// updated failed to be rolled back.
	PreciseLinkStatusIntermediaryResourceUpdateRollbackFailed
	// PreciseLinkStatusIntermediaryResourceUpdateRollbackComplete is used when
	// another change in the same blueprint has failed
	// and the current link for which intermediary resources were succsefully updated
	// has been rolled back.
	PreciseLinkStatusIntermediaryResourceUpdateRollbackComplete
)

type PreciseResourceStatus

type PreciseResourceStatus int

PreciseResourceStatus is used to represent a more precise current state of a resource in a blueprint instance. This is used to allow the container "engine" to be more efficient in deploying a blueprint, by avoiding blocking on resource finalisation that isn't always needed to be able to successfully deploy the resources that are dependent on the resource in question.

const (
	// PreciseResourceStatusUnknown is used when we can't
	// determine an accurate status for a resource.
	PreciseResourceStatusUnknown PreciseResourceStatus = iota
	// PreciseResourceStatusCreating is used when
	// an initial resource deployment is currently in progress.
	PreciseResourceStatusCreating
	// PreciseResourceStatusConfigComplete is used when
	// a resource has been configured successfully.
	// What this means is that the resource has been created
	// but is not yet in a stable state.
	// For example, an application in a container orchestration service
	// has been created but is not yet up and running.
	PreciseResourceStatusConfigComplete
	// ResourceStatusCreated is used when
	// a resource has been deployed
	// successfully.
	// This is used when a resource is in a stable state.
	PreciseResourceStatusCreated
	// ResourceStatusCreateFailed is used when
	// the first creation of a resource failed.
	PreciseResourceStatusCreateFailed
	// PreciseResourceStatusCreateRollingBack is used when
	// another change in the same blueprint has failed
	// and the current resource that was successfully
	// created is being rolled back.
	PreciseResourceStatusCreateRollingBack
	// PreciseResourceStatusCreateRollbackFailed is used when
	// another change in the same blueprint has failed
	// and the current resource that was successfully
	// created could not be rolled back.
	PreciseResourceStatusCreateRollbackFailed
	// PreciseResourceStatusCreateRollbackComplete is used when
	// another change in the same blueprint has failed
	// and the current resource that was successfully
	// created has been rolled back.
	PreciseResourceStatusCreateRollbackComplete
	// ResourceStatusDestroying is used when
	// a resource is in the process of being destroyed.
	PreciseResourceStatusDestroying
	// ResourceStatusDestroyed is used when
	// a resource has been destroyed.
	PreciseResourceStatusDestroyed
	// ResourceStatusDestroyFailed is used when
	// the destruction of a resource fails.
	PreciseResourceStatusDestroyFailed
	// PreciseResourceStatusDestroyRollingBack is used when
	// another change in the same blueprint has failed
	// and the current resource that was successfully
	// removed is being rolled back.
	// This involves recreating the resource from the previous state.
	PreciseResourceStatusDestroyRollingBack
	// PreciseResourceStatusDestroyRollbackFailed is used when
	// another change in the same blueprint has failed
	// and the current resource that was successfully
	// removed could not be rolled back (recreated).
	PreciseResourceStatusDestroyRollbackFailed
	// PreciseResourceStatusDestroyRollbackConfigComplete is used when
	// another change in the same blueprint has failed
	// and the current resource that was successfully
	// removed has been rolled back (recreated)
	// but is not yet in a stable state.
	PreciseResourceStatusDestroyRollbackConfigComplete
	// PreciseResourceStatusDestroyRollbackComplete is used when
	// another change in the same blueprint has failed
	// and the current resource that was successfully
	// removed has been rolled back (recreated).
	PreciseResourceStatusDestroyRollbackComplete
	// ResourceStatusUpdating is used when
	// a resource is being updated.
	PreciseResourceStatusUpdating
	// PreciseResourceStatusUpdateConfigComplete is used when
	// a resource being updated has been configured successfully.
	// What this means is that the resource has been updated
	// but is not yet in a stable state.
	// For example, an application in a container orchestration service
	// has been updated but the new version is not yet up and running.
	PreciseResourceStatusUpdateConfigComplete
	// ResourceStatusUpdated is used when a resource
	// has been sucessfully updated.
	PreciseResourceStatusUpdated
	// ResourceStatusUpdateFailed is used when a resource
	// has failed to update.
	PreciseResourceStatusUpdateFailed
	// PreciseResourceStatusUpdateRollingBack is used when
	// another change in the same blueprint has failed
	// and the current resource that was successfully
	// updated is being rolled back to the previous state.
	PreciseResourceStatusUpdateRollingBack
	// PreciseResourceStatusUpdateRollbackFailed is used when
	// another change in the same blueprint has failed
	// and the current resource that was successfully
	// updated could not be rolled back.
	PreciseResourceStatusUpdateRollbackFailed
	// PreciseResourceStatusUpdateRollbackConfigComplete is used when
	// another change in the same blueprint has failed
	// and the current resource that was successfully
	// updated has been rolled back to the previous state
	// but is not yet in a stable state.
	PreciseResourceStatusUpdateRollbackConfigComplete
	// PreciseResourceStatusUpdateRollbackComplete is used when
	// another change in the same blueprint has failed
	// and the current resource that was successfully
	// updated has been rolled back to the previous state.
	PreciseResourceStatusUpdateRollbackComplete
)

type ResourceStatus

type ResourceStatus int

ResourceStatus is used to represent the current state of a resource in a blueprint instance.

const (
	// ResourceStatusUnknown is used when we can't
	// determine an accurate status for a resource.
	ResourceStatusUnknown ResourceStatus = iota
	// ResourceStatusCreating is used when
	// an initial resource deployment is currently in progress.
	ResourceStatusCreating
	// ResourceStatusCreated is used when
	// a resource has been deployed
	// successfully.
	ResourceStatusCreated
	// ResourceStatusCreateFailed is used when
	// the first creation of a resource failed.
	ResourceStatusCreateFailed
	// ResourceStatusDestroying is used when
	// a resource is in the process of being destroyed.
	ResourceStatusDestroying
	// ResourceStatusDestroyed is used when
	// a resource has been destroyed.
	ResourceStatusDestroyed
	// ResourceStatusDestroyFailed is used when
	// the destruction of a resource fails.
	ResourceStatusDestroyFailed
	// ResourceStatusUpdating is used when
	// a resource is being updated.
	ResourceStatusUpdating
	// ResourceStatusUpdated is used when a resource
	// has been successfully updated.
	ResourceStatusUpdated
	// ResourceStatusUpdateFailed is used when a resource
	// has failed to update.
	ResourceStatusUpdateFailed
	// ResourceStatusRollingBack is used when
	// another change in the same blueprint has failed
	// and the latest change involving the current resource
	// is being rolled back.
	ResourceStatusRollingBack
	// ResourceStatusRollbackFailed is used when
	// another change in the same blueprint has failed
	// and the latest change involving the current resource
	// could not be rolled back.
	ResourceStatusRollbackFailed
	// ResourceStatusRollbackComplete is used when
	// another change in the same blueprint has failed
	// and the latest change involving the current resource
	// has been rolled back.
	ResourceStatusRollbackComplete
)

type ScalarType

type ScalarType string

ScalarType represents the type of a scalar value that can be used in annotation and configuration definitions.

const (
	// ScalarTypeString is the type of an element in a spec that is a string.
	ScalarTypeString ScalarType = "string"
	// ScalarTypeInteger is the type of an element in a spec that is an integer.
	ScalarTypeInteger ScalarType = "integer"
	// ScalarTypeFloat is the type of an element in a spec that is a float.
	ScalarTypeFloat ScalarType = "float"
	// ScalarTypeBool is the type of an element in a spec that is a boolean.
	ScalarTypeBool ScalarType = "boolean"
)

func TypeFromScalarValue

func TypeFromScalarValue(scalar *ScalarValue) ScalarType

TypeFromScalarValue returns the type of a scalar value as a ScalarType. If the scalar is nil, an empty string is returned.

type ScalarValue

type ScalarValue struct {
	IntValue    *int
	BoolValue   *bool
	FloatValue  *float64
	StringValue *string
	SourceMeta  *source.Meta
}

ScalarValue represents a scalar value in a blueprint specification. Pointers are used as empty values such as "", 0 and false are valid default values. When marshalling, only one value is expected to be set, if multiple values are provided for some reason the priority is as follows: 1. int 2. bool 3. float64 4. string

The reason strings are the lowest priority is because every other scalar type can be parsed as a string.

func ScalarFromBool

func ScalarFromBool(value bool) *ScalarValue

ScalarFromBool creates a scalar value from a boolean.

func ScalarFromFloat

func ScalarFromFloat(value float64) *ScalarValue

ScalarFromFloat creates a scalar value from a float.

func ScalarFromInt

func ScalarFromInt(value int) *ScalarValue

ScalarFromInt creates a scalar value from an integer.

func ScalarFromString

func ScalarFromString(value string) *ScalarValue

ScalarFromString creates a scalar value from a string.

func (*ScalarValue) Equal

func (v *ScalarValue) Equal(otherScalar *ScalarValue) bool

func (*ScalarValue) FromJSONNode

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

func (*ScalarValue) MarshalJSON

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

MarshalJSON fulfils the json.Marshaler interface to marshal a blueprint value into one of the supported scalar types.

func (*ScalarValue) MarshalYAML

func (v *ScalarValue) MarshalYAML() (any, error)

MarshalYAML fulfils the yaml.Marshaler interface to marshal a blueprint value into one of the supported scalar types.

func (*ScalarValue) ToString

func (v *ScalarValue) ToString() string

ToString returns the string representation of the scalar value that is useful for debugging and logging.

func (*ScalarValue) UnmarshalJSON

func (v *ScalarValue) UnmarshalJSON(data []byte) error

UnmarshalJSON fulfils the json.Unmarshaler interface to unmarshal a parsed blueprint value into one of the supported scalar types.

func (*ScalarValue) UnmarshalYAML

func (v *ScalarValue) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML fulfils the yaml.Unmarshaler interface to unmarshal a parsed blueprint value into one of the supported scalar types.

type SystemClock

type SystemClock struct{}

SystemClock is a Clock that returns the current time derived from the host system.

func (SystemClock) Now

func (d SystemClock) Now() time.Time

func (SystemClock) Since

func (d SystemClock) Since(t time.Time) time.Duration

type UUIDGenerator

type UUIDGenerator struct{}

UUIDGenerator is an ID generator that produces UUIDs.

func (*UUIDGenerator) GenerateID

func (u *UUIDGenerator) GenerateID() (string, error)

GenerateID generates a UUID v4.

Jump to

Keyboard shortcuts

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