Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion array_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func IsArrayAttributeChangeLine(line string) bool {

// IsArrayAttributeTerminator returns true if the line is "]" or "] -> null"
func IsArrayAttributeTerminator(line string) bool {
return strings.TrimSuffix(strings.TrimSpace(line), " -> null") == "]"
return strings.TrimSuffix(strings.TrimSpace(line), " -> null") == "]" || strings.TrimSuffix(strings.TrimSpace(line), " -> (known after apply)") == "]"
}

// IsOneLineEmptyArrayAttribute returns true if the line ends with a "[]"
Expand Down
2 changes: 1 addition & 1 deletion map_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func IsMapAttributeChangeLine(line string) bool {

// IsMapAttributeTerminator returns true if the line is a "}" or "},"
func IsMapAttributeTerminator(line string) bool {
return strings.TrimSuffix(strings.TrimSuffix(strings.TrimSpace(line), ","), " -> null") == "}"
return strings.TrimSuffix(strings.TrimSuffix(strings.TrimSpace(line), ","), " -> null") == "}" || strings.TrimSuffix(strings.TrimSuffix(strings.TrimSpace(line), ","), " -> (known after apply)") == "}"
}

// IsOneLineEmptyMapAttribute returns true if the line ends with a "{}"
Expand Down
65 changes: 65 additions & 0 deletions parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,71 @@ func TestParse(t *testing.T) {
},
},
},
"computedmap": {
file: "test/computedobject.stdout",
expected: []*ResourceChange{
&ResourceChange{
Address: "module.my-project.google_project_services.gcp_enabled_services[0]",
ModuleAddress: "module.my-project",
Type: "google_project_services",
Name: "gcp_enabled_services",
Index: 0,
UpdateType: UpdateInPlaceResource,
AttributeChanges: []attributeChange{
&AttributeChange{
Name: "disable_on_destroy",
OldValue: false,
NewValue: true,
UpdateType: UpdateInPlaceResource,
},
&AttributeChange{
Name: "id",
OldValue: "my-project",
NewValue: "test",
UpdateType: UpdateInPlaceResource,
},
&AttributeChange{
Name: "project",
OldValue: "my-project",
NewValue: "test2",
UpdateType: UpdateInPlaceResource,
},
&ArrayAttributeChange{
Name: "computed_services",
AttributeChanges: []attributeChange{
&AttributeChange{
OldValue: "appengine.googleapis.com",
NewValue: nil,
UpdateType: DestroyResource,
},
&AttributeChange{
OldValue: "audit.googleapis.com",
NewValue: nil,
UpdateType: DestroyResource,
},
},
UpdateType: UpdateInPlaceResource,
},
&MapAttributeChange{
Name: "computed_tags",
AttributeChanges: []attributeChange{
&AttributeChange{
Name: "key1",
OldValue: "old",
NewValue: "new",
UpdateType: UpdateInPlaceResource,
},
},
UpdateType: UpdateInPlaceResource,
},
&MapAttributeChange{
Name: "timeouts",
UpdateType: UpdateInPlaceResource,
},
},
},
},
},
"nested map": {
file: "test/nestedmap.stdout",
expected: []*ResourceChange{
Expand Down
24 changes: 24 additions & 0 deletions test/computedobject.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
------------------------------------------------------------------------

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
~ update in-place

Terraform will perform the following actions:

# module.my-project.google_project_services.gcp_enabled_services[0] will be updated in-place
~ resource "google_project_services" "gcp_enabled_services" {
~ disable_on_destroy = false -> true
~ id = "my-project" -> "test"
~ project = "my-project" -> "test2"
~ computed_services = [
- "appengine.googleapis.com",
- "audit.googleapis.com",
] -> (known after apply)
~ computed_tags = {
~ key1 = "old" -> "new"
} -> (known after apply)
~ timeouts {}
}

Plan: 0 to add, 0 to change, 1 to destroy.