From 78a96f50bb3502f2af16f8fe8c21fd06f0bbc549 Mon Sep 17 00:00:00 2001 From: James Nugent Date: Mon, 22 Aug 2016 19:24:29 +0200 Subject: [PATCH 1/2] provider/google: Hook in state migration function As part of Terraform 0.7.1 it was observed in issue #8345 that the state migration for google_compute_firewall did not appear to be running, causing a panic when an uninitialized member was read. This commit hooks up the state migration function (which _was_ independently unit tested but was not actually in place). There is currently no good test framework for this, I will address this issue in a future RFC. --- builtin/providers/google/resource_compute_firewall.go | 1 + 1 file changed, 1 insertion(+) diff --git a/builtin/providers/google/resource_compute_firewall.go b/builtin/providers/google/resource_compute_firewall.go index b2da01c76..6cc8409de 100644 --- a/builtin/providers/google/resource_compute_firewall.go +++ b/builtin/providers/google/resource_compute_firewall.go @@ -23,6 +23,7 @@ func resourceComputeFirewall() *schema.Resource { State: schema.ImportStatePassthrough, }, SchemaVersion: 1, + MigrateState: resourceComputeFirewallMigrateState, Schema: map[string]*schema.Schema{ "name": &schema.Schema{ From 5c83ca7a7780bee7aa04c20e2322e1592e135168 Mon Sep 17 00:00:00 2001 From: James Nugent Date: Mon, 22 Aug 2016 19:27:36 +0200 Subject: [PATCH 2/2] provider/google: Remove redundant type declaration This commit cleans up the google_compute_firewall resource to the Go 1.5+ style of not requiring map values to declare their type if they can be inferred. --- .../google/resource_compute_firewall.go | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/builtin/providers/google/resource_compute_firewall.go b/builtin/providers/google/resource_compute_firewall.go index 6cc8409de..a47da5573 100644 --- a/builtin/providers/google/resource_compute_firewall.go +++ b/builtin/providers/google/resource_compute_firewall.go @@ -26,29 +26,29 @@ func resourceComputeFirewall() *schema.Resource { MigrateState: resourceComputeFirewallMigrateState, Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Required: true, ForceNew: true, }, - "network": &schema.Schema{ + "network": { Type: schema.TypeString, Required: true, ForceNew: true, }, - "allow": &schema.Schema{ + "allow": { Type: schema.TypeSet, Required: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "protocol": &schema.Schema{ + "protocol": { Type: schema.TypeString, Required: true, }, - "ports": &schema.Schema{ + "ports": { Type: schema.TypeList, Optional: true, Elem: &schema.Schema{Type: schema.TypeString}, @@ -58,38 +58,38 @@ func resourceComputeFirewall() *schema.Resource { Set: resourceComputeFirewallAllowHash, }, - "description": &schema.Schema{ + "description": { Type: schema.TypeString, Optional: true, }, - "project": &schema.Schema{ + "project": { Type: schema.TypeString, Optional: true, ForceNew: true, Computed: true, }, - "self_link": &schema.Schema{ + "self_link": { Type: schema.TypeString, Computed: true, }, - "source_ranges": &schema.Schema{ + "source_ranges": { Type: schema.TypeSet, Optional: true, Elem: &schema.Schema{Type: schema.TypeString}, Set: schema.HashString, }, - "source_tags": &schema.Schema{ + "source_tags": { Type: schema.TypeSet, Optional: true, Elem: &schema.Schema{Type: schema.TypeString}, Set: schema.HashString, }, - "target_tags": &schema.Schema{ + "target_tags": { Type: schema.TypeSet, Optional: true, Elem: &schema.Schema{Type: schema.TypeString},