Make backend.StateMgr accept a context (#780)

Signed-off-by: Marcin Wyszynski <marcin.pixie@gmail.com>
This commit is contained in:
Marcin Wyszynski
2023-10-24 15:47:46 +02:00
committed by GitHub
parent f906c4792a
commit a6a54c3777
71 changed files with 534 additions and 268 deletions

View File

@@ -637,7 +637,7 @@ func (b *Remote) DeleteWorkspace(name string, _ bool) error {
}
// StateMgr implements backend.Enhanced.
func (b *Remote) StateMgr(name string) (statemgr.Full, error) {
func (b *Remote) StateMgr(ctx context.Context, name string) (statemgr.Full, error) {
if b.workspace == "" && name == backend.DefaultStateName {
return nil, backend.ErrDefaultWorkspaceNotSupported
}
@@ -653,7 +653,7 @@ func (b *Remote) StateMgr(name string) (statemgr.Full, error) {
name = b.prefix + name
}
workspace, err := b.client.Workspaces.Read(context.Background(), b.organization, name)
workspace, err := b.client.Workspaces.Read(ctx, b.organization, name)
if err != nil && err != tfe.ErrResourceNotFound {
return nil, fmt.Errorf("Failed to retrieve workspace %s: %w", name, err)
}
@@ -669,7 +669,7 @@ func (b *Remote) StateMgr(name string) (statemgr.Full, error) {
options.TerraformVersion = tfe.String(tfversion.String())
}
workspace, err = b.client.Workspaces.Create(context.Background(), b.organization, options)
workspace, err = b.client.Workspaces.Create(ctx, b.organization, options)
if err != nil {
return nil, fmt.Errorf("Error creating workspace %s: %w", name, err)
}