mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-25 01:00:16 -05:00
We previously built out addrs.UnifyMoveEndpoints with a different implementation strategy in mind, but that design turns out to not be viable because it forces us to move to AbsMoveable addresses too soon, before we've done the analysis required to identify chained and nested moves. Instead, UnifyMoveEndpoints will return a new type MoveEndpointInModule which conceptually represents a matching pattern which either matches or doesn't match a particular AbsMoveable. It does this by just binding the unified relative address from the MoveEndpoint to the module where it was declared, and thus allows us to distinguish between the part of the module path which applies to any instances of the given modules vs. the user-specified part which must identify particular module instances.
44 lines
1.6 KiB
Go
44 lines
1.6 KiB
Go
package addrs
|
|
|
|
// AbsMoveable is an interface implemented by address types that can be either
|
|
// the source or destination of a "moved" statement in configuration, along
|
|
// with any other similar cross-module state refactoring statements we might
|
|
// allow.
|
|
//
|
|
// Note that AbsMovable represents an absolute address relative to the root
|
|
// of the configuration, which is different than the direct representation
|
|
// of these in configuration where the author gives an address relative to
|
|
// the current module where the address is defined. The type MoveEndpoint
|
|
type AbsMoveable interface {
|
|
absMoveableSigil()
|
|
|
|
String() string
|
|
}
|
|
|
|
// The following are all of the possible AbsMovable address types:
|
|
var (
|
|
_ AbsMoveable = AbsResource{}
|
|
_ AbsMoveable = AbsResourceInstance{}
|
|
_ AbsMoveable = ModuleInstance(nil)
|
|
_ AbsMoveable = AbsModuleCall{}
|
|
)
|
|
|
|
// ConfigMoveable is similar to AbsMoveable but represents a static object in
|
|
// the configuration, rather than an instance of that object created by
|
|
// module expansion.
|
|
//
|
|
// Note that ConfigMovable represents an absolute address relative to the root
|
|
// of the configuration, which is different than the direct representation
|
|
// of these in configuration where the author gives an address relative to
|
|
// the current module where the address is defined. The type MoveEndpoint
|
|
// represents the relative form given directly in configuration.
|
|
type ConfigMoveable interface {
|
|
configMoveableSigil()
|
|
}
|
|
|
|
// The following are all of the possible ConfigMovable address types:
|
|
var (
|
|
_ ConfigMoveable = ConfigResource{}
|
|
_ ConfigMoveable = Module(nil)
|
|
)
|