internal

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: 21 Imported by: 0

Documentation

Index

Constants

View Source
const CurrentTimeUnixMock int64 = 1694097824

Thursday, 7th September 2023 14:43:44

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 NewMemoryStateContainer

func NewMemoryStateContainer() state.Container

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 ClockMock

type ClockMock struct{}

func (*ClockMock) Now

func (c *ClockMock) Now() time.Time

func (*ClockMock) Since

func (c *ClockMock) Since(t time.Time) time.Duration

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 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 MemoryStateContainer

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

func (*MemoryStateContainer) Children

func (*MemoryStateContainer) Exports

func (*MemoryStateContainer) Instances

func (*MemoryStateContainer) Metadata

func (*MemoryStateContainer) Resources

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
}

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) 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) WithParams

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

Jump to

Keyboard shortcuts

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