provider/openstack: Add ValueSpecs option to 'openstack_compute_keypair_v2' resource,
refactor to use common types.go and 'MapValueSpecs'
This commit is contained in:
parent
aaff62242d
commit
7438bbd7fe
|
@ -34,6 +34,11 @@ func resourceComputeKeypairV2() *schema.Resource {
|
|||
Optional: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
"value_specs": &schema.Schema{
|
||||
Type: schema.TypeMap,
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -45,9 +50,12 @@ func resourceComputeKeypairV2Create(d *schema.ResourceData, meta interface{}) er
|
|||
return fmt.Errorf("Error creating OpenStack compute client: %s", err)
|
||||
}
|
||||
|
||||
createOpts := keypairs.CreateOpts{
|
||||
createOpts := KeyPairCreateOpts{
|
||||
keypairs.CreateOpts{
|
||||
Name: d.Get("name").(string),
|
||||
PublicKey: d.Get("public_key").(string),
|
||||
},
|
||||
MapValueSpecs(d),
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] Create Options: %#v", createOpts)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package openstack
|
||||
|
||||
import (
|
||||
"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/keypairs"
|
||||
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips"
|
||||
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/routers"
|
||||
"github.com/gophercloud/gophercloud/openstack/networking/v2/networks"
|
||||
|
@ -20,6 +21,18 @@ func (opts FloatingIPCreateOpts) ToFloatingIPCreateMap() (map[string]interface{}
|
|||
return BuildRequest(opts, "floatingip")
|
||||
}
|
||||
|
||||
// KeyPairCreateOpts represents the attributes used when creating a new keypair.
|
||||
type KeyPairCreateOpts struct {
|
||||
keypairs.CreateOpts
|
||||
ValueSpecs map[string]string `json:"value_specs,omitempty"`
|
||||
}
|
||||
|
||||
// ToKeyPairCreateMap casts a CreateOpts struct to a map.
|
||||
// It overrides keypairs.ToKeyPairCreateMap to add the ValueSpecs field.
|
||||
func (opts KeyPairCreateOpts) ToKeyPairCreateMap() (map[string]interface{}, error) {
|
||||
return BuildRequest(opts, "keypair")
|
||||
}
|
||||
|
||||
// NetworkCreateOpts represents the attributes used when creating a new network.
|
||||
type NetworkCreateOpts struct {
|
||||
networks.CreateOpts
|
||||
|
|
|
@ -34,6 +34,8 @@ The following arguments are supported:
|
|||
* `public_key` - (Required) A pregenerated OpenSSH-formatted public key.
|
||||
Changing this creates a new keypair.
|
||||
|
||||
* `value_specs` - (Optional) Map of additional options.
|
||||
|
||||
## Attributes Reference
|
||||
|
||||
The following attributes are exported:
|
||||
|
|
Loading…
Reference in New Issue