From 03b52b7f1c82bbfa3291b6517aaebdb8dd5ae2d1 Mon Sep 17 00:00:00 2001 From: Dario Maiocchi Date: Thu, 16 Nov 2017 16:49:53 +0100 Subject: remove duplicata declaration and simplify code. This fix is with the cmd "gofmt -w -s *" --- libvirt/domain_def.go | 6 ++-- libvirt/provider.go | 2 +- libvirt/qemu_agent_test.go | 18 +++++------ libvirt/resource_cloud_init.go | 10 +++---- libvirt/resource_libvirt_coreos_ignition.go | 6 ++-- libvirt/resource_libvirt_domain.go | 46 ++++++++++++++--------------- libvirt/resource_libvirt_domain_console.go | 8 ++--- libvirt/resource_libvirt_domain_netiface.go | 20 ++++++------- libvirt/resource_libvirt_domain_test.go | 34 ++++++++++----------- libvirt/resource_libvirt_network.go | 20 ++++++------- libvirt/resource_libvirt_volume.go | 16 +++++----- libvirt/resource_libvirt_volume_test.go | 6 ++-- 12 files changed, 96 insertions(+), 96 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 c5f9b09f..2cdb3cb3 100644 --- a/libvirt/provider.go +++ b/libvirt/provider.go @@ -9,7 +9,7 @@ import ( 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 317bfd33..521e16de 100644 --- a/libvirt/resource_libvirt_domain.go +++ b/libvirt/resource_libvirt_domain.go @@ -48,58 +48,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, @@ -108,7 +108,7 @@ func resourceLibvirtDomain() *schema.Resource { Type: schema.TypeMap, }, }, - "disk": &schema.Schema{ + "disk": { Type: schema.TypeList, Optional: true, Required: false, @@ -117,7 +117,7 @@ func resourceLibvirtDomain() *schema.Resource { Type: schema.TypeMap, }, }, - "network_interface": &schema.Schema{ + "network_interface": { Type: schema.TypeList, Optional: true, Required: false, @@ -125,12 +125,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, @@ -138,28 +138,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, @@ -167,7 +167,7 @@ func resourceLibvirtDomain() *schema.Resource { Schema: bootDeviceSchema(), }, }, - "emulator": &schema.Schema{ + "emulator": { Type: schema.TypeString, Default: "/usr/bin/qemu-system-x86_64", Optional: true, @@ -178,7 +178,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, @@ -251,7 +251,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) @@ -261,7 +261,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), }, } 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 954f1ba5..5ea3af0b 100644 --- a/libvirt/resource_libvirt_domain_test.go +++ b/libvirt/resource_libvirt_domain_test.go @@ -25,7 +25,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), @@ -55,7 +55,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), @@ -97,14 +97,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), @@ -149,7 +149,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), @@ -157,7 +157,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), @@ -190,7 +190,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), @@ -229,7 +229,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), @@ -265,7 +265,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), @@ -341,7 +341,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), @@ -366,7 +366,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), @@ -400,7 +400,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), @@ -446,7 +446,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), @@ -654,7 +654,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), @@ -692,7 +692,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), @@ -725,7 +725,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), @@ -751,7 +751,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 afd5b16d..8d75b744 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), -- cgit v1.2.3 From 5b215d3b86f285045fc5966de5d6ec3bf2f095da Mon Sep 17 00:00:00 2001 From: MalloZup Date: Fri, 17 Nov 2017 11:54:11 +0100 Subject: don't allocate memory with 0 make variables --- libvirt/resource_libvirt_domain.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libvirt/resource_libvirt_domain.go b/libvirt/resource_libvirt_domain.go index 521e16de..6e8830b4 100644 --- a/libvirt/resource_libvirt_domain.go +++ b/libvirt/resource_libvirt_domain.go @@ -868,7 +868,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 { var virVol *libvirt.StorageVol if len(diskDef.Source.File) > 0 { @@ -899,8 +899,7 @@ func resourceLibvirtDomainRead(d *schema.ResourceData, meta interface{}) error { disks = append(disks, disk) } 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, @@ -921,7 +920,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 { @@ -932,7 +931,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) -- cgit v1.2.3