Documentation
¶
Index ¶
- func IsExportNotFound(err error) bool
- func IsInstanceNotFound(err error) bool
- func IsInstancesNotFound(err error) bool
- func IsLinkNotFound(err error) bool
- func IsResourceNotFound(err error) bool
- type ChildBlueprint
- type ChildrenContainer
- type Container
- type DependencyInfo
- type Element
- type ElementKind
- type Error
- type ErrorCode
- type ExportState
- type ExportsContainer
- type InstanceCompletionDuration
- type InstanceState
- type InstanceStatusInfo
- type InstanceSummary
- type InstancesContainer
- type InstancesNotFoundError
- type IntermediaryDriftChanges
- type IntermediaryDriftState
- type IntermediaryFieldChange
- type LinkCompletionDurations
- type LinkComponentCompletionDurations
- type LinkDriftFieldChange
- type LinkDriftState
- type LinkIntermediaryResourceState
- type LinkResourceDrift
- type LinkState
- type LinkStatusInfo
- type LinksContainer
- type ListInstancesParams
- type ListInstancesResult
- type MetadataContainer
- type ProvenanceState
- type ResourceCompletionDurations
- type ResourceDriftChanges
- type ResourceDriftFieldChange
- type ResourceDriftState
- type ResourceMetadataState
- type ResourceState
- type ResourceStatusInfo
- type ResourcesContainer
- type SystemMetadataState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsExportNotFound ¶
IsExportNotFound is a helper function that checks if the provided error is an export not found error.
func IsInstanceNotFound ¶
IsInstanceNotFound is a helper function that checks if the provided error is an instance not found error.
func IsInstancesNotFound ¶ added in v0.38.0
IsInstancesNotFound checks if the provided error is an instances not found error.
func IsLinkNotFound ¶
IsLinkNotFound is a helper function that checks if the provided error is a link not found error.
func IsResourceNotFound ¶
IsResourceNotFound is a helper function that checks if the provided error is a resource not found error.
Types ¶
type ChildBlueprint ¶
type ChildBlueprint struct {
ChildName string `json:"childName"`
State *InstanceState `json:"state"`
}
ChildBlueprint holds the state of a child blueprint along with its logical name in the parent blueprint.
func WrapChildBlueprintInstance ¶
func WrapChildBlueprintInstance(childName string, instance *InstanceState) *ChildBlueprint
func (*ChildBlueprint) ID ¶
func (b *ChildBlueprint) ID() string
func (*ChildBlueprint) Kind ¶
func (b *ChildBlueprint) Kind() ElementKind
func (*ChildBlueprint) LogicalName ¶
func (b *ChildBlueprint) LogicalName() string
type ChildrenContainer ¶
type ChildrenContainer interface {
// Get deals with retrieving the state for a given child blueprint
// in the provided blueprint instance.
Get(ctx context.Context, instanceID string, childName string) (InstanceState, error)
// Attach a blueprint instance as a child of the specified parent instance.
// Both the parent and child blueprint instances must already exist.
Attach(
ctx context.Context,
parentInstanceID string,
childInstanceID string,
childName string,
) error
// SaveDependencies deals with persisting the dependencies of a child blueprint
// in relation to other elements in the parent blueprint instance.
SaveDependencies(
ctx context.Context,
instanceID string,
childName string,
dependencies *DependencyInfo,
) error
// Detach deals with removing the relationship between a child blueprint
// and its parent blueprint instance.
// This will not remove the child blueprint instance itself,
// instances.Remove should be used to completely remove the child blueprint instance.
Detach(ctx context.Context, instanceID string, childName string) error
}
ChildrenContainer provides an interface for functionality related to persisting and retrieving child blueprint state in relation to a parent blueprint instance.
type Container ¶
type Container interface {
// Instances provides functionality to manage state for blueprint instances.
Instances() InstancesContainer
// Resources provides functionality to manage state for resources in blueprint instances.
Resources() ResourcesContainer
// Links provides functionality to manage state for links in blueprint instances.
Links() LinksContainer
// Children provides functionality to manage state for child blueprints in relation
// to their parent blueprint instances.
Children() ChildrenContainer
// Metadata provides functionality to manage metadata for blueprint instances.
Metadata() MetadataContainer
// Exports provides functionality to manage exported fields for blueprint instances.
Exports() ExportsContainer
}
Container provides an interface for services that persist blueprint instance state. Various methods are provided to deal with extracting and saving information for a blueprint instance. Instead of operating at the instance level and manipulating the entire state, methods are provided to deal with sub-components of the instance state such as resources, links, metadata and exports. Depending on the implementation, it can be more efficient to deal with sub-components of the instance state separately. Fr example, `Instances().Get` may be a view of the instance state that could be an expensive operation to perform involving multiple queries to a database or an expensive join operation. The state persistence method is entirely up to the application making use of this library.
type DependencyInfo ¶
type DependencyInfo struct {
// DependsOnResources holds a list of resource IDs that the
// child blueprint or resource depends on.
DependsOnResources []string `json:"dependsOnResources,omitempty"`
// DependsOnChildren holds a list of child blueprint names that the
// child blueprint or resource depends on.
DependsOnChildren []string `json:"dependsOnChildren,omitempty"`
}
ChildDependencyInfo holds information about the dependencies of a child blueprint or resource.
type Element ¶
type Element interface {
ID() string
LogicalName() string
Kind() ElementKind
}
Element provides a convenience interface for elements in blueprint state to extract common information such as an ID, logical name and type.
type ElementKind ¶
type ElementKind string
ElementKind represents the kind of an element in a blueprint instance.
const ( // ChildElement represents a child blueprint in a blueprint instance. ChildElement ElementKind = "child" // ResourceElement represents a resource in a blueprint instance. ResourceElement ElementKind = "resource" // LinkElement represents a link in a blueprint instance. LinkElement ElementKind = "link" )
type Error ¶
Error is an error type that MUST be used by implementations of the state.Container interface to allow the engine to be able to distinguish between failures and expected errors such as resource not found.
func ExportNotFoundError ¶
ExportNotFoundError is a helper function that creates a new error for when an export can not be found for the given blueprint instance.
func InstanceNotFoundError ¶
InstanceNotFoundError is a helper function that creates a new error for when a blueprint instance can not be found in the persistence that backs a state container.
func LinkNotFoundError ¶
LinkNotFoundError is a helper function that creates a new error for when a link can not be found in the persistence that backs a state container.
func ResourceNotFoundError ¶
ResourceNotFoundError is a helper function that creates a new error for when a resource can not be found in the persistence that backs a state container.
type ErrorCode ¶
type ErrorCode string
const ( // ErrResourceNotFound is used when a resource could not be found // in a blueprint instance. ErrResourceNotFound ErrorCode = "resource_not_found" // ErrLinkNotFound is used when a link could not be found // in a blueprint instance. ErrLinkNotFound ErrorCode = "link_not_found" // ErrInstanceNotFound is used when a blueprint instance could not be found. ErrInstanceNotFound ErrorCode = "instance_not_found" // ErrExportNotFound is the error code that is used when // an export is not found in the state. ErrExportNotFound ErrorCode = "export_not_found" )
type ExportState ¶
type ExportState struct {
// Value holds the resolved exported value.
Value *core.MappingNode `json:"value"`
// Type holds the type of the exported value.
Type schema.ExportType `json:"type"`
// Description holds a human-friendly description of the export.
Description string `json:"description,omitempty"`
// Field holds the path of a field in a blueprint element
// that should be exported.
Field string `json:"field"`
}
ExportState holds state that is persisted for an export in a blueprint instance.
type ExportsContainer ¶
type ExportsContainer interface {
// GetAll deals with retrieving exported fields for a given blueprint instance.
GetAll(ctx context.Context, instanceID string) (map[string]*ExportState, error)
// Get deals with retrieving an exported field for a given blueprint instance.
Get(ctx context.Context, instanceID string, exportName string) (ExportState, error)
// SaveAll deals with persisting exported fields for a given blueprint instance.
SaveAll(ctx context.Context, instanceID string, exports map[string]*ExportState) error
// Save deals with persisting an exported field for a given blueprint instance.
Save(ctx context.Context, instanceID string, exportName string, export ExportState) error
// RemoveAll deals with removing all exported fields for a given blueprint instance.
RemoveAll(ctx context.Context, instanceID string) (map[string]*ExportState, error)
// Remove deals with removing an exported field for a given blueprint instance.
Remove(ctx context.Context, instanceID string, exportName string) (ExportState, error)
}
ExportsContainer provides an interface for functionality related to persisting and retrieving exported fields for a blueprint instance.
type InstanceCompletionDuration ¶
type InstanceCompletionDuration struct {
// PrepareDuration is the duration in milliseconds for the preparation phase
// of a blueprint instance deployment to be completed.
PrepareDuration *float64 `json:"prepareDuration,omitempty"`
// TotalDuration is the duration in milliseconds for the blueprint instance to reach the final
// status.
TotalDuration *float64 `json:"totalDuration,omitempty"`
}
InstanceCompletionDuration holds duration information for the deployment of a blueprint instance.
type InstanceState ¶
type InstanceState struct {
InstanceID string `json:"id"`
// InstanceName holds a user-defined globally unique name for the blueprint instance.
// In multi-tenant systems this expected to be prefixed by an account or organisation
// name or ID.
InstanceName string `json:"name"`
Status core.InstanceStatus `json:"status"`
// LastStatusUpdateTimestamp holds the unix timestamp when the blueprint instance deployment
// status was last updated.
LastStatusUpdateTimestamp int `json:"lastStatusUpdateTimestamp,omitempty"`
// LastDeployedTimestamp holds the unix timestamp when the blueprint instance was last deployed.
LastDeployedTimestamp int `json:"lastDeployedTimestamp"`
// LastDeployAttempTimestamp holds the unix timestamp when an attempt
// was last made to deploy the blueprint instance.
LastDeployAttemptTimestamp int `json:"lastDeployAttemptTimestamp"`
// A mapping of logical resource definition name
// to the resource IDs
// that are created from the resource definition.
ResourceIDs map[string]string `json:"resourceIds"`
// A mapping of resource IDs to the resource state.
Resources map[string]*ResourceState `json:"resources"`
// A mapping of logical link definition names
// to the state of each link in the blueprint instance.
Links map[string]*LinkState `json:"links"`
// Metadata is used internally to store additional non-structured information
// that is relevant to the blueprint framework but can also be used to store
// additional information that is relevant to the application/tool
// making use of the framework.
Metadata map[string]*core.MappingNode `json:"metadata"`
Exports map[string]*ExportState `json:"exports"`
ChildBlueprints map[string]*InstanceState `json:"childBlueprints"`
// ChildDependencies holds a mapping of child blueprint names to their dependencies.
ChildDependencies map[string]*DependencyInfo `json:"childDependencies,omitempty"`
// Durations holds duration information for the latest deployment of the blueprint instance.
Durations *InstanceCompletionDuration `json:"durations,omitempty"`
}
InstanceState stores the state of a blueprint instance including resources, metadata, exported fields and child blueprints.
type InstanceStatusInfo ¶
type InstanceStatusInfo struct {
Status core.InstanceStatus `json:"status"`
FailureReasons []string `json:"failureReasons,omitempty"`
LastDeployedTimestamp *int `json:"lastDeployedTimestamp,omitempty"`
LastDeployAttemptTimestamp *int `json:"lastDeployAttemptTimestamp,omitempty"`
LastStatusUpdateTimestamp *int `json:"lastStatusUpdateTimestamp,omitempty"`
Durations *InstanceCompletionDuration `json:"durations,omitempty"`
}
InstanceStatusInfo holds information about the status of a blueprint instance that is primarily used when updating the status of a blueprint instance.
type InstanceSummary ¶ added in v0.37.0
type InstanceSummary struct {
InstanceID string `json:"id"`
InstanceName string `json:"name"`
Status core.InstanceStatus `json:"status"`
LastDeployedTimestamp int64 `json:"lastDeployedTimestamp"`
}
InstanceSummary provides a lightweight summary of a blueprint instance for listing.
type InstancesContainer ¶
type InstancesContainer interface {
// Get deals with retrieving the state for a given blueprint
// instance ID.
Get(ctx context.Context, instanceID string) (InstanceState, error)
// LookupIDByName deals with retrieving the ID of a blueprint instance
// given a unique name.
// This is useful for situations where the user makes requests to carry
// out an action, only providing a name that they have defined.
// This exists to allow the majority of the deployment/change staging
// system to work based off of an instance ID
// while allowing the user to provide their own name to carry out an
// action on an instance.
LookupIDByName(ctx context.Context, instanceName string) (string, error)
// List retrieves blueprint instances with pagination and optional filtering.
// The search parameter filters instances whose names contain the search term (case-insensitive).
// Returns a paginated result with total count for UI pagination controls.
List(ctx context.Context, params ListInstancesParams) (ListInstancesResult, error)
// Save deals with persisting a blueprint instance.
Save(ctx context.Context, instanceState InstanceState) error
// SaveBatch deals with persisting multiple blueprint instances efficiently.
// This is optimized for bulk operations such as state import where many instances
// need to be saved at once. Implementations should use batch operations where possible.
SaveBatch(ctx context.Context, instances []InstanceState) error
// GetBatch retrieves multiple instances by their IDs or names efficiently.
// Each identifier can be either an instance ID or an instance name.
// Returns instances in the same order as the input identifiers.
// Returns an error if any instance is not found.
GetBatch(ctx context.Context, instanceIDsOrNames []string) ([]InstanceState, error)
// UpdateStatus deals with updating the status of the latest blueprint
// instance deployment.
UpdateStatus(
ctx context.Context,
instanceID string,
statusInfo InstanceStatusInfo,
) error
// Remove deals with removing the state for a given blueprint instance.
// This is not for destroying the actual deployed resources, just removing the state.
Remove(ctx context.Context, instanceID string) (InstanceState, error)
}
InstancesContainer provides an interface for functionality related to persisting and retrieving the top-level state of a blueprint instance.
type InstancesNotFoundError ¶ added in v0.38.0
type InstancesNotFoundError struct {
MissingIDsOrNames []string
}
InstancesNotFoundError represents an error when multiple instances could not be found by their IDs or names.
func NewInstancesNotFoundError ¶ added in v0.38.0
func NewInstancesNotFoundError(missingIDsOrNames []string) *InstancesNotFoundError
NewInstancesNotFoundError creates a new error for when multiple instances could not be found.
func (*InstancesNotFoundError) Error ¶ added in v0.38.0
func (e *InstancesNotFoundError) Error() string
type IntermediaryDriftChanges ¶ added in v0.37.0
type IntermediaryDriftChanges struct {
// ModifiedFields contains fields that exist in both states but have different values.
ModifiedFields []IntermediaryFieldChange `json:"modifiedFields,omitempty"`
// NewFields contains fields that exist in external state but not in persisted state.
NewFields []IntermediaryFieldChange `json:"newFields,omitempty"`
// RemovedFields contains fields that exist in persisted state but not in external state.
RemovedFields []IntermediaryFieldChange `json:"removedFields,omitempty"`
}
IntermediaryDriftChanges contains the field-level changes detected between persisted and external state for an intermediary resource.
type IntermediaryDriftState ¶ added in v0.37.0
type IntermediaryDriftState struct {
// ResourceID is the ID of the intermediary resource.
ResourceID string `json:"resourceId"`
// ResourceType is the type of the intermediary resource.
ResourceType string `json:"resourceType"`
// PersistedState is what we have in the state store.
PersistedState *core.MappingNode `json:"persistedState"`
// ExternalState is what was found in the cloud.
ExternalState *core.MappingNode `json:"externalState"`
// Changes contains the detailed diff between persisted and external state.
Changes *IntermediaryDriftChanges `json:"changes,omitempty"`
// Exists indicates whether the resource exists in the cloud.
Exists bool `json:"exists"`
// Timestamp holds the unix timestamp of when the drift was detected.
Timestamp *int `json:"timestamp,omitempty"`
}
IntermediaryDriftState contains drift information for an intermediary resource owned by a link.
type IntermediaryFieldChange ¶ added in v0.37.0
type IntermediaryFieldChange struct {
// FieldPath is the path to the field (e.g., "spec.policy.statements").
FieldPath string `json:"fieldPath"`
// PrevValue is the value in persisted state.
PrevValue *core.MappingNode `json:"prevValue,omitempty"`
// NewValue is the value in external state.
NewValue *core.MappingNode `json:"newValue,omitempty"`
}
IntermediaryFieldChange represents a single field change in an intermediary resource.
type LinkCompletionDurations ¶
type LinkCompletionDurations struct {
// ResourceAUpdate is the duration information for the update of resource A in the link.
// This will only be present if the link has reached resource A updated status.
ResourceAUpdate *LinkComponentCompletionDurations `json:"resourceAUpdate,omitempty"`
// ResourceBUpdate is the duration information for the update of resource B in the link.
// This will only be present if the link has reached resource B updated status.
ResourceBUpdate *LinkComponentCompletionDurations `json:"resourceBUpdate,omitempty"`
// IntermediaryResources is the duration information for the update, creation or removal
// of intermediary resources in the link.
// This will only be present if the link has reached intermediary resources updated status.
IntermediaryResources *LinkComponentCompletionDurations `json:"intermediaryResources,omitempty"`
// TotalDuration is the duration in milliseconds for the link change to reach the final
// status.
TotalDuration *float64 `json:"totalDuration,omitempty"`
}
LinkCompletionDurations holds duration information for the deployment of a link change.
type LinkComponentCompletionDurations ¶
type LinkComponentCompletionDurations struct {
// TotalDuration is the duration in milliseconds for the link component
// change to reach the final status.
TotalDuration *float64 `json:"totalDuration,omitempty"`
// AttemptDurations holds a list of durations in milliseconds
// for each attempt to deploy the link component.
// Attempt durations are in order as per the "Attempt" field in a status update message.
AttemptDurations []float64 `json:"attemptDurations,omitempty"`
}
type LinkDriftFieldChange ¶ added in v0.37.0
type LinkDriftFieldChange struct {
// ResourceFieldPath is the path in the resource spec (e.g., "spec.policy.statements").
ResourceFieldPath string `json:"resourceFieldPath"`
// LinkDataPath is the corresponding path in link.Data.
LinkDataPath string `json:"linkDataPath"`
// LinkDataValue is what the link has stored.
LinkDataValue *core.MappingNode `json:"linkDataValue"`
// ExternalValue is what was found in the cloud.
ExternalValue *core.MappingNode `json:"externalValue"`
}
LinkDriftFieldChange represents a change to a link-managed field on a resource. This is used when detecting drift via ResourceDataMappings.
type LinkDriftState ¶ added in v0.37.0
type LinkDriftState struct {
// LinkID is the unique identifier for the link.
LinkID string `json:"linkId"`
// LinkName is the logical name of the link (format: "{resourceA}::{resourceB}").
LinkName string `json:"linkName"`
// ResourceADrift contains drift detected in ResourceA fields managed by this link.
// These are fields specified in ResourceDataMappings that map to ResourceA.
ResourceADrift *LinkResourceDrift `json:"resourceADrift,omitempty"`
// ResourceBDrift contains drift detected in ResourceB fields managed by this link.
// These are fields specified in ResourceDataMappings that map to ResourceB.
ResourceBDrift *LinkResourceDrift `json:"resourceBDrift,omitempty"`
// IntermediaryDrift contains drift detected in intermediary resources
// owned by this link. Key is the intermediary resource ID.
IntermediaryDrift map[string]*IntermediaryDriftState `json:"intermediaryDrift,omitempty"`
// Timestamp holds the unix timestamp of when the drift was detected.
Timestamp *int `json:"timestamp,omitempty"`
}
LinkDriftState holds information about how a link has drifted from the current state persisted in the blueprint framework. Link drift is detected via ResourceDataMappings (comparing link.Data against resource external state) and intermediary resources (via GetIntermediaryExternalState on the link provider).
type LinkIntermediaryResourceState ¶
type LinkIntermediaryResourceState struct {
// A globally unique identifier for the resource.
ResourceID string `json:"id"`
ResourceType string `json:"type"`
InstanceID string `json:"instanceId"`
Status core.ResourceStatus `json:"status"`
PreciseStatus core.PreciseResourceStatus `json:"preciseStatus"`
// LastDeployedTimestamp holds the unix timestamp when the resource was last deployed.
LastDeployedTimestamp int `json:"lastDeployedTimestamp"`
// LastDeployAttempTimestamp holds the unix timestamp when an attempt was last made to deploy the resource.
LastDeployAttemptTimestamp int `json:"lastDeployAttemptTimestamp"`
// ResourceSpecData holds the resolved resource spec
// for the currently deployed version of the resource along with computed
// fields derived from the deployed resource in the provider.
ResourceSpecData *core.MappingNode `json:"resourceSpecData"`
FailureReasons []string `json:"failureReasons,omitempty"`
}
LinkIntermediaryResourceState holds information about the state of an intermediary resources created for a link.
type LinkResourceDrift ¶ added in v0.37.0
type LinkResourceDrift struct {
// ResourceID is the ID of the resource.
ResourceID string `json:"resourceId"`
// ResourceName is the logical name of the resource in the blueprint.
ResourceName string `json:"resourceName"`
// MappedFieldChanges contains changes to fields managed by this link.
// These are the fields specified in ResourceDataMappings.
MappedFieldChanges []*LinkDriftFieldChange `json:"mappedFieldChanges"`
}
LinkResourceDrift contains drift information for a linked resource's fields that are managed by a link via ResourceDataMappings.
type LinkState ¶
type LinkState struct {
// A globally unique identifier for the link.
LinkID string `json:"id"`
// The logical name of the link in the blueprint.
// This is a combination of the logical names of the 2 resources that are linked.
// For example, if a link is between a VPC and a subnet,
// the link name would be "vpc::subnet".
Name string `json:"name"`
InstanceID string `json:"instanceId"`
Status core.LinkStatus `json:"status"`
PreciseStatus core.PreciseLinkStatus `json:"preciseStatus"`
// LastStatusUpdateTimestamp holds the unix timestamp when the link deployment
// status was last updated.
LastStatusUpdateTimestamp int `json:"lastStatusUpdateTimestamp,omitempty"`
// LastDeployedTimestamp holds the unix timestamp when the link was last deployed.
LastDeployedTimestamp int `json:"lastDeployedTimestamp"`
// LastDeployAttempTimestamp holds the unix timestamp when an attempt was last made to deploy the link.
LastDeployAttemptTimestamp int `json:"lastDeployAttemptTimestamp"`
// IntermediaryResourceStates holds the state of intermediary resources
// that are created by the provider's implementation of a link.
IntermediaryResourceStates []*LinkIntermediaryResourceState `json:"intermediaryResourceStates"`
// Data is the map that holds the structure of
// the "raw" link data to hold information about a link that is not
// stored directly in the resources that are linked and is not
// stored in intermediary resources.
// This should hold information that may include values that are populated
// in one or both of the resources in the link relationship along with
// intermediary resources.
Data map[string]*core.MappingNode `json:"data"`
// ResourceDataMappings provides mappings of resource spec fields
// to the link data fields created when updating intermediary resources
// in a link relationship.
// The format is:
// {resourceName}::{fieldPath} -> {linkDataFieldPath}
// e.g. "orderServiceRole::spec.policy.name" -> "orderServiceRole.policy"
// This is useful for applying link data projections to resources to take
// link changes into account when checking for drift.
//
// {resourceName} represents the logical name of the resource in single blueprint instance.
ResourceDataMappings map[string]string `json:"resourceDataMappings,omitempty"`
// Holds the latest reasons for failures in deploying a link,
// this only ever holds the results of the latest deployment attempt.
FailureReasons []string `json:"failureReasons"`
// Drifted indicates whether or not the link state has drifted
// due to changes in the upstream provider. This includes drift in
// resource fields managed via ResourceDataMappings and intermediary resources.
Drifted bool `json:"drifted,omitempty"`
// LastDriftDetectedTimestamp holds the unix timestamp when drift was last detected.
LastDriftDetectedTimestamp *int `json:"lastDriftDetectedTimestamp,omitempty"`
// Durations holds duration information for the latest deployment of the link.
Durations *LinkCompletionDurations `json:"durations,omitempty"`
}
LinkState provides a way to store some state for links between resources. This is useful for holding state about intermediary resources managed by a provider's implementation of a link in addition to tracking the deployment status for a link.
func (*LinkState) Kind ¶
func (l *LinkState) Kind() ElementKind
func (*LinkState) LogicalName ¶
type LinkStatusInfo ¶
type LinkStatusInfo struct {
Status core.LinkStatus `json:"status"`
PreciseStatus core.PreciseLinkStatus `json:"preciseStatus"`
LastDeployedTimestamp *int `json:"lastDeployedTimestamp,omitempty"`
LastDeployAttemptTimestamp *int `json:"lastDeployAttemptTimestamp,omitempty"`
LastStatusUpdateTimestamp *int `json:"lastStatusUpdateTimestamp,omitempty"`
Durations *LinkCompletionDurations `json:"durations,omitempty"`
FailureReasons []string `json:"failureReasons,omitempty"`
}
LinkStatusInfo holds information about the status of a link that is primarily used when updating the status of a link.
type LinksContainer ¶
type LinksContainer interface {
// Get deals with retrieving the link state for a given globally unique
// link ID.
Get(ctx context.Context, linkID string) (LinkState, error)
// GetByName deals with retrieving the state for a given link
// in the provided blueprint instance by its logical name ({resourceA}::{resourceB}).
GetByName(ctx context.Context, instanceID string, linkName string) (LinkState, error)
// ListWithResourceDataMappings deals with retrieving all links in a given blueprint instance
// that have resource data mappings that map to a spec field in the resource with the given
// name in the blueprint instance.
ListWithResourceDataMappings(
ctx context.Context,
instanceID string,
resourceName string,
) ([]LinkState, error)
// Save deals with persisting a link in the system and attaching it to the blueprint instance
// for the instance ID in the provided link state structure.
Save(ctx context.Context, linkState LinkState) error
// UpdateStatus deals with updating the status of the latest deployment of a given link.
UpdateStatus(
ctx context.Context,
linkID string,
statusInfo LinkStatusInfo,
) error
// Remove deals with removing the state of a link from
// the system
Remove(ctx context.Context, linkID string) (LinkState, error)
// GetDrift deals with retrieving the current drift state for a given link.
GetDrift(ctx context.Context, linkID string) (LinkDriftState, error)
// SaveDrift deals with persisting the drift state for a given link.
SaveDrift(ctx context.Context, driftState LinkDriftState) error
// RemoveDrift deals with removing the drift state for a given link.
RemoveDrift(ctx context.Context, linkID string) (LinkDriftState, error)
}
LinksContainer provides an interface for functionality related to persisting and retrieving link state in a blueprint instance.
type ListInstancesParams ¶ added in v0.37.0
type ListInstancesParams struct {
// Search filters instances by name (case-insensitive substring match).
Search string
// Offset is the number of items to skip for pagination.
Offset int
// Limit is the maximum number of items to return (0 = no limit).
Limit int
}
ListInstancesParams holds parameters for listing blueprint instances.
type ListInstancesResult ¶ added in v0.37.0
type ListInstancesResult struct {
// Instances contains the list of instance summaries for the current page.
Instances []InstanceSummary `json:"instances"`
// TotalCount is the total number of matching instances before pagination.
TotalCount int `json:"totalCount"`
}
ListInstancesResult holds the result of listing blueprint instances.
type MetadataContainer ¶
type MetadataContainer interface {
// Get deals with retrieving metadata for a given blueprint instance.
Get(ctx context.Context, instanceID string) (map[string]*core.MappingNode, error)
// Save deals with persisting metadata for a given blueprint instance.
Save(ctx context.Context, instanceID string, metadata map[string]*core.MappingNode) error
// Remove deals with removing metadata from a given blueprint instance.
Remove(ctx context.Context, instanceID string) (map[string]*core.MappingNode, error)
}
MetadataContainer provides an interface for functionality related to persisting and retrieving metadata for a blueprint instance.
type ProvenanceState ¶ added in v0.37.0
type ProvenanceState struct {
// ProvisionedBy is a marker indicating the resource was provisioned by Bluelink.
ProvisionedBy string `json:"provisionedBy"`
// DeployEngineVersion is the version of the deploy engine used.
DeployEngineVersion string `json:"deployEngineVersion"`
// ProviderPluginID is the identifier for the provider plugin (e.g., "newstack-cloud/aws").
ProviderPluginID string `json:"providerPluginId"`
// ProviderPluginVersion is the version of the provider plugin.
ProviderPluginVersion string `json:"providerPluginVersion"`
// ProvisionedAt is the unix timestamp when the resource was provisioned.
ProvisionedAt int64 `json:"provisionedAt"`
}
ProvenanceState stores Bluelink provenance information for a resource.
type ResourceCompletionDurations ¶
type ResourceCompletionDurations struct {
// ConfigCompleteDuration is the duration in milliseconds for the resource to be configured.
// This will only be present if the resource has reached config complete status.
ConfigCompleteDuration *float64 `json:"configCompleteDuration,omitempty"`
// TotalDuration is the duration in milliseconds for the resource change to reach the final
// status.
TotalDuration *float64 `json:"totalDuration,omitempty"`
// AttemptDurations holds a list of durations in milliseconds
// for each attempt to deploy the resource.
// Attempt durations are in order as per the "Attempt" field in a status update message.
AttemptDurations []float64 `json:"attemptDurations,omitempty"`
}
ResourceCompletionDurations holds duration information for the deployment of a resource change.
type ResourceDriftChanges ¶
type ResourceDriftChanges struct {
ModifiedFields []*ResourceDriftFieldChange `json:"modifiedFields"`
NewFields []*ResourceDriftFieldChange `json:"newFields"`
RemovedFields []string `json:"removedFields"`
UnchangedFields []string `json:"unchangedFields"`
}
ResourceDriftChanges holds the changes that have been detected in the resource state in the upstream provider.
type ResourceDriftFieldChange ¶
type ResourceDriftFieldChange struct {
// FieldPath holds the path of the field in the resource spec.
// For example, "spec.template.spec.containers[0].image".
FieldPath string `json:"fieldPath"`
// StateValue holds the value of the field in the current state
// persisted in the blueprint framework.
StateValue *core.MappingNode `json:"stateValue"`
// DriftedValue holds the value of the field in the drifted state
// in the upstream provider.
DriftedValue *core.MappingNode `json:"driftedValue"`
}
ResourceDriftFieldChange represents a change in a field value of a resource that is used in drift detection.
type ResourceDriftState ¶
type ResourceDriftState struct {
// A globally unique identifier for the resource the drift state is for.
ResourceID string `json:"resourceId"`
// The logical name of the resource in the blueprint the drift state is for.
ResourceName string `json:"resourceName"`
// SpecData holds the resource spec
// for the drifted version of the resource derived
// from the upstream provider.
SpecData *core.MappingNode `json:"specData"`
// Difference holds the changes that have been detected
// in the resource state in the upstream provider.
// This holds a representation of changes from the current
// state to the drifted state.
Difference *ResourceDriftChanges `json:"difference"`
// Timestamp holds the unix timestamp of when the drift
// was detected.
Timestamp *int `json:"timestamp,omitempty"`
}
ResourceDriftState holds information about how a resource has drifted from the current state persisted in the blueprint framework.
type ResourceMetadataState ¶
type ResourceMetadataState struct {
DisplayName string `json:"displayName,omitempty"`
Annotations map[string]*core.MappingNode `json:"annotations,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
Custom *core.MappingNode `json:"custom,omitempty"`
}
ResourceMetadataState holds metadata for a resource that is derived from a source blueprint.
type ResourceState ¶
type ResourceState struct {
// A globally unique identifier for the resource.
ResourceID string `json:"id"`
// The logical name of the resource in the blueprint.
Name string `json:"name"`
// The type of the resource as defined in the source blueprint.
Type string `json:"type"`
// The name of the resource template in the source blueprint
// that the resource is derived from.
// This will be empty if the resource is not derived from a resource template.
TemplateName string `json:"templateName,omitempty"`
InstanceID string `json:"instanceId"`
Status core.ResourceStatus `json:"status"`
PreciseStatus core.PreciseResourceStatus `json:"preciseStatus"`
// LastStatusUpdateTimestamp holds the unix timestamp when the resource deployment
// status was last updated.
LastStatusUpdateTimestamp int `json:"lastStatusUpdateTimestamp,omitempty"`
// LastDeployedTimestamp holds the unix timestamp when the resource was last deployed.
LastDeployedTimestamp int `json:"lastDeployedTimestamp"`
// LastDeployAttempTimestamp holds the unix timestamp when an attempt was last made to deploy the resource.
LastDeployAttemptTimestamp int `json:"lastDeployAttemptTimestamp"`
// SpecData holds the resolved resource spec
// for the currently deployed version of the resource along with computed
// fields derived from the deployed resource in the provider.
SpecData *core.MappingNode `json:"specData"`
// ComputedFields holds field paths that are computed at deploy time by the provider
// (e.g., ARN, URL, external ID). Used by clients to display "Outputs" for resources.
ComputedFields []string `json:"computedFields,omitempty"`
// Description holds a human-friendly description of the resource derived
// from a source blueprint.
Description string `json:"description,omitempty"`
// Metadata holds metadata for the resource that is derived from a source blueprint
// that includes additional information that allows for extensions built on top of the
// blueprint framework along with the storage of labels, annotations and a human-friendly
// display name for the resource.
Metadata *ResourceMetadataState `json:"metadata,omitempty"`
// SystemMetadata holds system-generated metadata for the resource.
// This includes provenance information and is separate from user-defined blueprint metadata.
SystemMetadata *SystemMetadataState `json:"systemMetadata,omitempty"`
// DependsOnResources holds a list of resource names that the resource depends on,
// this dependency is derived from "hard" links, references and the use of the dependsOn
// property in the source blueprint.
DependsOnResources []string `json:"dependsOnResources,omitempty"`
// DependsOnChildren holds a list of child blueprint names that the resource depends on.
// This dependency is derived from references in the source blueprint.
DependsOnChildren []string `json:"dependsOnChildren,omitempty"`
// Holds the latest reasons for failures in deploying a resource,
// this only ever holds the results of the latest deployment attempt.
FailureReasons []string `json:"failureReasons"`
// Drifted indicates whether or not the resource state has drifted
// due to changes in the upstream provider.
Drifted bool `json:"drifted,omitempty"`
// LastDriftDetectedTimestamp holds the unix timestamp when drift was last detected.
LastDriftDetectedTimestamp *int `json:"lastDriftDetectedTimestamp,omitempty"`
// Durations holds duration information for the latest deployment of the resource.
Durations *ResourceCompletionDurations `json:"durations,omitempty"`
}
ResourceState provides the current state of a resource in a blueprint instance. This includes the status, the Raw data from the upstream resouce provider along with reasons for failure when a resource is in a failure state.
func (*ResourceState) ID ¶
func (r *ResourceState) ID() string
func (*ResourceState) Kind ¶
func (r *ResourceState) Kind() ElementKind
func (*ResourceState) LogicalName ¶
func (r *ResourceState) LogicalName() string
type ResourceStatusInfo ¶
type ResourceStatusInfo struct {
Status core.ResourceStatus `json:"status"`
PreciseStatus core.PreciseResourceStatus `json:"preciseStatus"`
LastDeployedTimestamp *int `json:"lastDeployedTimestamp,omitempty"`
LastDeployAttemptTimestamp *int `json:"lastDeployAttemptTimestamp,omitempty"`
LastStatusUpdateTimestamp *int `json:"lastStatusUpdateTimestamp,omitempty"`
Durations *ResourceCompletionDurations `json:"durations,omitempty"`
FailureReasons []string `json:"failureReasons,omitempty"`
}
ResourceStatusInfo holds information about the status of a resource that is primarily used when updating the status of a resource.
type ResourcesContainer ¶
type ResourcesContainer interface {
// Get deals with retrieving resource state for a given globally unique
// resource ID.
Get(ctx context.Context, resourceID string) (ResourceState, error)
// GetByName deals with retrieving the state for a given resource
// in the provided blueprint instance by its logical name.
GetByName(ctx context.Context, instanceID string, resourceName string) (ResourceState, error)
// Save deals with persisting a resource in a blueprint instance.
// This both creates a resource with the given unique ID and attaches
// it to the blueprint instance ID in the provided resource state structure.
Save(
ctx context.Context,
resourceState ResourceState,
) error
// UpdateStatus deals with updating the status of the latest deployment of a given resource.
UpdateStatus(
ctx context.Context,
resourceID string,
statusInfo ResourceStatusInfo,
) error
// Remove deals with removing the state of a resource from the system.
Remove(ctx context.Context, resourceID string) (ResourceState, error)
// GetDrift deals with retrieving the current drift state for a given resource.
GetDrift(ctx context.Context, resourceID string) (ResourceDriftState, error)
// SaveDrift deals with persisting the drift state for a given resource.
SaveDrift(ctx context.Context, driftState ResourceDriftState) error
// RemoveDrift deals with removing the drift state for a given resource.
RemoveDrift(ctx context.Context, resourceID string) (ResourceDriftState, error)
}
ResourcesContainer provides an interface for functionality related to persisting and retrieving resource state in a blueprint instance.
type SystemMetadataState ¶ added in v0.37.0
type SystemMetadataState struct {
// Provenance stores provenance information for resources,
// particularly useful for resources that do not support external tagging.
Provenance *ProvenanceState `json:"provenance,omitempty"`
}
SystemMetadataState holds system-generated metadata for a resource. This is separate from ResourceMetadataState which holds user-defined blueprint metadata.