mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-25 01:00:16 -05:00
Revert PRs that introduced propogating contexts (#835)
Co-authored-by: Dmitry Kisler <admin@dkisler.com>
This commit is contained in:
@@ -23,12 +23,13 @@ const (
|
||||
keyEnvPrefix = "env:"
|
||||
)
|
||||
|
||||
func (b *Backend) Workspaces(ctx context.Context) ([]string, error) {
|
||||
func (b *Backend) Workspaces() ([]string, error) {
|
||||
prefix := b.keyName + keyEnvPrefix
|
||||
params := containers.ListBlobsInput{
|
||||
Prefix: &prefix,
|
||||
}
|
||||
|
||||
ctx := context.TODO()
|
||||
client, err := b.armClient.getContainersClient(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -60,11 +61,12 @@ func (b *Backend) Workspaces(ctx context.Context) ([]string, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (b *Backend) DeleteWorkspace(ctx context.Context, name string, _ bool) error {
|
||||
func (b *Backend) DeleteWorkspace(name string, _ bool) error {
|
||||
if name == backend.DefaultStateName || name == "" {
|
||||
return fmt.Errorf("can't delete default state")
|
||||
}
|
||||
|
||||
ctx := context.TODO()
|
||||
client, err := b.armClient.getBlobClient(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -79,7 +81,8 @@ func (b *Backend) DeleteWorkspace(ctx context.Context, name string, _ bool) erro
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *Backend) StateMgr(ctx context.Context, name string) (statemgr.Full, error) {
|
||||
func (b *Backend) StateMgr(name string) (statemgr.Full, error) {
|
||||
ctx := context.TODO()
|
||||
blobClient, err := b.armClient.getBlobClient(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -96,7 +99,7 @@ func (b *Backend) StateMgr(ctx context.Context, name string) (statemgr.Full, err
|
||||
stateMgr := &remote.State{Client: client}
|
||||
|
||||
// Grab the value
|
||||
if err := stateMgr.RefreshState(ctx); err != nil {
|
||||
if err := stateMgr.RefreshState(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
//if this isn't the default state name, we need to create the object so
|
||||
@@ -105,21 +108,21 @@ func (b *Backend) StateMgr(ctx context.Context, name string) (statemgr.Full, err
|
||||
// take a lock on this state while we write it
|
||||
lockInfo := statemgr.NewLockInfo()
|
||||
lockInfo.Operation = "init"
|
||||
lockId, err := client.Lock(ctx, lockInfo)
|
||||
lockId, err := client.Lock(lockInfo)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to lock azure state: %w", err)
|
||||
}
|
||||
|
||||
// Local helper function so we can call it multiple places
|
||||
lockUnlock := func(parent error) error {
|
||||
if err := stateMgr.Unlock(ctx, lockId); err != nil {
|
||||
if err := stateMgr.Unlock(lockId); err != nil {
|
||||
return fmt.Errorf(strings.TrimSpace(errStateUnlock), lockId, err)
|
||||
}
|
||||
return parent
|
||||
}
|
||||
|
||||
// Grab the value
|
||||
if err := stateMgr.RefreshState(ctx); err != nil {
|
||||
if err := stateMgr.RefreshState(); err != nil {
|
||||
err = lockUnlock(err)
|
||||
return nil, err
|
||||
}
|
||||
@@ -131,7 +134,7 @@ func (b *Backend) StateMgr(ctx context.Context, name string) (statemgr.Full, err
|
||||
err = lockUnlock(err)
|
||||
return nil, err
|
||||
}
|
||||
if err := stateMgr.PersistState(ctx, nil); err != nil {
|
||||
if err := stateMgr.PersistState(nil); err != nil {
|
||||
err = lockUnlock(err)
|
||||
return nil, err
|
||||
}
|
||||
@@ -146,6 +149,10 @@ func (b *Backend) StateMgr(ctx context.Context, name string) (statemgr.Full, err
|
||||
return stateMgr, nil
|
||||
}
|
||||
|
||||
func (b *Backend) client() *RemoteClient {
|
||||
return &RemoteClient{}
|
||||
}
|
||||
|
||||
func (b *Backend) path(name string) string {
|
||||
if name == backend.DefaultStateName {
|
||||
return b.keyName
|
||||
|
||||
Reference in New Issue
Block a user