mirror of
https://github.com/restic/restic.git
synced 2025-08-13 07:57:40 +00:00
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:
@@ -128,7 +128,7 @@ func newMinioTestSuite(ctx context.Context, t testing.TB) *test.Suite[MinioTestC
|
||||
|
||||
return &test.Suite[MinioTestConfig]{
|
||||
// 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.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.KeyID = key
|
||||
cfg.Config.Secret = options.NewSecretString(secret)
|
||||
return cfg, nil
|
||||
return &cfg, nil
|
||||
},
|
||||
|
||||
// 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,
|
||||
|
||||
// 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"))
|
||||
if err != nil {
|
||||
return s3.Config{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cfg.KeyID = os.Getenv("RESTIC_TEST_S3_KEY")
|
||||
|
Reference in New Issue
Block a user