github.com/terramate-io/tf@v0.0.0-20230830114523-fce866b4dfcd/states/statemgr/lock.go (about)

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