Merge pull request #10858 from hashicorp/paddy_10823_create_timeout_force_new

Remove create_timeout backwards incompatibilities.
This commit is contained in:
Paddy 2017-01-03 14:23:39 -08:00 committed by GitHub
commit 5fba7570b2
3 changed files with 21 additions and 1 deletions

View File

@ -301,7 +301,6 @@ func resourceComputeInstance() *schema.Resource {
Type: schema.TypeInt, Type: schema.TypeInt,
Optional: true, Optional: true,
Default: 4, Default: 4,
ForceNew: true,
}, },
}, },
} }

View File

@ -32,6 +32,13 @@ func resourceComputeInstanceMigrateState(
return is, err return is, err
} }
return is, nil return is, nil
case 2:
log.Println("[INFO] Found Compute Instance State v2; migrating to v3")
is, err := migrateStateV2toV3(is)
if err != nil {
return is, err
}
return is, nil
default: default:
return is, fmt.Errorf("Unexpected schema version: %d", v) return is, fmt.Errorf("Unexpected schema version: %d", v)
} }
@ -138,3 +145,10 @@ func migrateStateV1toV2(is *terraform.InstanceState) (*terraform.InstanceState,
log.Printf("[DEBUG] Attributes after migration: %#v", is.Attributes) log.Printf("[DEBUG] Attributes after migration: %#v", is.Attributes)
return is, nil return is, nil
} }
func migrateStateV2toV3(is *terraform.InstanceState) (*terraform.InstanceState, error) {
log.Printf("[DEBUG] Attributes before migration: %#v", is.Attributes)
is.Attributes["create_timeout"] = "4"
log.Printf("[DEBUG] Attributes after migration: %#v", is.Attributes)
return is, nil
}

View File

@ -48,6 +48,13 @@ func TestComputeInstanceMigrateState(t *testing.T) {
"service_account.0.scopes.3435931483": "https://www.googleapis.com/auth/datastore", "service_account.0.scopes.3435931483": "https://www.googleapis.com/auth/datastore",
}, },
}, },
"add new create_timeout attribute": {
StateVersion: 2,
Attributes: map[string]string{},
Expected: map[string]string{
"create_timeout": "4",
},
},
} }
for tn, tc := range cases { for tn, tc := range cases {