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 ¶
- func Env(envPrefix, bucket, prefix string, c Creds) map[string]string
- type BindingInput
- type Bucket
- type Creds
- type Endpoint
- type EndpointInput
- type ErrInUseBy
- type ErrInvalid
- type Listing
- type Manager
- func (m *Manager) Buckets(ctx context.Context, ref string) ([]Bucket, error)
- func (m *Manager) CheckWritable(ctx context.Context, ref, bucket, prefix string) error
- func (m *Manager) CreateBucket(ctx context.Context, ref, name string) error
- func (m *Manager) Credentials(ctx context.Context, ref string) (Creds, error)
- func (m *Manager) Delete(ctx context.Context, ref string) error
- func (m *Manager) DeleteObject(ctx context.Context, ref, bucket, key string) (int, error)
- func (m *Manager) Get(ctx context.Context, ref string) (Endpoint, error)
- func (m *Manager) List(ctx context.Context) ([]Endpoint, error)
- func (m *Manager) Objects(ctx context.Context, ref, bucket, prefix, startAfter string) (Listing, error)
- func (m *Manager) Open(ctx context.Context, ref, bucket, key string) (io.ReadCloser, minio.ObjectInfo, error)
- func (m *Manager) Put(ctx context.Context, ref string, in EndpointInput) (Endpoint, error)
- func (m *Manager) Resolve(ctx context.Context, serviceID string, in []BindingInput) ([]store.S3Binding, error)
- func (m *Manager) Upload(ctx context.Context, ref, bucket, key string, r io.Reader, size int64, ...) error
- func (m *Manager) Usage(ctx context.Context, ref, bucket, prefix string) (Usage, error)
- type Object
- type Usage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 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 (*Manager) CheckWritable ¶ added in v0.1.9
CheckWritable checks that a bucket exists and accepts writes under prefix, by writing and removing a small object.
func (*Manager) CreateBucket ¶
func (*Manager) Credentials ¶
Credentials unseals an endpoint's credentials (by ID or name).
func (*Manager) DeleteObject ¶
Delete removes an object, or every object under a folder key ("…/").
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 ¶
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.