From 59b5efc25aee9d7af40307789543dd40d29d9f1f Mon Sep 17 00:00:00 2001 From: Jon Perritt Date: Mon, 26 Jan 2015 22:35:18 -0700 Subject: [PATCH] add defaultFuncs; fix bug with server createOpts --- .../openstack/resource_openstack_compute_instance_v2.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/builtin/providers/openstack/resource_openstack_compute_instance_v2.go b/builtin/providers/openstack/resource_openstack_compute_instance_v2.go index f6a922f43..bacf3707e 100644 --- a/builtin/providers/openstack/resource_openstack_compute_instance_v2.go +++ b/builtin/providers/openstack/resource_openstack_compute_instance_v2.go @@ -39,11 +39,13 @@ func resourceComputeInstanceV2() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: false, + DefaultFunc: envDefaultFunc("OS_IMAGE_ID"), }, "flavor_ref": &schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: false, + DefaultFunc: envDefaultFunc("OS_FLAVOR_ID"), }, "security_groups": &schema.Schema{ Type: schema.TypeSet, @@ -127,7 +129,7 @@ func resourceComputeInstanceV2Create(d *schema.ResourceData, meta interface{}) e var createOpts servers.CreateOptsBuilder - serverCreateOpts := &servers.CreateOpts{ + createOpts = &servers.CreateOpts{ Name: d.Get("name").(string), ImageRef: d.Get("image_ref").(string), FlavorRef: d.Get("flavor_ref").(string), @@ -141,7 +143,7 @@ func resourceComputeInstanceV2Create(d *schema.ResourceData, meta interface{}) e if keyName, ok := d.Get("key_pair").(string); ok && keyName != "" { createOpts = &keypairs.CreateOptsExt{ - serverCreateOpts, + createOpts, keyName, } }