backend: let ParseConfig return a Config pointer

In order to change the backend initialization in `global.go` to be able
to generically call cfg.ApplyEnvironment() for supported backends, the
`interface{}` returned by `ParseConfig` must contain a pointer to the
configuration.

An alternative would be to use reflection to convert the type from
`interface{}(Config)` to `interface{}(*Config)` (from value to pointer
type). However, this would just complicate the type mess further.
This commit is contained in:
Michael Eischer 2023-04-21 21:35:34 +02:00
parent 25a0be7f26
commit f903db492c
26 changed files with 165 additions and 146 deletions

View file

@ -540,8 +540,8 @@ func parseConfig(loc location.Location, opts options.Options) (interface{}, erro
switch loc.Scheme { switch loc.Scheme {
case "local": case "local":
cfg := loc.Config.(local.Config) cfg := loc.Config.(*local.Config)
if err := opts.Apply(loc.Scheme, &cfg); err != nil { if err := opts.Apply(loc.Scheme, cfg); err != nil {
return nil, err return nil, err
} }
@ -549,8 +549,8 @@ func parseConfig(loc location.Location, opts options.Options) (interface{}, erro
return cfg, nil return cfg, nil
case "sftp": case "sftp":
cfg := loc.Config.(sftp.Config) cfg := loc.Config.(*sftp.Config)
if err := opts.Apply(loc.Scheme, &cfg); err != nil { if err := opts.Apply(loc.Scheme, cfg); err != nil {
return nil, err return nil, err
} }
@ -558,12 +558,12 @@ func parseConfig(loc location.Location, opts options.Options) (interface{}, erro
return cfg, nil return cfg, nil
case "s3": case "s3":
cfg := loc.Config.(s3.Config) cfg := loc.Config.(*s3.Config)
if err := s3.ApplyEnvironment(&cfg); err != nil { if err := s3.ApplyEnvironment(cfg); err != nil {
return nil, err return nil, err
} }
if err := opts.Apply(loc.Scheme, &cfg); err != nil { if err := opts.Apply(loc.Scheme, cfg); err != nil {
return nil, err return nil, err
} }
@ -571,12 +571,12 @@ func parseConfig(loc location.Location, opts options.Options) (interface{}, erro
return cfg, nil return cfg, nil
case "gs": case "gs":
cfg := loc.Config.(gs.Config) cfg := loc.Config.(*gs.Config)
if err := gs.ApplyEnvironment(&cfg); err != nil { if err := gs.ApplyEnvironment(cfg); err != nil {
return nil, err return nil, err
} }
if err := opts.Apply(loc.Scheme, &cfg); err != nil { if err := opts.Apply(loc.Scheme, cfg); err != nil {
return nil, err return nil, err
} }
@ -584,12 +584,12 @@ func parseConfig(loc location.Location, opts options.Options) (interface{}, erro
return cfg, nil return cfg, nil
case "azure": case "azure":
cfg := loc.Config.(azure.Config) cfg := loc.Config.(*azure.Config)
if err := azure.ApplyEnvironment(&cfg); err != nil { if err := azure.ApplyEnvironment(cfg); err != nil {
return nil, err return nil, err
} }
if err := opts.Apply(loc.Scheme, &cfg); err != nil { if err := opts.Apply(loc.Scheme, cfg); err != nil {
return nil, err return nil, err
} }
@ -597,13 +597,13 @@ func parseConfig(loc location.Location, opts options.Options) (interface{}, erro
return cfg, nil return cfg, nil
case "swift": case "swift":
cfg := loc.Config.(swift.Config) cfg := loc.Config.(*swift.Config)
if err := swift.ApplyEnvironment("", &cfg); err != nil { if err := swift.ApplyEnvironment("", cfg); err != nil {
return nil, err return nil, err
} }
if err := opts.Apply(loc.Scheme, &cfg); err != nil { if err := opts.Apply(loc.Scheme, cfg); err != nil {
return nil, err return nil, err
} }
@ -611,28 +611,28 @@ func parseConfig(loc location.Location, opts options.Options) (interface{}, erro
return cfg, nil return cfg, nil
case "b2": case "b2":
cfg := loc.Config.(b2.Config) cfg := loc.Config.(*b2.Config)
if err := b2.ApplyEnvironment(&cfg); err != nil { if err := b2.ApplyEnvironment(cfg); err != nil {
return nil, err return nil, err
} }
if err := opts.Apply(loc.Scheme, &cfg); err != nil { if err := opts.Apply(loc.Scheme, cfg); err != nil {
return nil, err return nil, err
} }
debug.Log("opening b2 repository at %#v", cfg) debug.Log("opening b2 repository at %#v", cfg)
return cfg, nil return cfg, nil
case "rest": case "rest":
cfg := loc.Config.(rest.Config) cfg := loc.Config.(*rest.Config)
if err := opts.Apply(loc.Scheme, &cfg); err != nil { if err := opts.Apply(loc.Scheme, cfg); err != nil {
return nil, err return nil, err
} }
debug.Log("opening rest repository at %#v", cfg) debug.Log("opening rest repository at %#v", cfg)
return cfg, nil return cfg, nil
case "rclone": case "rclone":
cfg := loc.Config.(rclone.Config) cfg := loc.Config.(*rclone.Config)
if err := opts.Apply(loc.Scheme, &cfg); err != nil { if err := opts.Apply(loc.Scheme, cfg); err != nil {
return nil, err return nil, err
} }
@ -669,23 +669,23 @@ func open(ctx context.Context, s string, gopts GlobalOptions, opts options.Optio
switch loc.Scheme { switch loc.Scheme {
case "local": case "local":
be, err = local.Open(ctx, cfg.(local.Config)) be, err = local.Open(ctx, *cfg.(*local.Config))
case "sftp": case "sftp":
be, err = sftp.Open(ctx, cfg.(sftp.Config)) be, err = sftp.Open(ctx, *cfg.(*sftp.Config))
case "s3": case "s3":
be, err = s3.Open(ctx, cfg.(s3.Config), rt) be, err = s3.Open(ctx, *cfg.(*s3.Config), rt)
case "gs": case "gs":
be, err = gs.Open(cfg.(gs.Config), rt) be, err = gs.Open(*cfg.(*gs.Config), rt)
case "azure": case "azure":
be, err = azure.Open(ctx, cfg.(azure.Config), rt) be, err = azure.Open(ctx, *cfg.(*azure.Config), rt)
case "swift": case "swift":
be, err = swift.Open(ctx, cfg.(swift.Config), rt) be, err = swift.Open(ctx, *cfg.(*swift.Config), rt)
case "b2": case "b2":
be, err = b2.Open(ctx, cfg.(b2.Config), rt) be, err = b2.Open(ctx, *cfg.(*b2.Config), rt)
case "rest": case "rest":
be, err = rest.Open(cfg.(rest.Config), rt) be, err = rest.Open(*cfg.(*rest.Config), rt)
case "rclone": case "rclone":
be, err = rclone.Open(cfg.(rclone.Config), lim) be, err = rclone.Open(*cfg.(*rclone.Config), lim)
default: default:
return nil, errors.Fatalf("invalid backend: %q", loc.Scheme) return nil, errors.Fatalf("invalid backend: %q", loc.Scheme)
@ -745,23 +745,23 @@ func create(ctx context.Context, s string, opts options.Options) (restic.Backend
var be restic.Backend var be restic.Backend
switch loc.Scheme { switch loc.Scheme {
case "local": case "local":
be, err = local.Create(ctx, cfg.(local.Config)) be, err = local.Create(ctx, *cfg.(*local.Config))
case "sftp": case "sftp":
be, err = sftp.Create(ctx, cfg.(sftp.Config)) be, err = sftp.Create(ctx, *cfg.(*sftp.Config))
case "s3": case "s3":
be, err = s3.Create(ctx, cfg.(s3.Config), rt) be, err = s3.Create(ctx, *cfg.(*s3.Config), rt)
case "gs": case "gs":
be, err = gs.Create(ctx, cfg.(gs.Config), rt) be, err = gs.Create(ctx, *cfg.(*gs.Config), rt)
case "azure": case "azure":
be, err = azure.Create(ctx, cfg.(azure.Config), rt) be, err = azure.Create(ctx, *cfg.(*azure.Config), rt)
case "swift": case "swift":
be, err = swift.Open(ctx, cfg.(swift.Config), rt) be, err = swift.Open(ctx, *cfg.(*swift.Config), rt)
case "b2": case "b2":
be, err = b2.Create(ctx, cfg.(b2.Config), rt) be, err = b2.Create(ctx, *cfg.(*b2.Config), rt)
case "rest": case "rest":
be, err = rest.Create(ctx, cfg.(rest.Config), rt) be, err = rest.Create(ctx, *cfg.(*rest.Config), rt)
case "rclone": case "rclone":
be, err = rclone.Create(ctx, cfg.(rclone.Config)) be, err = rclone.Create(ctx, *cfg.(*rclone.Config))
default: default:
debug.Log("invalid repository scheme: %v", s) debug.Log("invalid repository scheme: %v", s)
return nil, errors.Fatalf("invalid scheme %q", loc.Scheme) return nil, errors.Fatalf("invalid scheme %q", loc.Scheme)

View file

@ -29,10 +29,10 @@ func newAzureTestSuite(t testing.TB) *test.Suite[azure.Config] {
MinimalData: true, MinimalData: true,
// NewConfig returns a config for a new temporary backend that will be used in tests. // NewConfig returns a config for a new temporary backend that will be used in tests.
NewConfig: func() (azure.Config, error) { NewConfig: func() (*azure.Config, error) {
cfg, err := azure.ParseConfig(os.Getenv("RESTIC_TEST_AZURE_REPOSITORY")) cfg, err := azure.ParseConfig(os.Getenv("RESTIC_TEST_AZURE_REPOSITORY"))
if err != nil { if err != nil {
return azure.Config{}, err return nil, err
} }
cfg.AccountName = os.Getenv("RESTIC_TEST_AZURE_ACCOUNT_NAME") cfg.AccountName = os.Getenv("RESTIC_TEST_AZURE_ACCOUNT_NAME")
@ -150,7 +150,7 @@ func TestUploadLargeFile(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
be, err := azure.Create(ctx, cfg, tr) be, err := azure.Create(ctx, *cfg, tr)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View file

@ -34,9 +34,9 @@ func init() {
// ParseConfig parses the string s and extracts the azure config. The // ParseConfig parses the string s and extracts the azure config. The
// configuration format is azure:containerName:/[prefix]. // configuration format is azure:containerName:/[prefix].
func ParseConfig(s string) (Config, error) { func ParseConfig(s string) (*Config, error) {
if !strings.HasPrefix(s, "azure:") { if !strings.HasPrefix(s, "azure:") {
return Config{}, errors.New("azure: invalid format") return nil, errors.New("azure: invalid format")
} }
// strip prefix "azure:" // strip prefix "azure:"
@ -46,13 +46,13 @@ func ParseConfig(s string) (Config, error) {
// remainder as prefix // remainder as prefix
container, prefix, colon := strings.Cut(s, ":") container, prefix, colon := strings.Cut(s, ":")
if !colon { if !colon {
return Config{}, errors.New("azure: invalid format: bucket name or path not found") return nil, errors.New("azure: invalid format: bucket name or path not found")
} }
prefix = strings.TrimPrefix(path.Clean(prefix), "/") prefix = strings.TrimPrefix(path.Clean(prefix), "/")
cfg := NewConfig() cfg := NewConfig()
cfg.Container = container cfg.Container = container
cfg.Prefix = prefix cfg.Prefix = prefix
return cfg, nil return &cfg, nil
} }
// ApplyEnvironment saves values from the environment to the config. // ApplyEnvironment saves values from the environment to the config.

View file

@ -30,10 +30,10 @@ func newB2TestSuite(t testing.TB) *test.Suite[b2.Config] {
WaitForDelayedRemoval: 10 * time.Second, WaitForDelayedRemoval: 10 * time.Second,
// NewConfig returns a config for a new temporary backend that will be used in tests. // NewConfig returns a config for a new temporary backend that will be used in tests.
NewConfig: func() (b2.Config, error) { NewConfig: func() (*b2.Config, error) {
cfg, err := b2.ParseConfig(os.Getenv("RESTIC_TEST_B2_REPOSITORY")) cfg, err := b2.ParseConfig(os.Getenv("RESTIC_TEST_B2_REPOSITORY"))
if err != nil { if err != nil {
return b2.Config{}, err return nil, err
} }
cfg.AccountID = os.Getenv("RESTIC_TEST_B2_ACCOUNT_ID") cfg.AccountID = os.Getenv("RESTIC_TEST_B2_ACCOUNT_ID")

View file

@ -59,15 +59,15 @@ func checkBucketName(name string) error {
// ParseConfig parses the string s and extracts the b2 config. The supported // ParseConfig parses the string s and extracts the b2 config. The supported
// configuration format is b2:bucketname/prefix. If no prefix is given the // configuration format is b2:bucketname/prefix. If no prefix is given the
// prefix "restic" will be used. // prefix "restic" will be used.
func ParseConfig(s string) (Config, error) { func ParseConfig(s string) (*Config, error) {
if !strings.HasPrefix(s, "b2:") { if !strings.HasPrefix(s, "b2:") {
return Config{}, errors.New("invalid format, want: b2:bucket-name[:path]") return nil, errors.New("invalid format, want: b2:bucket-name[:path]")
} }
s = s[3:] s = s[3:]
bucket, prefix, _ := strings.Cut(s, ":") bucket, prefix, _ := strings.Cut(s, ":")
if err := checkBucketName(bucket); err != nil { if err := checkBucketName(bucket); err != nil {
return Config{}, err return nil, err
} }
if len(prefix) > 0 { if len(prefix) > 0 {
@ -78,7 +78,7 @@ func ParseConfig(s string) (Config, error) {
cfg.Bucket = bucket cfg.Bucket = bucket
cfg.Prefix = prefix cfg.Prefix = prefix
return cfg, nil return &cfg, nil
} }
// ApplyEnvironment saves values from the environment to the config. // ApplyEnvironment saves values from the environment to the config.

View file

@ -35,9 +35,9 @@ func init() {
// ParseConfig parses the string s and extracts the gcs config. The // ParseConfig parses the string s and extracts the gcs config. The
// supported configuration format is gs:bucketName:/[prefix]. // supported configuration format is gs:bucketName:/[prefix].
func ParseConfig(s string) (Config, error) { func ParseConfig(s string) (*Config, error) {
if !strings.HasPrefix(s, "gs:") { if !strings.HasPrefix(s, "gs:") {
return Config{}, errors.New("gs: invalid format") return nil, errors.New("gs: invalid format")
} }
// strip prefix "gs:" // strip prefix "gs:"
@ -47,7 +47,7 @@ func ParseConfig(s string) (Config, error) {
// remainder as prefix // remainder as prefix
bucket, prefix, colon := strings.Cut(s, ":") bucket, prefix, colon := strings.Cut(s, ":")
if !colon { if !colon {
return Config{}, errors.New("gs: invalid format: bucket name or path not found") return nil, errors.New("gs: invalid format: bucket name or path not found")
} }
prefix = strings.TrimPrefix(path.Clean(prefix), "/") prefix = strings.TrimPrefix(path.Clean(prefix), "/")
@ -55,7 +55,7 @@ func ParseConfig(s string) (Config, error) {
cfg := NewConfig() cfg := NewConfig()
cfg.Bucket = bucket cfg.Bucket = bucket
cfg.Prefix = prefix cfg.Prefix = prefix
return cfg, nil return &cfg, nil
} }
// ApplyEnvironment saves values from the environment to the config. // ApplyEnvironment saves values from the environment to the config.

View file

@ -26,10 +26,10 @@ func newGSTestSuite(t testing.TB) *test.Suite[gs.Config] {
MinimalData: true, MinimalData: true,
// NewConfig returns a config for a new temporary backend that will be used in tests. // NewConfig returns a config for a new temporary backend that will be used in tests.
NewConfig: func() (gs.Config, error) { NewConfig: func() (*gs.Config, error) {
cfg, err := gs.ParseConfig(os.Getenv("RESTIC_TEST_GS_REPOSITORY")) cfg, err := gs.ParseConfig(os.Getenv("RESTIC_TEST_GS_REPOSITORY"))
if err != nil { if err != nil {
return gs.Config{}, err return nil, err
} }
cfg.ProjectID = os.Getenv("RESTIC_TEST_GS_PROJECT_ID") cfg.ProjectID = os.Getenv("RESTIC_TEST_GS_PROJECT_ID")

View file

@ -27,12 +27,12 @@ func init() {
} }
// ParseConfig parses a local backend config. // ParseConfig parses a local backend config.
func ParseConfig(s string) (Config, error) { func ParseConfig(s string) (*Config, error) {
if !strings.HasPrefix(s, "local:") { if !strings.HasPrefix(s, "local:") {
return Config{}, errors.New(`invalid format, prefix "local" not found`) return nil, errors.New(`invalid format, prefix "local" not found`)
} }
cfg := NewConfig() cfg := NewConfig()
cfg.Path = s[6:] cfg.Path = s[6:]
return cfg, nil return &cfg, nil
} }

View file

@ -0,0 +1,18 @@
package local
import (
"testing"
"github.com/restic/restic/internal/backend/test"
)
var configTests = []test.ConfigTestData[Config]{
{S: "local:/some/path", Cfg: Config{
Path: "/some/path",
Connections: 2,
}},
}
func TestParseConfig(t *testing.T) {
test.ParseConfigTester(t, ParseConfig, configTests)
}

View file

@ -15,7 +15,7 @@ import (
func newTestSuite(t testing.TB) *test.Suite[local.Config] { func newTestSuite(t testing.TB) *test.Suite[local.Config] {
return &test.Suite[local.Config]{ return &test.Suite[local.Config]{
// NewConfig returns a config for a new temporary backend that will be used in tests. // NewConfig returns a config for a new temporary backend that will be used in tests.
NewConfig: func() (local.Config, error) { NewConfig: func() (*local.Config, error) {
dir, err := os.MkdirTemp(rtest.TestTempDir, "restic-test-local-") dir, err := os.MkdirTemp(rtest.TestTempDir, "restic-test-local-")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@ -23,7 +23,7 @@ func newTestSuite(t testing.TB) *test.Suite[local.Config] {
t.Logf("create new backend at %v", dir) t.Logf("create new backend at %v", dir)
cfg := local.Config{ cfg := &local.Config{
Path: dir, Path: dir,
Connections: 2, Connections: 2,
} }

View file

@ -29,7 +29,7 @@ type parser struct {
stripPassword func(string) string stripPassword func(string) string
} }
func configToAny[C any](parser func(string) (C, error)) func(string) (interface{}, error) { func configToAny[C any](parser func(string) (*C, error)) func(string) (interface{}, error) {
return func(s string) (interface{}, error) { return func(s string) (interface{}, error) {
return parser(s) return parser(s)
} }

View file

@ -29,7 +29,7 @@ var parseTests = []struct {
{ {
"local:/srv/repo", "local:/srv/repo",
Location{Scheme: "local", Location{Scheme: "local",
Config: local.Config{ Config: &local.Config{
Path: "/srv/repo", Path: "/srv/repo",
Connections: 2, Connections: 2,
}, },
@ -38,7 +38,7 @@ var parseTests = []struct {
{ {
"local:dir1/dir2", "local:dir1/dir2",
Location{Scheme: "local", Location{Scheme: "local",
Config: local.Config{ Config: &local.Config{
Path: "dir1/dir2", Path: "dir1/dir2",
Connections: 2, Connections: 2,
}, },
@ -47,7 +47,7 @@ var parseTests = []struct {
{ {
"local:dir1/dir2", "local:dir1/dir2",
Location{Scheme: "local", Location{Scheme: "local",
Config: local.Config{ Config: &local.Config{
Path: "dir1/dir2", Path: "dir1/dir2",
Connections: 2, Connections: 2,
}, },
@ -56,7 +56,7 @@ var parseTests = []struct {
{ {
"dir1/dir2", "dir1/dir2",
Location{Scheme: "local", Location{Scheme: "local",
Config: local.Config{ Config: &local.Config{
Path: "dir1/dir2", Path: "dir1/dir2",
Connections: 2, Connections: 2,
}, },
@ -65,7 +65,7 @@ var parseTests = []struct {
{ {
"/dir1/dir2", "/dir1/dir2",
Location{Scheme: "local", Location{Scheme: "local",
Config: local.Config{ Config: &local.Config{
Path: "/dir1/dir2", Path: "/dir1/dir2",
Connections: 2, Connections: 2,
}, },
@ -74,7 +74,7 @@ var parseTests = []struct {
{ {
"local:../dir1/dir2", "local:../dir1/dir2",
Location{Scheme: "local", Location{Scheme: "local",
Config: local.Config{ Config: &local.Config{
Path: "../dir1/dir2", Path: "../dir1/dir2",
Connections: 2, Connections: 2,
}, },
@ -83,7 +83,7 @@ var parseTests = []struct {
{ {
"/dir1/dir2", "/dir1/dir2",
Location{Scheme: "local", Location{Scheme: "local",
Config: local.Config{ Config: &local.Config{
Path: "/dir1/dir2", Path: "/dir1/dir2",
Connections: 2, Connections: 2,
}, },
@ -92,7 +92,7 @@ var parseTests = []struct {
{ {
"/dir1:foobar/dir2", "/dir1:foobar/dir2",
Location{Scheme: "local", Location{Scheme: "local",
Config: local.Config{ Config: &local.Config{
Path: "/dir1:foobar/dir2", Path: "/dir1:foobar/dir2",
Connections: 2, Connections: 2,
}, },
@ -101,7 +101,7 @@ var parseTests = []struct {
{ {
`\dir1\foobar\dir2`, `\dir1\foobar\dir2`,
Location{Scheme: "local", Location{Scheme: "local",
Config: local.Config{ Config: &local.Config{
Path: `\dir1\foobar\dir2`, Path: `\dir1\foobar\dir2`,
Connections: 2, Connections: 2,
}, },
@ -110,7 +110,7 @@ var parseTests = []struct {
{ {
`c:\dir1\foobar\dir2`, `c:\dir1\foobar\dir2`,
Location{Scheme: "local", Location{Scheme: "local",
Config: local.Config{ Config: &local.Config{
Path: `c:\dir1\foobar\dir2`, Path: `c:\dir1\foobar\dir2`,
Connections: 2, Connections: 2,
}, },
@ -119,7 +119,7 @@ var parseTests = []struct {
{ {
`C:\Users\appveyor\AppData\Local\Temp\1\restic-test-879453535\repo`, `C:\Users\appveyor\AppData\Local\Temp\1\restic-test-879453535\repo`,
Location{Scheme: "local", Location{Scheme: "local",
Config: local.Config{ Config: &local.Config{
Path: `C:\Users\appveyor\AppData\Local\Temp\1\restic-test-879453535\repo`, Path: `C:\Users\appveyor\AppData\Local\Temp\1\restic-test-879453535\repo`,
Connections: 2, Connections: 2,
}, },
@ -128,7 +128,7 @@ var parseTests = []struct {
{ {
`c:/dir1/foobar/dir2`, `c:/dir1/foobar/dir2`,
Location{Scheme: "local", Location{Scheme: "local",
Config: local.Config{ Config: &local.Config{
Path: `c:/dir1/foobar/dir2`, Path: `c:/dir1/foobar/dir2`,
Connections: 2, Connections: 2,
}, },
@ -137,7 +137,7 @@ var parseTests = []struct {
{ {
"sftp:user@host:/srv/repo", "sftp:user@host:/srv/repo",
Location{Scheme: "sftp", Location{Scheme: "sftp",
Config: sftp.Config{ Config: &sftp.Config{
User: "user", User: "user",
Host: "host", Host: "host",
Path: "/srv/repo", Path: "/srv/repo",
@ -148,7 +148,7 @@ var parseTests = []struct {
{ {
"sftp:host:/srv/repo", "sftp:host:/srv/repo",
Location{Scheme: "sftp", Location{Scheme: "sftp",
Config: sftp.Config{ Config: &sftp.Config{
User: "", User: "",
Host: "host", Host: "host",
Path: "/srv/repo", Path: "/srv/repo",
@ -159,7 +159,7 @@ var parseTests = []struct {
{ {
"sftp://user@host/srv/repo", "sftp://user@host/srv/repo",
Location{Scheme: "sftp", Location{Scheme: "sftp",
Config: sftp.Config{ Config: &sftp.Config{
User: "user", User: "user",
Host: "host", Host: "host",
Path: "srv/repo", Path: "srv/repo",
@ -170,7 +170,7 @@ var parseTests = []struct {
{ {
"sftp://user@host//srv/repo", "sftp://user@host//srv/repo",
Location{Scheme: "sftp", Location{Scheme: "sftp",
Config: sftp.Config{ Config: &sftp.Config{
User: "user", User: "user",
Host: "host", Host: "host",
Path: "/srv/repo", Path: "/srv/repo",
@ -182,7 +182,7 @@ var parseTests = []struct {
{ {
"s3://eu-central-1/bucketname", "s3://eu-central-1/bucketname",
Location{Scheme: "s3", Location{Scheme: "s3",
Config: s3.Config{ Config: &s3.Config{
Endpoint: "eu-central-1", Endpoint: "eu-central-1",
Bucket: "bucketname", Bucket: "bucketname",
Prefix: "", Prefix: "",
@ -193,7 +193,7 @@ var parseTests = []struct {
{ {
"s3://hostname.foo/bucketname", "s3://hostname.foo/bucketname",
Location{Scheme: "s3", Location{Scheme: "s3",
Config: s3.Config{ Config: &s3.Config{
Endpoint: "hostname.foo", Endpoint: "hostname.foo",
Bucket: "bucketname", Bucket: "bucketname",
Prefix: "", Prefix: "",
@ -204,7 +204,7 @@ var parseTests = []struct {
{ {
"s3://hostname.foo/bucketname/prefix/directory", "s3://hostname.foo/bucketname/prefix/directory",
Location{Scheme: "s3", Location{Scheme: "s3",
Config: s3.Config{ Config: &s3.Config{
Endpoint: "hostname.foo", Endpoint: "hostname.foo",
Bucket: "bucketname", Bucket: "bucketname",
Prefix: "prefix/directory", Prefix: "prefix/directory",
@ -215,7 +215,7 @@ var parseTests = []struct {
{ {
"s3:eu-central-1/repo", "s3:eu-central-1/repo",
Location{Scheme: "s3", Location{Scheme: "s3",
Config: s3.Config{ Config: &s3.Config{
Endpoint: "eu-central-1", Endpoint: "eu-central-1",
Bucket: "repo", Bucket: "repo",
Prefix: "", Prefix: "",
@ -226,7 +226,7 @@ var parseTests = []struct {
{ {
"s3:eu-central-1/repo/prefix/directory", "s3:eu-central-1/repo/prefix/directory",
Location{Scheme: "s3", Location{Scheme: "s3",
Config: s3.Config{ Config: &s3.Config{
Endpoint: "eu-central-1", Endpoint: "eu-central-1",
Bucket: "repo", Bucket: "repo",
Prefix: "prefix/directory", Prefix: "prefix/directory",
@ -237,7 +237,7 @@ var parseTests = []struct {
{ {
"s3:https://hostname.foo/repo", "s3:https://hostname.foo/repo",
Location{Scheme: "s3", Location{Scheme: "s3",
Config: s3.Config{ Config: &s3.Config{
Endpoint: "hostname.foo", Endpoint: "hostname.foo",
Bucket: "repo", Bucket: "repo",
Prefix: "", Prefix: "",
@ -248,7 +248,7 @@ var parseTests = []struct {
{ {
"s3:https://hostname.foo/repo/prefix/directory", "s3:https://hostname.foo/repo/prefix/directory",
Location{Scheme: "s3", Location{Scheme: "s3",
Config: s3.Config{ Config: &s3.Config{
Endpoint: "hostname.foo", Endpoint: "hostname.foo",
Bucket: "repo", Bucket: "repo",
Prefix: "prefix/directory", Prefix: "prefix/directory",
@ -259,7 +259,7 @@ var parseTests = []struct {
{ {
"s3:http://hostname.foo/repo", "s3:http://hostname.foo/repo",
Location{Scheme: "s3", Location{Scheme: "s3",
Config: s3.Config{ Config: &s3.Config{
Endpoint: "hostname.foo", Endpoint: "hostname.foo",
Bucket: "repo", Bucket: "repo",
Prefix: "", Prefix: "",
@ -271,7 +271,7 @@ var parseTests = []struct {
{ {
"swift:container17:/", "swift:container17:/",
Location{Scheme: "swift", Location{Scheme: "swift",
Config: swift.Config{ Config: &swift.Config{
Container: "container17", Container: "container17",
Prefix: "", Prefix: "",
Connections: 5, Connections: 5,
@ -281,7 +281,7 @@ var parseTests = []struct {
{ {
"swift:container17:/prefix97", "swift:container17:/prefix97",
Location{Scheme: "swift", Location{Scheme: "swift",
Config: swift.Config{ Config: &swift.Config{
Container: "container17", Container: "container17",
Prefix: "prefix97", Prefix: "prefix97",
Connections: 5, Connections: 5,
@ -291,7 +291,7 @@ var parseTests = []struct {
{ {
"rest:http://hostname.foo:1234/", "rest:http://hostname.foo:1234/",
Location{Scheme: "rest", Location{Scheme: "rest",
Config: rest.Config{ Config: &rest.Config{
URL: parseURL("http://hostname.foo:1234/"), URL: parseURL("http://hostname.foo:1234/"),
Connections: 5, Connections: 5,
}, },
@ -299,7 +299,7 @@ var parseTests = []struct {
}, },
{ {
"b2:bucketname:/prefix", Location{Scheme: "b2", "b2:bucketname:/prefix", Location{Scheme: "b2",
Config: b2.Config{ Config: &b2.Config{
Bucket: "bucketname", Bucket: "bucketname",
Prefix: "prefix", Prefix: "prefix",
Connections: 5, Connections: 5,
@ -308,7 +308,7 @@ var parseTests = []struct {
}, },
{ {
"b2:bucketname", Location{Scheme: "b2", "b2:bucketname", Location{Scheme: "b2",
Config: b2.Config{ Config: &b2.Config{
Bucket: "bucketname", Bucket: "bucketname",
Prefix: "", Prefix: "",
Connections: 5, Connections: 5,

View file

@ -18,8 +18,9 @@ type memConfig struct {
func newTestSuite() *test.Suite[*memConfig] { func newTestSuite() *test.Suite[*memConfig] {
return &test.Suite[*memConfig]{ return &test.Suite[*memConfig]{
// NewConfig returns a config for a new temporary backend that will be used in tests. // NewConfig returns a config for a new temporary backend that will be used in tests.
NewConfig: func() (*memConfig, error) { NewConfig: func() (**memConfig, error) {
return &memConfig{}, nil cfg := &memConfig{}
return &cfg, nil
}, },
// CreateFn is a function that creates a temporary repository for the tests. // CreateFn is a function that creates a temporary repository for the tests.

View file

@ -17,11 +17,11 @@ func newTestSuite(t testing.TB) *test.Suite[rclone.Config] {
return &test.Suite[rclone.Config]{ return &test.Suite[rclone.Config]{
// NewConfig returns a config for a new temporary backend that will be used in tests. // NewConfig returns a config for a new temporary backend that will be used in tests.
NewConfig: func() (rclone.Config, error) { NewConfig: func() (*rclone.Config, error) {
t.Logf("use backend at %v", dir) t.Logf("use backend at %v", dir)
cfg := rclone.NewConfig() cfg := rclone.NewConfig()
cfg.Remote = dir cfg.Remote = dir
return cfg, nil return &cfg, nil
}, },
// CreateFn is a function that creates a temporary repository for the tests. // CreateFn is a function that creates a temporary repository for the tests.

View file

@ -34,13 +34,13 @@ func NewConfig() Config {
} }
// ParseConfig parses the string s and extracts the remote server URL. // ParseConfig parses the string s and extracts the remote server URL.
func ParseConfig(s string) (Config, error) { func ParseConfig(s string) (*Config, error) {
if !strings.HasPrefix(s, "rclone:") { if !strings.HasPrefix(s, "rclone:") {
return Config{}, errors.New("invalid rclone backend specification") return nil, errors.New("invalid rclone backend specification")
} }
s = s[7:] s = s[7:]
cfg := NewConfig() cfg := NewConfig()
cfg.Remote = s cfg.Remote = s
return cfg, nil return &cfg, nil
} }

View file

@ -26,21 +26,21 @@ func NewConfig() Config {
} }
// ParseConfig parses the string s and extracts the REST server URL. // ParseConfig parses the string s and extracts the REST server URL.
func ParseConfig(s string) (Config, error) { func ParseConfig(s string) (*Config, error) {
if !strings.HasPrefix(s, "rest:") { if !strings.HasPrefix(s, "rest:") {
return Config{}, errors.New("invalid REST backend specification") return nil, errors.New("invalid REST backend specification")
} }
s = prepareURL(s) s = prepareURL(s)
u, err := url.Parse(s) u, err := url.Parse(s)
if err != nil { if err != nil {
return Config{}, errors.WithStack(err) return nil, errors.WithStack(err)
} }
cfg := NewConfig() cfg := NewConfig()
cfg.URL = u cfg.URL = u
return cfg, nil return &cfg, nil
} }
// StripPassword removes the password from the URL // StripPassword removes the password from the URL

View file

@ -77,10 +77,10 @@ func newTestSuite(_ context.Context, t testing.TB, url *url.URL, minimalData boo
MinimalData: minimalData, MinimalData: minimalData,
// NewConfig returns a config for a new temporary backend that will be used in tests. // NewConfig returns a config for a new temporary backend that will be used in tests.
NewConfig: func() (rest.Config, error) { NewConfig: func() (*rest.Config, error) {
cfg := rest.NewConfig() cfg := rest.NewConfig()
cfg.URL = url cfg.URL = url
return cfg, nil return &cfg, nil
}, },
// CreateFn is a function that creates a temporary repository for the tests. // CreateFn is a function that creates a temporary repository for the tests.

View file

@ -45,7 +45,7 @@ func init() {
// supported configuration formats are s3://host/bucketname/prefix and // supported configuration formats are s3://host/bucketname/prefix and
// s3:host/bucketname/prefix. The host can also be a valid s3 region // s3:host/bucketname/prefix. The host can also be a valid s3 region
// name. If no prefix is given the prefix "restic" will be used. // name. If no prefix is given the prefix "restic" will be used.
func ParseConfig(s string) (Config, error) { func ParseConfig(s string) (*Config, error) {
switch { switch {
case strings.HasPrefix(s, "s3:http"): case strings.HasPrefix(s, "s3:http"):
// assume that a URL has been specified, parse it and // assume that a URL has been specified, parse it and
@ -53,11 +53,11 @@ func ParseConfig(s string) (Config, error) {
// bucket name and prefix // bucket name and prefix
url, err := url.Parse(s[3:]) url, err := url.Parse(s[3:])
if err != nil { if err != nil {
return Config{}, errors.WithStack(err) return nil, errors.WithStack(err)
} }
if url.Path == "" { if url.Path == "" {
return Config{}, errors.New("s3: bucket name not found") return nil, errors.New("s3: bucket name not found")
} }
bucket, path, _ := strings.Cut(url.Path[1:], "/") bucket, path, _ := strings.Cut(url.Path[1:], "/")
@ -67,7 +67,7 @@ func ParseConfig(s string) (Config, error) {
case strings.HasPrefix(s, "s3:"): case strings.HasPrefix(s, "s3:"):
s = s[3:] s = s[3:]
default: default:
return Config{}, errors.New("s3: invalid format") return nil, errors.New("s3: invalid format")
} }
// use the first entry of the path as the endpoint and the // use the first entry of the path as the endpoint and the
// remainder as bucket name and prefix // remainder as bucket name and prefix
@ -76,9 +76,9 @@ func ParseConfig(s string) (Config, error) {
return createConfig(endpoint, bucket, prefix, false) return createConfig(endpoint, bucket, prefix, false)
} }
func createConfig(endpoint, bucket, prefix string, useHTTP bool) (Config, error) { func createConfig(endpoint, bucket, prefix string, useHTTP bool) (*Config, error) {
if endpoint == "" { if endpoint == "" {
return Config{}, errors.New("s3: invalid format, host/region or bucket name not found") return nil, errors.New("s3: invalid format, host/region or bucket name not found")
} }
if prefix != "" { if prefix != "" {
@ -90,7 +90,7 @@ func createConfig(endpoint, bucket, prefix string, useHTTP bool) (Config, error)
cfg.UseHTTP = useHTTP cfg.UseHTTP = useHTTP
cfg.Bucket = bucket cfg.Bucket = bucket
cfg.Prefix = prefix cfg.Prefix = prefix
return cfg, nil return &cfg, nil
} }
// ApplyEnvironment saves values from the environment to the config. // ApplyEnvironment saves values from the environment to the config.

View file

@ -128,7 +128,7 @@ func newMinioTestSuite(ctx context.Context, t testing.TB) *test.Suite[MinioTestC
return &test.Suite[MinioTestConfig]{ return &test.Suite[MinioTestConfig]{
// NewConfig returns a config for a new temporary backend that will be used in tests. // NewConfig returns a config for a new temporary backend that will be used in tests.
NewConfig: func() (MinioTestConfig, error) { NewConfig: func() (*MinioTestConfig, error) {
cfg := MinioTestConfig{} cfg := MinioTestConfig{}
cfg.tempdir = rtest.TempDir(t) cfg.tempdir = rtest.TempDir(t)
@ -142,7 +142,7 @@ func newMinioTestSuite(ctx context.Context, t testing.TB) *test.Suite[MinioTestC
cfg.Config.UseHTTP = true cfg.Config.UseHTTP = true
cfg.Config.KeyID = key cfg.Config.KeyID = key
cfg.Config.Secret = options.NewSecretString(secret) cfg.Config.Secret = options.NewSecretString(secret)
return cfg, nil return &cfg, nil
}, },
// CreateFn is a function that creates a temporary repository for the tests. // CreateFn is a function that creates a temporary repository for the tests.
@ -224,10 +224,10 @@ func newS3TestSuite(t testing.TB) *test.Suite[s3.Config] {
MinimalData: true, MinimalData: true,
// NewConfig returns a config for a new temporary backend that will be used in tests. // NewConfig returns a config for a new temporary backend that will be used in tests.
NewConfig: func() (s3.Config, error) { NewConfig: func() (*s3.Config, error) {
cfg, err := s3.ParseConfig(os.Getenv("RESTIC_TEST_S3_REPOSITORY")) cfg, err := s3.ParseConfig(os.Getenv("RESTIC_TEST_S3_REPOSITORY"))
if err != nil { if err != nil {
return s3.Config{}, err return nil, err
} }
cfg.KeyID = os.Getenv("RESTIC_TEST_S3_KEY") cfg.KeyID = os.Getenv("RESTIC_TEST_S3_KEY")

View file

@ -35,14 +35,14 @@ func init() {
// and sftp:user@host:directory. The directory will be path Cleaned and can // and sftp:user@host:directory. The directory will be path Cleaned and can
// be an absolute path if it starts with a '/' (e.g. // be an absolute path if it starts with a '/' (e.g.
// sftp://user@host//absolute and sftp:user@host:/absolute). // sftp://user@host//absolute and sftp:user@host:/absolute).
func ParseConfig(s string) (Config, error) { func ParseConfig(s string) (*Config, error) {
var user, host, port, dir string var user, host, port, dir string
switch { switch {
case strings.HasPrefix(s, "sftp://"): case strings.HasPrefix(s, "sftp://"):
// parse the "sftp://user@host/path" url format // parse the "sftp://user@host/path" url format
url, err := url.Parse(s) url, err := url.Parse(s)
if err != nil { if err != nil {
return Config{}, errors.WithStack(err) return nil, errors.WithStack(err)
} }
if url.User != nil { if url.User != nil {
user = url.User.Username() user = url.User.Username()
@ -51,7 +51,7 @@ func ParseConfig(s string) (Config, error) {
port = url.Port() port = url.Port()
dir = url.Path dir = url.Path
if dir == "" { if dir == "" {
return Config{}, errors.Errorf("invalid backend %q, no directory specified", s) return nil, errors.Errorf("invalid backend %q, no directory specified", s)
} }
dir = dir[1:] dir = dir[1:]
@ -63,7 +63,7 @@ func ParseConfig(s string) (Config, error) {
var colon bool var colon bool
host, dir, colon = strings.Cut(s, ":") host, dir, colon = strings.Cut(s, ":")
if !colon { if !colon {
return Config{}, errors.New("sftp: invalid format, hostname or path not found") return nil, errors.New("sftp: invalid format, hostname or path not found")
} }
// split user and host at the "@" // split user and host at the "@"
data := strings.SplitN(host, "@", 3) data := strings.SplitN(host, "@", 3)
@ -75,12 +75,12 @@ func ParseConfig(s string) (Config, error) {
host = data[1] host = data[1]
} }
default: default:
return Config{}, errors.New(`invalid format, does not start with "sftp:"`) return nil, errors.New(`invalid format, does not start with "sftp:"`)
} }
p := path.Clean(dir) p := path.Clean(dir)
if strings.HasPrefix(p, "~") { if strings.HasPrefix(p, "~") {
return Config{}, errors.New("sftp path starts with the tilde (~) character, that fails for most sftp servers.\nUse a relative directory, most servers interpret this as relative to the user's home directory") return nil, errors.New("sftp path starts with the tilde (~) character, that fails for most sftp servers.\nUse a relative directory, most servers interpret this as relative to the user's home directory")
} }
cfg := NewConfig() cfg := NewConfig()
@ -89,5 +89,5 @@ func ParseConfig(s string) (Config, error) {
cfg.Port = port cfg.Port = port
cfg.Path = p cfg.Path = p
return cfg, nil return &cfg, nil
} }

View file

@ -32,7 +32,7 @@ var sftpServer = findSFTPServerBinary()
func newTestSuite(t testing.TB) *test.Suite[sftp.Config] { func newTestSuite(t testing.TB) *test.Suite[sftp.Config] {
return &test.Suite[sftp.Config]{ return &test.Suite[sftp.Config]{
// NewConfig returns a config for a new temporary backend that will be used in tests. // NewConfig returns a config for a new temporary backend that will be used in tests.
NewConfig: func() (sftp.Config, error) { NewConfig: func() (*sftp.Config, error) {
dir, err := os.MkdirTemp(rtest.TestTempDir, "restic-test-sftp-") dir, err := os.MkdirTemp(rtest.TestTempDir, "restic-test-sftp-")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@ -40,7 +40,7 @@ func newTestSuite(t testing.TB) *test.Suite[sftp.Config] {
t.Logf("create new backend at %v", dir) t.Logf("create new backend at %v", dir)
cfg := sftp.Config{ cfg := &sftp.Config{
Path: dir, Path: dir,
Command: fmt.Sprintf("%q -e", sftpServer), Command: fmt.Sprintf("%q -e", sftpServer),
Connections: 5, Connections: 5,

View file

@ -50,19 +50,19 @@ func NewConfig() Config {
} }
// ParseConfig parses the string s and extract swift's container name and prefix. // ParseConfig parses the string s and extract swift's container name and prefix.
func ParseConfig(s string) (Config, error) { func ParseConfig(s string) (*Config, error) {
if !strings.HasPrefix(s, "swift:") { if !strings.HasPrefix(s, "swift:") {
return Config{}, errors.New("invalid URL, expected: swift:container-name:/[prefix]") return nil, errors.New("invalid URL, expected: swift:container-name:/[prefix]")
} }
s = strings.TrimPrefix(s, "swift:") s = strings.TrimPrefix(s, "swift:")
container, prefix, _ := strings.Cut(s, ":") container, prefix, _ := strings.Cut(s, ":")
if prefix == "" { if prefix == "" {
return Config{}, errors.Errorf("prefix is empty") return nil, errors.Errorf("prefix is empty")
} }
if prefix[0] != '/' { if prefix[0] != '/' {
return Config{}, errors.Errorf("prefix does not start with slash (/)") return nil, errors.Errorf("prefix does not start with slash (/)")
} }
prefix = prefix[1:] prefix = prefix[1:]
@ -70,7 +70,7 @@ func ParseConfig(s string) (Config, error) {
cfg.Container = container cfg.Container = container
cfg.Prefix = prefix cfg.Prefix = prefix
return cfg, nil return &cfg, nil
} }
// ApplyEnvironment saves values from the environment to the config. // ApplyEnvironment saves values from the environment to the config.

View file

@ -42,14 +42,14 @@ func newSwiftTestSuite(t testing.TB) *test.Suite[swift.Config] {
}, },
// NewConfig returns a config for a new temporary backend that will be used in tests. // NewConfig returns a config for a new temporary backend that will be used in tests.
NewConfig: func() (swift.Config, error) { NewConfig: func() (*swift.Config, error) {
cfg, err := swift.ParseConfig(os.Getenv("RESTIC_TEST_SWIFT")) cfg, err := swift.ParseConfig(os.Getenv("RESTIC_TEST_SWIFT"))
if err != nil { if err != nil {
return swift.Config{}, err return nil, err
} }
if err = swift.ApplyEnvironment("RESTIC_TEST_", &cfg); err != nil { if err = swift.ApplyEnvironment("RESTIC_TEST_", &cfg); err != nil {
return swift.Config{}, err return nil, err
} }
cfg.Prefix += fmt.Sprintf("/test-%d", time.Now().UnixNano()) cfg.Prefix += fmt.Sprintf("/test-%d", time.Now().UnixNano())
t.Logf("using prefix %v", cfg.Prefix) t.Logf("using prefix %v", cfg.Prefix)

View file

@ -11,7 +11,7 @@ type ConfigTestData[C comparable] struct {
Cfg C Cfg C
} }
func ParseConfigTester[C comparable](t *testing.T, parser func(s string) (C, error), tests []ConfigTestData[C]) { func ParseConfigTester[C comparable](t *testing.T, parser func(s string) (*C, error), tests []ConfigTestData[C]) {
for i, test := range tests { for i, test := range tests {
t.Run(fmt.Sprint(i), func(t *testing.T) { t.Run(fmt.Sprint(i), func(t *testing.T) {
cfg, err := parser(test.S) cfg, err := parser(test.S)
@ -19,9 +19,9 @@ func ParseConfigTester[C comparable](t *testing.T, parser func(s string) (C, err
t.Fatalf("%s failed: %v", test.S, err) t.Fatalf("%s failed: %v", test.S, err)
} }
if !reflect.DeepEqual(cfg, test.Cfg) { if !reflect.DeepEqual(*cfg, test.Cfg) {
t.Fatalf("input: %s\n wrong config, want:\n %#v\ngot:\n %#v", t.Fatalf("input: %s\n wrong config, want:\n %#v\ngot:\n %#v",
test.S, test.Cfg, cfg) test.S, test.Cfg, *cfg)
} }
}) })
} }

View file

@ -13,10 +13,10 @@ import (
// Suite implements a test suite for restic backends. // Suite implements a test suite for restic backends.
type Suite[C any] struct { type Suite[C any] struct {
// Config should be used to configure the backend. // Config should be used to configure the backend.
Config C Config *C
// NewConfig returns a config for a new temporary backend that will be used in tests. // NewConfig returns a config for a new temporary backend that will be used in tests.
NewConfig func() (C, error) NewConfig func() (*C, error)
// CreateFn is a function that creates a temporary repository for the tests. // CreateFn is a function that creates a temporary repository for the tests.
Create func(cfg C) (restic.Backend, error) Create func(cfg C) (restic.Backend, error)
@ -61,7 +61,7 @@ func (s *Suite[C]) RunTests(t *testing.T) {
} }
if s.Cleanup != nil { if s.Cleanup != nil {
if err = s.Cleanup(s.Config); err != nil { if err = s.Cleanup(*s.Config); err != nil {
t.Fatal(err) t.Fatal(err)
} }
} }
@ -158,13 +158,13 @@ func (s *Suite[C]) RunBenchmarks(b *testing.B) {
return return
} }
if err = s.Cleanup(s.Config); err != nil { if err = s.Cleanup(*s.Config); err != nil {
b.Fatal(err) b.Fatal(err)
} }
} }
func (s *Suite[C]) create(t testing.TB) restic.Backend { func (s *Suite[C]) create(t testing.TB) restic.Backend {
be, err := s.Create(s.Config) be, err := s.Create(*s.Config)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -172,7 +172,7 @@ func (s *Suite[C]) create(t testing.TB) restic.Backend {
} }
func (s *Suite[C]) open(t testing.TB) restic.Backend { func (s *Suite[C]) open(t testing.TB) restic.Backend {
be, err := s.Open(s.Config) be, err := s.Open(*s.Config)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View file

@ -57,7 +57,7 @@ func (s *Suite[C]) TestCreateWithConfig(t *testing.T) {
store(t, b, restic.ConfigFile, []byte("test config")) store(t, b, restic.ConfigFile, []byte("test config"))
// now create the backend again, this must fail // now create the backend again, this must fail
_, err = s.Create(s.Config) _, err = s.Create(*s.Config)
if err == nil { if err == nil {
t.Fatalf("expected error not found for creating a backend with an existing config file") t.Fatalf("expected error not found for creating a backend with an existing config file")
} }