gcs

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package gcs is the Google Cloud Storage backend, on the native cloud.google.com/go/storage client rather than GCS's S3-interop XML API. The difference is the credential: interop needs an HMAC key pair — downloaded key material a deployment has to store and rotate — where this authenticates with Application Default Credentials, which on GKE is a Workload Identity binding and no material at all (#240).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Bucket is the bucket's name, which must already exist: there is no
	// create-if-missing here, and nothing asks the bucket about itself. The
	// permission-minimal shape #241 made optional for the S3 backend is the only
	// shape this one has, so the deployment identity holds object permissions and
	// nothing bucket-level — deploy/gcp grants roles/storage.objectUser to the
	// processes that write and roles/storage.objectViewer to the one that only
	// reads (#240 slice 2). The cost is that a
	// misspelled bucket or a missing IAM binding surfaces on first use rather
	// than at startup — where it is still named, not swallowed, because absence
	// is checked rather than assumed (see the absence method).
	Bucket string

	// Client overrides the ADC-authenticated client New would build. Tests point
	// it at a fake-GCS container; the caller owns closing it.
	Client *storage.Client
}

Config names the bucket. Authentication is Application Default Credentials — Workload Identity on GKE — so no credential appears here, and neither does an endpoint: the client resolves Google's own (CLAUDE.md principle 4 is about not hard-coding a *provider's* endpoint into a protocol adapter, and this adapter speaks to exactly one provider).

type Store

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

Store implements blob.Store against one GCS bucket.

func New

func New(ctx context.Context, cfg Config) (*Store, error)

New builds the client and returns a store. It makes no request: there is nothing to check that would not cost the bucket-level privilege this backend exists to do without.

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, key string) error

func (*Store) Get

func (s *Store) Get(ctx context.Context, key string) (io.ReadCloser, int64, error)

func (*Store) Put

func (s *Store) Put(ctx context.Context, key string, r io.Reader, size int64, contentType string) error

Directories

Path Synopsis
Package gcstest is test support for the GCS backend: one Dockerized fake-gcs-server per test binary, per-test fresh buckets, and the gate for the opt-in tier that calls real Cloud Storage.
Package gcstest is test support for the GCS backend: one Dockerized fake-gcs-server per test binary, per-test fresh buckets, and the gate for the opt-in tier that calls real Cloud Storage.

Jump to

Keyboard shortcuts

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