2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-22 12:55:18 +00:00

gs: replace usage of context.Background()

This commit is contained in:
Michael Eischer 2023-04-08 11:59:44 +02:00
parent 616926d2c1
commit c934c99d41
3 changed files with 3 additions and 4 deletions

View File

@ -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":

View File

@ -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 {

View File

@ -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
}