Documentation
¶
Overview ¶
Package gcs emulates Cloud Storage (SRS 5.4): the JSON API v1 (buckets, objects, uploads, notifications, IAM, HMAC keys), the XML API subset used by the official clients for reads and by S3-style tools, V4 signed URLs and POST policies, Pub/Sub notifications and lifecycle rules. Object data is stored in files under the service data directory.
Index ¶
- Constants
- func New(env *emu.Env) emu.Service
- type Service
- func (s *Service) ApplySeed(ctx context.Context, section *yaml.Node, baseDir string) error
- func (s *Service) ClockAdvanced(ctx context.Context) error
- func (s *Service) EnvVars(gw string, endpoints map[string]string) map[string]string
- func (s *Service) EvaluateLifecycle(ctx context.Context) error
- func (s *Service) Name() string
- func (s *Service) Ready() error
- func (s *Service) Register(r emu.Router) error
- func (s *Service) Reset(ctx context.Context) error
- func (s *Service) ResourceCounts() map[string]int
- func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *Service) ServeObject(w http.ResponseWriter, r *http.Request, bucket, path string)
- func (s *Service) Start(ctx context.Context) error
- func (s *Service) Stop(ctx context.Context) error
Constants ¶
const Name = "gcs"
Name is the service name.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the Cloud Storage service module.
func (*Service) ClockAdvanced ¶
ClockAdvanced re-evaluates lifecycle rules after `gcpemu time advance` (FR-GCS-008).
func (*Service) EvaluateLifecycle ¶
EvaluateLifecycle applies every bucket's lifecycle rules once, using the emulator clock. The core can call it after `gcpemu time advance`; it also runs periodically in the background.
func (*Service) Register ¶
Register mounts the JSON API paths at the gateway root (the official clients use "/storage/v1/", "/upload/storage/v1/" and "/download/storage/v1/"), plus "/storage/" for prefix routing and storage.googleapis.com for host mode.
func (*Service) Reset ¶
Reset implements emu.Resetter: object data files are deleted; the core clears the metadata store.
func (*Service) ResourceCounts ¶ added in v0.2.0
ResourceCounts implements emu.ResourceCounter.
func (*Service) ServeHTTP ¶
func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP dispatches JSON API, upload, download, batch and XML API requests.
func (*Service) ServeObject ¶
ServeObject serves an object of bucket to a load balancer backend bucket request (FR-INT-003): the request path maps to the object name; the bucket's website configuration applies (mainPageSuffix for "/" and directory paths, notFoundPage with status 404); Range, HEAD and conditional requests (If-None-Match, If-Modified-Since) are honoured. Errors use the XML API format, as storage.googleapis.com returns them to a load balancer.