From 2eaf6beff0062774ae5b3ec163f8ebe6f0154623 Mon Sep 17 00:00:00 2001 From: Jake Champlin Date: Fri, 21 Apr 2017 10:09:26 -0400 Subject: [PATCH] provider/opc: Fix Instance Label / Update Docs Fix issue with an instances label causing a ForceNew if omitted. Also updates mistyped docs for the `opc_compute_security_list` resource. ``` $ make testacc TEST=./builtin/providers/opc TESTARGS="-run=TestAccOPCInstance_emptyLabel" ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /terraform/vendor/) 2017/04/21 09:57:48 Generated command/internal_plugin_list.go TF_ACC=1 go test ./builtin/providers/opc -v -run=TestAccOPCInstance_emptyLabel -timeout 120m === RUN TestAccOPCInstance_emptyLabel --- PASS: TestAccOPCInstance_emptyLabel (574.79s) PASS ok github.com/hashicorp/terraform/builtin/providers/opc 574.835s ``` --- builtin/providers/opc/resource_instance.go | 1 + .../providers/opc/resource_instance_test.go | 35 +++++++++++++++++++ .../r/opc_compute_security_list.html.markdown | 2 +- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/builtin/providers/opc/resource_instance.go b/builtin/providers/opc/resource_instance.go index 686ff7b0a..7e413b13f 100644 --- a/builtin/providers/opc/resource_instance.go +++ b/builtin/providers/opc/resource_instance.go @@ -80,6 +80,7 @@ func resourceInstance() *schema.Resource { "label": { Type: schema.TypeString, Optional: true, + Computed: true, ForceNew: true, }, diff --git a/builtin/providers/opc/resource_instance_test.go b/builtin/providers/opc/resource_instance_test.go index a29f08c8d..d2371110f 100644 --- a/builtin/providers/opc/resource_instance_test.go +++ b/builtin/providers/opc/resource_instance_test.go @@ -136,6 +136,27 @@ func TestAccOPCInstance_storage(t *testing.T) { }) } +func TestAccOPCInstance_emptyLabel(t *testing.T) { + resName := "opc_compute_instance.test" + rInt := acctest.RandInt() + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccOPCCheckInstanceDestroy, + Steps: []resource.TestStep{ + { + Config: testAccInstanceEmptyLabel(rInt), + Check: resource.ComposeTestCheckFunc( + testAccOPCCheckInstanceExists, + resource.TestCheckResourceAttr(resName, "name", fmt.Sprintf("acc-test-instance-%d", rInt)), + resource.TestCheckResourceAttrSet(resName, "label"), + ), + }, + }, + }) +} + func testAccOPCCheckInstanceExists(s *terraform.State) error { client := testAccProvider.Meta().(*compute.Client).Instances() @@ -271,3 +292,17 @@ resource "opc_compute_instance" "test" { } }`, rInt, rInt, rInt) } + +func testAccInstanceEmptyLabel(rInt int) string { + return fmt.Sprintf(` +resource "opc_compute_instance" "test" { + name = "acc-test-instance-%d" + shape = "oc3" + image_list = "/oracle/public/oel_6.7_apaas_16.4.5_1610211300" + instance_attributes = <