mirror of https://github.com/hashicorp/terraform
This adds a "lock" config (default true) to allow users to optionally disable state locking with Consul. This is necessary if the token given doesn't have session permission and is necessary for backwards compatibility.pull/12710/head
parent
59baa13953
commit
1daff7a826
@ -0,0 +1,38 @@
|
||||
package state
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
// LockDisabled implements State and Locker but disables state locking.
|
||||
// If State doesn't support locking, this is a no-op. This is useful for
|
||||
// easily disabling locking of an existing state or for tests.
|
||||
type LockDisabled struct {
|
||||
// We can't embed State directly since Go dislikes that a field is
|
||||
// State and State interface has a method State
|
||||
Inner State
|
||||
}
|
||||
|
||||
func (s *LockDisabled) State() *terraform.State {
|
||||
return s.Inner.State()
|
||||
}
|
||||
|
||||
func (s *LockDisabled) WriteState(v *terraform.State) error {
|
||||
return s.Inner.WriteState(v)
|
||||
}
|
||||
|
||||
func (s *LockDisabled) RefreshState() error {
|
||||
return s.Inner.RefreshState()
|
||||
}
|
||||
|
||||
func (s *LockDisabled) PersistState() error {
|
||||
return s.Inner.PersistState()
|
||||
}
|
||||
|
||||
func (s *LockDisabled) Lock(info *LockInfo) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
func (s *LockDisabled) Unlock(id string) error {
|
||||
return nil
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
package state
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestLockDisabled_impl(t *testing.T) {
|
||||
var _ State = new(LockDisabled)
|
||||
var _ Locker = new(LockDisabled)
|
||||
}
|
||||
Loading…
Reference in new issue