Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: fix expand bug #676

Merged
merged 1 commit into from
Dec 16, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions terraform/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -1816,21 +1816,23 @@ func (n *GraphNodeResource) expand(g *depgraph.Graph, count int, diff *ModuleDif
delete(keys, name)
}

if state == nil {
if count == 1 {
// If the count is one, check the state for ".0"
// appended, which might exist if we go from
// count > 1 to count == 1.
k := r.Id() + ".0"
if count == 1 {
// If the count is one, check the state for ".0"
// appended, which might exist if we go from
// count > 1 to count == 1.
k := r.Id() + ".0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be within the if below? Do we have tests covering this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's correct as is... Will have an additional look at the existing test and if we need additional tests, but let's first see what @armon thinks of this...

if state == nil {
state = n.State.Resources[k]
delete(keys, k)
} else if i == 0 {
// If count is greater than one, check for state
// with just the ID, which might exist if we go
// from count == 1 to count > 1
}
delete(keys, k)
} else if i == 0 {
// If count is greater than one, check for state
// with just the ID, which might exist if we go
// from count == 1 to count > 1
if state == nil {
state = n.State.Resources[r.Id()]
delete(keys, r.Id())
}
delete(keys, r.Id())
}
}

Expand Down