gcs

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 48 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const Name = "gcs"

Name is the service name.

Variables

This section is empty.

Functions

func New

func New(env *emu.Env) emu.Service

New returns the service.

Types

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is the Cloud Storage service module.

func (*Service) ApplySeed

func (s *Service) ApplySeed(ctx context.Context, section *yaml.Node, baseDir string) error

ApplySeed implements emu.Seeder.

func (*Service) ClockAdvanced

func (s *Service) ClockAdvanced(ctx context.Context) error

ClockAdvanced re-evaluates lifecycle rules after `gcpemu time advance` (FR-GCS-008).

func (*Service) EnvVars

func (s *Service) EnvVars(gw string, endpoints map[string]string) map[string]string

EnvVars implements emu.EnvVarer (FR-CORE-004).

func (*Service) EvaluateLifecycle

func (s *Service) EvaluateLifecycle(ctx context.Context) error

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) Name

func (s *Service) Name() string

Name implements emu.Service.

func (*Service) Ready

func (s *Service) Ready() error

Ready implements emu.Service.

func (*Service) Register

func (s *Service) Register(r emu.Router) error

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

func (s *Service) Reset(ctx context.Context) error

Reset implements emu.Resetter: object data files are deleted; the core clears the metadata store.

func (*Service) ResourceCounts added in v0.2.0

func (s *Service) ResourceCounts() map[string]int

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

func (s *Service) ServeObject(w http.ResponseWriter, r *http.Request, bucket, path string)

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.

func (*Service) Start

func (s *Service) Start(ctx context.Context) error

Start opens the per-service port (default 4443, for STORAGE_EMULATOR_HOST) and starts the lifecycle evaluator.

func (*Service) Stop

func (s *Service) Stop(ctx context.Context) error

Stop shuts the listener and background work down.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL