diff options
author | Dario Maiocchi <dmaiocchi@suse.com> | 2017-11-12 18:22:37 +0100 |
---|---|---|
committer | Dario Maiocchi <dmaiocchi@suse.com> | 2017-11-16 11:26:29 +0100 |
commit | c4edcb9136cab5e05c7c688002236843913a3f7b (patch) | |
tree | 0455a0373966981669372844e9ed9fab9eb394b4 /libvirt | |
parent | 2d00bffd3419f8235fefc101ebfc60bf1ed7ed94 (diff) | |
download | terraform-provider-libvirt-c4edcb9136cab5e05c7c688002236843913a3f7b.tar terraform-provider-libvirt-c4edcb9136cab5e05c7c688002236843913a3f7b.tar.gz |
golint on various files
Diffstat (limited to 'libvirt')
-rw-r--r-- | libvirt/cloudinit_def_test.go | 2 | ||||
-rw-r--r-- | libvirt/pool_sync.go | 14 | ||||
-rw-r--r-- | libvirt/pool_sync_test.go | 6 | ||||
-rw-r--r-- | libvirt/resource_libvirt_domain.go | 2 | ||||
-rw-r--r-- | libvirt/resource_libvirt_domain_test.go | 4 | ||||
-rw-r--r-- | libvirt/utils.go | 11 | ||||
-rw-r--r-- | libvirt/utils_test.go | 24 |
7 files changed, 33 insertions, 30 deletions
diff --git a/libvirt/cloudinit_def_test.go b/libvirt/cloudinit_def_test.go index 56e5f866..ab01f4e7 100644 --- a/libvirt/cloudinit_def_test.go +++ b/libvirt/cloudinit_def_test.go @@ -152,7 +152,7 @@ ssh_authorized_keys: t.Errorf("Unexpectd error %v", err) } - if strings.Contains(res, ud_key) { + if strings.Contains(res, udKey) { t.Error("Should not have found string defined by user data") } diff --git a/libvirt/pool_sync.go b/libvirt/pool_sync.go index 5349b6fe..f99af77e 100644 --- a/libvirt/pool_sync.go +++ b/libvirt/pool_sync.go @@ -4,25 +4,25 @@ import ( "sync" ) -// LibVirtPoolSync makes possible to synchronize operations +// LVirtPoolSync makes possible to synchronize operations // against libvirt pools. // Doing pool.Refresh() operations while uploading or removing // a volume into the pool causes errors inside of libvirtd -type LibVirtPoolSync struct { +type LVirtPoolSync struct { PoolLocks map[string]*sync.Mutex internalMutex sync.Mutex } -// NewLibVirtPoolSync Allocate a new instance of LibVirtPoolSync -func NewLibVirtPoolSync() LibVirtPoolSync { - pool := LibVirtPoolSync{} +// NewLVirtPoolSync Allocate a new instance of LVirtPoolSync +func NewLVirtPoolSync() LVirtPoolSync { + pool := LVirtPoolSync{} pool.PoolLocks = make(map[string]*sync.Mutex) return pool } // AcquireLock Acquire a lock for the specified pool -func (ps LibVirtPoolSync) AcquireLock(pool string) { +func (ps LVirtPoolSync) AcquireLock(pool string) { ps.internalMutex.Lock() defer ps.internalMutex.Unlock() @@ -36,7 +36,7 @@ func (ps LibVirtPoolSync) AcquireLock(pool string) { } // ReleaseLock Release the look for the specified pool -func (ps LibVirtPoolSync) ReleaseLock(pool string) { +func (ps LVirtPoolSync) ReleaseLock(pool string) { ps.internalMutex.Lock() defer ps.internalMutex.Unlock() diff --git a/libvirt/pool_sync_test.go b/libvirt/pool_sync_test.go index 630ae2a4..90ad4849 100644 --- a/libvirt/pool_sync_test.go +++ b/libvirt/pool_sync_test.go @@ -5,7 +5,7 @@ import ( ) func TestAcquireLock(t *testing.T) { - ps := NewLibVirtPoolSync() + ps := NewLVirtPoolSync() ps.AcquireLock("test") @@ -17,7 +17,7 @@ func TestAcquireLock(t *testing.T) { } func TestReleaseLock(t *testing.T) { - ps := NewLibVirtPoolSync() + ps := NewLVirtPoolSync() ps.AcquireLock("test") @@ -34,7 +34,7 @@ func TestReleaseLock(t *testing.T) { } func TestReleaseNotExistingLock(t *testing.T) { - ps := NewLibVirtPoolSync() + ps := NewLVirtPoolSync() ps.ReleaseLock("test") _, found := ps.PoolLocks["test"] diff --git a/libvirt/resource_libvirt_domain.go b/libvirt/resource_libvirt_domain.go index 70c06b93..80374e15 100644 --- a/libvirt/resource_libvirt_domain.go +++ b/libvirt/resource_libvirt_domain.go @@ -26,7 +26,7 @@ type DomainMeta struct { } // PoolSync exported pool sync -var PoolSync = NewLibVirtPoolSync() +var PoolSync = NewLVirtPoolSync() func init() { spew.Config.Indent = "\t" diff --git a/libvirt/resource_libvirt_domain_test.go b/libvirt/resource_libvirt_domain_test.go index d88873a2..368ed2c2 100644 --- a/libvirt/resource_libvirt_domain_test.go +++ b/libvirt/resource_libvirt_domain_test.go @@ -635,7 +635,7 @@ func TestAccLibvirtDomain_FirmwareNoTemplate(t *testing.T) { resource.TestCheckResourceAttr( "libvirt_domain.acceptance-test-domain", "name", "terraform-test-firmware-no-template"), resource.TestCheckResourceAttr( - "libvirt_domain.acceptance-test-domain", "nvram.file", nvram_path), + "libvirt_domain.acceptance-test-domain", "nvram.file", nvramPath), resource.TestCheckResourceAttr( "libvirt_domain.acceptance-test-domain", "firmware", "/usr/share/ovmf/OVMF.fd"), ), @@ -673,7 +673,7 @@ func TestAccLibvirtDomain_FirmwareTemplate(t *testing.T) { resource.TestCheckResourceAttr( "libvirt_domain.acceptance-test-domain", "name", "terraform-test-firmware-with-template"), resource.TestCheckResourceAttr( - "libvirt_domain.acceptance-test-domain", "nvram.file", nvram_path), + "libvirt_domain.acceptance-test-domain", "nvram.file", nvramPath), resource.TestCheckResourceAttr( "libvirt_domain.acceptance-test-domain", "nvram.template", "/usr/share/qemu/OVMF.fd"), resource.TestCheckResourceAttr( diff --git a/libvirt/utils.go b/libvirt/utils.go index bb2f0b3c..087d1638 100644 --- a/libvirt/utils.go +++ b/libvirt/utils.go @@ -27,8 +27,11 @@ func DiskLetterForIndex(i int) string { return fmt.Sprintf("%s%c", DiskLetterForIndex(q-1), letter) } -var waitSleepInterval = 1 * time.Second -var waitTimeout = 5 * time.Minute +// WaitSleepInterval time +var WaitSleepInterval = 1 * time.Second + +// WaitTimeout time +var WaitTimeout = 5 * time.Minute // WaitForSuccess wait for success and timeout after 5 minutes. func WaitForSuccess(errorMessage string, f func() error) error { @@ -40,8 +43,8 @@ func WaitForSuccess(errorMessage string, f func() error) error { } log.Printf("[DEBUG] %s. Re-trying.\n", err) - time.Sleep(waitSleepInterval) - if time.Since(start) > waitTimeout { + time.Sleep(WaitSleepInterval) + if time.Since(start) > WaitTimeout { return fmt.Errorf("%s: %s", errorMessage, err) } } diff --git a/libvirt/utils_test.go b/libvirt/utils_test.go index c702637e..19318216 100644 --- a/libvirt/utils_test.go +++ b/libvirt/utils_test.go @@ -36,15 +36,15 @@ func TestIPsRange(t *testing.T) { } func TestWaitForSuccessEverythingFine(t *testing.T) { - waitSleep := WAIT_SLEEP_INTERVAL - waitTimeout := WAIT_TIMEOUT + waitSleep := WaitSleepInterval + waitTimeout := WaitTimeout defer func() { - WAIT_SLEEP_INTERVAL = waitSleep - WAIT_TIMEOUT = waitTimeout + WaitSleepInterval = waitSleep + WaitTimeout = waitTimeout }() - WAIT_TIMEOUT = 1 * time.Second - WAIT_SLEEP_INTERVAL = 1 * time.Nanosecond + WaitTimeout = 1 * time.Second + WaitSleepInterval = 1 * time.Nanosecond err := WaitForSuccess( "boom", @@ -58,15 +58,15 @@ func TestWaitForSuccessEverythingFine(t *testing.T) { } func TestWaitForSuccessBrokenFunction(t *testing.T) { - waitSleep := WAIT_SLEEP_INTERVAL - waitTimeout := WAIT_TIMEOUT + waitSleep := WaitSleepInterval + waitTimeout := WaitTimeout defer func() { - WAIT_SLEEP_INTERVAL = waitSleep - WAIT_TIMEOUT = waitTimeout + WaitSleepInterval = waitSleep + WaitTimeout = waitTimeout }() - WAIT_TIMEOUT = 1 * time.Second - WAIT_SLEEP_INTERVAL = 1 * time.Nanosecond + WaitTimeout = 1 * time.Second + WaitSleepInterval = 1 * time.Nanosecond err := WaitForSuccess( "boom", |