fakeparameter

package
v0.0.0-...-8775593 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package fakeparameter contains the data model and helpers for testing code that uses Parameter Store. Because this stores parameter values in plaintext in the DB, this is only meant as a helper to facilitate testing and should never be used in production code.

Index

Constants

View Source
const Collection = "fake_parameters"

Collection is the name of the collection in the DB holding the fake parameters. This is for testing only.

Variables

View Source
var (
	NameKey        = bsonutil.MustHaveTag(FakeParameter{}, "Name")
	ValueKey       = bsonutil.MustHaveTag(FakeParameter{}, "Value")
	LastUpdatedKey = bsonutil.MustHaveTag(FakeParameter{}, "LastUpdated")
)
View Source
var ExecutionEnvironmentType = "production"

ExecutionEnvironmentType is the type of environment in which the code is running. This exists a safety mechanism against accidentally calling this logic in non-testing environment. For tests, this should always be overridden to "test".

Functions

func DeleteOneID

func DeleteOneID(ctx context.Context, id string) (bool, error)

DeleteOneID deletes a fake parameter with the given ID. Returns whether any matching parameter was deleted.

Types

type FakeParameter

type FakeParameter struct {
	// Name is the unique identifying name for the parameter.
	Name string `bson:"_id,omitempty"`
	// Value is the parameter value.
	Value string `bson:"value,omitempty"`
	// LastUpdated is the last time the parameter was updated.
	LastUpdated time.Time `bson:"last_updated,omitempty"`
}

FakeParameter is the data model for a fake parameter stored in the DB. This is for testing only.

func FindByIDs

func FindByIDs(ctx context.Context, ids ...string) ([]FakeParameter, error)

FindByIDs finds one or more fake parameters by their names.

func FindOneID

func FindOneID(ctx context.Context, id string) (*FakeParameter, error)

FindOneID finds a single fake parameter by its name.

func (*FakeParameter) Insert

func (p *FakeParameter) Insert(ctx context.Context) error

Insert inserts a single parameter into the fake parameter store.

func (*FakeParameter) Upsert

func (p *FakeParameter) Upsert(ctx context.Context) error

Upsert inserts a single parameter into the fake parameter store or replaces an one if one with the same ID already exists.

type FakeSSMClient

type FakeSSMClient struct{}

FakeSSMClient implements the parameterstore.SSMClient interface backed by the fake parameters in the DB. This should only be used in testing.

func NewFakeSSMClient

func NewFakeSSMClient() *FakeSSMClient

NewFakeSSMClient returns a fake SSM client implementation backed by the DB. This should only be used in testing.

func (*FakeSSMClient) DeleteParameters

func (c *FakeSSMClient) DeleteParameters(ctx context.Context, input *ssm.DeleteParametersInput) ([]*ssm.DeleteParametersOutput, error)

DeleteParameters deletes the specified parameters from the fake parameter store.

func (*FakeSSMClient) DeleteParametersSimple

func (c *FakeSSMClient) DeleteParametersSimple(ctx context.Context, input *ssm.DeleteParametersInput) ([]string, error)

DeleteParametersSimple is the same as DeleteParameters but only returns the deleted parameter names.

func (*FakeSSMClient) GetParameters

func (c *FakeSSMClient) GetParameters(ctx context.Context, input *ssm.GetParametersInput) ([]*ssm.GetParametersOutput, error)

GetParameters retrieves the specified parameters from the fake parameter store.

func (*FakeSSMClient) GetParametersSimple

func (c *FakeSSMClient) GetParametersSimple(ctx context.Context, input *ssm.GetParametersInput) ([]ssmTypes.Parameter, error)

GetParametersSimple is the same as GetParameters but only returns the parameters.

func (*FakeSSMClient) PutParameter

func (c *FakeSSMClient) PutParameter(ctx context.Context, input *ssm.PutParameterInput) (*ssm.PutParameterOutput, error)

PutParameter inserts a parameter into the fake parameter store.

Jump to

Keyboard shortcuts

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