Documentation
¶
Index ¶
- Variables
- type Container
- type CorsRule
- type ExportedContainer
- type Handler
- func (h *Handler) ChaosOperations() []string
- func (h *Handler) ChaosRegions() []string
- func (h *Handler) ChaosServiceName() string
- func (h *Handler) ExtractOperation(c *echo.Context) string
- func (h *Handler) ExtractResource(c *echo.Context) string
- func (h *Handler) GetSupportedOperations() []string
- func (h *Handler) Handler() echo.HandlerFunc
- func (h *Handler) MatchPriority() int
- func (h *Handler) Name() string
- func (h *Handler) Restore(ctx context.Context, data []byte) error
- func (h *Handler) RouteMatcher() service.Matcher
- func (h *Handler) Snapshot(ctx context.Context) []byte
- type InMemoryBackend
- func (b *InMemoryBackend) CreateContainer(ctx context.Context, accountID, name string, tags map[string]string) (*Container, error)
- func (b *InMemoryBackend) DeleteContainer(ctx context.Context, name string) error
- func (b *InMemoryBackend) DeleteContainerPolicy(ctx context.Context, name string) error
- func (b *InMemoryBackend) DeleteCorsPolicy(ctx context.Context, name string) error
- func (b *InMemoryBackend) DeleteLifecyclePolicy(ctx context.Context, name string) error
- func (b *InMemoryBackend) DeleteMetricPolicy(ctx context.Context, name string) error
- func (b *InMemoryBackend) DescribeContainer(ctx context.Context, name string) (*Container, error)
- func (b *InMemoryBackend) GetContainerPolicy(ctx context.Context, name string) (string, error)
- func (b *InMemoryBackend) GetCorsPolicy(ctx context.Context, name string) ([]CorsRule, error)
- func (b *InMemoryBackend) GetLifecyclePolicy(ctx context.Context, name string) (string, error)
- func (b *InMemoryBackend) GetMetricPolicy(ctx context.Context, name string) (MetricPolicy, error)
- func (b *InMemoryBackend) ListContainers(ctx context.Context, nextToken string, maxResults int) ([]*Container, string, error)
- func (b *InMemoryBackend) ListTagsForResource(ctx context.Context, resourceARN string) (map[string]string, error)
- func (b *InMemoryBackend) PutContainerPolicy(ctx context.Context, name, policy string) error
- func (b *InMemoryBackend) PutCorsPolicy(ctx context.Context, name string, rules []CorsRule) error
- func (b *InMemoryBackend) PutLifecyclePolicy(ctx context.Context, name, policy string) error
- func (b *InMemoryBackend) PutMetricPolicy(ctx context.Context, name string, policy MetricPolicy) error
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) SetActivationDelay(d time.Duration)
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- func (b *InMemoryBackend) StartAccessLogging(ctx context.Context, name string) error
- func (b *InMemoryBackend) StopAccessLogging(ctx context.Context, name string) error
- func (b *InMemoryBackend) TagResource(ctx context.Context, resourceARN string, tags map[string]string) error
- func (b *InMemoryBackend) UntagResource(ctx context.Context, resourceARN string, tagKeys []string) error
- type MetricPolicy
- type MetricPolicyRule
- type Provider
- type StorageBackend
Constants ¶
This section is empty.
Variables ¶
var ( // ErrContainerNotFound is returned when a container does not exist. ErrContainerNotFound = awserr.New( "container not found", awserr.ErrNotFound, ) // ErrContainerAlreadyExists is returned when a container already exists. ErrContainerAlreadyExists = awserr.New( "container already exists", awserr.ErrAlreadyExists, ) // ErrPolicyNotFound is returned when no container policy has been set. ErrPolicyNotFound = awserr.New( "no policy found for container", awserr.ErrNotFound, ) // ErrCorsPolicyNotFound is returned when no CORS policy has been set. ErrCorsPolicyNotFound = awserr.New( "no CORS policy found for container", awserr.ErrNotFound, ) // ErrLifecyclePolicyNotFound is returned when no lifecycle policy has been set. ErrLifecyclePolicyNotFound = awserr.New( "no lifecycle policy found for container", awserr.ErrNotFound, ) // ErrMetricPolicyNotFound is returned when no metric policy has been set. ErrMetricPolicyNotFound = awserr.New( "no metric policy found for container", awserr.ErrNotFound, ) // ErrMissingContainerName is returned when the container name is missing. ErrMissingContainerName = errors.New("ContainerName is required") // ErrInvalidContainerName is returned when the container name is invalid. // // The message intentionally does NOT repeat the "ValidationException:" type // prefix: writeBackendError already carries that in the response envelope's // __type field (see JSONErrorResponse), so baking it into the message text // too would double it up on the wire (e.g. "ValidationException: // ValidationException: ...", as every AWS SDK formats client-visible errors // as "api error <Type>: <message>"). ErrInvalidContainerName = errors.New( "container name must be 1-255 characters" + " and contain only letters, numbers, hyphens, and underscores", ) // ErrInvalidPolicy is returned when a policy string is not valid JSON. ErrInvalidPolicy = errors.New("policy must be valid JSON") // ErrCorsRuleInvalid is returned when a CORS rule is missing required fields. ErrCorsRuleInvalid = errors.New( "each CORS rule must have at least one AllowedOrigin and one AllowedHeader", ) // ErrInvalidMetricPolicy is returned when ContainerLevelMetrics has an invalid value. ErrInvalidMetricPolicy = errors.New( "ContainerLevelMetrics must be ENABLED or DISABLED", ) // ErrTooManyMetricRules is returned when more than 5 metric policy rules are provided. ErrTooManyMetricRules = errors.New( "metric policy may have at most 5 rules", ) // ErrObjectGroupInvalid is returned when a MetricPolicyRule's ObjectGroup // exceeds 900 characters or fails the required character-set pattern // (max/pattern per the ObjectGroup shape in the MediaStore API model). ErrObjectGroupInvalid = errors.New( "MetricPolicyRule ObjectGroup must be 1-900 characters and match the pattern" + ` /?(?:[A-Za-z0-9_=:\.\-\~\*]+/){0,10}(?:[A-Za-z0-9_=:\.\-\~\*]+)?/?`, ) // ErrObjectGroupNameInvalid is returned when a MetricPolicyRule's // ObjectGroupName exceeds 30 characters or contains characters outside // [a-zA-Z0-9_] (max/pattern per the ObjectGroupName shape in the model). ErrObjectGroupNameInvalid = errors.New( "MetricPolicyRule ObjectGroupName must be 1-30 characters and contain only" + " letters, numbers, and underscores", ) // ErrTooManyCorsRules is returned when a CORS policy has more than 100 rules. ErrTooManyCorsRules = errors.New( "CORS policy may have at most 100 rules", ) // ErrEmptyTagKey is returned when a tag with an empty key is provided. ErrEmptyTagKey = errors.New("tag key must not be empty") )
Functions ¶
This section is empty.
Types ¶
type Container ¶
type Container struct {
CreationTime *time.Time
Tags map[string]string
MetricPolicy *MetricPolicy // cached parsed policy; nil means not set
ARN string
ContainerPolicy string
LifecyclePolicy string
Endpoint string
Name string
Status string
CorsPolicy []*CorsRule // cached parsed rules; nil means not set
AccessLoggingEnabled bool
}
Container represents an AWS Elemental MediaStore container.
type CorsRule ¶
type CorsRule struct {
AllowedHeaders []string `json:"AllowedHeaders"`
AllowedMethods []string `json:"AllowedMethods,omitempty"`
AllowedOrigins []string `json:"AllowedOrigins"`
ExposeHeaders []string `json:"ExposeHeaders,omitempty"`
MaxAgeSeconds int `json:"MaxAgeSeconds,omitempty"`
}
CorsRule represents a single CORS rule.
type ExportedContainer ¶
type ExportedContainer = Container
ExportedContainer is a compatibility alias used by the dashboard package.
type Handler ¶
type Handler struct {
Backend StorageBackend
AccountID string
DefaultRegion string
}
Handler is the HTTP handler for the AWS Elemental MediaStore JSON 1.1 API.
func NewHandler ¶
func NewHandler(backend StorageBackend) *Handler
NewHandler creates a new MediaStore handler.
func (*Handler) ChaosOperations ¶
ChaosOperations returns all operations that can be fault-injected.
func (*Handler) ChaosRegions ¶
ChaosRegions returns all regions this handler handles.
func (*Handler) ChaosServiceName ¶
ChaosServiceName returns the lowercase AWS service name for fault rule matching.
func (*Handler) ExtractOperation ¶
ExtractOperation extracts the operation name from the X-Amz-Target header.
func (*Handler) ExtractResource ¶
ExtractResource extracts the container name from the request body.
func (*Handler) GetSupportedOperations ¶
GetSupportedOperations returns the list of supported MediaStore operations.
func (*Handler) Handler ¶
func (h *Handler) Handler() echo.HandlerFunc
Handler returns the Echo handler function for MediaStore requests.
func (*Handler) MatchPriority ¶
MatchPriority returns the routing priority.
func (*Handler) RouteMatcher ¶
RouteMatcher returns a function that matches MediaStore JSON 1.1 API requests.
func (*Handler) Snapshot ¶
Snapshot implements persistence.Persistable by delegating to the backend. MediaStore had no persistence at all before Phase 3.3 -- neither Handler nor InMemoryBackend implemented Snapshot/Restore, so cli.go's generic setupPersistence (which type-asserts the registered service.Registerable, i.e. the Handler, for a Snapshot/Restore pair) never picked MediaStore up: dead wiring, with no persistence underneath it either. This delegation (matching the codecommit/cleanrooms pattern) wires MediaStore into persistence for the first time.
type InMemoryBackend ¶
type InMemoryBackend struct {
// contains filtered or unexported fields
}
InMemoryBackend is the in-memory implementation of StorageBackend.
State is partitioned by region: containers[region] gives the store.Table of containers stored within that region (see store_setup.go for why this is a per-region map rather than a single flat table).
func NewInMemoryBackend ¶
func NewInMemoryBackend() *InMemoryBackend
NewInMemoryBackend creates a new in-memory MediaStore backend.
func (*InMemoryBackend) CreateContainer ¶
func (b *InMemoryBackend) CreateContainer( ctx context.Context, accountID, name string, tags map[string]string, ) (*Container, error)
CreateContainer creates a new MediaStore container in the ctx region.
func (*InMemoryBackend) DeleteContainer ¶
func (b *InMemoryBackend) DeleteContainer(ctx context.Context, name string) error
DeleteContainer removes a container from the ctx region.
func (*InMemoryBackend) DeleteContainerPolicy ¶
func (b *InMemoryBackend) DeleteContainerPolicy(ctx context.Context, name string) error
DeleteContainerPolicy removes the container access policy.
func (*InMemoryBackend) DeleteCorsPolicy ¶
func (b *InMemoryBackend) DeleteCorsPolicy(ctx context.Context, name string) error
DeleteCorsPolicy removes the CORS policy from a container.
func (*InMemoryBackend) DeleteLifecyclePolicy ¶
func (b *InMemoryBackend) DeleteLifecyclePolicy(ctx context.Context, name string) error
DeleteLifecyclePolicy removes the lifecycle policy from a container.
func (*InMemoryBackend) DeleteMetricPolicy ¶
func (b *InMemoryBackend) DeleteMetricPolicy(ctx context.Context, name string) error
DeleteMetricPolicy removes the metric policy from a container.
func (*InMemoryBackend) DescribeContainer ¶
DescribeContainer returns details about a container in the ctx region.
func (*InMemoryBackend) GetContainerPolicy ¶
GetContainerPolicy retrieves the container access policy.
func (*InMemoryBackend) GetCorsPolicy ¶
GetCorsPolicy retrieves the CORS policy for a container.
func (*InMemoryBackend) GetLifecyclePolicy ¶
GetLifecyclePolicy retrieves the lifecycle policy for a container.
func (*InMemoryBackend) GetMetricPolicy ¶
func (b *InMemoryBackend) GetMetricPolicy(ctx context.Context, name string) (MetricPolicy, error)
GetMetricPolicy retrieves the metric policy for a container.
func (*InMemoryBackend) ListContainers ¶
func (b *InMemoryBackend) ListContainers( ctx context.Context, nextToken string, maxResults int, ) ([]*Container, string, error)
ListContainers returns paginated containers in the ctx region sorted by name.
func (*InMemoryBackend) ListTagsForResource ¶
func (b *InMemoryBackend) ListTagsForResource( ctx context.Context, resourceARN string, ) (map[string]string, error)
ListTagsForResource returns tags for a container identified by ARN.
func (*InMemoryBackend) PutContainerPolicy ¶
func (b *InMemoryBackend) PutContainerPolicy(ctx context.Context, name, policy string) error
PutContainerPolicy stores a container access policy.
func (*InMemoryBackend) PutCorsPolicy ¶
PutCorsPolicy stores a CORS policy for a container.
func (*InMemoryBackend) PutLifecyclePolicy ¶
func (b *InMemoryBackend) PutLifecyclePolicy(ctx context.Context, name, policy string) error
PutLifecyclePolicy stores a lifecycle policy for a container.
func (*InMemoryBackend) PutMetricPolicy ¶
func (b *InMemoryBackend) PutMetricPolicy(ctx context.Context, name string, policy MetricPolicy) error
PutMetricPolicy stores a metric policy for a container.
func (*InMemoryBackend) Restore ¶
func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
Restore loads backend state from a JSON snapshot. It implements persistence.Persistable.
func (*InMemoryBackend) SetActivationDelay ¶ added in v1.2.0
func (b *InMemoryBackend) SetActivationDelay(d time.Duration)
SetActivationDelay configures the transient CREATING/DELETING window simulated by CreateContainer/DeleteContainer (see InMemoryBackend. activationDelay). A zero delay (the default) makes container-lifecycle transitions synchronous, matching this backend's previous always-instant behavior; a positive delay makes them genuinely observable, matching real AWS, so DescribeContainer/ListContainers polling loops (SDK waiters) see the transient state until the delay elapses.
func (*InMemoryBackend) Snapshot ¶
func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
Snapshot serializes the backend state to JSON. It implements persistence.Persistable.
func (*InMemoryBackend) StartAccessLogging ¶
func (b *InMemoryBackend) StartAccessLogging(ctx context.Context, name string) error
StartAccessLogging enables access logging for a container.
func (*InMemoryBackend) StopAccessLogging ¶
func (b *InMemoryBackend) StopAccessLogging(ctx context.Context, name string) error
StopAccessLogging disables access logging for a container.
func (*InMemoryBackend) TagResource ¶
func (b *InMemoryBackend) TagResource(ctx context.Context, resourceARN string, tags map[string]string) error
TagResource adds or updates tags on a container identified by ARN.
func (*InMemoryBackend) UntagResource ¶
func (b *InMemoryBackend) UntagResource(ctx context.Context, resourceARN string, tagKeys []string) error
UntagResource removes tags from a container identified by ARN.
type MetricPolicy ¶
type MetricPolicy struct {
ContainerLevelMetrics string `json:"ContainerLevelMetrics"`
MetricPolicyRules []MetricPolicyRule `json:"MetricPolicyRules,omitempty"`
}
MetricPolicy represents a metric policy.
type MetricPolicyRule ¶
type MetricPolicyRule struct {
ObjectGroup string `json:"ObjectGroup"`
ObjectGroupName string `json:"ObjectGroupName"`
}
MetricPolicyRule represents a metric policy rule.
type Provider ¶
type Provider struct{}
Provider implements service.Provider for the MediaStore service.
func (*Provider) Init ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init initializes the MediaStore service backend and handler.
type StorageBackend ¶
type StorageBackend interface {
// Snapshot and Restore implement persistence.Persistable. Handler
// delegates to them (see persistence.go) so cli.go's generic
// setupPersistence picks MediaStore up.
Snapshot(ctx context.Context) []byte
Restore(ctx context.Context, data []byte) error
CreateContainer(ctx context.Context, accountID, name string, tags map[string]string) (*Container, error)
DeleteContainer(ctx context.Context, name string) error
DescribeContainer(ctx context.Context, name string) (*Container, error)
ListContainers(ctx context.Context, nextToken string, maxResults int) ([]*Container, string, error)
PutContainerPolicy(ctx context.Context, name, policy string) error
GetContainerPolicy(ctx context.Context, name string) (string, error)
DeleteContainerPolicy(ctx context.Context, name string) error
PutCorsPolicy(ctx context.Context, name string, rules []CorsRule) error
GetCorsPolicy(ctx context.Context, name string) ([]CorsRule, error)
DeleteCorsPolicy(ctx context.Context, name string) error
PutLifecyclePolicy(ctx context.Context, name, policy string) error
GetLifecyclePolicy(ctx context.Context, name string) (string, error)
DeleteLifecyclePolicy(ctx context.Context, name string) error
PutMetricPolicy(ctx context.Context, name string, policy MetricPolicy) error
GetMetricPolicy(ctx context.Context, name string) (MetricPolicy, error)
DeleteMetricPolicy(ctx context.Context, name string) error
StartAccessLogging(ctx context.Context, name string) error
StopAccessLogging(ctx context.Context, name string) error
TagResource(ctx context.Context, resourceARN string, tags map[string]string) error
UntagResource(ctx context.Context, resourceARN string, tagKeys []string) error
ListTagsForResource(ctx context.Context, resourceARN string) (map[string]string, error)
}
StorageBackend is the interface for the MediaStore in-memory backend.
All methods take a context.Context whose resolved AWS region (stored under regionContextKey) partitions state: containers created in one region are invisible to every other region.