distribution/registry/storage/driver/swarm/driver.go

107 lines
3.8 KiB
Go

package swarm
import (
"context"
"io"
"github.com/distribution/distribution/v3/registry/storage/driver"
"github.com/distribution/distribution/v3/registry/storage/driver/factory"
)
const driverName = "torrent"
func init() {
factory.Register(driverName, &torrentDriverFactory{})
}
// torrentDriverFactory implements the factory.StorageDriverFactory interface.
type torrentDriverFactory struct{}
var _ factory.StorageDriverFactory = (*torrentDriverFactory)(nil)
func (f *torrentDriverFactory) Create(map[string]interface{}) (driver.StorageDriver, error) {
return New(), nil
}
// torrentDriver implements the driver.StorageDriver interface
type torrentDriver struct{}
var _ driver.StorageDriver = (*torrentDriver)(nil)
func New() *torrentDriver {
return &torrentDriver{}
}
// Name returns the human-readable "name" of the driver, useful in error
// messages and logging. By convention, this will just be the registration
// name, but drivers may provide other information here.
func (t *torrentDriver) Name() string {
return driverName
}
func (t *torrentDriver) Delete(ctx context.Context, path string) error {
return nil
}
// GetContent retrieves the content stored at "path" as a []byte.
// This should primarily be used for small objects.
func (t *torrentDriver) GetContent(ctx context.Context, path string) ([]byte, error) {
panic("not implemented") // TODO: Implement
}
// PutContent stores the []byte content at a location designated by "path".
// This should primarily be used for small objects.
func (t *torrentDriver) PutContent(ctx context.Context, path string, content []byte) error {
panic("not implemented") // TODO: Implement
}
// Reader retrieves an io.ReadCloser for the content stored at "path"
// with a given byte offset.
// May be used to resume reading a stream by providing a nonzero offset.
func (t *torrentDriver) Reader(ctx context.Context, path string, offset int64) (io.ReadCloser, error) {
panic("not implemented") // TODO: Implement
}
// Writer returns a FileWriter which will store the content written to it
// at the location designated by "path" after the call to Commit.
func (t *torrentDriver) Writer(ctx context.Context, path string, append bool) (driver.FileWriter, error) {
panic("not implemented") // TODO: Implement
}
// Stat retrieves the FileInfo for the given path, including the current
// size in bytes and the creation time.
func (t *torrentDriver) Stat(ctx context.Context, path string) (driver.FileInfo, error) {
return &swarmFile{}, nil
}
// List returns a list of the objects that are direct descendants of the
// given path.
func (t *torrentDriver) List(ctx context.Context, path string) ([]string, error) {
panic("not implemented") // TODO: Implement
}
// Move moves an object stored at sourcePath to destPath, removing the
// original object.
// Note: This may be no more efficient than a copy followed by a delete for
// many implementations.
func (t *torrentDriver) Move(ctx context.Context, sourcePath string, destPath string) error {
panic("not implemented") // TODO: Implement
}
// URLFor returns a URL which may be used to retrieve the content stored at
// the given path, possibly using the given options.
// May return an ErrUnsupportedMethod in certain StorageDriver
// implementations.
func (t *torrentDriver) URLFor(ctx context.Context, path string, options map[string]interface{}) (string, error) {
panic("not implemented") // TODO: Implement
}
// Walk traverses a filesystem defined within driver, starting
// from the given path, calling f on each file.
// If the returned error from the WalkFn is ErrSkipDir and fileInfo refers
// to a directory, the directory will not be entered and Walk
// will continue the traversal. If fileInfo refers to a normal file, processing stops
func (t *torrentDriver) Walk(ctx context.Context, path string, f driver.WalkFn) error {
panic("not implemented") // TODO: Implement
}