Documentation
¶
Overview ¶
SharedDiscovery is a shared library that supports getting data from the discovery dynamodb tables based on several criteria, including:
- APIToken
- Country
- Workspace (tablename)
Admin Capabilities ¶
This library also supports the idea of admin calls that can get any token needed. This is done using HMAC. For out purposes, the private key is stored in Secrets Manager under the name of the brand/environment.
Example ¶
Typical usage is to setup a variable with the interface type and initialize that variable in your modules init function using the New() function provided
var shareddiscovery IFace
// setup AWS Session
session, _ := session.NewSession()
// setup DynamoDB
dynamo := dynamodb.New(session)
// define a QueryInput
query := QueryInput{Workspace: "tableName"}
// setup shareddiscovery now
shareddiscovery = New(dynamo)
// call functions
_, err := shareddiscovery.GetConfig(context.Background(), "someApiToken", query)
if err != nil {
// deal with the error
}
Index ¶
- type IFace
- type QueryInput
- type SharedDiscovery
- func (service SharedDiscovery) AdminGetAPIToken(ctx context.Context, secretKey string, query QueryInput) (string, error)
- func (service SharedDiscovery) GetConfig(ctx context.Context, apiToken string, query QueryInput) (map[string]interface{}, error)
- func (service SharedDiscovery) GetValidation(ctx context.Context, query QueryInput) (bool, error)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IFace ¶
type IFace interface {
GetValidation(ctx context.Context, query QueryInput) (bool, error)
GetConfig(ctx context.Context, apiToken string, query QueryInput) (map[string]interface{}, error)
AdminGetAPIToken(ctx context.Context, secretKey string, query QueryInput) (string, error)
}
IFace describes what is required for building a SharedDiscovery implementation.
type QueryInput ¶
type QueryInput struct {
AppName string
Brand string
Country string
Environment string
Signature string
QueryString map[string]string
Workspace string
}
QueryInput defines the values used to query dynamo with.
type SharedDiscovery ¶
type SharedDiscovery struct {
}
SharedDiscovery is a custom service object for interacting with the global config
func New ¶
func New(dynamodb dynamodbiface.DynamoDBAPI) SharedDiscovery
New is a constructor that takes a preconfigured dynamodbiface and returns an implementation of SharedDiscoveryIFace Use this in your init function after creating your aws session and initializing dynamo.
func (SharedDiscovery) AdminGetAPIToken ¶
func (service SharedDiscovery) AdminGetAPIToken(ctx context.Context, secretKey string, query QueryInput) (string, error)
AdminGetAPIToken queries the dynamo table using the provided query and returns the correct apiToken for the caller to use to then make a request using the GetConfig call. It first validates the HMAC signature against the provided secretKey/query params to verify the caller is who they say they are.
func (SharedDiscovery) GetConfig ¶
func (service SharedDiscovery) GetConfig(ctx context.Context, apiToken string, query QueryInput) (map[string]interface{}, error)
GetConfig uses the provided `APIToken` to get the correct configuration from the specified `tableName`.
func (SharedDiscovery) GetValidation ¶ added in v0.0.2
func (service SharedDiscovery) GetValidation(ctx context.Context, query QueryInput) (bool, error)
GetValidation uses the provided `AppName` and `Country` to check the item exists in the specified `tableName`.
Directories
¶
| Path | Synopsis |
|---|---|
|
mocks
|
|
|
mock_dynamodbiface
Package mock_dynamodbiface is a generated GoMock package.
|
Package mock_dynamodbiface is a generated GoMock package. |
