backend/remote-state/gcloud: Use the context provided to configure().
Calling context.Background() from outside the main() function is discouraged. The configure functions are only called from "…/helper/schema".Backend.Configure which provides the Background context, i.e. a long-living context we can use for backend communication.
This commit is contained in:
parent
2e5fca78c2
commit
edf2096e28
|
@ -58,11 +58,16 @@ func (b *Backend) configure(ctx context.Context) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
data := schema.FromContextBackendConfig(ctx)
|
||||
// ctx is a background context with the backend config added.
|
||||
// Since no context is passed to RemoteClient.Get(), .Lock(), etc. but
|
||||
// one is required for calling the GCP API, we're holding on to this
|
||||
// context here and re-use it later.
|
||||
b.storageContext = ctx
|
||||
|
||||
data := schema.FromContextBackendConfig(b.storageContext)
|
||||
|
||||
b.bucketName = data.Get("bucket").(string)
|
||||
b.stateDir = data.Get("state_dir").(string)
|
||||
b.storageContext = googleContext.Background()
|
||||
|
||||
var tokenSource oauth2.TokenSource
|
||||
|
||||
|
|
Loading…
Reference in New Issue