add AffectedAbsResource to interface
This commit is contained in:
parent
11566b1d11
commit
aeecc6a627
|
@ -28,7 +28,7 @@ var (
|
|||
// instance.
|
||||
type AbsMoveableResource interface {
|
||||
AbsMoveable
|
||||
Type() string
|
||||
AffectedAbsResource() AbsResource
|
||||
}
|
||||
|
||||
// The following are all of the possible AbsMoveableResource types:
|
||||
|
|
|
@ -186,8 +186,9 @@ func (r AbsResource) String() string {
|
|||
return fmt.Sprintf("%s.%s", r.Module.String(), r.Resource.String())
|
||||
}
|
||||
|
||||
func (r AbsResource) Type() string {
|
||||
return r.Resource.Type
|
||||
// AffectedAbsResource returns the AbsResource.
|
||||
func (r AbsResource) AffectedAbsResource() AbsResource {
|
||||
return r
|
||||
}
|
||||
|
||||
func (r AbsResource) Equal(o AbsResource) bool {
|
||||
|
@ -271,8 +272,12 @@ func (r AbsResourceInstance) String() string {
|
|||
return fmt.Sprintf("%s.%s", r.Module.String(), r.Resource.String())
|
||||
}
|
||||
|
||||
func (r AbsResourceInstance) Type() string {
|
||||
return r.Resource.Resource.Type
|
||||
// AffectedAbsResource returns the AbsResource for the instance.
|
||||
func (r AbsResourceInstance) AffectedAbsResource() AbsResource {
|
||||
return AbsResource{
|
||||
Module: r.Module,
|
||||
Resource: r.Resource.Resource,
|
||||
}
|
||||
}
|
||||
|
||||
func (r AbsResourceInstance) Equal(o AbsResourceInstance) bool {
|
||||
|
|
|
@ -249,14 +249,13 @@ func moveableObjectExists(addr addrs.AbsMoveable, in instances.Set) bool {
|
|||
}
|
||||
|
||||
func resourceTypesDiffer(absFrom, absTo addrs.AbsMoveable) bool {
|
||||
switch absFrom.(type) {
|
||||
case addrs.AbsResourceInstance, addrs.AbsResource:
|
||||
absFrom := absFrom.(addrs.AbsMoveableResource)
|
||||
switch absFrom := absFrom.(type) {
|
||||
case addrs.AbsMoveableResource:
|
||||
// addrs.UnifyMoveEndpoints guarantees that both addresses are of the
|
||||
// same kind, so at this point we can assume that absTo is also an
|
||||
// addrs.AbsResourceInstance or addrs.AbsResource.
|
||||
absTo := absTo.(addrs.AbsMoveableResource)
|
||||
return absFrom.Type() != absTo.Type()
|
||||
return absFrom.AffectedAbsResource().Resource.Type != absTo.AffectedAbsResource().Resource.Type
|
||||
default:
|
||||
return false
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue