move trimspace to powershell exit check

This commit is contained in:
Matthew Hooker 2017-10-25 09:24:06 -07:00
parent 0be02ab217
commit 812fd12a0b
No known key found for this signature in database
GPG Key ID: 7B5F933D9CE8C6A1
2 changed files with 4 additions and 7 deletions

View File

@ -291,9 +291,7 @@ func (d *HypervPS4Driver) verifyPSHypervModule() error {
return err
}
res := strings.TrimSpace(cmdOut)
if res == "False" {
if powershell.IsFalse(cmdOut) {
err := fmt.Errorf("%s", "PS Hyper-V module is not loaded. Make sure Hyper-V feature is on.")
return err
}
@ -318,8 +316,7 @@ return $principal.IsInRole($hypervrole)
return false, err
}
res := strings.TrimSpace(cmdOut)
return powershell.IsTrue(res), nil
return powershell.IsTrue(cmdOut), nil
}
func (d *HypervPS4Driver) verifyHypervPermissions() error {

View File

@ -18,11 +18,11 @@ const (
)
func IsTrue(s string) bool {
return s == powerShellTrue
return strings.TrimSpace(s) == powerShellTrue
}
func IsFalse(s string) bool {
return s == powerShellFalse
return strings.TrimSpace(s) == powerShellFalse
}
type PowerShellCmd struct {