mirror of
https://github.com/gomods/athens
synced 2026-02-03 13:20:30 +00:00
* Storage: split storage.Getter interface * no need to clean up whats not there * unimplement rdmb getter * unimplement rdmb getter * make storage tests happy * comment out rdmbs from tests * fix tests * fix stuff we're removing anyway * PR fixes * oops * fix gcp exists
49 lines
1.5 KiB
Go
49 lines
1.5 KiB
Go
package storage
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
)
|
|
|
|
// BackendConnector is a regular storage backend with Connect functionality
|
|
type BackendConnector interface {
|
|
Backend
|
|
Connect() error
|
|
}
|
|
|
|
type noOpConnectedBackend struct {
|
|
backend Backend
|
|
}
|
|
|
|
// NoOpBackendConnector wraps storage backend with Connect functionality
|
|
func NoOpBackendConnector(b Backend) BackendConnector {
|
|
return noOpConnectedBackend{backend: b}
|
|
}
|
|
|
|
func (n noOpConnectedBackend) Connect() error {
|
|
return nil
|
|
}
|
|
|
|
func (n noOpConnectedBackend) Exists(ctx context.Context, module, version string) bool {
|
|
return n.backend.Exists(ctx, module, version)
|
|
}
|
|
|
|
func (n noOpConnectedBackend) Info(ctx context.Context, module, vsn string) ([]byte, error) {
|
|
return n.backend.Info(ctx, module, vsn)
|
|
}
|
|
func (n noOpConnectedBackend) GoMod(ctx context.Context, module, vsn string) ([]byte, error) {
|
|
return n.backend.GoMod(ctx, module, vsn)
|
|
}
|
|
func (n noOpConnectedBackend) Zip(ctx context.Context, module, vsn string) (io.ReadCloser, error) {
|
|
return n.backend.Zip(ctx, module, vsn)
|
|
}
|
|
func (n noOpConnectedBackend) List(ctx context.Context, module string) ([]string, error) {
|
|
return n.backend.List(ctx, module)
|
|
}
|
|
func (n noOpConnectedBackend) Save(ctx context.Context, module, version string, mod []byte, zip io.Reader, info []byte) error {
|
|
return n.backend.Save(ctx, module, version, mod, zip, info)
|
|
}
|
|
func (n noOpConnectedBackend) Delete(ctx context.Context, module, version string) error {
|
|
return n.backend.Delete(ctx, module, version)
|
|
}
|