mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-25 01:00:16 -05:00
Make backend.StateMgr accept a context (#780)
Signed-off-by: Marcin Wyszynski <marcin.pixie@gmail.com>
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user