Documentation
¶
Overview ¶
Package gcs defines the Google Cloud Storage provider contract.
Slice 0 intentionally pins the stable configuration surface and SDK intake without enabling command dispatch or implementing provider operations.
Index ¶
- Constants
- func DefaultScopes() []string
- type Config
- type ConfigError
- type Provider
- func (p *Provider) Close() error
- func (p *Provider) ConditionalWriteCapabilities() provider.ConditionalWriteCapabilities
- func (p *Provider) DeleteObject(ctx context.Context, key string) error
- func (p *Provider) GetObject(ctx context.Context, key string) (io.ReadCloser, int64, error)
- func (p *Provider) GetObjectRevision(ctx context.Context, key string, revision provider.SourceRevision) (io.ReadCloser, provider.ObjectMeta, error)
- func (p *Provider) GetObjectVersioned(ctx context.Context, key string) (io.ReadCloser, provider.ObjectMeta, error)
- func (p *Provider) GetRange(ctx context.Context, key string, start, endInclusive int64) (io.ReadCloser, int64, error)
- func (p *Provider) Head(ctx context.Context, key string) (*provider.ObjectMeta, error)
- func (p *Provider) List(ctx context.Context, opts provider.ListOptions) (*provider.ListResult, error)
- func (p *Provider) ListCommonPrefixes(ctx context.Context, opts provider.ListCommonPrefixesOptions) (*provider.ListCommonPrefixesResult, error)
- func (p *Provider) ListWithDelimiter(ctx context.Context, opts provider.ListWithDelimiterOptions) (*provider.ListWithDelimiterResult, error)
- func (p *Provider) PutObject(ctx context.Context, key string, body io.Reader, contentLength int64) error
- func (p *Provider) PutObjectConditional(ctx context.Context, key string, body io.Reader, contentLength int64, ...) (provider.PutResult, error)
- func (p *Provider) PutObjectConditionalWithOptions(ctx context.Context, key string, body io.Reader, _ int64, ...) (provider.PutResult, error)
- func (p *Provider) PutObjectResult(ctx context.Context, key string, body io.Reader, contentLength int64) (provider.PutResult, error)
- func (p *Provider) PutObjectResultWithOptions(ctx context.Context, key string, body io.Reader, _ int64, ...) (provider.PutResult, error)
- func (p *Provider) PutObjectWithOptions(ctx context.Context, key string, body io.Reader, contentLength int64, ...) error
Constants ¶
const ( // DefaultMaxKeys is the default page size for List operations. DefaultMaxKeys = 1000 // MaxAllowedKeys is the maximum page size accepted by the JSON API list // maxResults parameter. MaxAllowedKeys = 1000 // DefaultWriterChunkSizeBytes is the GCS SDK's default storage.Writer // ChunkSize. Each active writer allocates this much buffer memory unless a // provider config overrides WriterChunkSizeBytes. DefaultWriterChunkSizeBytes = 16 * 1024 * 1024 // MinWriterChunkSizeBytes is the GCS SDK's minimum resumable-upload chunk // quantum. The SDK rounds positive chunk sizes up to this multiple. MinWriterChunkSizeBytes = googleapi.MinUploadChunkSize )
Variables ¶
This section is empty.
Functions ¶
func DefaultScopes ¶
func DefaultScopes() []string
DefaultScopes returns the provider's default OAuth scope set for ADC/token construction points that require explicit scopes.
Types ¶
type Config ¶
type Config struct {
// Bucket is the GCS bucket name (required).
Bucket string
// Project is the optional GCP project for client construction. Empty lets
// the SDK infer project context when supported.
Project string
// Anonymous issues unauthenticated read requests for public buckets. It is
// mutually exclusive with TokenSource and never falls back to ADC.
Anonymous bool
// TokenSource overrides credential resolution with caller-managed OAuth2
// tokens. It takes precedence over ADC and intentionally carries an already
// resolved credential handle rather than a credentials filepath.
TokenSource oauth2.TokenSource
// MaxKeys is the default page size for List operations.
// Zero uses the provider default (1000). Values over 1000 are clamped.
MaxKeys int
// MaxIdleConnsPerHost optionally sizes the per-host idle HTTP connection
// pool for high-concurrency transfer paths. Zero leaves SDK defaults.
MaxIdleConnsPerHost int
// MaxConnsPerHost optionally caps total HTTP connections per host. Zero
// leaves SDK defaults.
MaxConnsPerHost int
// WriterChunkSizeBytes optionally overrides storage.Writer.ChunkSize for
// high-concurrency write paths. Zero keeps the SDK default; positive values
// are rounded by the SDK to a 256 KiB multiple; negative values are invalid.
WriterChunkSizeBytes int
}
Config configures a Google Cloud Storage provider.
Authentication priority:
- Anonymous unauthenticated reads when Anonymous is true; this is mutually exclusive with TokenSource and must fail closed for mutating operations.
- Caller-injected TokenSource, if provided.
- Google Application Default Credentials from the operator environment.
Credential source file paths are intentionally absent. GCP ADC external account files may contain credential_source.executable hooks, so manifest, CLI, and other untrusted config surfaces must never choose a credentials filepath for this package.
func (Config) AuthClientOptions ¶
func (c Config) AuthClientOptions() []option.ClientOption
AuthClientOptions returns the SDK auth options implied by the config. It is intentionally limited to typed handles and anonymous mode; ADC remains the SDK default when no auth option is returned.
type ConfigError ¶
ConfigError represents a configuration validation error.
func (*ConfigError) Error ¶
func (e *ConfigError) Error() string
Error implements the error interface.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider implements read operations for Google Cloud Storage.
func (*Provider) ConditionalWriteCapabilities ¶
func (p *Provider) ConditionalWriteCapabilities() provider.ConditionalWriteCapabilities
ConditionalWriteCapabilities declares the conditional-write predicates this GCS adapter honors: IfAbsent only, mapped to a DoesNotExist generation precondition. GCS has no ETag If-Match compare-and-swap here, so IfMatchETag is not offered and PutObjectConditional returns ErrUnsupportedPrecondition for it; conditional multipart completion is likewise unsupported.
func (*Provider) DeleteObject ¶
DeleteObject deletes an object.
func (*Provider) GetObjectRevision ¶
func (p *Provider) GetObjectRevision(ctx context.Context, key string, revision provider.SourceRevision) (io.ReadCloser, provider.ObjectMeta, error)
GetObjectRevision downloads exactly the admitted generation or ETag.
func (*Provider) GetObjectVersioned ¶
func (p *Provider) GetObjectVersioned(ctx context.Context, key string) (io.ReadCloser, provider.ObjectMeta, error)
GetObjectVersioned downloads an object and returns the generation observed from the same read handle.
func (*Provider) GetRange ¶
func (p *Provider) GetRange(ctx context.Context, key string, start, endInclusive int64) (io.ReadCloser, int64, error)
GetRange downloads a byte range as a stream.
func (*Provider) List ¶
func (p *Provider) List(ctx context.Context, opts provider.ListOptions) (*provider.ListResult, error)
List returns a page of objects with the given prefix.
func (*Provider) ListCommonPrefixes ¶
func (p *Provider) ListCommonPrefixes(ctx context.Context, opts provider.ListCommonPrefixesOptions) (*provider.ListCommonPrefixesResult, error)
ListCommonPrefixes returns immediate child prefixes for prefix discovery.
func (*Provider) ListWithDelimiter ¶
func (p *Provider) ListWithDelimiter(ctx context.Context, opts provider.ListWithDelimiterOptions) (*provider.ListWithDelimiterResult, error)
ListWithDelimiter returns direct objects and immediate child prefixes.
func (*Provider) PutObject ¶
func (p *Provider) PutObject(ctx context.Context, key string, body io.Reader, contentLength int64) error
PutObject uploads an object.