aboutsummaryrefslogtreecommitdiff
path: root/libvirt
diff options
context:
space:
mode:
authorDario Maiocchi <dmaiocchi@suse.com>2017-11-12 19:38:03 +0100
committerDario Maiocchi <dmaiocchi@suse.com>2017-11-16 11:26:29 +0100
commit1205df84cacd81887839c31572952dc21065da77 (patch)
tree690391771350f9c60fe7d1ea536396dbdbef896a /libvirt
parentc4edcb9136cab5e05c7c688002236843913a3f7b (diff)
downloadterraform-provider-libvirt-1205df84cacd81887839c31572952dc21065da77.tar
terraform-provider-libvirt-1205df84cacd81887839c31572952dc21065da77.tar.gz
common string constant for errmsg lvirtconn is nil
Diffstat (limited to 'libvirt')
-rw-r--r--libvirt/resource_cloud_init.go6
-rw-r--r--libvirt/resource_libvirt_coreos_ignition.go6
-rw-r--r--libvirt/resource_libvirt_domain.go10
-rw-r--r--libvirt/resource_libvirt_network.go10
-rw-r--r--libvirt/resource_libvirt_volume.go6
-rw-r--r--libvirt/utils.go3
6 files changed, 22 insertions, 19 deletions
diff --git a/libvirt/resource_cloud_init.go b/libvirt/resource_cloud_init.go
index da3e9832..23639546 100644
--- a/libvirt/resource_cloud_init.go
+++ b/libvirt/resource_cloud_init.go
@@ -47,7 +47,7 @@ func resourceCloudInitCreate(d *schema.ResourceData, meta interface{}) error {
log.Printf("[DEBUG] creating cloudinit")
virConn := meta.(*Client).libvirt
if virConn == nil {
- return fmt.Errorf("the libvirt connection was nil")
+ return fmt.Errorf(LibVirtConIsNil)
}
cloudInit := newCloudInitDef()
@@ -85,7 +85,7 @@ func resourceCloudInitCreate(d *schema.ResourceData, meta interface{}) error {
func resourceCloudInitRead(d *schema.ResourceData, meta interface{}) error {
virConn := meta.(*Client).libvirt
if virConn == nil {
- return fmt.Errorf("the libvirt connection was nil")
+ return fmt.Errorf(LibVirtConIsNil)
}
ci, err := newCloudInitDefFromRemoteISO(virConn, d.Id())
@@ -107,7 +107,7 @@ func resourceCloudInitRead(d *schema.ResourceData, meta interface{}) error {
func resourceCloudInitDelete(d *schema.ResourceData, meta interface{}) error {
virConn := meta.(*Client).libvirt
if virConn == nil {
- return fmt.Errorf("the libvirt connection was nil")
+ return fmt.Errorf(LibVirtConIsNil)
}
key, err := getCloudInitVolumeKeyFromTerraformID(d.Id())
diff --git a/libvirt/resource_libvirt_coreos_ignition.go b/libvirt/resource_libvirt_coreos_ignition.go
index 58af44ed..01312663 100644
--- a/libvirt/resource_libvirt_coreos_ignition.go
+++ b/libvirt/resource_libvirt_coreos_ignition.go
@@ -36,7 +36,7 @@ func resourceIgnitionCreate(d *schema.ResourceData, meta interface{}) error {
log.Printf("[DEBUG] creating ignition file")
virConn := meta.(*Client).libvirt
if virConn == nil {
- return fmt.Errorf("the libvirt connection was nil")
+ return fmt.Errorf(LibVirtConIsNil)
}
ignition := newIgnitionDef()
@@ -66,7 +66,7 @@ func resourceIgnitionCreate(d *schema.ResourceData, meta interface{}) error {
func resourceIgnitionRead(d *schema.ResourceData, meta interface{}) error {
virConn := meta.(*Client).libvirt
if virConn == nil {
- return fmt.Errorf("the libvirt connection was nil")
+ return fmt.Errorf(LibVirtConIsNil)
}
ign, err := newIgnitionDefFromRemoteVol(virConn, d.Id())
@@ -83,7 +83,7 @@ func resourceIgnitionRead(d *schema.ResourceData, meta interface{}) error {
func resourceIgnitionDelete(d *schema.ResourceData, meta interface{}) error {
virConn := meta.(*Client).libvirt
if virConn == nil {
- return fmt.Errorf("the libvirt connection was nil")
+ return fmt.Errorf(LibVirtConIsNil)
}
key, err := getIgnitionVolumeKeyFromTerraformID(d.Id())
diff --git a/libvirt/resource_libvirt_domain.go b/libvirt/resource_libvirt_domain.go
index 80374e15..652bc17e 100644
--- a/libvirt/resource_libvirt_domain.go
+++ b/libvirt/resource_libvirt_domain.go
@@ -194,7 +194,7 @@ func resourceLibvirtDomainExists(d *schema.ResourceData, meta interface{}) (bool
virConn := meta.(*Client).libvirt
if virConn == nil {
- return false, fmt.Errorf("the libvirt connection was nil")
+ return false, fmt.Errorf(LibVirtConIsNil)
}
domain, err := virConn.LookupDomainByUUIDString(d.Id())
@@ -214,7 +214,7 @@ func resourceLibvirtDomainCreate(d *schema.ResourceData, meta interface{}) error
virConn := meta.(*Client).libvirt
if virConn == nil {
- return fmt.Errorf("the libvirt connection was nil")
+ return fmt.Errorf(LibVirtConIsNil)
}
domainDef, err := newDomainDefForConnection(virConn)
@@ -707,7 +707,7 @@ func resourceLibvirtDomainUpdate(d *schema.ResourceData, meta interface{}) error
virConn := meta.(*Client).libvirt
if virConn == nil {
- return fmt.Errorf("the libvirt connection was nil")
+ return fmt.Errorf(LibVirtConIsNil)
}
domain, err := virConn.LookupDomainByUUIDString(d.Id())
if err != nil {
@@ -807,7 +807,7 @@ func resourceLibvirtDomainRead(d *schema.ResourceData, meta interface{}) error {
virConn := meta.(*Client).libvirt
if virConn == nil {
- return fmt.Errorf("the libvirt connection was nil")
+ return fmt.Errorf(LibVirtConIsNil)
}
domain, err := virConn.LookupDomainByUUIDString(d.Id())
@@ -1026,7 +1026,7 @@ func resourceLibvirtDomainDelete(d *schema.ResourceData, meta interface{}) error
virConn := meta.(*Client).libvirt
if virConn == nil {
- return fmt.Errorf("the libvirt connection was nil")
+ return fmt.Errorf(LibVirtConIsNil)
}
log.Printf("[DEBUG] Deleting domain %s", d.Id())
diff --git a/libvirt/resource_libvirt_network.go b/libvirt/resource_libvirt_network.go
index 88dcac7a..50bcedf8 100644
--- a/libvirt/resource_libvirt_network.go
+++ b/libvirt/resource_libvirt_network.go
@@ -113,7 +113,7 @@ func dnsForwarderSchema() map[string]*schema.Schema {
func resourceLibvirtNetworkExists(d *schema.ResourceData, meta interface{}) (bool, error) {
virConn := meta.(*Client).libvirt
if virConn == nil {
- return false, fmt.Errorf("the libvirt connection was nil")
+ return false, fmt.Errorf(LibVirtConIsNil)
}
network, err := virConn.LookupNetworkByUUIDString(d.Id())
if err != nil {
@@ -132,7 +132,7 @@ func resourceLibvirtNetworkExists(d *schema.ResourceData, meta interface{}) (boo
func resourceLibvirtNetworkUpdate(d *schema.ResourceData, meta interface{}) error {
virConn := meta.(*Client).libvirt
if virConn == nil {
- return fmt.Errorf("the libvirt connection was nil")
+ return fmt.Errorf(LibVirtConIsNil)
}
network, err := virConn.LookupNetworkByUUIDString(d.Id())
if err != nil {
@@ -165,7 +165,7 @@ func resourceLibvirtNetworkCreate(d *schema.ResourceData, meta interface{}) erro
// see https://libvirt.org/formatnetwork.html
virConn := meta.(*Client).libvirt
if virConn == nil {
- return fmt.Errorf("the libvirt connection was nil")
+ return fmt.Errorf(LibVirtConIsNil)
}
networkDef := newNetworkDef()
@@ -337,7 +337,7 @@ func resourceLibvirtNetworkCreate(d *schema.ResourceData, meta interface{}) erro
func resourceLibvirtNetworkRead(d *schema.ResourceData, meta interface{}) error {
virConn := meta.(*Client).libvirt
if virConn == nil {
- return fmt.Errorf("the libvirt connection was nil")
+ return fmt.Errorf(LibVirtConIsNil)
}
network, err := virConn.LookupNetworkByUUIDString(d.Id())
@@ -396,7 +396,7 @@ func resourceLibvirtNetworkRead(d *schema.ResourceData, meta interface{}) error
func resourceLibvirtNetworkDelete(d *schema.ResourceData, meta interface{}) error {
virConn := meta.(*Client).libvirt
if virConn == nil {
- return fmt.Errorf("the libvirt connection was nil")
+ return fmt.Errorf(LibVirtConIsNil)
}
log.Printf("[DEBUG] Deleting network ID %s", d.Id())
diff --git a/libvirt/resource_libvirt_volume.go b/libvirt/resource_libvirt_volume.go
index cdf1ddb0..afd5b16d 100644
--- a/libvirt/resource_libvirt_volume.go
+++ b/libvirt/resource_libvirt_volume.go
@@ -82,7 +82,7 @@ func remoteImageSize(url string) (int, error) {
func resourceLibvirtVolumeCreate(d *schema.ResourceData, meta interface{}) error {
virConn := meta.(*Client).libvirt
if virConn == nil {
- return fmt.Errorf("the libvirt connection was nil")
+ return fmt.Errorf(LibVirtConIsNil)
}
poolName := "default"
@@ -262,7 +262,7 @@ func resourceLibvirtVolumeCreate(d *schema.ResourceData, meta interface{}) error
func resourceLibvirtVolumeRead(d *schema.ResourceData, meta interface{}) error {
virConn := meta.(*Client).libvirt
if virConn == nil {
- return fmt.Errorf("the libvirt connection was nil")
+ return fmt.Errorf(LibVirtConIsNil)
}
volume, err := virConn.LookupStorageVolByKey(d.Id())
@@ -334,7 +334,7 @@ func resourceLibvirtVolumeRead(d *schema.ResourceData, meta interface{}) error {
func resourceLibvirtVolumeDelete(d *schema.ResourceData, meta interface{}) error {
virConn := meta.(*Client).libvirt
if virConn == nil {
- return fmt.Errorf("the libvirt connection was nil")
+ return fmt.Errorf(LibVirtConIsNil)
}
return RemoveVolume(virConn, d.Id())
diff --git a/libvirt/utils.go b/libvirt/utils.go
index 087d1638..d043051c 100644
--- a/libvirt/utils.go
+++ b/libvirt/utils.go
@@ -13,6 +13,9 @@ import (
var diskLetters = []rune("abcdefghijklmnopqrstuvwxyz")
+// LibVirtConIsNil is a global string error msg
+const LibVirtConIsNil string = "the libvirt connection was nil"
+
// DiskLetterForIndex return diskLetters for index
func DiskLetterForIndex(i int) string {