X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=vendor%2Fgithub.com%2Fhashicorp%2Fterraform%2Fterraform%2Fgraph_builder_refresh.go;h=0634f9698d8fe7715f698af5b1c08dfc01a6c68c;hb=9b12e4fe6f3c95986f1f3ec791636c58ca7e7583;hp=88ae3380c4b96870a8f0c0040649faabe00bba8b;hpb=cec3de8a3bcaffd21dedd1bf42da4b490cae7e16;p=github%2Ffretlink%2Fterraform-provider-statuscake.git diff --git a/vendor/github.com/hashicorp/terraform/terraform/graph_builder_refresh.go b/vendor/github.com/hashicorp/terraform/terraform/graph_builder_refresh.go index 88ae338..0634f96 100644 --- a/vendor/github.com/hashicorp/terraform/terraform/graph_builder_refresh.go +++ b/vendor/github.com/hashicorp/terraform/terraform/graph_builder_refresh.go @@ -1,6 +1,8 @@ package terraform import ( + "log" + "github.com/hashicorp/terraform/config" "github.com/hashicorp/terraform/config/module" "github.com/hashicorp/terraform/dag" @@ -56,8 +58,16 @@ func (b *RefreshGraphBuilder) Steps() []GraphTransformer { } } - concreteResource := func(a *NodeAbstractResource) dag.Vertex { - return &NodeRefreshableResource{ + concreteManagedResource := func(a *NodeAbstractResource) dag.Vertex { + return &NodeRefreshableManagedResource{ + NodeAbstractCountResource: &NodeAbstractCountResource{ + NodeAbstractResource: a, + }, + } + } + + concreteManagedResourceInstance := func(a *NodeAbstractResource) dag.Vertex { + return &NodeRefreshableManagedResourceInstance{ NodeAbstractResource: a, } } @@ -71,13 +81,25 @@ func (b *RefreshGraphBuilder) Steps() []GraphTransformer { } steps := []GraphTransformer{ - // Creates all the resources represented in the state - &StateTransformer{ - Concrete: concreteResource, - State: b.State, - }, - - // Creates all the data resources that aren't in the state + // Creates all the managed resources that aren't in the state, but only if + // we have a state already. No resources in state means there's not + // anything to refresh. + func() GraphTransformer { + if b.State.HasResources() { + return &ConfigTransformer{ + Concrete: concreteManagedResource, + Module: b.Module, + Unique: true, + ModeFilter: true, + Mode: config.ManagedResourceMode, + } + } + log.Println("[TRACE] No managed resources in state during refresh, skipping managed resource transformer") + return nil + }(), + + // Creates all the data resources that aren't in the state. This will also + // add any orphans from scaling in as destroy nodes. &ConfigTransformer{ Concrete: concreteDataResource, Module: b.Module, @@ -86,6 +108,15 @@ func (b *RefreshGraphBuilder) Steps() []GraphTransformer { Mode: config.DataResourceMode, }, + // 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{ + Concrete: concreteManagedResourceInstance, + State: b.State, + Module: b.Module, + }, + // Attach the state &AttachStateTransformer{State: b.State},