Documentation
¶
Overview ¶
Filesystem storage backend for Nixery.
Google Cloud Storage backend for Nixery.
Package storage implements an interface that can be implemented by storage backends, such as Google Cloud Storage or the local filesystem.
Index ¶
- type Backend
- type FSBackend
- func (b *FSBackend) Fetch(ctx context.Context, key string) (io.ReadCloser, error)
- func (b *FSBackend) Move(ctx context.Context, old, new string) error
- func (b *FSBackend) Name() string
- func (b *FSBackend) Persist(ctx context.Context, key, contentType string, f Persister) (string, int64, error)
- func (b *FSBackend) Serve(digest string, r *http.Request, w http.ResponseWriter) error
- type GCSBackend
- func (b *GCSBackend) Fetch(ctx context.Context, path string) (io.ReadCloser, error)
- func (b *GCSBackend) Move(ctx context.Context, old, new string) error
- func (b *GCSBackend) Name() string
- func (b *GCSBackend) Persist(ctx context.Context, path, contentType string, f Persister) (string, int64, error)
- func (b *GCSBackend) Serve(digest string, r *http.Request, w http.ResponseWriter) error
- type Persister
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface { // Name returns the name of the storage backend, for use in // log messages and such. Name() string // Persist provides a user-supplied function with a writer // that stores data in the storage backend. // // It needs to return the SHA256 hash of the data written as // well as the total number of bytes, as those are required // for the image manifest. Persist(ctx context.Context, path, contentType string, f Persister) (string, int64, error) // Fetch retrieves data from the storage backend. Fetch(ctx context.Context, path string) (io.ReadCloser, error) // Move renames a path inside the storage backend. This is // used for staging uploads while calculating their hashes. Move(ctx context.Context, old, new string) error // Serve provides a handler function to serve HTTP requests // for objects in the storage backend. Serve(digest string, r *http.Request, w http.ResponseWriter) error }
type FSBackend ¶
type FSBackend struct {
// contains filtered or unexported fields
}
func NewFSBackend ¶
type GCSBackend ¶
type GCSBackend struct {
// contains filtered or unexported fields
}
func NewGCSBackend ¶
func NewGCSBackend() (*GCSBackend, error)
Constructs a new GCS bucket backend based on the configured environment variables.
func (*GCSBackend) Fetch ¶
func (b *GCSBackend) Fetch(ctx context.Context, path string) (io.ReadCloser, error)
func (*GCSBackend) Move ¶
func (b *GCSBackend) Move(ctx context.Context, old, new string) error
renameObject renames an object in the specified Cloud Storage bucket.
The Go API for Cloud Storage does not support renaming objects, but the HTTP API does. The code below makes the relevant call manually.
func (*GCSBackend) Name ¶
func (b *GCSBackend) Name() string
func (*GCSBackend) Serve ¶
func (b *GCSBackend) Serve(digest string, r *http.Request, w http.ResponseWriter) error
Click to show internal directories.
Click to hide internal directories.