From 4a1bd39cda5de28c93fc96cff8af5af1818759a5 Mon Sep 17 00:00:00 2001 From: lalyos Date: Thu, 16 Oct 2014 16:45:17 +0200 Subject: [PATCH 1/3] Fixing name collision of driver.ErrMachineNotExist and virtualbox.ErrMachineNotExist --- virtualbox/machine.go | 2 +- virtualbox/vbm.go | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/virtualbox/machine.go b/virtualbox/machine.go index 2009d01..f61646c 100644 --- a/virtualbox/machine.go +++ b/virtualbox/machine.go @@ -330,7 +330,7 @@ func GetMachine(id string) (*Machine, error) { stdout, stderr, err := vbmOutErr("showvminfo", id, "--machinereadable") if err != nil { if reMachineNotFound.FindString(stderr) != "" { - return nil, ErrMachineNotExist + return nil, driver.ErrMachineNotExist } return nil, err } diff --git a/virtualbox/vbm.go b/virtualbox/vbm.go index 641c071..bc36d91 100644 --- a/virtualbox/vbm.go +++ b/virtualbox/vbm.go @@ -25,9 +25,8 @@ var ( ) var ( - ErrMachineExist = errors.New("machine already exists") - ErrMachineNotExist = errors.New("machine does not exist") - ErrVBMNotFound = errors.New("VBoxManage not found") + ErrMachineExist = errors.New("machine already exists") + ErrVBMNotFound = errors.New("VBoxManage not found") ) func vbm(args ...string) error { From 78bc9cc7ba7a39d09ab6360d51f674331b84f220 Mon Sep 17 00:00:00 2001 From: lalyos Date: Thu, 16 Oct 2014 16:49:07 +0200 Subject: [PATCH 2/3] Moving ErrMachineExist to driver package "machine already exists" is not virtualbox specific --- driver/driver.go | 1 + virtualbox/machine.go | 2 +- virtualbox/vbm.go | 3 +-- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/driver/driver.go b/driver/driver.go index 9b5524a..2fbb8ab 100644 --- a/driver/driver.go +++ b/driver/driver.go @@ -53,6 +53,7 @@ var ( ErrNotSupported = errors.New("machine not supported") ErrMachineNotExist = errors.New("machine not exist") + ErrMachineExist = errors.New("machine already exists") ErrPrerequisites = errors.New("prerequisites for machine not satisfied (hypervisor installed?)") ) diff --git a/virtualbox/machine.go b/virtualbox/machine.go index f61646c..54d3059 100644 --- a/virtualbox/machine.go +++ b/virtualbox/machine.go @@ -443,7 +443,7 @@ func CreateMachine(mc *driver.MachineConfig) (*Machine, error) { } for _, m := range machineNames { if m == mc.VM { - return nil, ErrMachineExist + return nil, driver.ErrMachineExist } } diff --git a/virtualbox/vbm.go b/virtualbox/vbm.go index bc36d91..a4f534f 100644 --- a/virtualbox/vbm.go +++ b/virtualbox/vbm.go @@ -25,8 +25,7 @@ var ( ) var ( - ErrMachineExist = errors.New("machine already exists") - ErrVBMNotFound = errors.New("VBoxManage not found") + ErrVBMNotFound = errors.New("VBoxManage not found") ) func vbm(args ...string) error { From 013d5ccf8b07ba2d4b634308206ac9173c324d55 Mon Sep 17 00:00:00 2001 From: lalyos Date: Thu, 16 Oct 2014 16:54:25 +0200 Subject: [PATCH 3/3] Fixing error message when no suitable driver found Right now The error message is misleading in case of a non existing driver: "boot2docker-vm": machine not supported Its not the machine which is not supported, but the driver $ boot2docker --driver=nosuchdriver info Boot2Docker-cli version: v1.3.0 Git commit: 1d0b71b error in run: Failed to get machine "boot2docker-vm": machine not supported --- driver/driver.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/driver/driver.go b/driver/driver.go index 2fbb8ab..525ee9b 100644 --- a/driver/driver.go +++ b/driver/driver.go @@ -51,7 +51,7 @@ var ( // All registred machines machines map[string]InitFunc - ErrNotSupported = errors.New("machine not supported") + ErrNotSupported = errors.New("driver not supported") ErrMachineNotExist = errors.New("machine not exist") ErrMachineExist = errors.New("machine already exists") ErrPrerequisites = errors.New("prerequisites for machine not satisfied (hypervisor installed?)")