提交 452054bf 编写于 作者: T Thomas Stromberg

Implement PR comments

上级 deb31b42
......@@ -45,7 +45,7 @@ var sshCmd = &cobra.Command{
}
if host.Driver.DriverName() == "none" {
console.Fatal(`'none' driver does not support 'minikube ssh' command`)
os.Exit(0)
os.Exit(1)
}
err = cluster.CreateSSHShell(api, args)
if err != nil {
......
......@@ -360,14 +360,20 @@ func validateNetwork(h *host.Host) string {
if err != nil {
reportErrAndExit("Unable to get VM IP address", err)
}
console.OutStyle("connectivity", "%q IP address is %s.", cfg.GetMachineName(), ip)
console.OutStyle("connectivity", "%q IP address is %s", cfg.GetMachineName(), ip)
// Here is where we should be checking connectivity to/from the VM
optSeen := false
for _, k := range []string{"HTTP_PROXY", "HTTPS_PROXY", "NO_PROXY"} {
if v := os.Getenv(k); v != "" {
if !optSeen {
console.OutStyle("internet", "Found network options:")
optSeen = true
}
console.OutStyle("option", "%s=%s", k, v)
}
}
// Here is where we should be checking connectivity to/from the VM
return ip
}
......
......@@ -49,15 +49,15 @@ var updateContextCmd = &cobra.Command{
glog.Errorln("Error host driver ip status:", err)
cmdUtil.MaybeReportErrorAndExit(err)
}
ok, err := kcfg.UpdateKubeconfigIP(ip, constants.KubeconfigPath, machineName)
updated, err := kcfg.UpdateKubeconfigIP(ip, constants.KubeconfigPath, machineName)
if err != nil {
glog.Errorln("Error kubeconfig status:", err)
cmdUtil.MaybeReportErrorAndExit(err)
}
if ok {
console.Fatal("Reconfigured kubeconfig IP, now pointing at %s", ip)
if updated {
console.OutStyle("celebrate", "IP has been updated to point at %s", ip)
} else {
console.OutStyle("celebrate", "Kubeconfig IP has been updated to point at %s", ip)
console.OutStyle("meh", "IP was already correctly configured for %s", ip)
}
},
......
......@@ -40,9 +40,5 @@ func main() {
}
console.SetOutFile(os.Stdout)
console.SetErrFile(os.Stderr)
err := console.SetPreferredLanguage(os.Getenv("LANG"))
if err != nil {
glog.Warningf("unable to detect language: %v", err)
}
cmd.Execute()
}
......@@ -34,7 +34,7 @@ type CommandRunner interface {
//
// var b bytes.Buffer
// CombinedOutput(cmd, &b)
// console.Fatal(b.Bytes())
// fmt.Println(b.Bytes())
//
// Or, you can set out to os.Stdout, the command output and
// error would show on your terminal immediately before you
......
......@@ -153,11 +153,13 @@ func SetPreferredLanguageTag(l language.Tag) {
// SetPreferredLanguage configures which language future messages should use, based on a LANG string.
func SetPreferredLanguage(s string) error {
// "C" is commonly used to denote a neutral POSIX locale. See http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap07.html#tag_07_02
if s == "" || s == "C" {
SetPreferredLanguageTag(defaultLanguage)
return nil
}
// Ignore encoding preferences: we always output utf8. Handles "de_DE.utf8"
// Handles "de_DE" or "de_DE.utf8"
// We don't process encodings, since Rob Pike invented utf8 and we're mostly stuck with it.
parts := strings.Split(s, ".")
l, err := language.Parse(parts[0])
if err != nil {
......@@ -187,25 +189,22 @@ func wantsColor(fd uintptr) bool {
//
// MINIKUBE_IN_COLOR=[1, T, true, TRUE]
// MINIKUBE_IN_COLOR=[0, f, false, FALSE]
//
// If unset, we try to automatically determine suitability from the environment.
val := os.Getenv(OverrideEnv)
if val != "" {
glog.Infof("%s=%q\n", OverrideEnv, os.Getenv(OverrideEnv))
override, err := strconv.ParseBool(val)
if err != nil {
// That's OK, we will just fall-back to automatic detection.
glog.Errorf("ParseBool(%s): %v", OverrideEnv, err)
} else {
return override
}
return override
}
glog.Infof("%s=%q\n", OverrideEnv, os.Getenv(OverrideEnv))
switch os.Getenv(OverrideEnv) {
case "0":
return false
case "1":
return true
}
term := os.Getenv("TERM")
// As in: term-256color
// Example: term-256color
if !strings.Contains(term, "color") {
glog.Infof("TERM=%s, which probably does not support color", term)
return false
......
......@@ -33,48 +33,49 @@ type style struct {
// styles is a map of style name to style struct
// For consistency, ensure that emojis added render with the same width across platforms.
var styles = map[string]style{
"happy": {Prefix: "😄"},
"success": {Prefix: "✅"},
"failure": {Prefix: "❌"},
"conflict": {Prefix: "💥"},
"fatal": {Prefix: "💣"},
"notice": {Prefix: "📌"},
"ready": {Prefix: "🏄"},
"restarting": {Prefix: "🔄"},
"stopping": {Prefix: "✋"},
"stopped": {Prefix: "🛑"},
"warning": {Prefix: "⚠️"},
"waiting": {Prefix: "⌛"},
"usage": {Prefix: "💡"},
"launch": {Prefix: "🚀"},
"thumbs-up": {Prefix: "👍"},
"option": {Prefix: " ▪ "},
"crushed": {Prefix: "💔"},
"happy": {Prefix: "😄 "},
"success": {Prefix: "✅ "},
"failure": {Prefix: "❌ "},
"conflict": {Prefix: "💥 "},
"fatal": {Prefix: "💣 "},
"notice": {Prefix: "📌 "},
"ready": {Prefix: "🏄 "},
"restarting": {Prefix: "🔄 "},
"stopping": {Prefix: "✋ "},
"stopped": {Prefix: "🛑 "},
"warning": {Prefix: "⚠️ "},
"waiting": {Prefix: "⌛ "},
"usage": {Prefix: "💡 "},
"launch": {Prefix: "🚀 "},
"thumbs-up": {Prefix: "👍 "},
"option": {Prefix: " ▪ "}, // Indented bullet
"crushed": {Prefix: "💔 "},
// Specialized purpose styles
"iso-download": {Prefix: "💿"},
"file-download": {Prefix: "💾"},
"caching": {Prefix: "🤹"},
"starting-vm": {Prefix: "🔥"},
"starting-none": {Prefix: "🤹"},
"deleting-vm": {Prefix: "🔥"},
"copying": {Prefix: "✨"},
"connectivity": {Prefix: "📶"},
"mounting": {Prefix: "📁"},
"celebrate": {Prefix: "🎉"},
"container-runtime": {Prefix: "🎁"},
"Docker": {Prefix: "🐳"},
"CRIO": {Prefix: "🎁"}, // This should be a snow-flake, but the emoji has a strange width on macOS
"containerd": {Prefix: "📦"},
"permissions": {Prefix: "🔑"},
"enabling": {Prefix: "🔌"},
"pulling": {Prefix: "🚜"},
"verifying": {Prefix: "🤔"},
"verifying-noline": {Prefix: "🤔", OmitNewline: true},
"kubectl": {Prefix: "💗"},
"meh": {Prefix: "🙄"},
"embarassed": {Prefix: "🤦"},
"tip": {Prefix: "💡"},
"iso-download": {Prefix: "💿 "},
"file-download": {Prefix: "💾 "},
"caching": {Prefix: "🤹 "},
"starting-vm": {Prefix: "🔥 "},
"starting-none": {Prefix: "🤹 "},
"deleting-vm": {Prefix: "🔥 "},
"copying": {Prefix: "✨ "},
"connectivity": {Prefix: "📶 "},
"internet": {Prefix: "🌐 "},
"mounting": {Prefix: "📁 "},
"celebrate": {Prefix: "🎉 "},
"container-runtime": {Prefix: "🎁 "},
"Docker": {Prefix: "🐳 "},
"CRIO": {Prefix: "🎁 "}, // This should be a snow-flake, but the emoji has a strange width on macOS
"containerd": {Prefix: "📦 "},
"permissions": {Prefix: "🔑 "},
"enabling": {Prefix: "🔌 "},
"pulling": {Prefix: "🚜 "},
"verifying": {Prefix: "🤔 "},
"verifying-noline": {Prefix: "🤔 ", OmitNewline: true},
"kubectl": {Prefix: "💗 "},
"meh": {Prefix: "🙄 "},
"embarassed": {Prefix: "🤦 "},
"tip": {Prefix: "💡 "},
}
// Add a prefix to a string
......@@ -83,7 +84,7 @@ func applyPrefix(prefix, format string) string {
return format
}
// TODO(tstromberg): Ensure compatibility with RTL languages.
return prefix + " " + format
return prefix + format
}
// Apply styling to a format string
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册