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 (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/hashicorp/go-oracle-terraform/compute"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
@ -18,7 +19,7 @@ func resourceOPCStorageVolumeSnapshot() *schema.Resource {
|
|||
|
||||
Schema: map[string]*schema.Schema{
|
||||
// Required Attributes
|
||||
"volume": {
|
||||
"volume_name": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
|
@ -40,10 +41,10 @@ func resourceOPCStorageVolumeSnapshot() *schema.Resource {
|
|||
},
|
||||
|
||||
"parent_volume_bootable": {
|
||||
Type: schema.TypeString,
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
Default: "false",
|
||||
Default: false,
|
||||
},
|
||||
|
||||
"collocated": {
|
||||
|
@ -124,7 +125,7 @@ func resourceOPCStorageVolumeSnapshotCreate(d *schema.ResourceData, meta interfa
|
|||
|
||||
// Get required attribute
|
||||
input := &compute.CreateStorageVolumeSnapshotInput{
|
||||
Volume: d.Get("volume").(string),
|
||||
Volume: d.Get("volume_name").(string),
|
||||
}
|
||||
|
||||
if v, ok := d.GetOk("description"); ok {
|
||||
|
@ -135,8 +136,10 @@ func resourceOPCStorageVolumeSnapshotCreate(d *schema.ResourceData, meta interfa
|
|||
input.Name = v.(string)
|
||||
}
|
||||
|
||||
if v, ok := d.GetOk("parent_volume_bootable"); ok {
|
||||
input.ParentVolumeBootable = v.(string)
|
||||
// Convert parent_volume_bootable to string
|
||||
bootable := d.Get("parent_volume_bootable").(bool)
|
||||
if bootable {
|
||||
input.ParentVolumeBootable = "true"
|
||||
}
|
||||
|
||||
collocated := d.Get("collocated").(bool)
|
||||
|
@ -180,10 +183,9 @@ func resourceOPCStorageVolumeSnapshotRead(d *schema.ResourceData, meta interface
|
|||
return nil
|
||||
}
|
||||
|
||||
d.Set("volume", result.Volume)
|
||||
d.Set("volume_name", result.Volume)
|
||||
d.Set("description", result.Description)
|
||||
d.Set("name", result.Name)
|
||||
d.Set("parent_volume_bootable", result.ParentVolumeBootable)
|
||||
d.Set("property", result.Property)
|
||||
d.Set("platform", result.Platform)
|
||||
d.Set("account", result.Account)
|
||||
|
@ -197,6 +199,12 @@ func resourceOPCStorageVolumeSnapshotRead(d *schema.ResourceData, meta interface
|
|||
d.Set("status_timestamp", result.StatusTimestamp)
|
||||
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 {
|
||||
d.Set("collocated", false)
|
||||
} else {
|
||||
|
|
|
@ -82,7 +82,7 @@ resource "opc_compute_storage_volume_snapshot" "test" {
|
|||
name = "test-acc-stor-vol-%d"
|
||||
description = "storage volume snapshot"
|
||||
collocated = true
|
||||
volume = "${opc_compute_storage_volume.foo.name}"
|
||||
volume_name = "${opc_compute_storage_volume.foo.name}"
|
||||
}
|
||||
`, rInt, rInt)
|
||||
}
|
||||
|
|
|
@ -238,10 +238,10 @@ resource "opc_compute_storage_volume" "foo" {
|
|||
}
|
||||
|
||||
resource "opc_compute_storage_volume_snapshot" "foo" {
|
||||
description = "testing-acc"
|
||||
name = "test-acc-stor-snapshot-%d"
|
||||
collocated = true
|
||||
volume = "${opc_compute_storage_volume.foo.name}"
|
||||
description = "testing-acc"
|
||||
name = "test-acc-stor-snapshot-%d"
|
||||
collocated = true
|
||||
volume_name = "${opc_compute_storage_volume.foo.name}"
|
||||
}
|
||||
|
||||
// Create storage volume from snapshot
|
||||
|
|
|
@ -18,6 +18,7 @@ resource "opc_compute_storage_volume_snapshot" "test" {
|
|||
description = "Description for the Storage Volume"
|
||||
tags = ["bar", "foo"]
|
||||
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:
|
||||
|
||||
* `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.
|
||||
* `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"`.
|
||||
|
|
|
@ -85,6 +85,9 @@
|
|||
<li<%= sidebar_current("docs-opc-resource-storage-volume") %>>
|
||||
<a href="/docs/providers/opc/r/opc_compute_storage_volume.html">opc_compute_storage_volume</a>
|
||||
</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") %>>
|
||||
<a href="/docs/providers/opc/r/opc_compute_vnic_set.html">opc_compute_vnic_set</a>
|
||||
</li>
|
||||
|
|
Loading…
Reference in New Issue