mirror of https://github.com/docker/docs.git
check properly for username on different platforms
Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
This commit is contained in:
parent
d5a4f2f1c4
commit
720c4edfd2
6
main.go
6
main.go
|
@ -11,16 +11,12 @@ import (
|
|||
)
|
||||
|
||||
func before(c *cli.Context) error {
|
||||
|
||||
caCertPath := c.GlobalString("tls-ca-cert")
|
||||
caKeyPath := c.GlobalString("tls-ca-key")
|
||||
clientCertPath := c.GlobalString("tls-client-cert")
|
||||
clientKeyPath := c.GlobalString("tls-client-key")
|
||||
|
||||
org, err := utils.GetUsername()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
org := utils.GetUsername()
|
||||
bits := 2048
|
||||
|
||||
if _, err := os.Stat(utils.GetMachineDir()); err != nil {
|
||||
|
|
|
@ -3,7 +3,6 @@ package utils
|
|||
import (
|
||||
"io"
|
||||
"os"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
)
|
||||
|
@ -27,13 +26,22 @@ func GetMachineClientCertDir() string {
|
|||
return filepath.Join(GetMachineDir(), ".client")
|
||||
}
|
||||
|
||||
func GetUsername() (string, error) {
|
||||
u, err := user.Current()
|
||||
if err != nil {
|
||||
return "", err
|
||||
func GetUsername() string {
|
||||
u := "unknown"
|
||||
osUser := ""
|
||||
|
||||
switch runtime.GOOS {
|
||||
case "darwin", "linux":
|
||||
osUser = os.Getenv("USER")
|
||||
case "windows":
|
||||
osUser = os.Getenv("USERNAME")
|
||||
}
|
||||
|
||||
return u.Username, nil
|
||||
if osUser != "" {
|
||||
u = osUser
|
||||
}
|
||||
|
||||
return u
|
||||
}
|
||||
|
||||
func CopyFile(src, dst string) error {
|
||||
|
|
Loading…
Reference in New Issue