mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-25 08:21:07 -06:00
cleanup from resource state mods
This commit is contained in:
parent
ea51b790bc
commit
a7de3d07b8
@ -1422,7 +1422,7 @@ func TestContext2Refresh_vars(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, r := range mod.Resources {
|
||||
if r.Addr.Type == "" {
|
||||
if r.Addr.Resource.Type == "" {
|
||||
t.Fatalf("no type: %#v", r)
|
||||
}
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ func evaluateResourceCountExpressionKnown(expr hcl.Expression, ctx EvalContext)
|
||||
// or this function will block forever awaiting the lock.
|
||||
func fixResourceCountSetTransition(ctx EvalContext, addr addrs.AbsResource, countEnabled bool) {
|
||||
state := ctx.State()
|
||||
changed := state.MaybeFixUpResourceInstanceAddressForCount(addr, countEnabled)
|
||||
changed := state.MaybeFixUpResourceInstanceAddressForCount(addr.Config(), countEnabled)
|
||||
if changed {
|
||||
log.Printf("[TRACE] renamed first %s instance in transient state due to count argument change", addr)
|
||||
}
|
||||
|
@ -63,14 +63,13 @@ func (n *EvalCountFixZeroOneBoundaryGlobal) fixModule(ctx EvalContext, moduleAdd
|
||||
}
|
||||
|
||||
for _, r := range ms.Resources {
|
||||
addr := r.Addr.Absolute(moduleAddr)
|
||||
rCfg := cfg.Module.ResourceByAddr(r.Addr)
|
||||
rCfg := cfg.Module.ResourceByAddr(r.Addr.Resource)
|
||||
if rCfg == nil {
|
||||
log.Printf("[WARN] Not fixing up EachModes for %s because it has no config", addr)
|
||||
log.Printf("[WARN] Not fixing up EachModes for %s because it has no config", r.Addr)
|
||||
continue
|
||||
}
|
||||
hasCount := rCfg.Count != nil
|
||||
fixResourceCountSetTransition(ctx, addr, hasCount)
|
||||
fixResourceCountSetTransition(ctx, r.Addr, hasCount)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -74,13 +74,13 @@ func (t *OrphanResourceInstanceTransformer) transform(g *Graph, ms *states.Modul
|
||||
// pseudo-arguments here. They are handled by OrphanResourceCountTransformer.
|
||||
for _, rs := range ms.Resources {
|
||||
if m != nil {
|
||||
if r := m.ResourceByAddr(rs.Addr); r != nil {
|
||||
if r := m.ResourceByAddr(rs.Addr.Resource); r != nil {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
for key := range rs.Instances {
|
||||
addr := rs.Addr.Instance(key).Absolute(moduleAddr)
|
||||
addr := rs.Addr.Instance(key)
|
||||
abstract := NewNodeAbstractResourceInstance(addr)
|
||||
var node dag.Vertex = abstract
|
||||
if f := t.Concrete; f != nil {
|
||||
@ -153,13 +153,13 @@ func (t *OrphanResourceTransformer) Transform(g *Graph) error {
|
||||
|
||||
for _, rs := range ms.Resources {
|
||||
if mc != nil {
|
||||
if r := mc.Module.ResourceByAddr(rs.Addr); r != nil {
|
||||
if r := mc.Module.ResourceByAddr(rs.Addr.Resource); r != nil {
|
||||
// It's in the config, so nothing to do for this one.
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
addr := rs.Addr.Absolute(moduleAddr)
|
||||
addr := rs.Addr
|
||||
abstract := NewNodeAbstractResource(addr)
|
||||
var node dag.Vertex = abstract
|
||||
if f := t.Concrete; f != nil {
|
||||
|
@ -43,10 +43,8 @@ func (t *StateTransformer) Transform(g *Graph) error {
|
||||
}
|
||||
|
||||
for _, ms := range t.State.Modules {
|
||||
moduleAddr := ms.Addr
|
||||
|
||||
for _, rs := range ms.Resources {
|
||||
resourceAddr := rs.Addr.Absolute(moduleAddr)
|
||||
resourceAddr := rs.Addr
|
||||
|
||||
for key, is := range rs.Instances {
|
||||
addr := resourceAddr.Instance(key)
|
||||
|
Loading…
Reference in New Issue
Block a user