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:
@@ -4,7 +4,6 @@
|
||||
package gcs
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"path"
|
||||
"sort"
|
||||
@@ -26,11 +25,11 @@ const (
|
||||
|
||||
// Workspaces returns a list of names for the workspaces found on GCS. The default
|
||||
// state is always returned as the first element in the slice.
|
||||
func (b *Backend) Workspaces(ctx context.Context) ([]string, error) {
|
||||
func (b *Backend) Workspaces() ([]string, error) {
|
||||
states := []string{backend.DefaultStateName}
|
||||
|
||||
bucket := b.storageClient.Bucket(b.bucketName)
|
||||
objs := bucket.Objects(ctx, &storage.Query{
|
||||
objs := bucket.Objects(b.storageContext, &storage.Query{
|
||||
Delimiter: "/",
|
||||
Prefix: b.prefix,
|
||||
})
|
||||
@@ -59,7 +58,7 @@ func (b *Backend) Workspaces(ctx context.Context) ([]string, error) {
|
||||
}
|
||||
|
||||
// DeleteWorkspace deletes the named workspaces. The "default" state cannot be deleted.
|
||||
func (b *Backend) DeleteWorkspace(ctx context.Context, name string, _ bool) error {
|
||||
func (b *Backend) DeleteWorkspace(name string, _ bool) error {
|
||||
if name == backend.DefaultStateName {
|
||||
return fmt.Errorf("cowardly refusing to delete the %q state", name)
|
||||
}
|
||||
@@ -69,7 +68,7 @@ func (b *Backend) DeleteWorkspace(ctx context.Context, name string, _ bool) erro
|
||||
return err
|
||||
}
|
||||
|
||||
return c.Delete(ctx)
|
||||
return c.Delete()
|
||||
}
|
||||
|
||||
// client returns a remoteClient for the named state.
|
||||
@@ -79,18 +78,19 @@ func (b *Backend) client(name string) (*remoteClient, error) {
|
||||
}
|
||||
|
||||
return &remoteClient{
|
||||
storageClient: b.storageClient,
|
||||
bucketName: b.bucketName,
|
||||
stateFilePath: b.stateFile(name),
|
||||
lockFilePath: b.lockFile(name),
|
||||
encryptionKey: b.encryptionKey,
|
||||
kmsKeyName: b.kmsKeyName,
|
||||
storageContext: b.storageContext,
|
||||
storageClient: b.storageClient,
|
||||
bucketName: b.bucketName,
|
||||
stateFilePath: b.stateFile(name),
|
||||
lockFilePath: b.lockFile(name),
|
||||
encryptionKey: b.encryptionKey,
|
||||
kmsKeyName: b.kmsKeyName,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// StateMgr reads and returns the named state from GCS. If the named state does
|
||||
// not yet exist, a new state file is created.
|
||||
func (b *Backend) StateMgr(ctx context.Context, name string) (statemgr.Full, error) {
|
||||
func (b *Backend) StateMgr(name string) (statemgr.Full, error) {
|
||||
c, err := b.client(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -99,7 +99,7 @@ func (b *Backend) StateMgr(ctx context.Context, name string) (statemgr.Full, err
|
||||
st := &remote.State{Client: c}
|
||||
|
||||
// Grab the value
|
||||
if err := st.RefreshState(ctx); err != nil {
|
||||
if err := st.RefreshState(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -108,14 +108,14 @@ func (b *Backend) StateMgr(ctx context.Context, name string) (statemgr.Full, err
|
||||
|
||||
lockInfo := statemgr.NewLockInfo()
|
||||
lockInfo.Operation = "init"
|
||||
lockID, err := st.Lock(ctx, lockInfo)
|
||||
lockID, err := st.Lock(lockInfo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Local helper function so we can call it multiple places
|
||||
unlock := func(baseErr error) error {
|
||||
if err := st.Unlock(ctx, lockID); err != nil {
|
||||
if err := st.Unlock(lockID); err != nil {
|
||||
const unlockErrMsg = `%v
|
||||
Additionally, unlocking the state file on Google Cloud Storage failed:
|
||||
|
||||
@@ -135,7 +135,7 @@ func (b *Backend) StateMgr(ctx context.Context, name string) (statemgr.Full, err
|
||||
if err := st.WriteState(states.NewState()); err != nil {
|
||||
return nil, unlock(err)
|
||||
}
|
||||
if err := st.PersistState(ctx, nil); err != nil {
|
||||
if err := st.PersistState(nil); err != nil {
|
||||
return nil, unlock(err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user