diff options
author | Duncan Mac-Vicar P <dmacvicar@suse.de> | 2016-02-29 23:08:55 +0100 |
---|---|---|
committer | Duncan Mac-Vicar P <dmacvicar@suse.de> | 2016-02-29 23:08:55 +0100 |
commit | 40548257f6c09d4c28707f1c2cfa2e6d5a452061 (patch) | |
tree | 8e6536ee09cd947edf8cf1a24265b21d6116abd4 /libvirt | |
parent | 21d72ba8df711c927c68613ae5f8d926a9c32e0b (diff) | |
download | terraform-provider-libvirt-40548257f6c09d4c28707f1c2cfa2e6d5a452061.tar terraform-provider-libvirt-40548257f6c09d4c28707f1c2cfa2e6d5a452061.tar.gz |
go fmt
Diffstat (limited to 'libvirt')
-rw-r--r-- | libvirt/config.go | 4 | ||||
-rw-r--r-- | libvirt/provider.go | 4 | ||||
-rw-r--r-- | libvirt/resource_libvirt_domain.go | 38 | ||||
-rw-r--r-- | libvirt/resource_libvirt_domain_test.go | 12 |
4 files changed, 28 insertions, 30 deletions
diff --git a/libvirt/config.go b/libvirt/config.go index ae282d7d..75507d68 100644 --- a/libvirt/config.go +++ b/libvirt/config.go @@ -1,8 +1,8 @@ package libvirt import ( - "log" libvirt "gopkg.in/alexzorin/libvirt-go.v2" + "log" ) type Config struct { @@ -19,7 +19,7 @@ func (c *Config) Client() (*Client, error) { return nil, err } - client := &Client { + client := &Client{ libvirt: &conn, } diff --git a/libvirt/provider.go b/libvirt/provider.go index 1089521d..769c743c 100644 --- a/libvirt/provider.go +++ b/libvirt/provider.go @@ -9,8 +9,8 @@ func Provider() terraform.ResourceProvider { return &schema.Provider{ Schema: map[string]*schema.Schema{ "uri": &schema.Schema{ - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Required: true, DefaultFunc: schema.EnvDefaultFunc("LIBVIRT_DEFAULT_URI", nil), Description: "libvirt connection URI for operations. See https://libvirt.org/uri.html", }, diff --git a/libvirt/resource_libvirt_domain.go b/libvirt/resource_libvirt_domain.go index 4694f54e..83849815 100644 --- a/libvirt/resource_libvirt_domain.go +++ b/libvirt/resource_libvirt_domain.go @@ -1,22 +1,22 @@ package libvirt import ( + "encoding/xml" "fmt" "log" "strconv" - "encoding/xml" //"github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/schema" libvirt "gopkg.in/alexzorin/libvirt-go.v2" ) type defDomain struct { - XMLName xml.Name `xml:"domain"` - Name string `xml:"name"` - Type string `xml:"type,attr"` - Os defOs `xml:"os"` - Memory defMemory `xml:"memory"` - VCpu defVCpu `xml:"vcpu"` + XMLName xml.Name `xml:"domain"` + Name string `xml:"name"` + Type string `xml:"type,attr"` + Os defOs `xml:"os"` + Memory defMemory `xml:"memory"` + VCpu defVCpu `xml:"vcpu"` } type defOs struct { @@ -24,19 +24,19 @@ type defOs struct { } type defOsType struct { - Arch string `xml:"arch,attr"` + Arch string `xml:"arch,attr"` Machine string `xml:"machine,attr"` - Name string `xml:"chardata"` + Name string `xml:"chardata"` } type defMemory struct { - Unit string `xml:"unit,attr"` - Amount int `xml:"chardata"` + Unit string `xml:"unit,attr"` + Amount int `xml:"chardata"` } type defVCpu struct { Placement string `xml:"unit,attr"` - Amount int `xml:"chardata"` + Amount int `xml:"chardata"` } func resourceLibvirtDomain() *schema.Resource { @@ -53,13 +53,12 @@ func resourceLibvirtDomain() *schema.Resource { "vcpu": &schema.Schema{ Type: schema.TypeInt, Optional: true, - Default: 1, + Default: 1, }, - "memory": &schema.Schema{ Type: schema.TypeInt, Optional: true, - Default: 512, + Default: 512, }, }, } @@ -76,18 +75,18 @@ func resourceLibvirtDomainCreate(d *schema.ResourceData, meta interface{}) error Type: "kvm", Os: defOs{ defOsType{ - Arch: "x86_64", + Arch: "x86_64", Machine: "pc-i440fx-2.4", - Name: "hvm", + Name: "hvm", }, }, Memory: defMemory{ - Unit: "MiB", + Unit: "MiB", Amount: d.Get("memory").(int), }, VCpu: defVCpu{ Placement: "static", - Amount: d.Get("vcpu").(int), + Amount: d.Get("vcpu").(int), }, } @@ -170,4 +169,3 @@ func resourceLibvirtDomainDelete(d *schema.ResourceData, meta interface{}) error return nil } - diff --git a/libvirt/resource_libvirt_domain_test.go b/libvirt/resource_libvirt_domain_test.go index b3219d32..2b709dea 100644 --- a/libvirt/resource_libvirt_domain_test.go +++ b/libvirt/resource_libvirt_domain_test.go @@ -2,19 +2,19 @@ package libvirt import ( "fmt" - "strconv" - "testing" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" "gopkg.in/alexzorin/libvirt-go.v2" + "strconv" + "testing" ) func TestAccLibvirtDomain_Basic(t *testing.T) { var domain libvirt.VirDomain resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, CheckDestroy: testAccCheckLibvirtDomainDestroy, Steps: []resource.TestStep{ resource.TestStep{ @@ -37,8 +37,8 @@ func TestAccLibvirtDomain_Detailed(t *testing.T) { var domain libvirt.VirDomain resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, CheckDestroy: testAccCheckLibvirtDomainDestroy, Steps: []resource.TestStep{ resource.TestStep{ |