Skip to content

Commit

Permalink
Reordering, comment update
Browse files Browse the repository at this point in the history
  • Loading branch information
pselle committed Aug 13, 2019
1 parent 06e72c6 commit e6817f6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion states/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func (s *SyncState) MaybeFixUpResourceInstanceAddressForCount(addr addrs.AbsReso
}

// SetResourceInstanceCurrent saves the given instance object as the current
// generation of the resource instance with the given address, simulataneously
// generation of the resource instance with the given address, simultaneously
// updating the recorded provider configuration address, dependencies, and
// resource EachMode.
//
Expand Down
18 changes: 9 additions & 9 deletions terraform/transform_orphan_count.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ func (t *OrphanResourceCountTransformer) Transform(g *Graph) error {
}

func (t *OrphanResourceCountTransformer) transformForEach(haveKeys map[addrs.InstanceKey]struct{}, g *Graph) error {
// If there is a no-key node, add this to the graph first,
// If there is a NoKey node, add this to the graph first,
// so that we can create edges to it in subsequent (StringKey) nodes.
// This is because the last item determines the resource mode for the whole resource,
// so if this (non-deterministically) happens to end up as the last one,
// that will change the resource's EachMode and our addressing for our instances
// will not work as expected
// (see SetResourceInstanceCurrent for more information) and we need to evaluate
// an orphaned (NoKey) resource before the in-memory state is updated
// to deal with a new for_each resource
_, hasNoKeyNode := haveKeys[addrs.NoKey]
var noKeyNode dag.Vertex
if hasNoKeyNode {
Expand All @@ -68,14 +68,14 @@ func (t *OrphanResourceCountTransformer) transformForEach(haveKeys map[addrs.Ins
}

for key := range haveKeys {
s, _ := key.(addrs.StringKey)
// If the key is present in our current for_each, carry on
if _, ok := t.ForEach[string(s)]; ok {
// If the key is no-key, we have already added it, so skip
if key == addrs.NoKey {
continue
}

// If the key is no-key, we have already added it, so skip
if key == addrs.NoKey {
s, _ := key.(addrs.StringKey)
// If the key is present in our current for_each, carry on
if _, ok := t.ForEach[string(s)]; ok {
continue
}

Expand Down

0 comments on commit e6817f6

Please sign in to comment.