core: OrphanResourceTransformer -> OrphanResourceInstanceTransformer
This transformer creates resource _instance_ nodes rather than resource nodes, so this name is a clearer descriptor for what it does.
This commit is contained in:
parent
311cdbdcab
commit
a806bb7d8c
|
@ -90,7 +90,7 @@ func (b *PlanGraphBuilder) Steps() []GraphTransformer {
|
|||
&OutputTransformer{Config: b.Config},
|
||||
|
||||
// Add orphan resources
|
||||
&OrphanResourceTransformer{
|
||||
&OrphanResourceInstanceTransformer{
|
||||
Concrete: b.ConcreteResourceOrphan,
|
||||
State: b.State,
|
||||
Config: b.Config,
|
||||
|
|
|
@ -123,7 +123,7 @@ func (b *RefreshGraphBuilder) Steps() []GraphTransformer {
|
|||
// Add any fully-orphaned resources from config (ones that have been
|
||||
// removed completely, not ones that are just orphaned due to a scaled-in
|
||||
// count.
|
||||
&OrphanResourceTransformer{
|
||||
&OrphanResourceInstanceTransformer{
|
||||
Concrete: concreteManagedResourceInstance,
|
||||
State: b.State,
|
||||
Config: b.Config,
|
||||
|
|
|
@ -6,13 +6,15 @@ import (
|
|||
"github.com/hashicorp/terraform/states"
|
||||
)
|
||||
|
||||
// OrphanResourceTransformer is a GraphTransformer that adds resource
|
||||
// orphans to the graph. A resource orphan is a resource that is
|
||||
// represented in the state but not in the configuration.
|
||||
//
|
||||
// This only adds orphans that have no representation at all in the
|
||||
// OrphanResourceInstanceTransformer is a GraphTransformer that adds orphaned
|
||||
// resource instances to the graph. An "orphan" is an instance that is present
|
||||
// in the state but belongs to a resource that is no longer present in the
|
||||
// configuration.
|
||||
type OrphanResourceTransformer struct {
|
||||
//
|
||||
// This is not the transformer that deals with "count orphans" (instances that
|
||||
// are no longer covered by a resource's "count" or "for_each" setting); that's
|
||||
// handled instead by OrphanResourceCountTransformer.
|
||||
type OrphanResourceInstanceTransformer struct {
|
||||
Concrete ConcreteResourceInstanceNodeFunc
|
||||
|
||||
// State is the global state. We require the global state to
|
||||
|
@ -24,7 +26,7 @@ type OrphanResourceTransformer struct {
|
|||
Config *configs.Config
|
||||
}
|
||||
|
||||
func (t *OrphanResourceTransformer) Transform(g *Graph) error {
|
||||
func (t *OrphanResourceInstanceTransformer) Transform(g *Graph) error {
|
||||
if t.State == nil {
|
||||
// If the entire state is nil, there can't be any orphans
|
||||
return nil
|
||||
|
@ -32,7 +34,7 @@ func (t *OrphanResourceTransformer) Transform(g *Graph) error {
|
|||
if t.Config == nil {
|
||||
// Should never happen: we can't be doing any Terraform operations
|
||||
// without at least an empty configuration.
|
||||
panic("OrpahResourceTransformer used without setting Config")
|
||||
panic("OrphanResourceInstanceTransformer used without setting Config")
|
||||
}
|
||||
|
||||
// Go through the modules and for each module transform in order
|
||||
|
@ -46,7 +48,7 @@ func (t *OrphanResourceTransformer) Transform(g *Graph) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (t *OrphanResourceTransformer) transform(g *Graph, ms *states.Module) error {
|
||||
func (t *OrphanResourceInstanceTransformer) transform(g *Graph, ms *states.Module) error {
|
||||
if ms == nil {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"github.com/hashicorp/terraform/states"
|
||||
)
|
||||
|
||||
func TestOrphanResourceTransformer(t *testing.T) {
|
||||
func TestOrphanResourceInstanceTransformer(t *testing.T) {
|
||||
mod := testModule(t, "transform-orphan-basic")
|
||||
|
||||
state := states.BuildState(func(s *states.SyncState) {
|
||||
|
@ -59,7 +59,7 @@ func TestOrphanResourceTransformer(t *testing.T) {
|
|||
}
|
||||
|
||||
{
|
||||
tf := &OrphanResourceTransformer{
|
||||
tf := &OrphanResourceInstanceTransformer{
|
||||
Concrete: testOrphanResourceConcreteFunc,
|
||||
State: state,
|
||||
Config: mod,
|
||||
|
@ -76,7 +76,7 @@ func TestOrphanResourceTransformer(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestOrphanResourceTransformer_countGood(t *testing.T) {
|
||||
func TestOrphanResourceInstanceTransformer_countGood(t *testing.T) {
|
||||
mod := testModule(t, "transform-orphan-count")
|
||||
|
||||
state := states.BuildState(func(s *states.SyncState) {
|
||||
|
@ -123,7 +123,7 @@ func TestOrphanResourceTransformer_countGood(t *testing.T) {
|
|||
}
|
||||
|
||||
{
|
||||
tf := &OrphanResourceTransformer{
|
||||
tf := &OrphanResourceInstanceTransformer{
|
||||
Concrete: testOrphanResourceConcreteFunc,
|
||||
State: state,
|
||||
Config: mod,
|
||||
|
@ -140,7 +140,7 @@ func TestOrphanResourceTransformer_countGood(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestOrphanResourceTransformer_countBad(t *testing.T) {
|
||||
func TestOrphanResourceInstanceTransformer_countBad(t *testing.T) {
|
||||
mod := testModule(t, "transform-orphan-count-empty")
|
||||
state := states.BuildState(func(s *states.SyncState) {
|
||||
s.SetResourceInstanceCurrent(
|
||||
|
@ -186,7 +186,7 @@ func TestOrphanResourceTransformer_countBad(t *testing.T) {
|
|||
}
|
||||
|
||||
{
|
||||
tf := &OrphanResourceTransformer{
|
||||
tf := &OrphanResourceInstanceTransformer{
|
||||
Concrete: testOrphanResourceConcreteFunc,
|
||||
State: state,
|
||||
Config: mod,
|
||||
|
@ -203,7 +203,7 @@ func TestOrphanResourceTransformer_countBad(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestOrphanResourceTransformer_modules(t *testing.T) {
|
||||
func TestOrphanResourceInstanceTransformer_modules(t *testing.T) {
|
||||
mod := testModule(t, "transform-orphan-modules")
|
||||
state := states.BuildState(func(s *states.SyncState) {
|
||||
s.SetResourceInstanceCurrent(
|
||||
|
@ -249,7 +249,7 @@ func TestOrphanResourceTransformer_modules(t *testing.T) {
|
|||
}
|
||||
|
||||
{
|
||||
tf := &OrphanResourceTransformer{
|
||||
tf := &OrphanResourceInstanceTransformer{
|
||||
Concrete: testOrphanResourceConcreteFunc,
|
||||
State: state,
|
||||
Config: mod,
|
||||
|
|
Loading…
Reference in New Issue