Add fixes from comments
- Adds docs to sidebar - Changes `volume` to `volume_name` in volume snapshot - Fixes tests - Changes `parent_volume_bootable` to boolean, and converts to string for API ``` $ make testacc TEST=./builtin/providers/opc TESTARGS="-run=TestAccOPCStorageVolumeSnapshot_basic" ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /terraform/vendor/) 2017/04/06 12:26:59 Generated command/internal_plugin_list.go TF_ACC=1 go test ./builtin/providers/opc -v -run=TestAccOPCStorageVolumeSnapshot_basic -timeout 120m === RUN TestAccOPCStorageVolumeSnapshot_basic --- PASS: TestAccOPCStorageVolumeSnapshot_basic (24.45s) PASS ok github.com/hashicorp/terraform/builtin/providers/opc 24.476s ```
This commit is contained in:
parent
e569fd3f6c
commit
3bd582b3d5
|
@ -2,6 +2,7 @@ package opc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/hashicorp/go-oracle-terraform/compute"
|
"github.com/hashicorp/go-oracle-terraform/compute"
|
||||||
"github.com/hashicorp/terraform/helper/schema"
|
"github.com/hashicorp/terraform/helper/schema"
|
||||||
|
@ -18,7 +19,7 @@ func resourceOPCStorageVolumeSnapshot() *schema.Resource {
|
||||||
|
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
// Required Attributes
|
// Required Attributes
|
||||||
"volume": {
|
"volume_name": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
|
@ -40,10 +41,10 @@ func resourceOPCStorageVolumeSnapshot() *schema.Resource {
|
||||||
},
|
},
|
||||||
|
|
||||||
"parent_volume_bootable": {
|
"parent_volume_bootable": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeBool,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
Default: "false",
|
Default: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
"collocated": {
|
"collocated": {
|
||||||
|
@ -124,7 +125,7 @@ func resourceOPCStorageVolumeSnapshotCreate(d *schema.ResourceData, meta interfa
|
||||||
|
|
||||||
// Get required attribute
|
// Get required attribute
|
||||||
input := &compute.CreateStorageVolumeSnapshotInput{
|
input := &compute.CreateStorageVolumeSnapshotInput{
|
||||||
Volume: d.Get("volume").(string),
|
Volume: d.Get("volume_name").(string),
|
||||||
}
|
}
|
||||||
|
|
||||||
if v, ok := d.GetOk("description"); ok {
|
if v, ok := d.GetOk("description"); ok {
|
||||||
|
@ -135,8 +136,10 @@ func resourceOPCStorageVolumeSnapshotCreate(d *schema.ResourceData, meta interfa
|
||||||
input.Name = v.(string)
|
input.Name = v.(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
if v, ok := d.GetOk("parent_volume_bootable"); ok {
|
// Convert parent_volume_bootable to string
|
||||||
input.ParentVolumeBootable = v.(string)
|
bootable := d.Get("parent_volume_bootable").(bool)
|
||||||
|
if bootable {
|
||||||
|
input.ParentVolumeBootable = "true"
|
||||||
}
|
}
|
||||||
|
|
||||||
collocated := d.Get("collocated").(bool)
|
collocated := d.Get("collocated").(bool)
|
||||||
|
@ -180,10 +183,9 @@ func resourceOPCStorageVolumeSnapshotRead(d *schema.ResourceData, meta interface
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
d.Set("volume", result.Volume)
|
d.Set("volume_name", result.Volume)
|
||||||
d.Set("description", result.Description)
|
d.Set("description", result.Description)
|
||||||
d.Set("name", result.Name)
|
d.Set("name", result.Name)
|
||||||
d.Set("parent_volume_bootable", result.ParentVolumeBootable)
|
|
||||||
d.Set("property", result.Property)
|
d.Set("property", result.Property)
|
||||||
d.Set("platform", result.Platform)
|
d.Set("platform", result.Platform)
|
||||||
d.Set("account", result.Account)
|
d.Set("account", result.Account)
|
||||||
|
@ -197,6 +199,12 @@ func resourceOPCStorageVolumeSnapshotRead(d *schema.ResourceData, meta interface
|
||||||
d.Set("status_timestamp", result.StatusTimestamp)
|
d.Set("status_timestamp", result.StatusTimestamp)
|
||||||
d.Set("uri", result.URI)
|
d.Set("uri", result.URI)
|
||||||
|
|
||||||
|
bootable, err := strconv.ParseBool(result.ParentVolumeBootable)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error converting parent volume to boolean: %v", err)
|
||||||
|
}
|
||||||
|
d.Set("parent_volume_bootable", bootable)
|
||||||
|
|
||||||
if result.Property != compute.SnapshotPropertyCollocated {
|
if result.Property != compute.SnapshotPropertyCollocated {
|
||||||
d.Set("collocated", false)
|
d.Set("collocated", false)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -82,7 +82,7 @@ resource "opc_compute_storage_volume_snapshot" "test" {
|
||||||
name = "test-acc-stor-vol-%d"
|
name = "test-acc-stor-vol-%d"
|
||||||
description = "storage volume snapshot"
|
description = "storage volume snapshot"
|
||||||
collocated = true
|
collocated = true
|
||||||
volume = "${opc_compute_storage_volume.foo.name}"
|
volume_name = "${opc_compute_storage_volume.foo.name}"
|
||||||
}
|
}
|
||||||
`, rInt, rInt)
|
`, rInt, rInt)
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,10 +238,10 @@ resource "opc_compute_storage_volume" "foo" {
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "opc_compute_storage_volume_snapshot" "foo" {
|
resource "opc_compute_storage_volume_snapshot" "foo" {
|
||||||
description = "testing-acc"
|
description = "testing-acc"
|
||||||
name = "test-acc-stor-snapshot-%d"
|
name = "test-acc-stor-snapshot-%d"
|
||||||
collocated = true
|
collocated = true
|
||||||
volume = "${opc_compute_storage_volume.foo.name}"
|
volume_name = "${opc_compute_storage_volume.foo.name}"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create storage volume from snapshot
|
// Create storage volume from snapshot
|
||||||
|
|
|
@ -18,6 +18,7 @@ resource "opc_compute_storage_volume_snapshot" "test" {
|
||||||
description = "Description for the Storage Volume"
|
description = "Description for the Storage Volume"
|
||||||
tags = ["bar", "foo"]
|
tags = ["bar", "foo"]
|
||||||
collocated = true
|
collocated = true
|
||||||
|
volume_name = "${opc_compute_storage_volume.foo.name}"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -25,7 +26,7 @@ resource "opc_compute_storage_volume_snapshot" "test" {
|
||||||
|
|
||||||
The following arguments are supported:
|
The following arguments are supported:
|
||||||
|
|
||||||
* `volume` (Required) The name of the storage volume to create the snapshot from.
|
* `volume_name` (Required) The name of the storage volume to create the snapshot from.
|
||||||
* `description` (Optional) The description of the storage volume snapshot.
|
* `description` (Optional) The description of the storage volume snapshot.
|
||||||
* `name` (Optional) The name of the storage volume snapshot. Will be generated if unspecified.
|
* `name` (Optional) The name of the storage volume snapshot. Will be generated if unspecified.
|
||||||
* `parent_volume_bootable` (Optional) A string value of whether or not the parent volume is 'bootable' or not. Defaults to `"false"`.
|
* `parent_volume_bootable` (Optional) A string value of whether or not the parent volume is 'bootable' or not. Defaults to `"false"`.
|
||||||
|
|
|
@ -85,6 +85,9 @@
|
||||||
<li<%= sidebar_current("docs-opc-resource-storage-volume") %>>
|
<li<%= sidebar_current("docs-opc-resource-storage-volume") %>>
|
||||||
<a href="/docs/providers/opc/r/opc_compute_storage_volume.html">opc_compute_storage_volume</a>
|
<a href="/docs/providers/opc/r/opc_compute_storage_volume.html">opc_compute_storage_volume</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li<%= sidebar_current("docs-opc-resource-storage-volume-snapshot") %>>
|
||||||
|
<a href="/docs/providers/opc/r/opc_compute_storage_volume_snapshot.html">opc_compute_storage_volume_snapshot</a>
|
||||||
|
</li>
|
||||||
<li<%= sidebar_current("docs-opc-resource-vnic-set") %>>
|
<li<%= sidebar_current("docs-opc-resource-vnic-set") %>>
|
||||||
<a href="/docs/providers/opc/r/opc_compute_vnic_set.html">opc_compute_vnic_set</a>
|
<a href="/docs/providers/opc/r/opc_compute_vnic_set.html">opc_compute_vnic_set</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
Loading…
Reference in New Issue