github.com/opentofu/opentofu@v1.7.1/internal/states/statemgr/lock.go (about) 1 // Copyright (c) The OpenTofu Authors 2 // SPDX-License-Identifier: MPL-2.0 3 // Copyright (c) 2023 HashiCorp, Inc. 4 // SPDX-License-Identifier: MPL-2.0 5 6 package statemgr 7 8 import ( 9 "github.com/opentofu/opentofu/internal/states" 10 "github.com/opentofu/opentofu/internal/tofu" 11 ) 12 13 // LockDisabled implements State and Locker but disables state locking. 14 // If State doesn't support locking, this is a no-op. This is useful for 15 // easily disabling locking of an existing state or for tests. 16 type LockDisabled struct { 17 // We can't embed State directly since Go dislikes that a field is 18 // State and State interface has a method State 19 Inner Full 20 } 21 22 func (s *LockDisabled) State() *states.State { 23 return s.Inner.State() 24 } 25 26 func (s *LockDisabled) GetRootOutputValues() (map[string]*states.OutputValue, error) { 27 return s.Inner.GetRootOutputValues() 28 } 29 30 func (s *LockDisabled) WriteState(v *states.State) error { 31 return s.Inner.WriteState(v) 32 } 33 34 func (s *LockDisabled) RefreshState() error { 35 return s.Inner.RefreshState() 36 } 37 38 func (s *LockDisabled) PersistState(schemas *tofu.Schemas) error { 39 return s.Inner.PersistState(schemas) 40 } 41 42 func (s *LockDisabled) Lock(info *LockInfo) (string, error) { 43 return "", nil 44 } 45 46 func (s *LockDisabled) Unlock(id string) error { 47 return nil 48 }