summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Hipp <thomashipp@gmail.com>2017-11-23 09:24:01 +0100
committerGitHub <noreply@github.com>2017-11-23 09:24:01 +0100
commitbdbfc7ca1d4251fe5ecad10857ccec65a69afc65 (patch)
tree2fa527ca6fa4b238f357a7fb748741ff7be14ff3
parent88c0dfcca51f4d301810380dacd119a9f291417c (diff)
parent5b215d3b86f285045fc5966de5d6ec3bf2f095da (diff)
downloadterraform-provider-libvirt-bdbfc7ca1d4251fe5ecad10857ccec65a69afc65.tar
terraform-provider-libvirt-bdbfc7ca1d4251fe5ecad10857ccec65a69afc65.tar.gz
Merge pull request #241 from MalloZup/improve-codebase
remove duplicata declaration and simplify code.
-rw-r--r--libvirt/domain_def.go6
-rw-r--r--libvirt/provider.go2
-rw-r--r--libvirt/qemu_agent_test.go18
-rw-r--r--libvirt/resource_cloud_init.go10
-rw-r--r--libvirt/resource_libvirt_coreos_ignition.go6
-rw-r--r--libvirt/resource_libvirt_domain.go55
-rw-r--r--libvirt/resource_libvirt_domain_console.go8
-rw-r--r--libvirt/resource_libvirt_domain_netiface.go20
-rw-r--r--libvirt/resource_libvirt_domain_test.go34
-rw-r--r--libvirt/resource_libvirt_network.go20
-rw-r--r--libvirt/resource_libvirt_volume.go16
-rw-r--r--libvirt/resource_libvirt_volume_test.go6
12 files changed, 100 insertions, 101 deletions
diff --git a/libvirt/domain_def.go b/libvirt/domain_def.go
index 85004051..5f443a62 100644
--- a/libvirt/domain_def.go
+++ b/libvirt/domain_def.go
@@ -36,13 +36,13 @@ func newDomainDef() libvirtxml.Domain {
CPU: &libvirtxml.DomainCPU{},
Devices: &libvirtxml.DomainDeviceList{
Graphics: []libvirtxml.DomainGraphic{
- libvirtxml.DomainGraphic{
+ {
Type: "spice",
AutoPort: "yes",
},
},
Channels: []libvirtxml.DomainChannel{
- libvirtxml.DomainChannel{
+ {
Type: "unix",
Target: &libvirtxml.DomainChannelTarget{
Type: "virtio",
@@ -51,7 +51,7 @@ func newDomainDef() libvirtxml.Domain {
},
},
RNGs: []libvirtxml.DomainRNG{
- libvirtxml.DomainRNG{
+ {
Model: "virtio",
Backend: &libvirtxml.DomainRNGBackend{
Model: "random",
diff --git a/libvirt/provider.go b/libvirt/provider.go
index e1ebaeb4..07b0c72e 100644
--- a/libvirt/provider.go
+++ b/libvirt/provider.go
@@ -13,7 +13,7 @@ var poolMutexKV = mutexkv.NewMutexKV()
func Provider() terraform.ResourceProvider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
- "uri": &schema.Schema{
+ "uri": {
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("LIBVIRT_DEFAULT_URI", nil),
diff --git a/libvirt/qemu_agent_test.go b/libvirt/qemu_agent_test.go
index b38cd9d3..03546054 100644
--- a/libvirt/qemu_agent_test.go
+++ b/libvirt/qemu_agent_test.go
@@ -38,11 +38,11 @@ func TestGetDomainInterfacesViaQemuAgentNoInterfaces(t *testing.T) {
func TestGetDomainInterfacesViaQemuAgentIgnoreLoopbackDevice(t *testing.T) {
response := QemuAgentInterfacesResponse{
Interfaces: []QemuAgentInterface{
- QemuAgentInterface{
+ {
Name: "lo",
Hwaddr: "ho:me",
IPAddresses: []QemuAgentInterfaceIPAddress{
- QemuAgentInterfaceIPAddress{
+ {
Type: "ipv4",
Address: "127.0.0.1",
Prefix: 1,
@@ -69,11 +69,11 @@ func TestGetDomainInterfacesViaQemuAgentIgnoreLoopbackDevice(t *testing.T) {
func TestGetDomainInterfacesViaQemuAgentIgnoreDevicesWithoutAddress(t *testing.T) {
response := QemuAgentInterfacesResponse{
Interfaces: []QemuAgentInterface{
- QemuAgentInterface{
+ {
Name: "eth1",
Hwaddr: "xy:yy:zz",
IPAddresses: []QemuAgentInterfaceIPAddress{
- QemuAgentInterfaceIPAddress{
+ {
Type: "ipv4",
Address: "",
Prefix: 1,
@@ -100,11 +100,11 @@ func TestGetDomainInterfacesViaQemuAgentIgnoreDevicesWithoutAddress(t *testing.T
func TestGetDomainInterfacesViaQemuAgentUnknownIpAddressType(t *testing.T) {
response := QemuAgentInterfacesResponse{
Interfaces: []QemuAgentInterface{
- QemuAgentInterface{
+ {
Name: "eth2",
Hwaddr: "zy:yy:zz",
IPAddresses: []QemuAgentInterfaceIPAddress{
- QemuAgentInterfaceIPAddress{
+ {
Type: "ipv8",
Address: "i don't exist",
Prefix: 1,
@@ -136,16 +136,16 @@ func TestGetDomainInterfacesViaQemuAgent(t *testing.T) {
response := QemuAgentInterfacesResponse{
Interfaces: []QemuAgentInterface{
- QemuAgentInterface{
+ {
Name: device,
Hwaddr: mac,
IPAddresses: []QemuAgentInterfaceIPAddress{
- QemuAgentInterfaceIPAddress{
+ {
Type: "ipv4",
Address: ipv4Addr,
Prefix: 1,
},
- QemuAgentInterfaceIPAddress{
+ {
Type: "ipv6",
Address: ipv6Addr,
Prefix: 1,
diff --git a/libvirt/resource_cloud_init.go b/libvirt/resource_cloud_init.go
index 23639546..be52e02d 100644
--- a/libvirt/resource_cloud_init.go
+++ b/libvirt/resource_cloud_init.go
@@ -13,28 +13,28 @@ func resourceCloudInit() *schema.Resource {
Read: resourceCloudInitRead,
Delete: resourceCloudInitDelete,
Schema: map[string]*schema.Schema{
- "name": &schema.Schema{
+ "name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
- "pool": &schema.Schema{
+ "pool": {
Type: schema.TypeString,
Optional: true,
Default: "default",
ForceNew: true,
},
- "local_hostname": &schema.Schema{
+ "local_hostname": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
- "user_data": &schema.Schema{
+ "user_data": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
- "ssh_authorized_key": &schema.Schema{
+ "ssh_authorized_key": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
diff --git a/libvirt/resource_libvirt_coreos_ignition.go b/libvirt/resource_libvirt_coreos_ignition.go
index 01312663..5c14886d 100644
--- a/libvirt/resource_libvirt_coreos_ignition.go
+++ b/libvirt/resource_libvirt_coreos_ignition.go
@@ -12,18 +12,18 @@ func resourceIgnition() *schema.Resource {
Read: resourceIgnitionRead,
Delete: resourceIgnitionDelete,
Schema: map[string]*schema.Schema{
- "name": &schema.Schema{
+ "name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
- "pool": &schema.Schema{
+ "pool": {
Type: schema.TypeString,
Optional: true,
Default: "default",
ForceNew: true,
},
- "content": &schema.Schema{
+ "content": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
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)
diff --git a/libvirt/resource_libvirt_domain_console.go b/libvirt/resource_libvirt_domain_console.go
index 6159a82a..d8e11248 100644
--- a/libvirt/resource_libvirt_domain_console.go
+++ b/libvirt/resource_libvirt_domain_console.go
@@ -6,25 +6,25 @@ import (
func consoleSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
- "type": &schema.Schema{
+ "type": {
Type: schema.TypeString,
Optional: false,
Required: true,
ForceNew: true,
},
- "source_path": &schema.Schema{
+ "source_path": {
Type: schema.TypeString,
Optional: true,
Required: false,
ForceNew: true,
},
- "target_port": &schema.Schema{
+ "target_port": {
Type: schema.TypeString,
Optional: false,
Required: true,
ForceNew: true,
},
- "target_type": &schema.Schema{
+ "target_type": {
Type: schema.TypeString,
Optional: true,
Required: false,
diff --git a/libvirt/resource_libvirt_domain_netiface.go b/libvirt/resource_libvirt_domain_netiface.go
index 40fac691..7ffc948a 100644
--- a/libvirt/resource_libvirt_domain_netiface.go
+++ b/libvirt/resource_libvirt_domain_netiface.go
@@ -6,55 +6,55 @@ import (
func networkInterfaceCommonSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
- "network_id": &schema.Schema{
+ "network_id": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Computed: true,
},
- "network_name": &schema.Schema{
+ "network_name": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Computed: true,
},
- "bridge": &schema.Schema{
+ "bridge": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
- "vepa": &schema.Schema{
+ "vepa": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
- "macvtap": &schema.Schema{
+ "macvtap": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
- "passthrough": &schema.Schema{
+ "passthrough": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
- "hostname": &schema.Schema{
+ "hostname": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: false,
},
- "mac": &schema.Schema{
+ "mac": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
- "wait_for_lease": &schema.Schema{
+ "wait_for_lease": {
Type: schema.TypeBool,
Optional: true,
},
- "addresses": &schema.Schema{
+ "addresses": {
Type: schema.TypeList,
Optional: true,
Computed: true,
diff --git a/libvirt/resource_libvirt_domain_test.go b/libvirt/resource_libvirt_domain_test.go
index 65d9f898..2c9f1b52 100644
--- a/libvirt/resource_libvirt_domain_test.go
+++ b/libvirt/resource_libvirt_domain_test.go
@@ -26,7 +26,7 @@ func TestAccLibvirtDomain_Basic(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckLibvirtDomainDestroy,
Steps: []resource.TestStep{
- resource.TestStep{
+ {
Config: config,
Check: resource.ComposeTestCheckFunc(
testAccCheckLibvirtDomainExists("libvirt_domain.acceptance-test-domain-1", &domain),
@@ -56,7 +56,7 @@ func TestAccLibvirtDomain_Detailed(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckLibvirtDomainDestroy,
Steps: []resource.TestStep{
- resource.TestStep{
+ {
Config: config,
Check: resource.ComposeTestCheckFunc(
testAccCheckLibvirtDomainExists("libvirt_domain.acceptance-test-domain-2", &domain),
@@ -98,14 +98,14 @@ func TestAccLibvirtDomain_Volume(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckLibvirtDomainDestroy,
Steps: []resource.TestStep{
- resource.TestStep{
+ {
Config: configVolAttached,
Check: resource.ComposeTestCheckFunc(
testAccCheckLibvirtDomainExists("libvirt_domain.acceptance-test-domain", &domain),
testAccCheckLibvirtVolumeExists("libvirt_volume.acceptance-test-volume", &volume),
),
},
- resource.TestStep{
+ {
Config: configVolDettached,
Check: resource.ComposeTestCheckFunc(
testAccCheckLibvirtDomainExists("libvirt_domain.acceptance-test-domain", &domain),
@@ -150,7 +150,7 @@ func TestAccLibvirtDomain_VolumeTwoDisks(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckLibvirtDomainDestroy,
Steps: []resource.TestStep{
- resource.TestStep{
+ {
Config: configVolAttached,
Check: resource.ComposeTestCheckFunc(
testAccCheckLibvirtDomainExists("libvirt_domain.acceptance-test-domain", &domain),
@@ -158,7 +158,7 @@ func TestAccLibvirtDomain_VolumeTwoDisks(t *testing.T) {
testAccCheckLibvirtVolumeExists("libvirt_volume.acceptance-test-volume2", &volume),
),
},
- resource.TestStep{
+ {
Config: configVolDettached,
Check: resource.ComposeTestCheckFunc(
testAccCheckLibvirtDomainExists("libvirt_domain.acceptance-test-domain", &domain),
@@ -191,7 +191,7 @@ func TestAccLibvirtDomain_ScsiDisk(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckLibvirtDomainDestroy,
Steps: []resource.TestStep{
- resource.TestStep{
+ {
Config: configScsi,
Check: resource.ComposeTestCheckFunc(
testAccCheckLibvirtDomainExists("libvirt_domain.acceptance-test-domain", &domain),
@@ -262,7 +262,7 @@ func TestAccLibvirtDomain_NetworkInterface(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckLibvirtDomainDestroy,
Steps: []resource.TestStep{
- resource.TestStep{
+ {
Config: config,
Check: resource.ComposeTestCheckFunc(
testAccCheckLibvirtDomainExists("libvirt_domain.acceptance-test-domain", &domain),
@@ -298,7 +298,7 @@ func TestAccLibvirtDomain_Graphics(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckLibvirtDomainDestroy,
Steps: []resource.TestStep{
- resource.TestStep{
+ {
Config: config,
Check: resource.ComposeTestCheckFunc(
testAccCheckLibvirtDomainExists("libvirt_domain.acceptance-test-domain", &domain),
@@ -374,7 +374,7 @@ func TestAccLibvirtDomain_Cpu(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckLibvirtDomainDestroy,
Steps: []resource.TestStep{
- resource.TestStep{
+ {
Config: config,
Check: resource.ComposeTestCheckFunc(
testAccCheckLibvirtDomainExists("libvirt_domain.acceptance-test-domain", &domain),
@@ -399,7 +399,7 @@ func TestAccLibvirtDomain_Autostart(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckLibvirtDomainDestroy,
Steps: []resource.TestStep{
- resource.TestStep{
+ {
Config: config,
Check: resource.ComposeTestCheckFunc(
testAccCheckLibvirtDomainExists("libvirt_domain.acceptance-test-domain", &domain),
@@ -433,7 +433,7 @@ func TestAccLibvirtDomain_Filesystems(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckLibvirtDomainDestroy,
Steps: []resource.TestStep{
- resource.TestStep{
+ {
Config: config,
Check: resource.ComposeTestCheckFunc(
testAccCheckLibvirtDomainExists("libvirt_domain.acceptance-test-domain", &domain),
@@ -479,7 +479,7 @@ func TestAccLibvirtDomain_Consoles(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckLibvirtDomainDestroy,
Steps: []resource.TestStep{
- resource.TestStep{
+ {
Config: config,
Check: resource.ComposeTestCheckFunc(
testAccCheckLibvirtDomainExists("libvirt_domain.acceptance-test-domain", &domain),
@@ -722,7 +722,7 @@ func subtestAccLibvirtDomainFirmwareNoTemplate(t *testing.T, NVRAMPath string, f
Providers: testAccProviders,
CheckDestroy: testAccCheckLibvirtDomainDestroy,
Steps: []resource.TestStep{
- resource.TestStep{
+ {
Config: config,
Check: resource.ComposeTestCheckFunc(
testAccCheckLibvirtDomainExists("libvirt_domain.acceptance-test-domain", &domain),
@@ -760,7 +760,7 @@ func subtestAccLibvirtDomainFirmwareTemplate(t *testing.T, NVRAMPath string, fir
Providers: testAccProviders,
CheckDestroy: testAccCheckLibvirtDomainDestroy,
Steps: []resource.TestStep{
- resource.TestStep{
+ {
Config: config,
Check: resource.ComposeTestCheckFunc(
testAccCheckLibvirtDomainExists("libvirt_domain.acceptance-test-domain", &domain),
@@ -793,7 +793,7 @@ func TestAccLibvirtDomain_MachineType(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckLibvirtDomainDestroy,
Steps: []resource.TestStep{
- resource.TestStep{
+ {
Config: config,
Check: resource.ComposeTestCheckFunc(
testAccCheckLibvirtDomainExists("libvirt_domain.acceptance-test-domain", &domain),
@@ -819,7 +819,7 @@ func TestAccLibvirtDomain_ArchType(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckLibvirtDomainDestroy,
Steps: []resource.TestStep{
- resource.TestStep{
+ {
Config: config,
Check: resource.ComposeTestCheckFunc(
testAccCheckLibvirtDomainExists("libvirt_domain.acceptance-test-domain", &domain),
diff --git a/libvirt/resource_libvirt_network.go b/libvirt/resource_libvirt_network.go
index 50bcedf8..7bf93c75 100644
--- a/libvirt/resource_libvirt_network.go
+++ b/libvirt/resource_libvirt_network.go
@@ -43,29 +43,29 @@ func resourceLibvirtNetwork() *schema.Resource {
Exists: resourceLibvirtNetworkExists,
Update: resourceLibvirtNetworkUpdate,
Schema: map[string]*schema.Schema{
- "name": &schema.Schema{
+ "name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
- "domain": &schema.Schema{
+ "domain": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
- "mode": &schema.Schema{ // can be "none", "nat" (default), "route", "bridge"
+ "mode": { // can be "none", "nat" (default), "route", "bridge"
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Default: netModeNat,
},
- "bridge": &schema.Schema{
+ "bridge": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
- "addresses": &schema.Schema{
+ "addresses": {
Type: schema.TypeList,
Optional: true,
Required: false,
@@ -74,13 +74,13 @@ func resourceLibvirtNetwork() *schema.Resource {
Type: schema.TypeString,
},
},
- "running": &schema.Schema{
+ "running": {
Type: schema.TypeBool,
Optional: true,
Default: true,
ForceNew: false,
},
- "dns_forwarder": &schema.Schema{
+ "dns_forwarder": {
Type: schema.TypeList,
Optional: true,
Required: false,
@@ -95,13 +95,13 @@ func resourceLibvirtNetwork() *schema.Resource {
func dnsForwarderSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
- "address": &schema.Schema{
+ "address": {
Type: schema.TypeString,
Optional: true,
Required: false,
ForceNew: true,
},
- "domain": &schema.Schema{
+ "domain": {
Type: schema.TypeString,
Optional: true,
Required: false,
@@ -237,7 +237,7 @@ func resourceLibvirtNetworkCreate(d *schema.ResourceData, meta interface{}) erro
dni.DHCP = &libvirtxml.NetworkDHCP{
Ranges: []libvirtxml.NetworkDHCPRange{
- libvirtxml.NetworkDHCPRange{
+ {
Start: start.String(),
End: end.String(),
},
diff --git a/libvirt/resource_libvirt_volume.go b/libvirt/resource_libvirt_volume.go
index bc890e3c..7a7f6a40 100644
--- a/libvirt/resource_libvirt_volume.go
+++ b/libvirt/resource_libvirt_volume.go
@@ -13,44 +13,44 @@ import (
func volumeCommonSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
- "name": &schema.Schema{
+ "name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
- "pool": &schema.Schema{
+ "pool": {
Type: schema.TypeString,
Optional: true,
Default: "default",
ForceNew: true,
},
- "source": &schema.Schema{
+ "source": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
- "size": &schema.Schema{
+ "size": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
ForceNew: true,
},
- "format": &schema.Schema{
+ "format": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
- "base_volume_id": &schema.Schema{
+ "base_volume_id": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
- "base_volume_pool": &schema.Schema{
+ "base_volume_pool": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
- "base_volume_name": &schema.Schema{
+ "base_volume_name": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
diff --git a/libvirt/resource_libvirt_volume_test.go b/libvirt/resource_libvirt_volume_test.go
index 9f047a67..277b2990 100644
--- a/libvirt/resource_libvirt_volume_test.go
+++ b/libvirt/resource_libvirt_volume_test.go
@@ -95,7 +95,7 @@ func TestAccLibvirtVolume_Basic(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckLibvirtVolumeDestroy,
Steps: []resource.TestStep{
- resource.TestStep{
+ {
Config: testAccCheckLibvirtVolumeConfigBasic,
Check: resource.ComposeTestCheckFunc(
testAccCheckLibvirtVolumeExists("libvirt_volume.terraform-acceptance-test-1", &volume),
@@ -136,7 +136,7 @@ func TestAccLibvirtVolume_DownloadFromSource(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckLibvirtVolumeDestroy,
Steps: []resource.TestStep{
- resource.TestStep{
+ {
Config: config,
Check: resource.ComposeTestCheckFunc(
testAccCheckLibvirtVolumeExists("libvirt_volume.terraform-acceptance-test-2", &volume),
@@ -163,7 +163,7 @@ func TestAccLibvirtVolume_Format(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckLibvirtVolumeDestroy,
Steps: []resource.TestStep{
- resource.TestStep{
+ {
Config: testAccCheckLibvirtVolumeConfigFormat,
Check: resource.ComposeTestCheckFunc(
testAccCheckLibvirtVolumeExists("libvirt_volume.terraform-acceptance-test-3", &volume),