s3 backend should use Client.Delete to DeleteState
The s3.Backend was using it's own code for DeleteState, but the dynamo entries are only handled through the RemoteClient. Have DeleteState use a RemoteClient for delete.
This commit is contained in:
parent
ebf4413e95
commit
1fa7667ad4
|
@ -70,20 +70,16 @@ func (b *Backend) DeleteState(name string) error {
|
||||||
return fmt.Errorf("can't delete default state")
|
return fmt.Errorf("can't delete default state")
|
||||||
}
|
}
|
||||||
|
|
||||||
params := &s3.DeleteObjectInput{
|
client, err := b.remoteClient(name)
|
||||||
Bucket: &b.bucketName,
|
|
||||||
Key: aws.String(b.path(name)),
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err := b.s3Client.DeleteObject(params)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return client.Delete()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Backend) State(name string) (state.State, error) {
|
// get a remote client configured for this state
|
||||||
|
func (b *Backend) remoteClient(name string) (*RemoteClient, error) {
|
||||||
if name == "" {
|
if name == "" {
|
||||||
return nil, errors.New("missing state name")
|
return nil, errors.New("missing state name")
|
||||||
}
|
}
|
||||||
|
@ -99,8 +95,16 @@ func (b *Backend) State(name string) (state.State, error) {
|
||||||
ddbTable: b.ddbTable,
|
ddbTable: b.ddbTable,
|
||||||
}
|
}
|
||||||
|
|
||||||
stateMgr := &remote.State{Client: client}
|
return client, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Backend) State(name string) (state.State, error) {
|
||||||
|
client, err := b.remoteClient(name)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
stateMgr := &remote.State{Client: client}
|
||||||
// Check to see if this state already exists.
|
// Check to see if this state already exists.
|
||||||
// If we're trying to force-unlock a state, we can't take the lock before
|
// If we're trying to force-unlock a state, we can't take the lock before
|
||||||
// fetching the state. If the state doesn't exist, we have to assume this
|
// fetching the state. If the state doesn't exist, we have to assume this
|
||||||
|
|
Loading…
Reference in New Issue