summaryrefslogtreecommitdiff
path: root/libvirt
diff options
context:
space:
mode:
authorDuncan Mac-Vicar P <dmacvicar@suse.de>2016-03-05 16:01:46 +0100
committerDuncan Mac-Vicar P <dmacvicar@suse.de>2016-03-05 16:01:46 +0100
commit372ede62452a0a11cc2227738a90a478e82d37da (patch)
tree03de811b06a14d9c2192e9398d873032058a4495 /libvirt
parentd295b9969ae5cca8173a225b2d7f29eeef6b3935 (diff)
downloadterraform-provider-libvirt-372ede62452a0a11cc2227738a90a478e82d37da.tar
terraform-provider-libvirt-372ede62452a0a11cc2227738a90a478e82d37da.tar.gz
go fmt
Diffstat (limited to 'libvirt')
-rw-r--r--libvirt/domain_def.go39
-rw-r--r--libvirt/resource_libvirt_domain.go23
2 files changed, 30 insertions, 32 deletions
diff --git a/libvirt/domain_def.go b/libvirt/domain_def.go
index e6526e4d..97f7eae3 100644
--- a/libvirt/domain_def.go
+++ b/libvirt/domain_def.go
@@ -5,36 +5,35 @@ import (
)
type defVolume struct {
- XMLName xml.Name `xml:"volume"`
- Name string `xml:"name"`
- Target struct {
+ XMLName xml.Name `xml:"volume"`
+ Name string `xml:"name"`
+ Target struct {
Format struct {
- Type string `xml:"type,attr"`
+ Type string `xml:"type,attr"`
} `xml:"format"`
} `xml:"target"`
BackingStore struct {
- Path string `xml:"path"`
+ Path string `xml:"path"`
Format struct {
- Type string `xml:"type,attr"`
+ Type string `xml:"type,attr"`
} `xml:"format"`
} `xml:"backingStore"`
}
type defDisk struct {
- XMLName xml.Name `xml:"disk"`
- Type string `xml:"type,attr"`
- Device string `xml:"device,attr"`
- Format struct {
- Type string `xml:"type,attr"`
-
+ XMLName xml.Name `xml:"disk"`
+ Type string `xml:"type,attr"`
+ Device string `xml:"device,attr"`
+ Format struct {
+ Type string `xml:"type,attr"`
} `xml:"format"`
Source struct {
- Pool string `xml:"pool,attr"`
+ Pool string `xml:"pool,attr"`
Volume string `xml:"volume,attr"`
} `xml:"source"`
Target struct {
- Dev string `xml:"dev,attr"`
- Bus string `xml:"bus,attr"`
+ Dev string `xml:"dev,attr"`
+ Bus string `xml:"bus,attr"`
} `xml:"target"`
}
@@ -47,9 +46,9 @@ type defDomain struct {
VCpu defVCpu `xml:"vcpu"`
Devices struct {
RootDisk defDisk `xml:"disk"`
- Spice struct {
- Type string `xml:"type,attr"`
- Autoport string `xml:"autoport,attr"`
+ Spice struct {
+ Type string `xml:"type,attr"`
+ Autoport string `xml:"autoport,attr"`
} `xml:"graphics"`
} `xml:"devices"`
}
@@ -77,14 +76,14 @@ type defVCpu struct {
// Creates a domain definition with the defaults
// the provider uses
func newDomainDef() defDomain {
- // libvirt domain definition
+ // libvirt domain definition
domainDef := defDomain{}
domainDef.Type = "kvm"
domainDef.Os = defOs{}
domainDef.Os.Type = defOsType{}
domainDef.Os.Type.Arch = "x86_64"
- domainDef.Os.Type.Machine = "pc-i440fx-2.4"
+ domainDef.Os.Type.Machine = "pc-i440fx-2.4"
domainDef.Os.Type.Name = "hvm"
domainDef.Memory = defMemory{}
diff --git a/libvirt/resource_libvirt_domain.go b/libvirt/resource_libvirt_domain.go
index 2166f4b4..fe9510bf 100644
--- a/libvirt/resource_libvirt_domain.go
+++ b/libvirt/resource_libvirt_domain.go
@@ -12,7 +12,6 @@ import (
libvirt "gopkg.in/alexzorin/libvirt-go.v2"
)
-
func resourceLibvirtDomain() *schema.Resource {
return &schema.Resource{
Create: resourceLibvirtDomainCreate,
@@ -72,15 +71,15 @@ func resourceLibvirtDomainCreate(d *schema.ResourceData, meta interface{}) error
// create the volume
rootVolumeDef := defVolume{}
- rootVolumeDef.Name = "__terraform_" + d.Get("name").(string) + "-rootdisk";
- rootVolumeDef.Target.Format.Type = "qcow2";
+ rootVolumeDef.Name = "__terraform_" + d.Get("name").(string) + "-rootdisk"
+ rootVolumeDef.Target.Format.Type = "qcow2"
// use the base image as backing store
- rootVolumeDef.BackingStore.Format.Type = "qcow2";
+ rootVolumeDef.BackingStore.Format.Type = "qcow2"
baseVolPath, err := baseVol.GetPath()
if err != nil {
return fmt.Errorf("can't get name for base image '%s'", baseImage)
}
- rootVolumeDef.BackingStore.Path = baseVolPath;
+ rootVolumeDef.BackingStore.Path = baseVolPath
rootVolumeDefXml, err := xml.Marshal(rootVolumeDef)
if err != nil {
return fmt.Errorf("Error serializing libvirt volume: %s", err)
@@ -94,19 +93,19 @@ func resourceLibvirtDomainCreate(d *schema.ResourceData, meta interface{}) error
// create the disk
rootDisk := defDisk{}
- rootDisk.Type = "volume";
- rootDisk.Device = "disk";
- rootDisk.Format.Type = "qcow2";
+ rootDisk.Type = "volume"
+ rootDisk.Device = "disk"
+ rootDisk.Format.Type = "qcow2"
rootVolumeName, err := rootVolume.GetName()
if err != nil {
return fmt.Errorf("Error retrieving volume name: %s", err)
}
- rootDisk.Source.Volume = rootVolumeName;
- rootDisk.Source.Pool = storagePool;
- rootDisk.Target.Dev = "sda";
- rootDisk.Target.Bus = "virtio";
+ rootDisk.Source.Volume = rootVolumeName
+ rootDisk.Source.Pool = storagePool
+ rootDisk.Target.Dev = "sda"
+ rootDisk.Target.Bus = "virtio"
domainDef := newDomainDef()
domainDef.Name = d.Get("name").(string)