mirror of
https://github.com/restic/restic.git
synced 2025-12-11 18:47:50 +00:00
add package to create a prepopulated backend registry
This commit is contained in:
@@ -11,21 +11,12 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/restic/restic/internal/backend"
|
"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/cache"
|
||||||
"github.com/restic/restic/internal/backend/gs"
|
|
||||||
"github.com/restic/restic/internal/backend/limiter"
|
"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/location"
|
||||||
"github.com/restic/restic/internal/backend/logger"
|
"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/retry"
|
||||||
"github.com/restic/restic/internal/backend/s3"
|
|
||||||
"github.com/restic/restic/internal/backend/sema"
|
"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/debug"
|
||||||
"github.com/restic/restic/internal/options"
|
"github.com/restic/restic/internal/options"
|
||||||
"github.com/restic/restic/internal/repository"
|
"github.com/restic/restic/internal/repository"
|
||||||
@@ -174,20 +165,6 @@ func (opts *GlobalOptions) PreRun(needsPassword bool) error {
|
|||||||
return nil
|
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.
|
// resolvePassword determines the password to be used for opening the repository.
|
||||||
func resolvePassword(opts *GlobalOptions, envStr string) (string, error) {
|
func resolvePassword(opts *GlobalOptions, envStr string) (string, error) {
|
||||||
if opts.PasswordFile != "" && opts.PasswordCommand != "" {
|
if opts.PasswordFile != "" && opts.PasswordCommand != "" {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/restic/restic/internal/backend"
|
"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/backend/retry"
|
||||||
"github.com/restic/restic/internal/data"
|
"github.com/restic/restic/internal/data"
|
||||||
"github.com/restic/restic/internal/errors"
|
"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
|
// 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 },
|
backendTestHook: func(r backend.Backend) (backend.Backend, error) { return newOrderedListOnceBackend(r), nil },
|
||||||
// start with default set of backends
|
// start with default set of backends
|
||||||
backends: collectBackends(),
|
backends: all.Backends(),
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup = func() {
|
cleanup = func() {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"go.uber.org/automaxprocs/maxprocs"
|
"go.uber.org/automaxprocs/maxprocs"
|
||||||
|
|
||||||
|
"github.com/restic/restic/internal/backend/all"
|
||||||
"github.com/restic/restic/internal/debug"
|
"github.com/restic/restic/internal/debug"
|
||||||
"github.com/restic/restic/internal/errors"
|
"github.com/restic/restic/internal/errors"
|
||||||
"github.com/restic/restic/internal/feature"
|
"github.com/restic/restic/internal/feature"
|
||||||
@@ -173,7 +174,7 @@ func main() {
|
|||||||
version, runtime.Version(), runtime.GOOS, runtime.GOARCH)
|
version, runtime.Version(), runtime.GOOS, runtime.GOARCH)
|
||||||
|
|
||||||
globalOptions := GlobalOptions{
|
globalOptions := GlobalOptions{
|
||||||
backends: collectBackends(),
|
backends: all.Backends(),
|
||||||
}
|
}
|
||||||
func() {
|
func() {
|
||||||
term, cancel := termstatus.Setup(os.Stdin, os.Stdout, os.Stderr, globalOptions.Quiet)
|
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
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user