backend/remote-state/gcloud: Refactor Backend.DeleteState().
Fixes: * https://github.com/golang/go/wiki/CodeReviewComments#doc-comments * https://github.com/golang/go/wiki/CodeReviewComments#error-strings
This commit is contained in:
parent
fabba5c0c8
commit
9ae45e320f
|
@ -49,22 +49,18 @@ func (b *Backend) States() ([]string, error) {
|
||||||
return states, nil
|
return states, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DeleteState deletes the named state. The "default" state cannot be deleted.
|
||||||
func (b *Backend) DeleteState(name string) error {
|
func (b *Backend) DeleteState(name string) error {
|
||||||
if name == backend.DefaultStateName || name == "" {
|
if name == backend.DefaultStateName {
|
||||||
return fmt.Errorf("Can't delete default state")
|
return fmt.Errorf("cowardly refusing to delete the %q state", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
client, err := b.remoteClient(name)
|
client, err := b.remoteClient(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Failed to create Google Storage client: %v", err)
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = client.Delete()
|
return client.Delete()
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("Failed to delete state file %v: %v", client.stateFileURL(), err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// get a remote client configured for this state
|
// get a remote client configured for this state
|
||||||
|
|
Loading…
Reference in New Issue