summaryrefslogtreecommitdiff
path: root/libvirt/resource_libvirt_domain.go
diff options
context:
space:
mode:
Diffstat (limited to 'libvirt/resource_libvirt_domain.go')
-rw-r--r--libvirt/resource_libvirt_domain.go55
1 files changed, 27 insertions, 28 deletions
diff --git a/libvirt/resource_libvirt_domain.go b/libvirt/resource_libvirt_domain.go
index 7266923b..a3b16792 100644
--- a/libvirt/resource_libvirt_domain.go
+++ b/libvirt/resource_libvirt_domain.go
@@ -46,58 +46,58 @@ func resourceLibvirtDomain() *schema.Resource {
Create: schema.DefaultTimeout(5 * time.Minute),
},
Schema: map[string]*schema.Schema{
- "name": &schema.Schema{
+ "name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
- "metadata": &schema.Schema{
+ "metadata": {
Type: schema.TypeString,
Required: false,
Optional: true,
ForceNew: false,
},
- "vcpu": &schema.Schema{
+ "vcpu": {
Type: schema.TypeInt,
Optional: true,
Default: 1,
ForceNew: true,
},
- "memory": &schema.Schema{
+ "memory": {
Type: schema.TypeInt,
Optional: true,
Default: 512,
ForceNew: true,
},
- "firmware": &schema.Schema{
+ "firmware": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
- "nvram": &schema.Schema{
+ "nvram": {
Type: schema.TypeMap,
Optional: true,
ForceNew: true,
},
- "running": &schema.Schema{
+ "running": {
Type: schema.TypeBool,
Optional: true,
Default: true,
ForceNew: false,
},
- "cloudinit": &schema.Schema{
+ "cloudinit": {
Type: schema.TypeString,
Required: false,
Optional: true,
ForceNew: false,
},
- "coreos_ignition": &schema.Schema{
+ "coreos_ignition": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Default: "",
},
- "filesystem": &schema.Schema{
+ "filesystem": {
Type: schema.TypeList,
Optional: true,
Required: false,
@@ -106,7 +106,7 @@ func resourceLibvirtDomain() *schema.Resource {
Type: schema.TypeMap,
},
},
- "disk": &schema.Schema{
+ "disk": {
Type: schema.TypeList,
Optional: true,
Required: false,
@@ -115,7 +115,7 @@ func resourceLibvirtDomain() *schema.Resource {
Type: schema.TypeMap,
},
},
- "network_interface": &schema.Schema{
+ "network_interface": {
Type: schema.TypeList,
Optional: true,
Required: false,
@@ -123,12 +123,12 @@ func resourceLibvirtDomain() *schema.Resource {
Schema: networkInterfaceCommonSchema(),
},
},
- "graphics": &schema.Schema{
+ "graphics": {
Type: schema.TypeMap,
Optional: true,
Required: false,
},
- "console": &schema.Schema{
+ "console": {
Type: schema.TypeList,
Optional: true,
Required: false,
@@ -136,28 +136,28 @@ func resourceLibvirtDomain() *schema.Resource {
Schema: consoleSchema(),
},
},
- "cpu": &schema.Schema{
+ "cpu": {
Type: schema.TypeMap,
Optional: true,
Required: false,
ForceNew: true,
},
- "autostart": &schema.Schema{
+ "autostart": {
Type: schema.TypeBool,
Optional: true,
Required: false,
},
- "machine": &schema.Schema{
+ "machine": {
Type: schema.TypeString,
Optional: true,
Default: "pc",
},
- "arch": &schema.Schema{
+ "arch": {
Type: schema.TypeString,
Optional: true,
Default: "x86_64",
},
- "boot_device": &schema.Schema{
+ "boot_device": {
Type: schema.TypeList,
Optional: true,
Required: false,
@@ -165,7 +165,7 @@ func resourceLibvirtDomain() *schema.Resource {
Schema: bootDeviceSchema(),
},
},
- "emulator": &schema.Schema{
+ "emulator": {
Type: schema.TypeString,
Default: "/usr/bin/qemu-system-x86_64",
Optional: true,
@@ -176,7 +176,7 @@ func resourceLibvirtDomain() *schema.Resource {
func bootDeviceSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
- "dev": &schema.Schema{
+ "dev": {
Type: schema.TypeList,
Optional: true,
Required: false,
@@ -249,7 +249,7 @@ func resourceLibvirtDomainCreate(d *schema.ResourceData, meta interface{}) error
if graphics, ok := d.GetOk("graphics"); ok {
graphicsMap := graphics.(map[string]interface{})
domainDef.Devices.Graphics = []libvirtxml.DomainGraphic{
- libvirtxml.DomainGraphic{},
+ {},
}
if graphicsType, ok := graphicsMap["type"]; ok {
domainDef.Devices.Graphics[0].Type = graphicsType.(string)
@@ -259,7 +259,7 @@ func resourceLibvirtDomainCreate(d *schema.ResourceData, meta interface{}) error
}
if listenType, ok := graphicsMap["listen_type"]; ok {
domainDef.Devices.Graphics[0].Listeners = []libvirtxml.DomainGraphicListener{
- libvirtxml.DomainGraphicListener{
+ {
Type: listenType.(string),
},
}
@@ -884,7 +884,7 @@ func resourceLibvirtDomainRead(d *schema.ResourceData, meta interface{}) error {
}
d.Set("running", running)
- disks := make([]map[string]interface{}, 0)
+ var disks []map[string]interface{}
for _, diskDef := range domainDef.Devices.Disks {
// network drives do not have a volume associated
if diskDef.Type == "network" {
@@ -934,8 +934,7 @@ func resourceLibvirtDomainRead(d *schema.ResourceData, meta interface{}) error {
}
}
d.Set("disks", disks)
-
- filesystems := make([]map[string]interface{}, 0)
+ var filesystems []map[string]interface{}
for _, fsDef := range domainDef.Devices.Filesystems {
fs := map[string]interface{}{
"accessmode": fsDef.AccessMode,
@@ -956,7 +955,7 @@ func resourceLibvirtDomainRead(d *schema.ResourceData, meta interface{}) error {
addressesForMac := func(mac string) []string {
// look for an ip address and try to match it with the mac address
// not sure if using the target device name is a better idea here
- addrs := make([]string, 0)
+ var addrs []string
for _, ifaceWithAddr := range ifacesWithAddr {
if strings.ToUpper(ifaceWithAddr.Hwaddr) == mac {
for _, addr := range ifaceWithAddr.Addrs {
@@ -967,7 +966,7 @@ func resourceLibvirtDomainRead(d *schema.ResourceData, meta interface{}) error {
return addrs
}
- netIfaces := make([]map[string]interface{}, 0)
+ var netIfaces []map[string]interface{}
for i, networkInterfaceDef := range domainDef.Devices.Interfaces {
// we need it to read old values
prefix := fmt.Sprintf("network_interface.%d", i)