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