mirror of
https://github.com/restic/restic.git
synced 2025-10-19 15:43:21 +00:00
add package to create a prepopulated backend registry
This commit is contained in:
parent
a632f490fa
commit
394c8de502
4 changed files with 32 additions and 25 deletions
|
@ -11,21 +11,12 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/restic/restic/internal/backend"
|
||||
"github.com/restic/restic/internal/backend/azure"
|
||||
"github.com/restic/restic/internal/backend/b2"
|
||||
"github.com/restic/restic/internal/backend/cache"
|
||||
"github.com/restic/restic/internal/backend/gs"
|
||||
"github.com/restic/restic/internal/backend/limiter"
|
||||
"github.com/restic/restic/internal/backend/local"
|
||||
"github.com/restic/restic/internal/backend/location"
|
||||
"github.com/restic/restic/internal/backend/logger"
|
||||
"github.com/restic/restic/internal/backend/rclone"
|
||||
"github.com/restic/restic/internal/backend/rest"
|
||||
"github.com/restic/restic/internal/backend/retry"
|
||||
"github.com/restic/restic/internal/backend/s3"
|
||||
"github.com/restic/restic/internal/backend/sema"
|
||||
"github.com/restic/restic/internal/backend/sftp"
|
||||
"github.com/restic/restic/internal/backend/swift"
|
||||
"github.com/restic/restic/internal/debug"
|
||||
"github.com/restic/restic/internal/options"
|
||||
"github.com/restic/restic/internal/repository"
|
||||
|
@ -174,20 +165,6 @@ func (opts *GlobalOptions) PreRun(needsPassword bool) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func collectBackends() *location.Registry {
|
||||
backends := location.NewRegistry()
|
||||
backends.Register(azure.NewFactory())
|
||||
backends.Register(b2.NewFactory())
|
||||
backends.Register(gs.NewFactory())
|
||||
backends.Register(local.NewFactory())
|
||||
backends.Register(rclone.NewFactory())
|
||||
backends.Register(rest.NewFactory())
|
||||
backends.Register(s3.NewFactory())
|
||||
backends.Register(sftp.NewFactory())
|
||||
backends.Register(swift.NewFactory())
|
||||
return backends
|
||||
}
|
||||
|
||||
// resolvePassword determines the password to be used for opening the repository.
|
||||
func resolvePassword(opts *GlobalOptions, envStr string) (string, error) {
|
||||
if opts.PasswordFile != "" && opts.PasswordCommand != "" {
|
||||
|
|
|
@ -14,6 +14,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/restic/restic/internal/backend"
|
||||
"github.com/restic/restic/internal/backend/all"
|
||||
"github.com/restic/restic/internal/backend/retry"
|
||||
"github.com/restic/restic/internal/data"
|
||||
"github.com/restic/restic/internal/errors"
|
||||
|
@ -218,7 +219,7 @@ func withTestEnvironment(t testing.TB) (env *testEnvironment, cleanup func()) {
|
|||
// replace this hook with "nil" if listing a filetype more than once is necessary
|
||||
backendTestHook: func(r backend.Backend) (backend.Backend, error) { return newOrderedListOnceBackend(r), nil },
|
||||
// start with default set of backends
|
||||
backends: collectBackends(),
|
||||
backends: all.Backends(),
|
||||
}
|
||||
|
||||
cleanup = func() {
|
||||
|
|
|
@ -14,6 +14,7 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
"go.uber.org/automaxprocs/maxprocs"
|
||||
|
||||
"github.com/restic/restic/internal/backend/all"
|
||||
"github.com/restic/restic/internal/debug"
|
||||
"github.com/restic/restic/internal/errors"
|
||||
"github.com/restic/restic/internal/feature"
|
||||
|
@ -173,7 +174,7 @@ func main() {
|
|||
version, runtime.Version(), runtime.GOOS, runtime.GOARCH)
|
||||
|
||||
globalOptions := GlobalOptions{
|
||||
backends: collectBackends(),
|
||||
backends: all.Backends(),
|
||||
}
|
||||
func() {
|
||||
term, cancel := termstatus.Setup(os.Stdin, os.Stdout, os.Stderr, globalOptions.Quiet)
|
||||
|
|
28
internal/backend/all/all.go
Normal file
28
internal/backend/all/all.go
Normal file
|
@ -0,0 +1,28 @@
|
|||
package all
|
||||
|
||||
import (
|
||||
"github.com/restic/restic/internal/backend/azure"
|
||||
"github.com/restic/restic/internal/backend/b2"
|
||||
"github.com/restic/restic/internal/backend/gs"
|
||||
"github.com/restic/restic/internal/backend/local"
|
||||
"github.com/restic/restic/internal/backend/location"
|
||||
"github.com/restic/restic/internal/backend/rclone"
|
||||
"github.com/restic/restic/internal/backend/rest"
|
||||
"github.com/restic/restic/internal/backend/s3"
|
||||
"github.com/restic/restic/internal/backend/sftp"
|
||||
"github.com/restic/restic/internal/backend/swift"
|
||||
)
|
||||
|
||||
func Backends() *location.Registry {
|
||||
backends := location.NewRegistry()
|
||||
backends.Register(azure.NewFactory())
|
||||
backends.Register(b2.NewFactory())
|
||||
backends.Register(gs.NewFactory())
|
||||
backends.Register(local.NewFactory())
|
||||
backends.Register(rclone.NewFactory())
|
||||
backends.Register(rest.NewFactory())
|
||||
backends.Register(s3.NewFactory())
|
||||
backends.Register(sftp.NewFactory())
|
||||
backends.Register(swift.NewFactory())
|
||||
return backends
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue