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
- Variables
- func DeleteOneID(ctx context.Context, id string) (bool, error)
- type FakeParameter
- type FakeSSMClient
- func (c *FakeSSMClient) DeleteParameters(ctx context.Context, input *ssm.DeleteParametersInput) ([]*ssm.DeleteParametersOutput, error)
- func (c *FakeSSMClient) DeleteParametersSimple(ctx context.Context, input *ssm.DeleteParametersInput) ([]string, error)
- func (c *FakeSSMClient) GetParameters(ctx context.Context, input *ssm.GetParametersInput) ([]*ssm.GetParametersOutput, error)
- func (c *FakeSSMClient) GetParametersSimple(ctx context.Context, input *ssm.GetParametersInput) ([]ssmTypes.Parameter, error)
- func (c *FakeSSMClient) PutParameter(ctx context.Context, input *ssm.PutParameterInput) (*ssm.PutParameterOutput, error)
Constants ¶
const Collection = "fake_parameters"
Collection is the name of the collection in the DB holding the fake parameters. This is for testing only.
Variables ¶
var ( NameKey = bsonutil.MustHaveTag(FakeParameter{}, "Name") ValueKey = bsonutil.MustHaveTag(FakeParameter{}, "Value") LastUpdatedKey = bsonutil.MustHaveTag(FakeParameter{}, "LastUpdated") )
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 ¶
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.
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.