mirror of
https://github.com/restic/restic.git
synced 2025-10-10 12:10:26 +00:00
backend: Unify backend construction using factory and registry
This unified construction removes most backend-specific code from global.go. The backend registry will also enable integration tests to use custom backends if necessary.
This commit is contained in:
@@ -15,6 +15,8 @@ import (
|
||||
|
||||
"github.com/restic/restic/internal/backend"
|
||||
"github.com/restic/restic/internal/backend/layout"
|
||||
"github.com/restic/restic/internal/backend/limiter"
|
||||
"github.com/restic/restic/internal/backend/location"
|
||||
"github.com/restic/restic/internal/debug"
|
||||
"github.com/restic/restic/internal/errors"
|
||||
"github.com/restic/restic/internal/restic"
|
||||
@@ -41,6 +43,14 @@ type SFTP struct {
|
||||
|
||||
var _ restic.Backend = &SFTP{}
|
||||
|
||||
func NewFactory() location.Factory {
|
||||
return location.NewLimitedBackendFactory(ParseConfig, location.NoPassword, func(ctx context.Context, cfg Config, _ limiter.Limiter) (*SFTP, error) {
|
||||
return Create(ctx, cfg)
|
||||
}, func(ctx context.Context, cfg Config, _ limiter.Limiter) (*SFTP, error) {
|
||||
return Open(ctx, cfg)
|
||||
})
|
||||
}
|
||||
|
||||
const defaultLayout = "default"
|
||||
|
||||
func startClient(cfg Config) (*SFTP, error) {
|
||||
|
Reference in New Issue
Block a user