s3

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 14 Imported by: 0 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 s3 manages S3 endpoints, service bindings and the bucket browser (§16). SynCloud has no shared volumes: anything shared or durable goes to an S3-compatible store, external (AWS, R2, B2, …) or self-hosted (MinIO or Garage deployed as a service and registered here like any other).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Env

func Env(envPrefix, bucket, prefix string, c Creds) map[string]string

Env is the environment a bound task gets.

Types

type BindingInput

type BindingInput struct {
	Endpoint  string `json:"endpoint"` // name or ID
	Bucket    string `json:"bucket"`
	Prefix    string `json:"prefix"`
	EnvPrefix string `json:"envPrefix"` // e.g. MEDIA_ for a second binding
}

BindingInput attaches a bucket to a service.

type Bucket

type Bucket struct {
	Name      string    `json:"name"`
	CreatedAt time.Time `json:"createdAt"`
	BoundBy   []string  `json:"boundBy"` // project/env/service
}

Bucket is a bucket and the services bound to it.

type Creds

type Creds struct {
	URL, Region, AccessKeyID, SecretAccessKey string
	PathStyle                                 bool
}

Creds are what a bound task receives.

type Endpoint

type Endpoint struct {
	ID          string    `json:"id"`
	Name        string    `json:"name"`
	URL         string    `json:"url"`
	Region      string    `json:"region"`
	AccessKeyID string    `json:"accessKeyId"`
	PathStyle   bool      `json:"pathStyle"`
	CreatedAt   time.Time `json:"createdAt"`
	Bindings    int       `json:"bindings"`
}

Endpoint is an endpoint as the API shows it (never the secret).

type EndpointInput

type EndpointInput struct {
	Name            string `json:"name"`
	URL             string `json:"url"`
	Region          string `json:"region"`
	AccessKeyID     string `json:"accessKeyId"`
	SecretAccessKey string `json:"secretAccessKey"`
	PathStyle       bool   `json:"pathStyle"`
}

EndpointInput creates or updates an endpoint. An empty secret on update keeps the stored one.

type ErrInUseBy added in v0.1.9

type ErrInUseBy struct{ By string }

ErrInUseBy means a platform consumer still uses the endpoint.

func (ErrInUseBy) Error added in v0.1.9

func (e ErrInUseBy) Error() string

type ErrInvalid

type ErrInvalid struct{ Err error }

ErrInvalid wraps validation errors.

func (ErrInvalid) Error

func (e ErrInvalid) Error() string

type Listing

type Listing struct {
	Prefix    string   `json:"prefix"`
	Objects   []Object `json:"objects"`
	Truncated bool     `json:"truncated"`
}

Listing is one page of a bucket under a prefix.

type Manager

type Manager struct {

	// InUse names a platform consumer of an endpoint (by ID) that blocks
	// its deletion, e.g. the registry's storage ("" = none).
	InUse func(ctx context.Context, id string) string
	// OnChange is called after an endpoint is updated (its ID).
	OnChange func(id string)
	// contains filtered or unexported fields
}

func New

func New(st *store.Store, box *secrets.Box) *Manager

func (*Manager) Buckets

func (m *Manager) Buckets(ctx context.Context, ref string) ([]Bucket, error)

func (*Manager) CheckWritable added in v0.1.9

func (m *Manager) CheckWritable(ctx context.Context, ref, bucket, prefix string) error

CheckWritable checks that a bucket exists and accepts writes under prefix, by writing and removing a small object.

func (*Manager) CreateBucket

func (m *Manager) CreateBucket(ctx context.Context, ref, name string) error

func (*Manager) Credentials

func (m *Manager) Credentials(ctx context.Context, ref string) (Creds, error)

Credentials unseals an endpoint's credentials (by ID or name).

func (*Manager) Delete

func (m *Manager) Delete(ctx context.Context, ref string) error

func (*Manager) DeleteObject

func (m *Manager) DeleteObject(ctx context.Context, ref, bucket, key string) (int, error)

Delete removes an object, or every object under a folder key ("…/").

func (*Manager) Get

func (m *Manager) Get(ctx context.Context, ref string) (Endpoint, error)

func (*Manager) List

func (m *Manager) List(ctx context.Context) ([]Endpoint, error)

func (*Manager) Objects

func (m *Manager) Objects(ctx context.Context, ref, bucket, prefix, startAfter string) (Listing, error)

Objects lists one level under prefix ("folders" first), at most 1000 entries starting after startAfter.

func (*Manager) Open

func (m *Manager) Open(ctx context.Context, ref, bucket, key string) (io.ReadCloser, minio.ObjectInfo, error)

Open streams an object.

func (*Manager) Put

func (m *Manager) Put(ctx context.Context, ref string, in EndpointInput) (Endpoint, error)

Put creates (ref == "") or updates an endpoint, after checking that the credentials work.

func (*Manager) Resolve

func (m *Manager) Resolve(ctx context.Context, serviceID string, in []BindingInput) ([]store.S3Binding, error)

Resolve validates bindings for a service and returns them ready to store.

func (*Manager) Upload

func (m *Manager) Upload(ctx context.Context, ref, bucket, key string, r io.Reader, size int64, contentType string) error

func (*Manager) Usage

func (m *Manager) Usage(ctx context.Context, ref, bucket, prefix string) (Usage, error)

type Object

type Object struct {
	Key          string     `json:"key"`
	Folder       bool       `json:"folder"`
	Size         int64      `json:"size"`
	LastModified *time.Time `json:"lastModified,omitempty"`
	ContentType  string     `json:"contentType,omitempty"`
}

Object is one entry of a listing: an object or a "folder" (common prefix).

type Usage

type Usage struct {
	Objects int64 `json:"objects"`
	Bytes   int64 `json:"bytes"`
	Partial bool  `json:"partial"`
}

Usage is a bucket's (or prefix's) size, counted by listing (at most 1M objects).

Jump to

Keyboard shortcuts

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