mirror of https://github.com/docker/docs.git
Signed-off-by: David Gageot <david@gageot.net>
This commit is contained in:
parent
fa8fa69e7c
commit
22cf29b2ee
|
|
@ -130,6 +130,11 @@ func (d *Driver) GetState() (state.State, error) {
|
|||
|
||||
// PreCreateCheck checks that the machine creation process can be started safely.
|
||||
func (d *Driver) PreCreateCheck() error {
|
||||
// Check that powershell was found
|
||||
if powershell == "" {
|
||||
return ErrPowerShellNotFound
|
||||
}
|
||||
|
||||
// Check that hyperv is installed
|
||||
if err := hypervAvailable(); err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -4,9 +4,7 @@ import (
|
|||
"bufio"
|
||||
"bytes"
|
||||
"errors"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"fmt"
|
||||
|
|
@ -17,17 +15,13 @@ import (
|
|||
var powershell string
|
||||
|
||||
var (
|
||||
ErrNotAdministrator = errors.New("Hyper-v commands have to be run as an Administrator")
|
||||
ErrNotInstalled = errors.New("Hyper-V PowerShell Module is not available")
|
||||
ErrPowerShellNotFound = errors.New("Powershell was not found in the path")
|
||||
ErrNotAdministrator = errors.New("Hyper-v commands have to be run as an Administrator")
|
||||
ErrNotInstalled = errors.New("Hyper-V PowerShell Module is not available")
|
||||
)
|
||||
|
||||
func init() {
|
||||
systemPath := strings.Split(os.Getenv("PATH"), ";")
|
||||
for _, path := range systemPath {
|
||||
if strings.Index(path, "WindowsPowerShell") != -1 {
|
||||
powershell = filepath.Join(path, "powershell.exe")
|
||||
}
|
||||
}
|
||||
powershell, _ = exec.LookPath("powershell.exe")
|
||||
}
|
||||
|
||||
func cmdOut(args ...string) (string, error) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue