terraform/backend/remote-state/consul/backend_state.go

39 lines
815 B
Go
Raw Normal View History

2017-03-02 07:15:08 +01:00
package consul
import (
"github.com/hashicorp/terraform/backend"
"github.com/hashicorp/terraform/state"
"github.com/hashicorp/terraform/state/remote"
)
func (b *Backend) States() ([]string, error) {
return nil, backend.ErrNamedStatesNotSupported
}
func (b *Backend) DeleteState(name string) error {
return backend.ErrNamedStatesNotSupported
}
func (b *Backend) State(name string) (state.State, error) {
if name != backend.DefaultStateName {
return nil, backend.ErrNamedStatesNotSupported
}
// Get the Consul API client
client, err := b.clientRaw()
if err != nil {
return nil, err
}
// Determine the path of the data
path := b.configData.Get("path").(string)
// Build the remote state client
return &remote.State{
Client: &RemoteClient{
Client: client,
Path: path,
},
}, nil
}