github.com/terramate-io/tf@v0.0.0-20230830114523-fce866b4dfcd/addrs/moveable.go (about)

     1  // Copyright (c) HashiCorp, Inc.
     2  // SPDX-License-Identifier: MPL-2.0
     3  
     4  package addrs
     5  
     6  // AbsMoveable is an interface implemented by address types that can be either
     7  // the source or destination of a "moved" statement in configuration, along
     8  // with any other similar cross-module state refactoring statements we might
     9  // allow.
    10  //
    11  // Note that AbsMoveable represents an absolute address relative to the root
    12  // of the configuration, which is different than the direct representation
    13  // of these in configuration where the author gives an address relative to
    14  // the current module where the address is defined. The type MoveEndpoint
    15  type AbsMoveable interface {
    16  	absMoveableSigil()
    17  	UniqueKeyer
    18  
    19  	String() string
    20  }
    21  
    22  // The following are all of the possible AbsMoveable address types:
    23  var (
    24  	_ AbsMoveable = AbsResource{}
    25  	_ AbsMoveable = AbsResourceInstance{}
    26  	_ AbsMoveable = ModuleInstance(nil)
    27  	_ AbsMoveable = AbsModuleCall{}
    28  )
    29  
    30  // AbsMoveableResource is an AbsMoveable that is either a resource or a resource
    31  // instance.
    32  type AbsMoveableResource interface {
    33  	AbsMoveable
    34  	AffectedAbsResource() AbsResource
    35  }
    36  
    37  // The following are all of the possible AbsMoveableResource types:
    38  var (
    39  	_ AbsMoveableResource = AbsResource{}
    40  	_ AbsMoveableResource = AbsResourceInstance{}
    41  )
    42  
    43  // ConfigMoveable is similar to AbsMoveable but represents a static object in
    44  // the configuration, rather than an instance of that object created by
    45  // module expansion.
    46  //
    47  // Note that ConfigMovable represents an absolute address relative to the root
    48  // of the configuration, which is different than the direct representation
    49  // of these in configuration where the author gives an address relative to
    50  // the current module where the address is defined. The type MoveEndpoint
    51  // represents the relative form given directly in configuration.
    52  type ConfigMoveable interface {
    53  	configMoveableSigil()
    54  }
    55  
    56  // The following are all of the possible ConfigMovable address types:
    57  var (
    58  	_ ConfigMoveable = ConfigResource{}
    59  	_ ConfigMoveable = Module(nil)
    60  )