Skip to content

Commit

Permalink
feat(client-go): add minimal windows support
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua-Anderson authored and Joshua Anderson committed Jul 29, 2015
1 parent c4b722d commit 8351e1c
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ cache/image/bin/
client/dist/
client/makeself/
client-go/deis
client-go/deis.exe
contrib/azure/azure-user-data
contrib/bumpver/bumpver
deisctl/deisctl
Expand Down
3 changes: 2 additions & 1 deletion client-go/cmd/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"net/url"
"strings"
"syscall"

"github.com/deis/deis/client-go/controller/client"
"golang.org/x/crypto/ssh/terminal"
Expand Down Expand Up @@ -191,7 +192,7 @@ func Regenerate(username string, all bool) error {
}

func readPassword() (string, error) {
password, err := terminal.ReadPassword(0)
password, err := terminal.ReadPassword(int(syscall.Stdin))

return string(password), err
}
Expand Down
3 changes: 1 addition & 2 deletions client-go/cmd/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cmd
import (
"fmt"
"io/ioutil"
"os"
"path"
"regexp"
"strconv"
Expand Down Expand Up @@ -129,7 +128,7 @@ func chooseKey() (api.KeyCreateRequest, error) {
}

func listKeys() ([]api.KeyCreateRequest, error) {
folder := path.Join(os.Getenv("HOME"), ".ssh")
folder := path.Join(client.FindHome(), ".ssh")
files, err := ioutil.ReadDir(folder)

if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion client-go/controller/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (c Client) Save() error {
return err
}

if err = os.MkdirAll(path.Join(os.Getenv("HOME"), "/.deis/"), 0775); err != nil {
if err = os.MkdirAll(path.Join(FindHome(), "/.deis/"), 0775); err != nil {
return err
}

Expand Down
12 changes: 12 additions & 0 deletions client-go/controller/client/home_unix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// +build linux darwin

package client

import (
"os"
)

// FindHome returns the HOME directory of the current user
func FindHome() string {
return os.Getenv("HOME")
}
10 changes: 10 additions & 0 deletions client-go/controller/client/home_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package client

import (
"os"
)

// FindHome returns the HOME directory of the current user
func FindHome() string {
return os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH")
}
2 changes: 1 addition & 1 deletion client-go/controller/client/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func locateSettingsFile() string {
filename = "client"
}

return path.Join(os.Getenv("HOME"), ".deis", filename+".json")
return path.Join(FindHome(), ".deis", filename+".json")
}

func deleteSettings() error {
Expand Down
11 changes: 11 additions & 0 deletions client-go/controller/client/webbrowser_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package client

import (
"os/exec"
)

// Webbrowser opens a URL with the default browser.
func Webbrowser(u string) (err error) {
_, err = exec.Command("cmd", "/c", "start", u).Output()
return
}
1 change: 1 addition & 0 deletions client-go/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
godep go build -a -installsuffix cgo -ldflags '-s' -o deis.exe .

0 comments on commit 8351e1c

Please sign in to comment.