gcsrelease

package
v1.85.2 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrReleaseExists = errors.New("release version already exists; delete it first to re-publish")

ErrReleaseExists is returned by Upload when the version is already published. Published versions are immutable; delete the release first to re-publish it.

Functions

func NewHandler

func NewHandler(m release.Manager, signer Signer) http.Handler

NewHandler returns an http.Handler serving release metadata and signed download URLs.

Types

type Bucket

type Bucket interface {
	Object(name string) Object
	SignedURL(object string, opts *storage.SignedURLOptions) (string, error)
}

Bucket abstracts the operations needed on a GCS bucket so that implementations can be swapped for testing.

func NewBucket

func NewBucket(b *storage.BucketHandle) Bucket

NewBucket wraps a *storage.BucketHandle as a Bucket.

type DownloadResponse

type DownloadResponse struct {
	Bundle release.Bundle `json:"bundle"`
	URL    string         `json:"url"`
}

DownloadResponse is the JSON payload for the download endpoint.

type Manager

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

Manager decorates a release.Manager, storing binary data in GCS while delegating metadata operations to the inner manager.

func NewManager

func NewManager(inner release.Manager, bucket Bucket, opts ...Option) *Manager

NewManager returns a Manager that stores binary data in bucket and delegates metadata to inner.

func (*Manager) Create

func (m *Manager) Create(ctx context.Context, p release.Package) error

Create delegates to the inner manager.

func (*Manager) Delete

func (m *Manager) Delete(ctx context.Context, pkg string, ver release.Version) error

Delete removes metadata via the inner manager and then deletes the GCS object. A missing metadata document does not stop the object delete: a publish that dies between the blob commit and the metadata write orphans an object whose presence blocks re-publishing the version, and Delete is the only cleanup path.

func (*Manager) DeletePackage

func (m *Manager) DeletePackage(ctx context.Context, pkg string) error

DeletePackage delegates to the inner manager.

func (*Manager) Get

Get fetches bundle metadata from the inner manager and optionally streams binary data from GCS, verifying the SHA256 checksum.

func (*Manager) GetPackage

func (m *Manager) GetPackage(ctx context.Context, pkg string) (release.Package, error)

GetPackage delegates to the inner manager.

func (*Manager) List

func (m *Manager) List(ctx context.Context, pkg string, filters map[string]string) (iterator.Iterator[release.Bundle], error)

List delegates to the inner manager.

func (*Manager) ListPackages

func (m *Manager) ListPackages(ctx context.Context, filters map[string]string) (iterator.Iterator[release.Package], error)

ListPackages delegates to the inner manager.

func (*Manager) SignedDownloadURL

func (m *Manager) SignedDownloadURL(ctx context.Context, pkg string, version release.Version) (string, error)

SignedDownloadURL returns a short-lived signed URL for the given package version.

func (*Manager) UpdatePackageMetadata

func (m *Manager) UpdatePackageMetadata(ctx context.Context, pkg string, metadata map[string]string) error

UpdatePackageMetadata delegates to the inner manager.

func (*Manager) Upload

func (m *Manager) Upload(ctx context.Context, bundle release.Bundle, r release.ProgressReader) error

Upload writes binary data to GCS and metadata to the inner manager. Published versions are immutable: re-uploading an existing version fails with ErrReleaseExists before any data is transferred, and the create-only GCS writer guarantees that even a concurrent publish can never replace an already-published artifact.

type Object

type Object interface {
	// NewCreateWriter returns a writer that creates the object.
	// Finalising the write fails when the object already exists,
	// leaving the existing object untouched.
	NewCreateWriter(ctx context.Context) io.WriteCloser
	NewReader(ctx context.Context) (ObjectReader, error)
	Delete(ctx context.Context) error
}

Object abstracts the operations needed on a GCS object.

type ObjectReader

type ObjectReader interface {
	io.ReadCloser
	Size() int64
}

ObjectReader extends io.ReadCloser with a Size method, which corresponds to storage.Reader.Attrs.Size.

type Option

type Option func(*Manager)

Option configures the Manager.

func WithPrefix

func WithPrefix(prefix string) Option

WithPrefix sets a key prefix for GCS objects.

func WithSignedURLOptions

func WithSignedURLOptions(opts *storage.SignedURLOptions) Option

WithSignedURLOptions sets options applied when generating signed URLs.

type Signer

type Signer interface {
	SignedDownloadURL(ctx context.Context, pkg string, version release.Version) (string, error)
}

Signer can produce short-lived signed URLs for GCS objects.

Jump to

Keyboard shortcuts

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