Documentation
¶
Index ¶
- Variables
- func DetectAPIVersion(r *http.Request, provider Provider) string
- func DetectAction(r *http.Request) string
- func DetectService(r *http.Request) string
- type LazyService
- type Provider
- type Registry
- func (reg *Registry) All() []service.Service
- func (reg *Registry) List() []service.Service
- func (reg *Registry) Lookup(name string) (service.Service, error)
- func (reg *Registry) LookupTarget(target RouteTarget) (service.Service, error)
- func (reg *Registry) LookupVersioned(key ServiceKey) (service.Service, error)
- func (reg *Registry) Register(svc service.Service)
- func (reg *Registry) RegisterLazy(name string, factory ServiceFactory)
- func (reg *Registry) RegisterLazyVersioned(key ServiceKey, factory ServiceFactory)
- func (reg *Registry) RegisterVersioned(key ServiceKey, svc service.Service)
- func (reg *Registry) SetDefaultVersion(provider Provider, serviceName, apiVersion string)
- type RouteTarget
- type ServiceFactory
- type ServiceKey
Constants ¶
This section is empty.
Variables ¶
var TargetToService = map[string]string{
"dynamodb": "dynamodb",
"dax": "dynamodb",
"amazonsqs": "sqs",
"amazonses": "ses",
"amazonsns": "sns",
"awskms": "kms",
"amazonkinesis": "kinesis",
"tagging": "tagging",
"logs": "logs",
"awslambda": "lambda",
"awscognitoidentityproviderservice": "cognito-idp",
"secretsmanager": "secretsmanager",
}
targetToService maps the lowercased X-Amz-Target service prefix to the canonical CloudMock service name. This handles services whose target prefix doesn't match their SigV4 signing name (e.g. Cognito uses "AWSCognitoIdentityProviderService" in X-Amz-Target but "cognito-idp" in the credential scope). TargetToService maps the lowercased X-Amz-Target service prefix to the canonical CloudMock service name.
Functions ¶
func DetectAPIVersion ¶
DetectAPIVersion extracts the provider-specific API version.
func DetectAction ¶
DetectAction determines the AWS API action from the request. It checks X-Amz-Target (part after the dot) first, then the ?Action= query parameter. Returns empty string if not detected.
func DetectService ¶
DetectService determines the AWS service name from the request. It checks the Authorization header credential scope first (Credential=AKID/date/region/SERVICE/aws4_request), then falls back to X-Amz-Target (stripping the version suffix, e.g. "DynamoDB_20120810" → "dynamodb"), then checks for presigned URL query parameters (X-Amz-Credential). Returns lowercase service name, or empty string if not detected.
Types ¶
type LazyService ¶
type LazyService struct {
// contains filtered or unexported fields
}
LazyService is a lightweight placeholder that satisfies service.Service for services registered via RegisterLazy that have not yet been initialized. It must never be used to handle real requests; Lookup will always return the real service after the first call.
func (*LazyService) Actions ¶
func (l *LazyService) Actions() []service.Action
func (*LazyService) HandleRequest ¶
func (l *LazyService) HandleRequest(_ *service.RequestContext) (*service.Response, error)
func (*LazyService) HealthCheck ¶
func (l *LazyService) HealthCheck() error
func (*LazyService) Name ¶
func (l *LazyService) Name() string
type Provider ¶
type Provider string
Provider identifies the cloud provider protocol that owns a request.
func DetectProvider ¶
DetectProvider identifies the cloud provider for r.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds the set of registered AWS service mocks.
func (*Registry) All ¶
All returns all services, forcing initialization of any lazy services. This is used by snapshot export/import which needs the real service instances.
func (*Registry) List ¶
List returns lightweight representations of all known services — both already-initialized and pending-lazy — in unspecified order. Lazy services are represented by a LazyService placeholder so that they are visible without forcing initialization.
func (*Registry) Lookup ¶
Lookup returns the service registered under name, or an error if none exists. If the service has a pending lazy factory it is initialized on first call and the result is cached for all subsequent calls.
func (*Registry) LookupTarget ¶
func (reg *Registry) LookupTarget(target RouteTarget) (service.Service, error)
LookupTarget resolves a provider-aware route target. AWS targets without an explicit API version fall back to the legacy Lookup path for backward compatibility with existing CloudMock service registration.
func (*Registry) LookupVersioned ¶
func (reg *Registry) LookupVersioned(key ServiceKey) (service.Service, error)
LookupVersioned returns the service registered under key. If key omits APIVersion and a default version is configured for that provider/service, the default version is used.
func (*Registry) Register ¶
Register adds svc to the registry, keyed by svc.Name(). If a service with the same name is already registered it is replaced. Registering an eager service also removes any pending lazy factory for that name.
func (*Registry) RegisterLazy ¶
func (reg *Registry) RegisterLazy(name string, factory ServiceFactory)
RegisterLazy records a factory for name. The factory is called at most once, the first time Lookup is called for that name. Registering a lazy factory overwrites any existing factory for the same name, but does not affect an already-initialized eager service.
func (*Registry) RegisterLazyVersioned ¶
func (reg *Registry) RegisterLazyVersioned(key ServiceKey, factory ServiceFactory)
RegisterLazyVersioned records a versioned service factory. The factory is called at most once, on the first LookupVersioned for that exact key.
func (*Registry) RegisterVersioned ¶
func (reg *Registry) RegisterVersioned(key ServiceKey, svc service.Service)
RegisterVersioned adds svc under a provider/service/API-version key. It allows two implementations for the same logical service to coexist when cloud providers expose parallel API versions.
func (*Registry) SetDefaultVersion ¶
SetDefaultVersion declares the API version used when a request omits an explicit version for a provider/service pair.
type RouteTarget ¶
RouteTarget is the provider-aware routing identity for an incoming request. The legacy AWS router only needed Service and Action; Azure and future providers also need an API version because resource-provider versions can coexist for the same logical service.
func DetectTarget ¶
func DetectTarget(r *http.Request) RouteTarget
DetectTarget returns the provider, service, action, and API version for r.
type ServiceFactory ¶
ServiceFactory is a function that constructs and returns a Service. It is called at most once per service name when using RegisterLazy.
type ServiceKey ¶
ServiceKey identifies a registered service implementation.