forked from TrueCloudLab/restic
gs: replace usage of context.Background()
This commit is contained in:
parent
616926d2c1
commit
c934c99d41
3 changed files with 3 additions and 4 deletions
|
@ -801,7 +801,7 @@ func create(ctx context.Context, s string, opts options.Options) (restic.Backend
|
|||
case "s3":
|
||||
be, err = s3.Create(ctx, cfg.(s3.Config), rt)
|
||||
case "gs":
|
||||
be, err = gs.Create(cfg.(gs.Config), rt)
|
||||
be, err = gs.Create(ctx, cfg.(gs.Config), rt)
|
||||
case "azure":
|
||||
be, err = azure.Create(ctx, cfg.(azure.Config), rt)
|
||||
case "swift":
|
||||
|
|
|
@ -124,14 +124,13 @@ func Open(cfg Config, rt http.RoundTripper) (restic.Backend, error) {
|
|||
//
|
||||
// The service account must have the "storage.buckets.create" permission to
|
||||
// create a bucket the does not yet exist.
|
||||
func Create(cfg Config, rt http.RoundTripper) (restic.Backend, error) {
|
||||
func Create(ctx context.Context, cfg Config, rt http.RoundTripper) (restic.Backend, error) {
|
||||
be, err := open(cfg, rt)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "open")
|
||||
}
|
||||
|
||||
// Try to determine if the bucket exists. If it does not, try to create it.
|
||||
ctx := context.Background()
|
||||
exists, err := be.bucketExists(ctx, be.bucket)
|
||||
if err != nil {
|
||||
if e, ok := err.(*googleapi.Error); ok && e.Code == http.StatusForbidden {
|
||||
|
|
|
@ -42,7 +42,7 @@ func newGSTestSuite(t testing.TB) *test.Suite {
|
|||
Create: func(config interface{}) (restic.Backend, error) {
|
||||
cfg := config.(gs.Config)
|
||||
|
||||
be, err := gs.Create(cfg, tr)
|
||||
be, err := gs.Create(context.Background(), cfg, tr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue