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 {
|
func before(c *cli.Context) error {
|
||||||
|
|
||||||
caCertPath := c.GlobalString("tls-ca-cert")
|
caCertPath := c.GlobalString("tls-ca-cert")
|
||||||
caKeyPath := c.GlobalString("tls-ca-key")
|
caKeyPath := c.GlobalString("tls-ca-key")
|
||||||
clientCertPath := c.GlobalString("tls-client-cert")
|
clientCertPath := c.GlobalString("tls-client-cert")
|
||||||
clientKeyPath := c.GlobalString("tls-client-key")
|
clientKeyPath := c.GlobalString("tls-client-key")
|
||||||
|
|
||||||
org, err := utils.GetUsername()
|
org := utils.GetUsername()
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
bits := 2048
|
bits := 2048
|
||||||
|
|
||||||
if _, err := os.Stat(utils.GetMachineDir()); err != nil {
|
if _, err := os.Stat(utils.GetMachineDir()); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ package utils
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"os/user"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
)
|
)
|
||||||
|
|
@ -27,13 +26,22 @@ func GetMachineClientCertDir() string {
|
||||||
return filepath.Join(GetMachineDir(), ".client")
|
return filepath.Join(GetMachineDir(), ".client")
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetUsername() (string, error) {
|
func GetUsername() string {
|
||||||
u, err := user.Current()
|
u := "unknown"
|
||||||
if err != nil {
|
osUser := ""
|
||||||
return "", err
|
|
||||||
|
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 {
|
func CopyFile(src, dst string) error {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue