Documentation ¶
Overview ¶
Package mock provides mock implementations of interfaces for testing purposes.
Index ¶
- Variables
- func ResetGlobalECSService()
- func ResetGlobalSecretCache()
- type ECSClient
- func (c *ECSClient) DeregisterTaskDefinition(ctx context.Context, in *awsECS.DeregisterTaskDefinitionInput) (*awsECS.DeregisterTaskDefinitionOutput, error)
- func (c *ECSClient) DescribeTaskDefinition(ctx context.Context, in *awsECS.DescribeTaskDefinitionInput) (*awsECS.DescribeTaskDefinitionOutput, error)
- func (c *ECSClient) DescribeTasks(ctx context.Context, in *awsECS.DescribeTasksInput) (*awsECS.DescribeTasksOutput, error)
- func (c *ECSClient) ListTaskDefinitions(ctx context.Context, in *awsECS.ListTaskDefinitionsInput) (*awsECS.ListTaskDefinitionsOutput, error)
- func (c *ECSClient) ListTasks(ctx context.Context, in *awsECS.ListTasksInput) (*awsECS.ListTasksOutput, error)
- func (c *ECSClient) RegisterTaskDefinition(ctx context.Context, in *awsECS.RegisterTaskDefinitionInput) (*awsECS.RegisterTaskDefinitionOutput, error)
- func (c *ECSClient) RunTask(ctx context.Context, in *awsECS.RunTaskInput) (*awsECS.RunTaskOutput, error)
- func (c *ECSClient) StopTask(ctx context.Context, in *awsECS.StopTaskInput) (*awsECS.StopTaskOutput, error)
- func (c *ECSClient) TagResource(ctx context.Context, in *awsECS.TagResourceInput) (*awsECS.TagResourceOutput, error)
- type ECSCluster
- type ECSContainer
- type ECSContainerDefinition
- type ECSPod
- type ECSPodCreator
- type ECSPodDefinitionCache
- type ECSPodDefinitionManager
- type ECSService
- type ECSTask
- type ECSTaskDefinition
- type SecretCache
- type SecretsManagerClient
- func (c *SecretsManagerClient) CreateSecret(ctx context.Context, in *secretsmanager.CreateSecretInput) (*secretsmanager.CreateSecretOutput, error)
- func (c *SecretsManagerClient) DeleteSecret(ctx context.Context, in *secretsmanager.DeleteSecretInput) (*secretsmanager.DeleteSecretOutput, error)
- func (c *SecretsManagerClient) DescribeSecret(ctx context.Context, in *secretsmanager.DescribeSecretInput) (*secretsmanager.DescribeSecretOutput, error)
- func (c *SecretsManagerClient) GetSecretValue(ctx context.Context, in *secretsmanager.GetSecretValueInput) (*secretsmanager.GetSecretValueOutput, error)
- func (c *SecretsManagerClient) ListSecrets(ctx context.Context, in *secretsmanager.ListSecretsInput) (*secretsmanager.ListSecretsOutput, error)
- func (c *SecretsManagerClient) TagResource(ctx context.Context, in *secretsmanager.TagResourceInput) (*secretsmanager.TagResourceOutput, error)
- func (c *SecretsManagerClient) UpdateSecretValue(ctx context.Context, in *secretsmanager.UpdateSecretInput) (*secretsmanager.UpdateSecretOutput, error)
- type StoredSecret
- type TagClient
- type Vault
- func (m *Vault) CreateSecret(ctx context.Context, s cocoa.NamedSecret) (id string, err error)
- func (m *Vault) DeleteSecret(ctx context.Context, id string) error
- func (m *Vault) GetValue(ctx context.Context, id string) (val string, err error)
- func (m *Vault) UpdateValue(ctx context.Context, s cocoa.NamedSecret) error
Constants ¶
This section is empty.
Variables ¶
var GlobalSecretCache map[string]StoredSecret
GlobalSecretCache is a global secret storage cache that provides a simplified in-memory implementation of a secrets storage service. This can be used indirectly with the SecretsManagerClient to access and modify secrets, or used directly.
Functions ¶
func ResetGlobalECSService ¶
func ResetGlobalECSService()
ResetGlobalECSService resets the global fake ECS service back to an initialized but clean state.
func ResetGlobalSecretCache ¶
func ResetGlobalSecretCache()
ResetGlobalSecretCache resets the global fake secret storage cache to an initialized but clean state.
Types ¶
type ECSClient ¶
type ECSClient struct { RegisterTaskDefinitionInput *awsECS.RegisterTaskDefinitionInput RegisterTaskDefinitionOutput *awsECS.RegisterTaskDefinitionOutput RegisterTaskDefinitionError error DescribeTaskDefinitionInput *awsECS.DescribeTaskDefinitionInput DescribeTaskDefinitionOutput *awsECS.DescribeTaskDefinitionOutput DescribeTaskDefinitionError error ListTaskDefinitionsInput *awsECS.ListTaskDefinitionsInput ListTaskDefinitionsOutput *awsECS.ListTaskDefinitionsOutput ListTaskDefinitionsError error DeregisterTaskDefinitionInput *awsECS.DeregisterTaskDefinitionInput DeregisterTaskDefinitionOutput *awsECS.DeregisterTaskDefinitionOutput DeregisterTaskDefinitionError error RunTaskInput *awsECS.RunTaskInput RunTaskOutput *awsECS.RunTaskOutput RunTaskError error DescribeTasksInput *awsECS.DescribeTasksInput DescribeTasksOutput *awsECS.DescribeTasksOutput DescribeTasksError error ListTasksInput *awsECS.ListTasksInput ListTasksOutput *awsECS.ListTasksOutput ListTasksError error StopTaskInput *awsECS.StopTaskInput StopTaskOutput *awsECS.StopTaskOutput StopTaskError error TagResourceInput *awsECS.TagResourceInput TagResourceOutput *awsECS.TagResourceOutput TagResourceError error }
ECSClient provides a mock implementation of a cocoa.ECSClient. This makes it possible to introspect on inputs to the client and control the client's output. It provides some default implementations where possible. By default, it will issue the API calls to the fake GlobalECSService.
func (*ECSClient) DeregisterTaskDefinition ¶
func (c *ECSClient) DeregisterTaskDefinition(ctx context.Context, in *awsECS.DeregisterTaskDefinitionInput) (*awsECS.DeregisterTaskDefinitionOutput, error)
DeregisterTaskDefinition saves the input and deletes an existing mock task definition. The mock output can be customized. By default, it will delete a cached task definition if it exists.
func (*ECSClient) DescribeTaskDefinition ¶
func (c *ECSClient) DescribeTaskDefinition(ctx context.Context, in *awsECS.DescribeTaskDefinitionInput) (*awsECS.DescribeTaskDefinitionOutput, error)
DescribeTaskDefinition saves the input and returns information about the matching task definition. The mock output can be customized. By default, it will return the task definition information if it exists.
func (*ECSClient) DescribeTasks ¶
func (c *ECSClient) DescribeTasks(ctx context.Context, in *awsECS.DescribeTasksInput) (*awsECS.DescribeTasksOutput, error)
DescribeTasks saves the input and returns information about the existing tasks. The mock output can be customized. By default, it will describe all cached tasks that match.
func (*ECSClient) ListTaskDefinitions ¶
func (c *ECSClient) ListTaskDefinitions(ctx context.Context, in *awsECS.ListTaskDefinitionsInput) (*awsECS.ListTaskDefinitionsOutput, error)
ListTaskDefinitions saves the input and lists all matching task definitions. The mock output can be customized. By default, it will list all cached task definitions that match the input filters.
func (*ECSClient) ListTasks ¶
func (c *ECSClient) ListTasks(ctx context.Context, in *awsECS.ListTasksInput) (*awsECS.ListTasksOutput, error)
ListTasks saves the input and lists all matching tasks. The mock output can be customized. By default, it will list all cached task definitions that match the input filters.
func (*ECSClient) RegisterTaskDefinition ¶
func (c *ECSClient) RegisterTaskDefinition(ctx context.Context, in *awsECS.RegisterTaskDefinitionInput) (*awsECS.RegisterTaskDefinitionOutput, error)
RegisterTaskDefinition saves the input and returns a new mock task definition. The mock output can be customized. By default, it will create a cached task definition based on the input.
func (*ECSClient) RunTask ¶
func (c *ECSClient) RunTask(ctx context.Context, in *awsECS.RunTaskInput) (*awsECS.RunTaskOutput, error)
RunTask saves the input options and returns the mock result of running a task definition. The mock output can be customized. By default, it will create mock output based on the input.
func (*ECSClient) StopTask ¶
func (c *ECSClient) StopTask(ctx context.Context, in *awsECS.StopTaskInput) (*awsECS.StopTaskOutput, error)
StopTask saves the input and stops a mock task. The mock output can be customized. By default, it will mark a cached task as stopped if it exists and is running.
func (*ECSClient) TagResource ¶
func (c *ECSClient) TagResource(ctx context.Context, in *awsECS.TagResourceInput) (*awsECS.TagResourceOutput, error)
TagResource saves the input and tags a mock task or task definition. The mock output can be customized. By default, it will add the tag to the resource if it exists.
type ECSCluster ¶
ECSCluster represents a mock ECS cluster running tasks in the global ECS service.
type ECSContainer ¶
type ECSContainer struct { ARN string TaskARN *string Name *string Image *string CPU *int32 MemoryMB *int32 Status string GoalStatus string }
ECSContainer represents a mock running ECS container within a task.
type ECSContainerDefinition ¶
type ECSContainerDefinition struct { Name *string Image *string Command []string MemoryMB *int32 CPU int32 EnvVars map[string]string Secrets map[string]string }
ECSContainerDefinition represents a mock ECS container definition in a mock ECS task definition.
type ECSPod ¶
type ECSPod struct { cocoa.ECSPod ResourcesOutput *cocoa.ECSPodResources StatusInfoOutput *cocoa.ECSPodStatusInfo LatestStatusInfoOutput *cocoa.ECSPodStatusInfo LatestStatusInfoError error StopError error DeleteError error }
ECSPod provides a mock implementation of a cocoa.ECSPod backed by another ECS pod implementation.
func (*ECSPod) Delete ¶
Delete deletes the mock pod and all of its underlying resources. The mock output can be customized. By default, it will return the result of the deleting the backing ECS pod.
func (*ECSPod) LatestStatusInfo ¶
LatestStatusInfo returns the mock latest status information about the pod. The mock output can be customized. By default, it will return the result of the backing ECS pod.
func (*ECSPod) Resources ¶
func (p *ECSPod) Resources() cocoa.ECSPodResources
Resources returns mock resource information about the pod. The mock output can be customized. By default, it will return the result of the backing ECS pod.
func (*ECSPod) StatusInfo ¶
func (p *ECSPod) StatusInfo() cocoa.ECSPodStatusInfo
StatusInfo returns mock cached status information about the pod. The mock output can be customized. By default, it will return the result of the backing ECS pod.
type ECSPodCreator ¶
type ECSPodCreator struct { cocoa.ECSPodCreator CreatePodInput []cocoa.ECSPodCreationOptions CreatePodOutput *cocoa.ECSPod CreatePodError error CreatePodFromExistingDefinitionInput []cocoa.ECSPodExecutionOptions CreatePodFromExistingDefinitionOutput *cocoa.ECSPod CreatePodFromExistingDefinitionError error }
ECSPodCreator provides a mock implementation of a cocoa.ECSPodCreator backed by another ECS pod creator implementation.
func NewECSPodCreator ¶
func NewECSPodCreator(c cocoa.ECSPodCreator) *ECSPodCreator
NewECSPodCreator creates a mock ECS pod creator backed by the given pod creator.
func (*ECSPodCreator) CreatePod ¶
func (m *ECSPodCreator) CreatePod(ctx context.Context, opts ...cocoa.ECSPodCreationOptions) (cocoa.ECSPod, error)
CreatePod saves the input and returns a new mock pod. The mock output can be customized. By default, it will return the result of creating the pod in the backing ECS pod creator.
func (*ECSPodCreator) CreatePodFromExistingDefinition ¶
func (m *ECSPodCreator) CreatePodFromExistingDefinition(ctx context.Context, def cocoa.ECSTaskDefinition, opts ...cocoa.ECSPodExecutionOptions) (cocoa.ECSPod, error)
CreatePodFromExistingDefinition saves the input and returns a new mock pod. The mock output can be customized. By default, it will return the result of creating the pod in the backing ECS pod creator.
type ECSPodDefinitionCache ¶
type ECSPodDefinitionCache struct { cocoa.ECSPodDefinitionCache PutInput *cocoa.ECSPodDefinitionItem PutError error DeleteInput *string DeleteError error Tag *string }
ECSPodDefinitionCache provides a mock implementation of a cocoa.ECSPodDefinitionCache backed by another ECS pod definition cache implementation.
func NewECSPodDefinitionCache ¶
func NewECSPodDefinitionCache(pdc cocoa.ECSPodDefinitionCache) *ECSPodDefinitionCache
NewECSPodDefinitionCache creates a mock ECS pod definition cache backed by the given pod definition cache.
func (*ECSPodDefinitionCache) Delete ¶
func (c *ECSPodDefinitionCache) Delete(ctx context.Context, id string) error
Delete deletes the pod definition matching the identifier from the mock cache. The mock output can be customized. By default, it will return the result of deleting the pod definition from the backing ECS pod definition cache.
func (*ECSPodDefinitionCache) GetTag ¶
func (c *ECSPodDefinitionCache) GetTag() string
GetTag returns the cache tracking tag. The mock output can be customized. By default, it will return the tag from the backing ECS pod definition cache.
func (*ECSPodDefinitionCache) Put ¶
func (c *ECSPodDefinitionCache) Put(ctx context.Context, item cocoa.ECSPodDefinitionItem) error
Put adds the item to the mock cache. The mock output can be customized. By default, it will return the result of putting the item in the backing ECS pod definition cache.
type ECSPodDefinitionManager ¶
type ECSPodDefinitionManager struct { cocoa.ECSPodDefinitionManager CreatePodDefinitionInput []cocoa.ECSPodDefinitionOptions CreatePodDefinitionOutput *cocoa.ECSPodDefinitionItem CreatePodDefinitionError error DeletePodDefinitionInput *string DeletePodDefinitionError error }
ECSPodDefinitionManager provides a mock implementation of a cocoa.ECSPodDefinitionManager backed by another ECS pod definition manager implementation.
func NewECSPodDefinitionManager ¶
func NewECSPodDefinitionManager(m cocoa.ECSPodDefinitionManager) *ECSPodDefinitionManager
NewECSPodDefinitionManager creates a mock ECS pod definition manager backed by the given pod definition manager.
func (*ECSPodDefinitionManager) CreatePodDefinition ¶
func (m *ECSPodDefinitionManager) CreatePodDefinition(ctx context.Context, opts ...cocoa.ECSPodDefinitionOptions) (*cocoa.ECSPodDefinitionItem, error)
CreatePodDefinition saves the input and returns a new mock pod definition item. The mock output can be customized. By default, it will return the result of creating the pod definition in the backing ECS pod definition manager.
func (*ECSPodDefinitionManager) DeletePodDefinition ¶
func (m *ECSPodDefinitionManager) DeletePodDefinition(ctx context.Context, id string) error
DeletePodDefinition saves the input and deletes the mock pod definition. The mock output can be customized. By default, it will return the result of deleting the pod definition from the backing ECS pod definition manager.
type ECSService ¶
type ECSService struct { Clusters map[string]ECSCluster TaskDefs map[string][]ECSTaskDefinition }
ECSService is a global implementation of ECS that provides a simplified in-memory implementation of the service that only stores metadata and does not orchestrate real containers or container instances. This can be used indirectly with the ECSClient to access or modify ECS resources, or used directly.
var GlobalECSService ECSService
GlobalECSService represents the global fake ECS service state.
type ECSTask ¶
type ECSTask struct { ARN string TaskDef ECSTaskDefinition Cluster *string CapacityProvider *string ContainerInstance *string Containers []ECSContainer Overrides *types.TaskOverride Group *string ExecEnabled bool Status string GoalStatus string Created *time.Time StopCode string StopReason *string Stopped *time.Time Tags map[string]string }
ECSTask represents a mock running ECS task within a cluster.
type ECSTaskDefinition ¶
type ECSTaskDefinition struct { ARN string Family *string Revision *int64 ContainerDefs []ECSContainerDefinition MemoryMB *string CPU *string TaskRole *string ExecutionRole *string Tags map[string]string Status *string Registered *time.Time Deregistered *time.Time }
ECSTaskDefinition represents a mock ECS task definition in the global ECS service.
type SecretCache ¶
type SecretCache struct { cocoa.SecretCache PutInput *cocoa.SecretCacheItem PutError error DeleteInput *string DeleteError error Tag *string }
SecretCache provides a mock implementation of a cocoa.SecretCache backed by another secret cache implementation.
func NewSecretCache ¶
func NewSecretCache(sc cocoa.SecretCache) *SecretCache
NewSecretCache creates a mock secret cache backed by the given secret cache.
func (*SecretCache) Delete ¶
func (c *SecretCache) Delete(ctx context.Context, id string) error
Delete removes the secret from the mock cache. The mock output can be customized. By default, it will return the result of deleting the secret from the backing secret cache.
func (*SecretCache) GetTag ¶
func (c *SecretCache) GetTag() string
GetTag returns the cache tracking tag. The mock output can be customized. By default, it will return the tag from the backing secret cache.
func (*SecretCache) Put ¶
func (c *SecretCache) Put(ctx context.Context, item cocoa.SecretCacheItem) error
Put adds the secret to the mock cache. The mock output can be customized. By default, it will return the result of putting the secret in the backing secret cache.
type SecretsManagerClient ¶
type SecretsManagerClient struct { CreateSecretInput *secretsmanager.CreateSecretInput CreateSecretOutput *secretsmanager.CreateSecretOutput CreateSecretError error GetSecretValueInput *secretsmanager.GetSecretValueInput GetSecretValueOutput *secretsmanager.GetSecretValueOutput GetSecretValueError error DescribeSecretInput *secretsmanager.DescribeSecretInput DescribeSecretOutput *secretsmanager.DescribeSecretOutput DescribeSecretError error ListSecretsInput *secretsmanager.ListSecretsInput ListSecretsOutput *secretsmanager.ListSecretsOutput ListSecretsError error UpdateSecretInput *secretsmanager.UpdateSecretInput UpdateSecretOutput *secretsmanager.UpdateSecretOutput UpdateSecretError error DeleteSecretInput *secretsmanager.DeleteSecretInput DeleteSecretOutput *secretsmanager.DeleteSecretOutput DeleteSecretError error TagResourceInput *secretsmanager.TagResourceInput TagResourceOutput *secretsmanager.TagResourceOutput TagResourceError error }
SecretsManagerClient provides a mock implementation of a cocoa.SecretsManagerClient. This makes it possible to introspect on inputs to the client and control the client's output. It provides some default implementations where possible. By default, it will issue the API calls to the fake GlobalSecretCache.
func (*SecretsManagerClient) CreateSecret ¶
func (c *SecretsManagerClient) CreateSecret(ctx context.Context, in *secretsmanager.CreateSecretInput) (*secretsmanager.CreateSecretOutput, error)
CreateSecret saves the input options and returns a new mock secret. The mock output can be customized. By default, it will create and save a cached mock secret based on the input in the global secret cache.
func (*SecretsManagerClient) DeleteSecret ¶
func (c *SecretsManagerClient) DeleteSecret(ctx context.Context, in *secretsmanager.DeleteSecretInput) (*secretsmanager.DeleteSecretOutput, error)
DeleteSecret saves the input options and deletes an existing mock secret. The mock output can be customized. By default, it will delete a cached mock secret if it exists.
func (*SecretsManagerClient) DescribeSecret ¶
func (c *SecretsManagerClient) DescribeSecret(ctx context.Context, in *secretsmanager.DescribeSecretInput) (*secretsmanager.DescribeSecretOutput, error)
DescribeSecret saves the input options and returns an existing mock secret's metadata information. The mock output can be customized. By default, it will return information about the cached mock secret if it exists in the global secret cache.
func (*SecretsManagerClient) GetSecretValue ¶
func (c *SecretsManagerClient) GetSecretValue(ctx context.Context, in *secretsmanager.GetSecretValueInput) (*secretsmanager.GetSecretValueOutput, error)
GetSecretValue saves the input options and returns an existing mock secret's value. The mock output can be customized. By default, it will return a cached mock secret if it exists in the global secret cache.
func (*SecretsManagerClient) ListSecrets ¶
func (c *SecretsManagerClient) ListSecrets(ctx context.Context, in *secretsmanager.ListSecretsInput) (*secretsmanager.ListSecretsOutput, error)
ListSecrets saves the input options and returns all matching mock secrets' metadata information. The mock output can be customized. By default, it will return any matching cached mock secrets in the global secret cache.
func (*SecretsManagerClient) TagResource ¶
func (c *SecretsManagerClient) TagResource(ctx context.Context, in *secretsmanager.TagResourceInput) (*secretsmanager.TagResourceOutput, error)
TagResource saves the input options and tags an existing mock secret. The mock output can be customized. By default, it will tag the cached mock secret if it exists.
func (*SecretsManagerClient) UpdateSecretValue ¶
func (c *SecretsManagerClient) UpdateSecretValue(ctx context.Context, in *secretsmanager.UpdateSecretInput) (*secretsmanager.UpdateSecretOutput, error)
UpdateSecretValue saves the input options and returns an updated mock secret value. The mock output can be customized. By default, it will update a cached mock secret if it exists in the global secret cache.
type StoredSecret ¶
type StoredSecret struct { // For the sake of simplicity, the secret ARN is synonymous with the secret // name. Name string Value string BinaryValue []byte IsDeleted bool Created time.Time LastUpdated time.Time LastAccessed time.Time Deleted time.Time Tags map[string]string }
StoredSecret is a representation of a secret kept in the global secret storage cache.
type TagClient ¶
type TagClient struct { GetResourcesInput *resourcegroupstaggingapi.GetResourcesInput GetResourcesOutput *resourcegroupstaggingapi.GetResourcesOutput GetResourcesError error }
TagClient provides a mock implementation of a cocoa.TagClient. This makes it possible to introspect on inputs to the client and control the client's output. It provides some default implementations where possible. By default, it will issue the API calls to either the fake GlobalECSService for ECS or fake GlobalSecretCache for Secrets Manager.
func (*TagClient) GetResources ¶
func (c *TagClient) GetResources(ctx context.Context, in *resourcegroupstaggingapi.GetResourcesInput) (*resourcegroupstaggingapi.GetResourcesOutput, error)
GetResources saves the input and filters for the resources matching the input filters. The mock output can be customized. By default, it will search for matching secrets in Secrets Manager and task definitions in ECS.
type Vault ¶
type Vault struct { cocoa.Vault CreateSecretInput *cocoa.NamedSecret CreateSecretOutput *string CreateSecretError error GetValueInput *string GetValueOutput *string GetValueError error UpdateValueInput *cocoa.NamedSecret UpdateValueError error DeleteSecretInput *string DeleteSecretError error }
Vault provides a mock implementation of a cocoa.Vault backed by any vault by default. This makes it possible to introspect on inputs to the vault and control the vault's output. It provides some default implementations where possible.
func (*Vault) CreateSecret ¶
CreateSecret saves the input options and returns a mock secret ID. The mock output can be customized. By default, it will call the backing Vault implementation's CreateSecret.
func (*Vault) DeleteSecret ¶
DeleteSecret saves the input options and deletes an existing mock secret. The mock output can be customized. By default, it will call the backing Vault implementation's DeleteSecret.
func (*Vault) GetValue ¶
GetValue saves the input options and returns an existing mock secret's value. The mock output can be customized. By default, it will call the backing Vault implementation's GetValue.
func (*Vault) UpdateValue ¶
UpdateValue saves the input options and updates an existing mock secret. The mock output can be customized. By default, it will call the backing Vault implementation's UpdateValue.