internal

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const ServerlessTransformName = "serverless-2024"

Variables

This section is empty.

Functions

func LoadInstanceState

func LoadInstanceState(
	stateSnapshotFile string,
) (*state.InstanceState, error)

func LoadStringFromFile

func LoadStringFromFile(
	filePath string,
) (string, error)

func NewTestLogger

func NewTestLogger() (core.Logger, error)

NewTestLogger creates a new instance of a logger to be used for testing.

func NormaliseResourceChanges

func NormaliseResourceChanges(changes *provider.Changes, excludeResourceInfo bool) *provider.Changes

NormaliseResourceChanges normalises the order of fields in a provider.Changes struct so that it can be compared deterministically in tests.

func OrderFieldChanges

func OrderFieldChanges(fieldChanges []provider.FieldChange) []provider.FieldChange

func OrderStringSlice

func OrderStringSlice(fields []string) []string

func RenderErrorTree

func RenderErrorTree(err error) string

RenderErrorTree produces a tree representation of a blueprint error.

func UnpackError

func UnpackError(err error) (error, bool)

UnpackError recursively unpacks a LoadError that can contain child errors. This is to be used when the terminating error is not a LoadError.

func UnpackLoadError

func UnpackLoadError(err error) (*errors.LoadError, bool)

UnpackLoadError recursively unpacks a LoadError that can contain child errors. This will recursively unpack the first child error until it reaches the last child error.

Types

type BlueprintSpecMock

type BlueprintSpecMock struct {
	Blueprint *schema.Blueprint
}

func NewBlueprintSpecMock

func NewBlueprintSpecMock(blueprint *schema.Blueprint) *BlueprintSpecMock

func (*BlueprintSpecMock) ResourceSchema

func (b *BlueprintSpecMock) ResourceSchema(resourceName string) *schema.Resource

func (*BlueprintSpecMock) Schema

func (b *BlueprintSpecMock) Schema() *schema.Blueprint

type DataSourceRegistryMock

type DataSourceRegistryMock struct {
	DataSources map[string]provider.DataSource
}

func (*DataSourceRegistryMock) CustomValidate

func (*DataSourceRegistryMock) Fetch

func (*DataSourceRegistryMock) GetFilterFields

func (*DataSourceRegistryMock) GetSpecDefinition

func (*DataSourceRegistryMock) GetTypeDescription

func (*DataSourceRegistryMock) HasDataSourceType

func (r *DataSourceRegistryMock) HasDataSourceType(ctx context.Context, dataSourceType string) (bool, error)

func (*DataSourceRegistryMock) ListDataSourceTypes

func (r *DataSourceRegistryMock) ListDataSourceTypes(
	ctx context.Context,
) ([]string, error)

type DynamoDBStreamResource

type DynamoDBStreamResource struct {
	// A stub for the resource state value to return when requesting the state
	// of the resource in the external provider.
	ExternalState                            *core.MappingNode
	FallbackToStateContainerForExternalState bool
	StateContainer                           state.Container
}

func (*DynamoDBStreamResource) CanLinkTo

func (*DynamoDBStreamResource) CustomValidate

func (*DynamoDBStreamResource) Deploy

func (*DynamoDBStreamResource) Destroy

func (*DynamoDBStreamResource) GetExamples

func (*DynamoDBStreamResource) GetType

func (*DynamoDBStreamResource) HasStabilised

type DynamoDBTableResource

type DynamoDBTableResource struct {
	// A stub for the resource state value to return when requesting the state
	// of the resource in the external provider.
	ExternalState                            *core.MappingNode
	FallbackToStateContainerForExternalState bool
	StateContainer                           state.Container
	// Tracks the number of stabilise calls have been made for a resource ID.
	// Unlike the test lambda resource, this is not used to test polling behaviour,
	// this is used to test that transient failures are handled correctly by the
	// resource deployer.
	CurrentStabiliseCalls map[string]int
	// contains filtered or unexported fields
}

func (*DynamoDBTableResource) CanLinkTo

func (*DynamoDBTableResource) CustomValidate

func (*DynamoDBTableResource) Deploy

func (*DynamoDBTableResource) Destroy

func (*DynamoDBTableResource) GetExamples

func (*DynamoDBTableResource) GetType

func (*DynamoDBTableResource) HasStabilised

type ExampleComplexResource

type ExampleComplexResource struct {
	// A stub for the resource state value to return when requesting the state
	// of the resource in the external provider.
	ExternalState                            *core.MappingNode
	FallbackToStateContainerForExternalState bool
	StateContainer                           state.Container
}

func (*ExampleComplexResource) CanLinkTo

func (*ExampleComplexResource) CustomValidate

func (*ExampleComplexResource) Deploy

func (*ExampleComplexResource) Destroy

func (*ExampleComplexResource) GetExamples

func (*ExampleComplexResource) GetType

func (*ExampleComplexResource) HasStabilised

type ExampleNullableFieldResource added in v0.37.0

type ExampleNullableFieldResource struct{}

ExampleNullableFieldResource is a test resource implementation that demonstrates nullable fields with default values, simulating resources like SQS queues where fields like delaySeconds have defaults but can also be explicitly set to null.

func (*ExampleNullableFieldResource) CanLinkTo added in v0.37.0

func (*ExampleNullableFieldResource) CustomValidate added in v0.37.0

func (*ExampleNullableFieldResource) Deploy added in v0.37.0

func (*ExampleNullableFieldResource) Destroy added in v0.37.0

func (*ExampleNullableFieldResource) GetExamples added in v0.37.0

func (*ExampleNullableFieldResource) GetExternalState added in v0.37.0

func (*ExampleNullableFieldResource) GetSpecDefinition added in v0.37.0

func (*ExampleNullableFieldResource) GetStabilisedDependencies added in v0.37.0

func (*ExampleNullableFieldResource) GetType added in v0.37.0

func (*ExampleNullableFieldResource) GetTypeDescription added in v0.37.0

func (*ExampleNullableFieldResource) HasStabilised added in v0.37.0

func (*ExampleNullableFieldResource) IsCommonTerminal added in v0.37.0

type ExampleTaggableResource added in v0.37.0

type ExampleTaggableResource struct{}

ExampleTaggableResource is a test resource implementation that demonstrates the use of SortArrayByField for order-independent tag comparison.

func (*ExampleTaggableResource) CanLinkTo added in v0.37.0

func (*ExampleTaggableResource) CustomValidate added in v0.37.0

func (*ExampleTaggableResource) Deploy added in v0.37.0

func (*ExampleTaggableResource) Destroy added in v0.37.0

func (*ExampleTaggableResource) GetExamples added in v0.37.0

func (*ExampleTaggableResource) GetExternalState added in v0.37.0

func (*ExampleTaggableResource) GetSpecDefinition added in v0.37.0

func (*ExampleTaggableResource) GetStabilisedDependencies added in v0.37.0

func (*ExampleTaggableResource) GetType added in v0.37.0

func (*ExampleTaggableResource) GetTypeDescription added in v0.37.0

func (*ExampleTaggableResource) HasStabilised added in v0.37.0

func (*ExampleTaggableResource) IsCommonTerminal added in v0.37.0

type FunctionRegistryMock

type FunctionRegistryMock struct {
	Functions map[string]provider.Function
	CallStack function.Stack
}

func (*FunctionRegistryMock) Call

func (*FunctionRegistryMock) ForCallContext

func (f *FunctionRegistryMock) ForCallContext(stack function.Stack) provider.FunctionRegistry

func (*FunctionRegistryMock) GetDefinition

func (*FunctionRegistryMock) HasFunction

func (f *FunctionRegistryMock) HasFunction(ctx context.Context, functionName string) (bool, error)

func (*FunctionRegistryMock) ListFunctions

func (r *FunctionRegistryMock) ListFunctions(
	ctx context.Context,
) ([]string, error)

type IAMRoleResource

type IAMRoleResource struct{}

IAMRoleResource is a stub implementation of a resource that represents an IAM role. This has been prepared primarily to be used in tests for intermediary resource deployment as a part of a link plugin implementation.

func (*IAMRoleResource) CanLinkTo

func (*IAMRoleResource) CustomValidate

func (*IAMRoleResource) Deploy

func (*IAMRoleResource) Destroy

func (*IAMRoleResource) GetExamples

func (*IAMRoleResource) GetType

func (*IAMRoleResource) HasStabilised

type InstanceTypeCustomVariableType

type InstanceTypeCustomVariableType struct{}

type Lambda2FunctionResource

type Lambda2FunctionResource struct {
	// A stub for the resource state value to return when requesting the state
	// of the resource in the external provider.
	ExternalState                            *core.MappingNode
	FallbackToStateContainerForExternalState bool
	StateContainer                           state.Container
}

func (*Lambda2FunctionResource) CanLinkTo

func (*Lambda2FunctionResource) CustomValidate

func (*Lambda2FunctionResource) Deploy

func (*Lambda2FunctionResource) Destroy

func (*Lambda2FunctionResource) GetExamples

func (*Lambda2FunctionResource) GetExternalState

func (*Lambda2FunctionResource) GetType

func (*Lambda2FunctionResource) HasStabilised

func (*Lambda2FunctionResource) IsCommonTerminal

type LambdaFunctionResource

type LambdaFunctionResource struct {
	// Tracks the number of destroy attempts for each unique resource ID.
	// This is used to emulate transient failures when destroying resources,
	// the blueprint container will retry destroying the resource until the
	// destroy attempt count exceeds the max destroy attempts.
	CurrentDestroyAttempts map[string]int
	// Tracks the number of deploy attempts for each unique resource ID.
	// This is used to emulate transient failures when deploying resources,
	// the blueprint container will retry deploying the resource until the
	// deploy attempt count exceeds the max deploy attempts.
	CurrentDeployAttemps map[string]int
	// Tracks the number of get external state attempts for each unique resource ID.
	// This is used to emulate transient failures when getting the external state
	// of resources, the drift checker will retry getting the external state
	// until the get external state attempt count exceeds the max get external state attempts.
	CurrentGetExternalStateAttemps map[string]int
	// Resource IDs for which the lambda function resource implementation
	// should fail with a terminal error.
	FailResourceIDs []string
	// A mapping of resource IDs to their respective stub resource stabilisation
	// configuration.
	StabiliseResourceIDs map[string]*StubResourceStabilisationConfig
	// Override stabilisation config to always report the resource as stabilised
	// on first check.
	AlwaysStabilise bool
	// Tracks the number of stabilise calls have been made for a resource ID.
	CurrentStabiliseCalls map[string]int
	// A list of instance IDs for which retry failures should be skipped.
	SkipRetryFailuresForInstances []string
	// A stub for the resource state value to return when requesting the state
	// of the resource in the external provider.
	ExternalState                            *core.MappingNode
	FallbackToStateContainerForExternalState bool
	StateContainer                           state.Container
	// contains filtered or unexported fields
}

func (*LambdaFunctionResource) CanLinkTo

func (*LambdaFunctionResource) CustomValidate

func (*LambdaFunctionResource) Deploy

func (*LambdaFunctionResource) Destroy

func (*LambdaFunctionResource) GetExamples

func (*LambdaFunctionResource) GetType

func (*LambdaFunctionResource) HasStabilised

type ProviderMock

type ProviderMock struct {
	NamespaceValue      string
	Resources           map[string]provider.Resource
	DataSources         map[string]provider.DataSource
	Links               map[string]provider.Link
	CustomVariableTypes map[string]provider.CustomVariableType
	ProviderRetryPolicy *provider.RetryPolicy
}

func (*ProviderMock) ConfigDefinition

func (p *ProviderMock) ConfigDefinition(ctx context.Context) (*core.ConfigDefinition, error)

func (*ProviderMock) CustomVariableType

func (p *ProviderMock) CustomVariableType(ctx context.Context, customVariableType string) (provider.CustomVariableType, error)

func (*ProviderMock) DataSource

func (p *ProviderMock) DataSource(ctx context.Context, dataSourceType string) (provider.DataSource, error)

func (*ProviderMock) Function

func (p *ProviderMock) Function(ctx context.Context, functionName string) (provider.Function, error)
func (p *ProviderMock) Link(ctx context.Context, resourceTypeA string, resourceTypeB string) (provider.Link, error)

func (*ProviderMock) ListCustomVariableTypes

func (p *ProviderMock) ListCustomVariableTypes(ctx context.Context) ([]string, error)

func (*ProviderMock) ListDataSourceTypes

func (p *ProviderMock) ListDataSourceTypes(ctx context.Context) ([]string, error)

func (*ProviderMock) ListFunctions

func (p *ProviderMock) ListFunctions(ctx context.Context) ([]string, error)

func (*ProviderMock) ListLinkTypes

func (p *ProviderMock) ListLinkTypes(ctx context.Context) ([]string, error)

func (*ProviderMock) ListResourceTypes

func (p *ProviderMock) ListResourceTypes(ctx context.Context) ([]string, error)

func (*ProviderMock) Namespace

func (p *ProviderMock) Namespace(ctx context.Context) (string, error)

func (*ProviderMock) Resource

func (p *ProviderMock) Resource(ctx context.Context, resourceType string) (provider.Resource, error)

func (*ProviderMock) RetryPolicy

func (p *ProviderMock) RetryPolicy(ctx context.Context) (*provider.RetryPolicy, error)

type ResourceRegistryMock

type ResourceRegistryMock struct {
	Resources      map[string]provider.Resource
	StateContainer state.Container

	// OnLockAcquired is called after a lock is successfully acquired.
	// This can be used in tests to cancel context after lock acquisition.
	OnLockAcquired func()
	// contains filtered or unexported fields
}

func NewResourceRegistryMock added in v0.30.0

func NewResourceRegistryMock(
	resources map[string]provider.Resource,
	opts ...ResourceRegistryMockOption,
) *ResourceRegistryMock

func (*ResourceRegistryMock) AcquireResourceLock added in v0.30.0

func (r *ResourceRegistryMock) AcquireResourceLock(
	ctx context.Context,
	input *provider.AcquireResourceLockInput,
) error

func (*ResourceRegistryMock) CustomValidate

func (*ResourceRegistryMock) Deploy

func (*ResourceRegistryMock) Destroy

func (r *ResourceRegistryMock) Destroy(
	ctx context.Context,
	resourceType string,
	input *provider.ResourceDestroyInput,
) error

func (*ResourceRegistryMock) GetSpecDefinition

func (*ResourceRegistryMock) GetStabilisedDependencies

func (*ResourceRegistryMock) GetTypeDescription

func (*ResourceRegistryMock) HasLocks added in v0.37.0

func (r *ResourceRegistryMock) HasLocks() bool

HasLocks returns true if there are any resource locks held. This is useful for testing that locks are properly released.

func (*ResourceRegistryMock) HasResourceInState added in v0.25.0

func (r *ResourceRegistryMock) HasResourceInState(
	ctx context.Context,
	input *provider.ResourceLookupInput,
) (bool, error)

func (*ResourceRegistryMock) HasResourceType

func (r *ResourceRegistryMock) HasResourceType(ctx context.Context, resourceType string) (bool, error)

func (*ResourceRegistryMock) ListResourceTypes

func (r *ResourceRegistryMock) ListResourceTypes(
	ctx context.Context,
) ([]string, error)

func (*ResourceRegistryMock) LookupResourceInState added in v0.25.0

func (r *ResourceRegistryMock) LookupResourceInState(
	ctx context.Context,
	input *provider.ResourceLookupInput,
) (*state.ResourceState, error)

func (*ResourceRegistryMock) ReleaseResourceLock added in v0.30.0

func (r *ResourceRegistryMock) ReleaseResourceLock(
	ctx context.Context,
	instanceID string,
	resourceName string,
)

func (*ResourceRegistryMock) ReleaseResourceLocks added in v0.30.0

func (r *ResourceRegistryMock) ReleaseResourceLocks(ctx context.Context, instanceID string)

func (*ResourceRegistryMock) ReleaseResourceLocksAcquiredBy added in v0.30.0

func (r *ResourceRegistryMock) ReleaseResourceLocksAcquiredBy(
	ctx context.Context,
	instanceID string,
	acquiredBy string,
)

func (*ResourceRegistryMock) WithParams

type ResourceRegistryMockOption added in v0.30.0

type ResourceRegistryMockOption func(*ResourceRegistryMock)

func WithResourceRegistryClock added in v0.30.0

func WithResourceRegistryClock(clock core.Clock) ResourceRegistryMockOption

func WithResourceRegistryLockCheckInterval added in v0.30.0

func WithResourceRegistryLockCheckInterval(interval time.Duration) ResourceRegistryMockOption

func WithResourceRegistryLockTimeout added in v0.30.0

func WithResourceRegistryLockTimeout(timeout time.Duration) ResourceRegistryMockOption

func WithResourceRegistryStateContainer added in v0.30.0

func WithResourceRegistryStateContainer(stateContainer state.Container) ResourceRegistryMockOption

type ServerlessTransformer

type ServerlessTransformer struct{}

func (*ServerlessTransformer) AbstractResource

func (t *ServerlessTransformer) AbstractResource(
	ctx context.Context,
	resourceType string,
) (transform.AbstractResource, error)

func (*ServerlessTransformer) ConfigDefinition

func (t *ServerlessTransformer) ConfigDefinition(
	ctx context.Context,
) (*core.ConfigDefinition, error)

func (*ServerlessTransformer) GetTransformName

func (t *ServerlessTransformer) GetTransformName(ctx context.Context) (string, error)

func (*ServerlessTransformer) ListAbstractResourceTypes

func (t *ServerlessTransformer) ListAbstractResourceTypes(
	ctx context.Context,
) ([]string, error)

type StaticIDGenerator

type StaticIDGenerator struct {
	ID string
}

func (*StaticIDGenerator) GenerateID

func (m *StaticIDGenerator) GenerateID() (string, error)

type StubResourceStabilisationConfig

type StubResourceStabilisationConfig struct {
	// The number of attempts to wait for a resource to stabilise
	// before giving up.
	// Set this to -1 for a resource that should never stabilise.
	StabilisesAfterAttempts int
}

StubResourceStabilisationConfig provides configuration for the test resource implementations to simulate eventual resource stabilisation.

type TestLogger

type TestLogger struct {
	// contains filtered or unexported fields
}

TestLogger is an implementation of the core.Logger interface that is used for automated testing.

func (*TestLogger) Debug

func (l *TestLogger) Debug(message string, fields ...core.LogField)

func (*TestLogger) Error

func (l *TestLogger) Error(message string, fields ...core.LogField)

func (*TestLogger) Fatal

func (l *TestLogger) Fatal(message string, fields ...core.LogField)

func (*TestLogger) Info

func (l *TestLogger) Info(message string, fields ...core.LogField)

func (*TestLogger) Named

func (l *TestLogger) Named(name string) core.Logger

func (*TestLogger) Warn

func (l *TestLogger) Warn(message string, fields ...core.LogField)

func (*TestLogger) WithFields

func (l *TestLogger) WithFields(fields ...core.LogField) core.Logger

type VPCDataSource

type VPCDataSource struct{}

func (*VPCDataSource) CustomValidate

func (*VPCDataSource) Fetch

func (*VPCDataSource) GetType

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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