Change console style string to enum
parent
25b4555d90
commit
34ccd2ad41
|
@ -76,7 +76,7 @@ minikube addons list`, addonName)
|
|||
exit.WithError("IsEnabled failed", err)
|
||||
}
|
||||
if !ok {
|
||||
console.ErrStyle("conflict", `addon '%s' is currently not enabled.
|
||||
console.ErrStyle(console.Conflict, `addon '%s' is currently not enabled.
|
||||
To enable this addon run:
|
||||
minikube addons enable %s`, addonName, addonName)
|
||||
os.Exit(exit.Unavailable)
|
||||
|
|
|
@ -55,7 +55,7 @@ func IsValidDriver(string, driver string) error {
|
|||
|
||||
// RequiresRestartMsg returns the "requires restart" message
|
||||
func RequiresRestartMsg(string, string) error {
|
||||
console.OutStyle("warning", "These changes will take effect upon a minikube delete and then a minikube start")
|
||||
console.OutStyle(console.WarningType, "These changes will take effect upon a minikube delete and then a minikube start")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ var dashboardCmd = &cobra.Command{
|
|||
cluster.EnsureMinikubeRunningOrExit(api, 1)
|
||||
|
||||
// Send status messages to stderr for folks re-using this output.
|
||||
console.ErrStyle("enabling", "Enabling dashboard ...")
|
||||
console.ErrStyle(console.Enabling, "Enabling dashboard ...")
|
||||
// Enable the dashboard add-on
|
||||
err = configcmd.Set("dashboard", "true")
|
||||
if err != nil {
|
||||
|
@ -91,19 +91,19 @@ var dashboardCmd = &cobra.Command{
|
|||
|
||||
ns := "kube-system"
|
||||
svc := "kubernetes-dashboard"
|
||||
console.ErrStyle("verifying", "Verifying dashboard health ...")
|
||||
console.ErrStyle(console.Verifying, "Verifying dashboard health ...")
|
||||
if err = util.RetryAfter(180, func() error { return service.CheckService(ns, svc) }, 1*time.Second); err != nil {
|
||||
exit.WithCode(exit.Unavailable, "%s:%s is not running: %v", ns, svc, err)
|
||||
}
|
||||
|
||||
console.ErrStyle("launch", "Launching proxy ...")
|
||||
console.ErrStyle(console.Launch, "Launching proxy ...")
|
||||
p, hostPort, err := kubectlProxy(kubectl)
|
||||
if err != nil {
|
||||
exit.WithError("kubectl proxy", err)
|
||||
}
|
||||
url := dashboardURL(hostPort, ns, svc)
|
||||
|
||||
console.ErrStyle("verifying", "Verifying proxy health ...")
|
||||
console.ErrStyle(console.Verifying, "Verifying proxy health ...")
|
||||
if err = util.RetryAfter(60, func() error { return checkURL(url) }, 1*time.Second); err != nil {
|
||||
exit.WithCode(exit.Unavailable, "%s is not responding properly: %v", url, err)
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ var dashboardCmd = &cobra.Command{
|
|||
if dashboardURLMode {
|
||||
console.OutLn(url)
|
||||
} else {
|
||||
console.ErrStyle("celebrate", "Opening %s in your default browser...", url)
|
||||
console.ErrStyle(console.Celebrate, "Opening %s in your default browser...", url)
|
||||
if err = browser.OpenURL(url); err != nil {
|
||||
console.Failure("failed to open browser: %v", err)
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ associated files.`,
|
|||
if err == nil && cc.MachineConfig.VMDriver == "none" {
|
||||
kc := cc.KubernetesConfig
|
||||
bsName := viper.GetString(cmdcfg.Bootstrapper)
|
||||
console.OutStyle("resetting", "Uninstalling Kubernetes %s using %s ...", kc.KubernetesVersion, bsName)
|
||||
console.OutStyle(console.Resetting, "Uninstalling Kubernetes %s using %s ...", kc.KubernetesVersion, bsName)
|
||||
clusterBootstrapper, err := GetClusterBootstrapper(api, viper.GetString(cmdcfg.Bootstrapper))
|
||||
if err != nil {
|
||||
console.ErrLn("Unable to get bootstrapper: %v", err)
|
||||
|
@ -73,7 +73,7 @@ associated files.`,
|
|||
if err = cluster.DeleteHost(api); err != nil {
|
||||
switch err := errors.Cause(err).(type) {
|
||||
case mcnerror.ErrHostDoesNotExist:
|
||||
console.OutStyle("meh", "%q cluster does not exist", profile)
|
||||
console.OutStyle(console.Meh, "%q cluster does not exist", profile)
|
||||
default:
|
||||
exit.WithError("Failed to delete cluster", err)
|
||||
}
|
||||
|
@ -85,12 +85,12 @@ associated files.`,
|
|||
|
||||
if err := os.Remove(constants.GetProfileFile(viper.GetString(pkg_config.MachineProfile))); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
console.OutStyle("meh", "%q profile does not exist", profile)
|
||||
console.OutStyle(console.Meh, "%q profile does not exist", profile)
|
||||
os.Exit(0)
|
||||
}
|
||||
exit.WithError("Failed to remove profile", err)
|
||||
}
|
||||
console.OutStyle("crushed", "The %q cluster has been deleted.", profile)
|
||||
console.OutStyle(console.Crushed, "The %q cluster has been deleted.", profile)
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -142,29 +142,29 @@ var mountCmd = &cobra.Command{
|
|||
cfg.Options[parts[0]] = parts[1]
|
||||
}
|
||||
|
||||
console.OutStyle("mounting", "Mounting host path %s into VM as %s ...", hostPath, vmPath)
|
||||
console.OutStyle("mount-options", "Mount options:")
|
||||
console.OutStyle("option", "Type: %s", cfg.Type)
|
||||
console.OutStyle("option", "UID: %s", cfg.UID)
|
||||
console.OutStyle("option", "GID: %s", cfg.GID)
|
||||
console.OutStyle("option", "Version: %s", cfg.Version)
|
||||
console.OutStyle("option", "MSize: %d", cfg.MSize)
|
||||
console.OutStyle("option", "Mode: %o (%s)", cfg.Mode, cfg.Mode)
|
||||
console.OutStyle("option", "Options: %s", cfg.Options)
|
||||
console.OutStyle(console.Mounting, "Mounting host path %s into VM as %s ...", hostPath, vmPath)
|
||||
console.OutStyle(console.MountOptions, "Mount options:")
|
||||
console.OutStyle(console.Option, "Type: %s", cfg.Type)
|
||||
console.OutStyle(console.Option, "UID: %s", cfg.UID)
|
||||
console.OutStyle(console.Option, "GID: %s", cfg.GID)
|
||||
console.OutStyle(console.Option, "Version: %s", cfg.Version)
|
||||
console.OutStyle(console.Option, "MSize: %d", cfg.MSize)
|
||||
console.OutStyle(console.Option, "Mode: %o (%s)", cfg.Mode, cfg.Mode)
|
||||
console.OutStyle(console.Option, "Options: %s", cfg.Options)
|
||||
|
||||
// An escape valve to allow future hackers to try NFS, VirtFS, or other FS types.
|
||||
if !supportedFilesystems[cfg.Type] {
|
||||
console.OutLn("")
|
||||
console.OutStyle("warning", "%s is not yet a supported filesystem. We will try anyways!", cfg.Type)
|
||||
console.OutStyle(console.WarningType, "%s is not yet a supported filesystem. We will try anyways!", cfg.Type)
|
||||
}
|
||||
|
||||
var wg sync.WaitGroup
|
||||
if cfg.Type == nineP {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
console.OutStyle("fileserver", "Userspace file server: ")
|
||||
console.OutStyle(console.Fileserver, "Userspace file server: ")
|
||||
ufs.StartServer(net.JoinHostPort(ip.String(), strconv.Itoa(port)), debugVal, hostPath)
|
||||
console.OutStyle("stopped", "Userspace file server is shutdown")
|
||||
console.OutStyle(console.Stopped, "Userspace file server is shutdown")
|
||||
wg.Done()
|
||||
}()
|
||||
}
|
||||
|
@ -180,10 +180,10 @@ var mountCmd = &cobra.Command{
|
|||
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
||||
go func() {
|
||||
for sig := range c {
|
||||
console.OutStyle("unmount", "Unmounting %s ...", vmPath)
|
||||
console.OutStyle(console.Unmount, "Unmounting %s ...", vmPath)
|
||||
err := cluster.Unmount(runner, vmPath)
|
||||
if err != nil {
|
||||
console.ErrStyle("failure", "Failed unmount: %v", err)
|
||||
console.ErrStyle(console.FailureType, "Failed unmount: %v", err)
|
||||
}
|
||||
exit.WithCode(exit.Interrupted, "Exiting due to %s signal", sig)
|
||||
}
|
||||
|
@ -193,9 +193,9 @@ var mountCmd = &cobra.Command{
|
|||
if err != nil {
|
||||
exit.WithError("mount failed", err)
|
||||
}
|
||||
console.OutStyle("success", "Successfully mounted %s to %s", hostPath, vmPath)
|
||||
console.OutStyle(console.SuccessType, "Successfully mounted %s to %s", hostPath, vmPath)
|
||||
console.OutLn("")
|
||||
console.OutStyle("notice", "NOTE: This process must stay alive for the mount to be accessible ...")
|
||||
console.OutStyle(console.Notice, "NOTE: This process must stay alive for the mount to be accessible ...")
|
||||
wg.Wait()
|
||||
},
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ var serviceListCmd = &cobra.Command{
|
|||
serviceURLs, err := service.GetServiceURLs(api, serviceListNamespace, serviceURLTemplate)
|
||||
if err != nil {
|
||||
console.Fatal("Failed to get service URL: %v", err)
|
||||
console.ErrStyle("notice", "Check that minikube is running and that you have specified the correct namespace (-n flag) if required.")
|
||||
console.ErrStyle(console.Notice, "Check that minikube is running and that you have specified the correct namespace (-n flag) if required.")
|
||||
os.Exit(exit.Unavailable)
|
||||
}
|
||||
|
||||
|
|
|
@ -169,7 +169,7 @@ assumes you have already installed one of the VM drivers: virtualbox/parallels/v
|
|||
|
||||
// runStart handles the executes the flow of "minikube start"
|
||||
func runStart(cmd *cobra.Command, args []string) {
|
||||
console.OutStyle("happy", "minikube %s on %s (%s)", version.GetVersion(), runtime.GOOS, runtime.GOARCH)
|
||||
console.OutStyle(console.Happy, "minikube %s on %s (%s)", version.GetVersion(), runtime.GOOS, runtime.GOARCH)
|
||||
validateConfig()
|
||||
|
||||
oldConfig, err := cfg.Load()
|
||||
|
@ -216,7 +216,7 @@ func runStart(cmd *cobra.Command, args []string) {
|
|||
if err := CacheImagesInConfigFile(); err != nil {
|
||||
exit.WithError("Failed to cache images", err)
|
||||
}
|
||||
console.OutStyle("check", "Download complete!")
|
||||
console.OutStyle(console.Check, "Download complete!")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -226,7 +226,7 @@ func runStart(cmd *cobra.Command, args []string) {
|
|||
// Makes minikube node ip to bypass http(s) proxy. since it is local traffic.
|
||||
err = proxy.ExcludeIP(ip)
|
||||
if err != nil {
|
||||
console.ErrStyle("Failed to set NO_PROXY Env. please Use `export NO_PROXY=$NO_PROXY,%s`.", ip)
|
||||
console.ErrStyle(console.FailureType, "Failed to set NO_PROXY Env. please Use `export NO_PROXY=$NO_PROXY,%s`.", ip)
|
||||
}
|
||||
// Save IP to configuration file for subsequent use
|
||||
config.KubernetesConfig.NodeIP = ip
|
||||
|
@ -240,12 +240,12 @@ func runStart(cmd *cobra.Command, args []string) {
|
|||
|
||||
cr := configureRuntimes(runner)
|
||||
version, _ := cr.Version()
|
||||
console.OutStyle(cr.Name(), "Configuring environment for Kubernetes %s on %s %s", k8sVersion, cr.Name(), version)
|
||||
console.OutStyle(cr.Style(), "Configuring environment for Kubernetes %s on %s %s", k8sVersion, cr.Name(), version)
|
||||
for _, v := range dockerOpt {
|
||||
console.OutStyle("option", "opt %s", v)
|
||||
console.OutStyle(console.Option, "opt %s", v)
|
||||
}
|
||||
for _, v := range dockerEnv {
|
||||
console.OutStyle("option", "env %s", v)
|
||||
console.OutStyle(console.Option, "env %s", v)
|
||||
}
|
||||
|
||||
// prepareHostEnvironment uses the downloaded images, so we need to wait for background task completion.
|
||||
|
@ -262,7 +262,7 @@ func runStart(cmd *cobra.Command, args []string) {
|
|||
}
|
||||
|
||||
if config.MachineConfig.VMDriver == constants.DriverNone {
|
||||
console.OutStyle("starting-none", "Configuring local host environment ...")
|
||||
console.OutStyle(console.StartingNone, "Configuring local host environment ...")
|
||||
prepareNone()
|
||||
}
|
||||
|
||||
|
@ -275,13 +275,13 @@ func runStart(cmd *cobra.Command, args []string) {
|
|||
|
||||
func showKubectlConnectInfo(kubeconfig *pkgutil.KubeConfigSetup) {
|
||||
if kubeconfig.KeepContext {
|
||||
console.OutStyle("kubectl", "To connect to this cluster, use: kubectl --context=%s", kubeconfig.ClusterName)
|
||||
console.OutStyle(console.Kubectl, "To connect to this cluster, use: kubectl --context=%s", kubeconfig.ClusterName)
|
||||
} else {
|
||||
console.OutStyle("ready", "Done! kubectl is now configured to use %q", cfg.GetMachineName())
|
||||
console.OutStyle(console.Ready, "Done! kubectl is now configured to use %q", cfg.GetMachineName())
|
||||
}
|
||||
_, err := exec.LookPath("kubectl")
|
||||
if err != nil {
|
||||
console.OutStyle("tip", "For best results, install kubectl: https://kubernetes.io/docs/tasks/tools/install-kubectl/")
|
||||
console.OutStyle(console.Tip, "For best results, install kubectl: https://kubernetes.io/docs/tasks/tools/install-kubectl/")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -416,7 +416,7 @@ func generateConfig(cmd *cobra.Command, k8sVersion string) (cfg.Config, error) {
|
|||
repository := viper.GetString(imageRepository)
|
||||
mirrorCountry := strings.ToLower(viper.GetString(imageMirrorCountry))
|
||||
if strings.ToLower(repository) == "auto" || mirrorCountry != "" {
|
||||
console.OutStyle("connectivity", "checking main repository and mirrors for images")
|
||||
console.OutStyle(console.Connectivity, "checking main repository and mirrors for images")
|
||||
found, autoSelectedRepository, err := selectImageRepository(mirrorCountry, k8sVersion)
|
||||
if err != nil {
|
||||
exit.WithError("Failed to check main repository and mirrors for images for images", err)
|
||||
|
@ -434,7 +434,7 @@ func generateConfig(cmd *cobra.Command, k8sVersion string) (cfg.Config, error) {
|
|||
}
|
||||
|
||||
if repository != "" {
|
||||
console.OutStyle("success", "using image repository %s", repository)
|
||||
console.OutStyle(console.SuccessType, "using image repository %s", repository)
|
||||
}
|
||||
|
||||
cfg := cfg.Config{
|
||||
|
@ -492,7 +492,7 @@ func prepareNone() {
|
|||
console.OutLn("")
|
||||
console.Warning("The 'none' driver provides limited isolation and may reduce system security and reliability.")
|
||||
console.Warning("For more information, see:")
|
||||
console.OutStyle("url", "https://github.com/kubernetes/minikube/blob/master/docs/vmdriver-none.md")
|
||||
console.OutStyle(console.Url, "https://github.com/kubernetes/minikube/blob/master/docs/vmdriver-none.md")
|
||||
console.OutLn("")
|
||||
}
|
||||
|
||||
|
@ -503,11 +503,11 @@ func prepareNone() {
|
|||
console.Warning("need to relocate them. For example, to overwrite your own settings:")
|
||||
|
||||
console.OutLn("")
|
||||
console.OutStyle("command", "sudo mv %s/.kube %s/.minikube $HOME", home, home)
|
||||
console.OutStyle("command", "sudo chown -R $USER $HOME/.kube $HOME/.minikube")
|
||||
console.OutStyle(console.Command, "sudo mv %s/.kube %s/.minikube $HOME", home, home)
|
||||
console.OutStyle(console.Command, "sudo chown -R $USER $HOME/.kube $HOME/.minikube")
|
||||
console.OutLn("")
|
||||
|
||||
console.OutStyle("tip", "This can also be done automatically by setting the env var CHANGE_MINIKUBE_NONE_USER=true")
|
||||
console.OutStyle(console.Tip, "This can also be done automatically by setting the env var CHANGE_MINIKUBE_NONE_USER=true")
|
||||
}
|
||||
|
||||
if err := pkgutil.MaybeChownDirRecursiveToMinikubeUser(constants.GetMinipath()); err != nil {
|
||||
|
@ -548,10 +548,10 @@ func validateNetwork(h *host.Host) string {
|
|||
for _, k := range proxy.EnvVars {
|
||||
if v := os.Getenv(k); v != "" {
|
||||
if !optSeen {
|
||||
console.OutStyle("internet", "Found network options:")
|
||||
console.OutStyle(console.Internet, "Found network options:")
|
||||
optSeen = true
|
||||
}
|
||||
console.OutStyle("option", "%s=%s", k, v)
|
||||
console.OutStyle(console.Option, "%s=%s", k, v)
|
||||
ipExcluded := proxy.IsIPExcluded(ip) // Skip warning if minikube ip is already in NO_PROXY
|
||||
if (k == "HTTP_PROXY" || k == "HTTPS_PROXY") && !ipExcluded && !warnedOnce {
|
||||
console.Warning("You appear to be using a proxy, but your NO_PROXY environment does not include the minikube IP (%s). Please see https://github.com/kubernetes/minikube/blob/master/docs/http_proxy.md for more details", ip)
|
||||
|
@ -587,11 +587,11 @@ func validateKubernetesVersions(old *cfg.Config) (string, bool) {
|
|||
|
||||
if nvs.LT(ovs) {
|
||||
nv = version.VersionPrefix + ovs.String()
|
||||
console.ErrStyle("conflict", "Kubernetes downgrade is not supported, will continue to use %v", nv)
|
||||
console.ErrStyle(console.Conflict, "Kubernetes downgrade is not supported, will continue to use %v", nv)
|
||||
return nv, isUpgrade
|
||||
}
|
||||
if nvs.GT(ovs) {
|
||||
console.OutStyle("thumbs-up", "minikube will upgrade the local cluster from Kubernetes %s to %s", ovs, nvs)
|
||||
console.OutStyle(console.ThumbsUp, "minikube will upgrade the local cluster from Kubernetes %s to %s", ovs, nvs)
|
||||
isUpgrade = true
|
||||
}
|
||||
return nv, isUpgrade
|
||||
|
@ -604,7 +604,7 @@ func prepareHostEnvironment(api libmachine.API, kc cfg.KubernetesConfig) bootstr
|
|||
exit.WithError("Failed to get bootstrapper", err)
|
||||
}
|
||||
for _, eo := range extraOptions {
|
||||
console.OutStyle("option", "%s.%s=%s", eo.Component, eo.Key, eo.Value)
|
||||
console.OutStyle(console.Option, "%s.%s=%s", eo.Component, eo.Key, eo.Value)
|
||||
}
|
||||
// Loads cached images, generates config files, download binaries
|
||||
if err := bs.UpdateCluster(kc); err != nil {
|
||||
|
@ -666,21 +666,21 @@ func bootstrapCluster(bs bootstrapper.Bootstrapper, r cruntime.Manager, runner b
|
|||
bsName := viper.GetString(cmdcfg.Bootstrapper)
|
||||
|
||||
if isUpgrade || !preexisting {
|
||||
console.OutStyle("pulling", "Pulling images ...")
|
||||
console.OutStyle(console.Pulling, "Pulling images ...")
|
||||
if err := bs.PullImages(kc); err != nil {
|
||||
console.OutStyle("failure", "Unable to pull images, which may be OK: %v", err)
|
||||
console.OutStyle(console.FailureType, "Unable to pull images, which may be OK: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
if preexisting {
|
||||
console.OutStyle("restarting", "Relaunching Kubernetes %s using %s ... ", kc.KubernetesVersion, bsName)
|
||||
console.OutStyle(console.Restarting, "Relaunching Kubernetes %s using %s ... ", kc.KubernetesVersion, bsName)
|
||||
if err := bs.RestartCluster(kc); err != nil {
|
||||
exit.WithLogEntries("Error restarting cluster", err, logs.FindProblems(r, bs, runner))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
console.OutStyle("launch", "Launching Kubernetes ... ")
|
||||
console.OutStyle(console.Launch, "Launching Kubernetes ... ")
|
||||
if err := bs.StartCluster(kc); err != nil {
|
||||
exit.WithLogEntries("Error starting cluster", err, logs.FindProblems(r, bs, runner))
|
||||
}
|
||||
|
@ -692,7 +692,7 @@ func configureMounts() {
|
|||
return
|
||||
}
|
||||
|
||||
console.OutStyle("mounting", "Creating mount %s ...", viper.GetString(mountString))
|
||||
console.OutStyle(console.Mounting, "Creating mount %s ...", viper.GetString(mountString))
|
||||
path := os.Args[0]
|
||||
mountDebugVal := 0
|
||||
if glog.V(8) {
|
||||
|
|
|
@ -53,7 +53,7 @@ itself, leaving all files intact. The cluster can be started again with the "sta
|
|||
err = cluster.StopHost(api)
|
||||
switch err := errors.Cause(err).(type) {
|
||||
case mcnerror.ErrHostDoesNotExist:
|
||||
console.OutStyle("meh", "%q VM does not exist, nothing to stop", profile)
|
||||
console.OutStyle(console.Meh, "%q VM does not exist, nothing to stop", profile)
|
||||
nonexistent = true
|
||||
return nil
|
||||
default:
|
||||
|
@ -64,11 +64,11 @@ itself, leaving all files intact. The cluster can be started again with the "sta
|
|||
exit.WithError("Unable to stop VM", err)
|
||||
}
|
||||
if !nonexistent {
|
||||
console.OutStyle("stopped", "%q stopped.", profile)
|
||||
console.OutStyle(console.Stopped, "%q stopped.", profile)
|
||||
}
|
||||
|
||||
if err := cmdUtil.KillMountProcess(); err != nil {
|
||||
console.OutStyle("warning", "Unable to kill mount process: %s", err)
|
||||
console.OutStyle(console.WarningType, "Unable to kill mount process: %s", err)
|
||||
}
|
||||
|
||||
machineName := pkg_config.GetMachineName()
|
||||
|
|
|
@ -49,9 +49,9 @@ var updateContextCmd = &cobra.Command{
|
|||
exit.WithError("update config", err)
|
||||
}
|
||||
if updated {
|
||||
console.OutStyle("celebrate", "%s IP has been updated to point at %s", machineName, ip)
|
||||
console.OutStyle(console.Celebrate, "%s IP has been updated to point at %s", machineName, ip)
|
||||
} else {
|
||||
console.OutStyle("meh", "%s IP was already correctly configured for %s", machineName, ip)
|
||||
console.OutStyle(console.Meh, "%s IP was already correctly configured for %s", machineName, ip)
|
||||
}
|
||||
|
||||
},
|
||||
|
|
|
@ -304,7 +304,7 @@ func (k *Bootstrapper) WaitCluster(k8s config.KubernetesConfig) error {
|
|||
// by a CNI plugin which is usually started after minikube has been brought
|
||||
// up. Otherwise, minikube won't start, as "k8s-app" pods are not ready.
|
||||
componentsOnly := k8s.NetworkPlugin == "cni"
|
||||
console.OutStyle("waiting-pods", "Verifying:")
|
||||
console.OutStyle(console.WaitingPods, "Verifying:")
|
||||
client, err := util.GetClient()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "k8s client")
|
||||
|
|
|
@ -107,7 +107,7 @@ func StartHost(api libmachine.API, config cfg.MachineConfig) (*host.Host, error)
|
|||
console.Warning("Alternatively, you may delete the existing VM using `minikube delete -p %s`", cfg.GetMachineName())
|
||||
console.Out("\n")
|
||||
} else if exists && cfg.GetMachineName() == constants.DefaultMachineName {
|
||||
console.OutStyle("tip", "Tip: Use 'minikube start -p <name>' to create a new cluster, or 'minikube delete' to delete this one.")
|
||||
console.OutStyle(console.Tip, "Tip: Use 'minikube start -p <name>' to create a new cluster, or 'minikube delete' to delete this one.")
|
||||
}
|
||||
|
||||
s, err := h.Driver.GetState()
|
||||
|
@ -117,9 +117,9 @@ func StartHost(api libmachine.API, config cfg.MachineConfig) (*host.Host, error)
|
|||
}
|
||||
|
||||
if s == state.Running {
|
||||
console.OutStyle("running", "Re-using the currently running %s VM for %q ...", h.Driver.DriverName(), cfg.GetMachineName())
|
||||
console.OutStyle(console.Running, "Re-using the currently running %s VM for %q ...", h.Driver.DriverName(), cfg.GetMachineName())
|
||||
} else {
|
||||
console.OutStyle("restarting", "Restarting existing %s VM for %q ...", h.Driver.DriverName(), cfg.GetMachineName())
|
||||
console.OutStyle(console.Restarting, "Restarting existing %s VM for %q ...", h.Driver.DriverName(), cfg.GetMachineName())
|
||||
if err := h.Driver.Start(); err != nil {
|
||||
return nil, errors.Wrap(err, "start")
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ func StartHost(api libmachine.API, config cfg.MachineConfig) (*host.Host, error)
|
|||
// configureHost handles any post-powerup configuration required
|
||||
func configureHost(h *host.Host, e *engine.Options) error {
|
||||
// Slightly counter-intuitive, but this is what DetectProvisioner & ConfigureAuth block on.
|
||||
console.OutStyle("waiting", "Waiting for SSH access ...")
|
||||
console.OutStyle(console.Waiting, "Waiting for SSH access ...")
|
||||
|
||||
if len(e.Env) > 0 {
|
||||
h.HostOptions.EngineOptions.Env = e.Env
|
||||
|
@ -224,7 +224,7 @@ func trySSHPowerOff(h *host.Host) {
|
|||
return
|
||||
}
|
||||
|
||||
console.OutStyle("shutdown", "Powering off %q via SSH ...", cfg.GetMachineName())
|
||||
console.OutStyle(console.Shutdown, "Powering off %q via SSH ...", cfg.GetMachineName())
|
||||
out, err := h.RunSSHCommand("sudo poweroff")
|
||||
// poweroff always results in an error, since the host disconnects.
|
||||
glog.Infof("poweroff result: out=%s, err=%v", out, err)
|
||||
|
@ -236,7 +236,7 @@ func StopHost(api libmachine.API) error {
|
|||
if err != nil {
|
||||
return errors.Wrapf(err, "load")
|
||||
}
|
||||
console.OutStyle("stopping", "Stopping %q in %s ...", cfg.GetMachineName(), host.DriverName)
|
||||
console.OutStyle(console.Stopping, "Stopping %q in %s ...", cfg.GetMachineName(), host.DriverName)
|
||||
if err := host.Stop(); err != nil {
|
||||
alreadyInStateError, ok := err.(mcnerror.ErrHostAlreadyInState)
|
||||
if ok && alreadyInStateError.State == state.Stopped {
|
||||
|
@ -258,7 +258,7 @@ func DeleteHost(api libmachine.API) error {
|
|||
trySSHPowerOff(host)
|
||||
}
|
||||
|
||||
console.OutStyle("deleting-host", "Deleting %q from %s ...", cfg.GetMachineName(), host.DriverName)
|
||||
console.OutStyle(console.DeletingHost, "Deleting %q from %s ...", cfg.GetMachineName(), host.DriverName)
|
||||
if err := host.Driver.Remove(); err != nil {
|
||||
return errors.Wrap(err, "host remove")
|
||||
}
|
||||
|
@ -346,7 +346,7 @@ To disable this message, run [minikube config set WantShowDriverDeprecationNotif
|
|||
|
||||
func createHost(api libmachine.API, config cfg.MachineConfig) (*host.Host, error) {
|
||||
preCreateHost(&config)
|
||||
console.OutStyle("starting-vm", "Creating %s VM (CPUs=%d, Memory=%dMB, Disk=%dMB) ...", config.VMDriver, config.CPUs, config.Memory, config.DiskSize)
|
||||
console.OutStyle(console.StartingVm, "Creating %s VM (CPUs=%d, Memory=%dMB, Disk=%dMB) ...", config.VMDriver, config.CPUs, config.Memory, config.DiskSize)
|
||||
def, err := registry.Driver(config.VMDriver)
|
||||
if err != nil {
|
||||
if err == registry.ErrDriverNotFound {
|
||||
|
|
|
@ -36,7 +36,7 @@ import (
|
|||
//
|
||||
// console.SetOutFile(os.Stdout)
|
||||
// console.Out("Starting up!")
|
||||
// console.OutStyle("status-change", "Configuring things")
|
||||
// console.OutStyle(console.StatusChange, "Configuring things")
|
||||
|
||||
// console.SetErrFile(os.Stderr)
|
||||
// console.Fatal("Oh no, everything failed.")
|
||||
|
@ -65,12 +65,12 @@ type fdWriter interface {
|
|||
}
|
||||
|
||||
// HasStyle checks if a style exists
|
||||
func HasStyle(style string) bool {
|
||||
func HasStyle(style StyleEnum) bool {
|
||||
return hasStyle(style)
|
||||
}
|
||||
|
||||
// OutStyle writes a stylized and formatted message to stdout
|
||||
func OutStyle(style, format string, a ...interface{}) {
|
||||
func OutStyle(style StyleEnum, format string, a ...interface{}) {
|
||||
outStyled, err := applyStyle(style, useColor, format, a...)
|
||||
if err != nil {
|
||||
glog.Errorf("applyStyle(%s): %v", style, err)
|
||||
|
@ -101,7 +101,7 @@ func OutLn(format string, a ...interface{}) {
|
|||
}
|
||||
|
||||
// ErrStyle writes a stylized and formatted error message to stderr
|
||||
func ErrStyle(style, format string, a ...interface{}) {
|
||||
func ErrStyle(style StyleEnum, format string, a ...interface{}) {
|
||||
format, err := applyStyle(style, useColor, format, a...)
|
||||
if err != nil {
|
||||
glog.Errorf("applyStyle(%s): %v", style, err)
|
||||
|
@ -134,22 +134,22 @@ func ErrLn(format string, a ...interface{}) {
|
|||
|
||||
// Success is a shortcut for writing a styled success message to stdout
|
||||
func Success(format string, a ...interface{}) {
|
||||
OutStyle("success", format, a...)
|
||||
OutStyle(SuccessType, format, a...)
|
||||
}
|
||||
|
||||
// Fatal is a shortcut for writing a styled fatal message to stderr
|
||||
func Fatal(format string, a ...interface{}) {
|
||||
ErrStyle("fatal", format, a...)
|
||||
ErrStyle(FatalType, format, a...)
|
||||
}
|
||||
|
||||
// Warning is a shortcut for writing a styled warning message to stderr
|
||||
func Warning(format string, a ...interface{}) {
|
||||
ErrStyle("warning", format, a...)
|
||||
ErrStyle(WarningType, format, a...)
|
||||
}
|
||||
|
||||
// Failure is a shortcut for writing a styled failure message to stderr
|
||||
func Failure(format string, a ...interface{}) {
|
||||
ErrStyle("failure", format, a...)
|
||||
ErrStyle(FailureType, format, a...)
|
||||
}
|
||||
|
||||
// SetPreferredLanguageTag configures which language future messages should use.
|
||||
|
|
|
@ -50,19 +50,19 @@ func (f *fakeFile) String() string {
|
|||
func TestOutStyle(t *testing.T) {
|
||||
|
||||
var tests = []struct {
|
||||
style string
|
||||
style StyleEnum
|
||||
message string
|
||||
params []interface{}
|
||||
want string
|
||||
wantASCII string
|
||||
}{
|
||||
{"happy", "Happy", nil, "😄 Happy\n", "* Happy\n"},
|
||||
{"option", "Option", nil, " ▪ Option\n", " - Option\n"},
|
||||
{"warning", "Warning", nil, "⚠️ Warning\n", "! Warning\n"},
|
||||
{"fatal", "Fatal: %v", []interface{}{"ugh"}, "💣 Fatal: ugh\n", "X Fatal: ugh\n"},
|
||||
{"waiting-pods", "wait", nil, "⌛ wait", "* wait"},
|
||||
{"issue", "http://i/%d", []interface{}{10000}, " ▪ http://i/10000\n", " - http://i/10000\n"},
|
||||
{"usage", "raw: %s %s", []interface{}{"'%'", "%d"}, "💡 raw: '%' %d\n", "* raw: '%' %d\n"},
|
||||
{Happy, "Happy", nil, "😄 Happy\n", "* Happy\n"},
|
||||
{Option, "Option", nil, " ▪ Option\n", " - Option\n"},
|
||||
{WarningType, "Warning", nil, "⚠️ Warning\n", "! Warning\n"},
|
||||
{FatalType, "Fatal: %v", []interface{}{"ugh"}, "💣 Fatal: ugh\n", "X Fatal: ugh\n"},
|
||||
{WaitingPods, "wait", nil, "⌛ wait", "* wait"},
|
||||
{Issue, "http://i/%d", []interface{}{10000}, " ▪ http://i/10000\n", " - http://i/10000\n"},
|
||||
{Usage, "raw: %s %s", []interface{}{"'%'", "%d"}, "💡 raw: '%' %d\n", "* raw: '%' %d\n"},
|
||||
}
|
||||
for _, tc := range tests {
|
||||
for _, override := range []bool{true, false} {
|
||||
|
@ -137,7 +137,7 @@ func TestErrStyle(t *testing.T) {
|
|||
os.Setenv(OverrideEnv, "1")
|
||||
f := newFakeFile()
|
||||
SetErrFile(f)
|
||||
ErrStyle("fatal", "error: %s", "%s%%%d")
|
||||
ErrStyle(FatalType, "error: %s", "%s%%%d")
|
||||
got := f.String()
|
||||
want := "💣 error: %s%%%d\n"
|
||||
if got != want {
|
||||
|
|
|
@ -47,67 +47,67 @@ 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: "💥 ", LowPrefix: lowWarning},
|
||||
"fatal": {Prefix: "💣 ", LowPrefix: lowError},
|
||||
"notice": {Prefix: "📌 "},
|
||||
"ready": {Prefix: "🏄 "},
|
||||
"running": {Prefix: "🏃 "},
|
||||
"provisioning": {Prefix: "🌱 "},
|
||||
"restarting": {Prefix: "🔄 "},
|
||||
"reconfiguring": {Prefix: "📯 "},
|
||||
"stopping": {Prefix: "✋ "},
|
||||
"stopped": {Prefix: "🛑 "},
|
||||
"warning": {Prefix: "⚠️ ", LowPrefix: lowWarning},
|
||||
"waiting": {Prefix: "⌛ "},
|
||||
"waiting-pods": {Prefix: "⌛ ", OmitNewline: true},
|
||||
"usage": {Prefix: "💡 "},
|
||||
"launch": {Prefix: "🚀 "},
|
||||
"sad": {Prefix: "😿 "},
|
||||
"thumbs-up": {Prefix: "👍 "},
|
||||
"option": {Prefix: " ▪ ", LowPrefix: lowIndent}, // Indented bullet
|
||||
"command": {Prefix: " ▪ ", LowPrefix: lowIndent}, // Indented bullet
|
||||
"log-entry": {Prefix: " "}, // Indent
|
||||
"crushed": {Prefix: "💔 "},
|
||||
"url": {Prefix: "👉 ", LowPrefix: lowIndent},
|
||||
"documentation": {Prefix: "📘 "},
|
||||
"issues": {Prefix: "⁉️ "},
|
||||
"issue": {Prefix: " ▪ ", LowPrefix: lowIndent}, // Indented bullet
|
||||
"check": {Prefix: "✔️ "},
|
||||
var styles = map[StyleEnum]style{
|
||||
Happy: {Prefix: "😄 "},
|
||||
SuccessType: {Prefix: "✅ "},
|
||||
FailureType: {Prefix: "❌ "},
|
||||
Conflict: {Prefix: "💥 ", LowPrefix: lowWarning},
|
||||
FatalType: {Prefix: "💣 ", LowPrefix: lowError},
|
||||
Notice: {Prefix: "📌 "},
|
||||
Ready: {Prefix: "🏄 "},
|
||||
Running: {Prefix: "🏃 "},
|
||||
Provisioning: {Prefix: "🌱 "},
|
||||
Restarting: {Prefix: "🔄 "},
|
||||
Reconfiguring: {Prefix: "📯 "},
|
||||
Stopping: {Prefix: "✋ "},
|
||||
Stopped: {Prefix: "🛑 "},
|
||||
WarningType: {Prefix: "⚠️ ", LowPrefix: lowWarning},
|
||||
Waiting: {Prefix: "⌛ "},
|
||||
WaitingPods: {Prefix: "⌛ ", OmitNewline: true},
|
||||
Usage: {Prefix: "💡 "},
|
||||
Launch: {Prefix: "🚀 "},
|
||||
Sad: {Prefix: "😿 "},
|
||||
ThumbsUp: {Prefix: "👍 "},
|
||||
Option: {Prefix: " ▪ ", LowPrefix: lowIndent}, // Indented bullet
|
||||
Command: {Prefix: " ▪ ", LowPrefix: lowIndent}, // Indented bullet
|
||||
LogEntry: {Prefix: " "}, // Indent
|
||||
Crushed: {Prefix: "💔 "},
|
||||
Url: {Prefix: "👉 ", LowPrefix: lowIndent},
|
||||
Documentation: {Prefix: "📘 "},
|
||||
Issues: {Prefix: "⁉️ "},
|
||||
Issue: {Prefix: " ▪ ", LowPrefix: lowIndent}, // Indented bullet
|
||||
Check: {Prefix: "✔️ "},
|
||||
|
||||
// Specialized purpose styles
|
||||
"iso-download": {Prefix: "💿 "},
|
||||
"file-download": {Prefix: "💾 "},
|
||||
"caching": {Prefix: "🤹 "},
|
||||
"starting-vm": {Prefix: "🔥 "},
|
||||
"starting-none": {Prefix: "🤹 "},
|
||||
"resetting": {Prefix: "🔄 "},
|
||||
"deleting-host": {Prefix: "🔥 "},
|
||||
"copying": {Prefix: "✨ "},
|
||||
"connectivity": {Prefix: "📶 "},
|
||||
"internet": {Prefix: "🌐 "},
|
||||
"mounting": {Prefix: "📁 "},
|
||||
"celebrate": {Prefix: "🎉 "},
|
||||
"container-runtime": {Prefix: "🎁 "},
|
||||
"Docker": {Prefix: "🐳 "},
|
||||
"CRI-O": {Prefix: "🎁 "}, // This should be a snow-flake, but the emoji has a strange width on macOS
|
||||
"containerd": {Prefix: "📦 "},
|
||||
"permissions": {Prefix: "🔑 "},
|
||||
"enabling": {Prefix: "🔌 "},
|
||||
"shutdown": {Prefix: "🛑 "},
|
||||
"pulling": {Prefix: "🚜 "},
|
||||
"verifying": {Prefix: "🤔 "},
|
||||
"verifying-noline": {Prefix: "🤔 ", OmitNewline: true},
|
||||
"kubectl": {Prefix: "💗 "},
|
||||
"meh": {Prefix: "🙄 ", LowPrefix: lowWarning},
|
||||
"embarrassed": {Prefix: "🤦 ", LowPrefix: lowWarning},
|
||||
"tip": {Prefix: "💡 "},
|
||||
"unmount": {Prefix: "🔥 "},
|
||||
"mount-options": {Prefix: "💾 "},
|
||||
"fileserver": {Prefix: "🚀 ", OmitNewline: true},
|
||||
IsoDownload: {Prefix: "💿 "},
|
||||
FileDownload: {Prefix: "💾 "},
|
||||
Caching: {Prefix: "🤹 "},
|
||||
StartingVm: {Prefix: "🔥 "},
|
||||
StartingNone: {Prefix: "🤹 "},
|
||||
Resetting: {Prefix: "🔄 "},
|
||||
DeletingHost: {Prefix: "🔥 "},
|
||||
Copying: {Prefix: "✨ "},
|
||||
Connectivity: {Prefix: "📶 "},
|
||||
Internet: {Prefix: "🌐 "},
|
||||
Mounting: {Prefix: "📁 "},
|
||||
Celebrate: {Prefix: "🎉 "},
|
||||
ContainerRuntime: {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: "🔌 "},
|
||||
Shutdown: {Prefix: "🛑 "},
|
||||
Pulling: {Prefix: "🚜 "},
|
||||
Verifying: {Prefix: "🤔 "},
|
||||
VerifyingNoLine: {Prefix: "🤔 ", OmitNewline: true},
|
||||
Kubectl: {Prefix: "💗 "},
|
||||
Meh: {Prefix: "🙄 ", LowPrefix: lowWarning},
|
||||
Embarrassed: {Prefix: "🤦 ", LowPrefix: lowWarning},
|
||||
Tip: {Prefix: "💡 "},
|
||||
Unmount: {Prefix: "🔥 "},
|
||||
MountOptions: {Prefix: "💾 "},
|
||||
Fileserver: {Prefix: "🚀 ", OmitNewline: true},
|
||||
}
|
||||
|
||||
// Add a prefix to a string
|
||||
|
@ -119,7 +119,7 @@ func applyPrefix(prefix, format string) string {
|
|||
return prefix + format
|
||||
}
|
||||
|
||||
func hasStyle(style string) bool {
|
||||
func hasStyle(style StyleEnum) bool {
|
||||
_, exists := styles[style]
|
||||
return exists
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ func lowPrefix(s style) string {
|
|||
}
|
||||
|
||||
// Apply styling to a format string
|
||||
func applyStyle(style string, useColor bool, format string, a ...interface{}) (string, error) {
|
||||
func applyStyle(style StyleEnum, useColor bool, format string, a ...interface{}) (string, error) {
|
||||
p := message.NewPrinter(preferredLanguage)
|
||||
for i, x := range a {
|
||||
if _, ok := x.(int); ok {
|
||||
|
|
|
@ -0,0 +1,146 @@
|
|||
/*
|
||||
Copyright 2019 The Kubernetes Authors All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package console
|
||||
|
||||
type StyleEnum int
|
||||
const (
|
||||
Happy StyleEnum = iota
|
||||
SuccessType
|
||||
FailureType
|
||||
Conflict
|
||||
FatalType
|
||||
Notice
|
||||
Ready
|
||||
Running
|
||||
Provisioning
|
||||
Restarting
|
||||
Reconfiguring
|
||||
Stopping
|
||||
Stopped
|
||||
WarningType
|
||||
Waiting
|
||||
WaitingPods
|
||||
Usage
|
||||
Launch
|
||||
Sad
|
||||
ThumbsUp
|
||||
Option
|
||||
Command
|
||||
LogEntry
|
||||
Crushed
|
||||
Url
|
||||
Documentation
|
||||
Issues
|
||||
Issue
|
||||
Check
|
||||
IsoDownload
|
||||
FileDownload
|
||||
Caching
|
||||
StartingVm
|
||||
StartingNone
|
||||
Resetting
|
||||
DeletingHost
|
||||
Copying
|
||||
Connectivity
|
||||
Internet
|
||||
Mounting
|
||||
Celebrate
|
||||
ContainerRuntime
|
||||
Docker
|
||||
Crio
|
||||
Containerd
|
||||
Permissions
|
||||
Enabling
|
||||
Shutdown
|
||||
Pulling
|
||||
Verifying
|
||||
VerifyingNoLine
|
||||
Kubectl
|
||||
Meh
|
||||
Embarrassed
|
||||
Tip
|
||||
Unmount
|
||||
MountOptions
|
||||
Fileserver
|
||||
)
|
||||
|
||||
func (style StyleEnum) String() string {
|
||||
var s = []string{"Happy",
|
||||
"SuccessType",
|
||||
"FailureType",
|
||||
"Conflict",
|
||||
"FatalType",
|
||||
"Notice",
|
||||
"Ready",
|
||||
"Running",
|
||||
"Provisioning",
|
||||
"Restarting",
|
||||
"Reconfiguring",
|
||||
"Stopping",
|
||||
"Stopped",
|
||||
"WarningType",
|
||||
"Waiting",
|
||||
"WaitingPods",
|
||||
"Usage",
|
||||
"Launch",
|
||||
"Sad",
|
||||
"ThumbsUp",
|
||||
"Option",
|
||||
"Command",
|
||||
"LogEntry",
|
||||
"Crushed",
|
||||
"Url",
|
||||
"Documentation",
|
||||
"Issues",
|
||||
"Issue",
|
||||
"Check",
|
||||
"IsoDownload",
|
||||
"FileDownload",
|
||||
"Caching",
|
||||
"StartingVm",
|
||||
"StartingNone",
|
||||
"Resetting",
|
||||
"DeletingHost",
|
||||
"Copying",
|
||||
"Connectivity",
|
||||
"Internet",
|
||||
"Mounting",
|
||||
"Celebrate",
|
||||
"ContainerRuntime",
|
||||
"Docker",
|
||||
"Crio",
|
||||
"Containerd",
|
||||
"Permissions",
|
||||
"Enabling",
|
||||
"Shutdown",
|
||||
"Pulling",
|
||||
"Verifying",
|
||||
"VerifyingNoLine",
|
||||
"Kubectl",
|
||||
"Meh",
|
||||
"Embarrassed",
|
||||
"Tip",
|
||||
"Unmount",
|
||||
"MountOptions",
|
||||
"Fileserver"}
|
||||
|
||||
if style > Fileserver{
|
||||
return "Unknown"
|
||||
}
|
||||
|
||||
return s[style]
|
||||
}
|
|
@ -21,6 +21,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/minikube/pkg/minikube/console"
|
||||
)
|
||||
|
||||
// Containerd contains containerd runtime state
|
||||
|
@ -34,6 +35,10 @@ func (r *Containerd) Name() string {
|
|||
return "containerd"
|
||||
}
|
||||
|
||||
func (r *Containerd) Style() console.StyleEnum {
|
||||
return console.Containerd
|
||||
}
|
||||
|
||||
// Version retrieves the current version of this runtime
|
||||
func (r *Containerd) Version() (string, error) {
|
||||
ver, err := r.Runner.CombinedOutput("containerd --version")
|
||||
|
|
|
@ -21,6 +21,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/minikube/pkg/minikube/console"
|
||||
)
|
||||
|
||||
// CRIO contains CRIO runtime state
|
||||
|
@ -34,6 +35,11 @@ func (r *CRIO) Name() string {
|
|||
return "CRI-O"
|
||||
}
|
||||
|
||||
// Name is a human readable name for CRIO
|
||||
func (r *CRIO) Style() console.StyleEnum {
|
||||
return console.Crio
|
||||
}
|
||||
|
||||
// Version retrieves the current version of this runtime
|
||||
func (r *CRIO) Version() (string, error) {
|
||||
ver, err := r.Runner.CombinedOutput("crio --version")
|
||||
|
|
|
@ -22,6 +22,7 @@ import (
|
|||
|
||||
"github.com/golang/glog"
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/minikube/pkg/minikube/console"
|
||||
)
|
||||
|
||||
// CommandRunner is the subset of bootstrapper.CommandRunner this package consumes
|
||||
|
@ -44,6 +45,8 @@ type Manager interface {
|
|||
Active() bool
|
||||
// Available returns an error if it is not possible to use this runtime on a host
|
||||
Available() error
|
||||
// Style is an associated StyleEnum for Name()
|
||||
Style() console.StyleEnum
|
||||
|
||||
// KubeletOptions returns kubelet options for a runtime.
|
||||
KubeletOptions() map[string]string
|
||||
|
|
|
@ -47,7 +47,7 @@ func TestName(t *testing.T) {
|
|||
if got != tc.want {
|
||||
t.Errorf("Name(%s) = %q, want: %q", tc.runtime, got, tc.want)
|
||||
}
|
||||
if !console.HasStyle(got) {
|
||||
if !console.HasStyle(r.Style()) {
|
||||
t.Fatalf("console.HasStyle(%s): %v", got, false)
|
||||
}
|
||||
})
|
||||
|
|
|
@ -22,6 +22,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/minikube/pkg/minikube/console"
|
||||
)
|
||||
|
||||
// Docker contains Docker runtime state
|
||||
|
@ -35,6 +36,11 @@ func (r *Docker) Name() string {
|
|||
return "Docker"
|
||||
}
|
||||
|
||||
// Name is a human readable name for Docker
|
||||
func (r *Docker) Style() console.StyleEnum {
|
||||
return console.Docker
|
||||
}
|
||||
|
||||
// Version retrieves the current version of this runtime
|
||||
func (r *Docker) Version() (string, error) {
|
||||
// Note: the server daemon has to be running, for this call to return successfully
|
||||
|
|
|
@ -46,7 +46,7 @@ const (
|
|||
|
||||
// Usage outputs a usage error and exits with error code 64
|
||||
func Usage(format string, a ...interface{}) {
|
||||
console.ErrStyle("usage", format, a...)
|
||||
console.ErrStyle(console.Usage, format, a...)
|
||||
os.Exit(BadUsage)
|
||||
}
|
||||
|
||||
|
@ -74,8 +74,8 @@ func WithProblem(msg string, p *problem.Problem) {
|
|||
console.Fatal(msg)
|
||||
p.Display()
|
||||
console.Err("\n")
|
||||
console.ErrStyle("sad", "If the above advice does not help, please let us know: ")
|
||||
console.ErrStyle("url", "https://github.com/kubernetes/minikube/issues/new")
|
||||
console.ErrStyle(console.Sad, "If the above advice does not help, please let us know: ")
|
||||
console.ErrStyle(console.Url, "https://github.com/kubernetes/minikube/issues/new")
|
||||
os.Exit(Config)
|
||||
}
|
||||
|
||||
|
@ -84,12 +84,12 @@ func WithLogEntries(msg string, err error, entries map[string][]string) {
|
|||
displayError(msg, err)
|
||||
|
||||
for name, lines := range entries {
|
||||
console.OutStyle("failure", "Problems detected in %q:", name)
|
||||
console.OutStyle(console.FailureType, "Problems detected in %q:", name)
|
||||
if len(lines) > MaxLogEntries {
|
||||
lines = lines[:MaxLogEntries]
|
||||
}
|
||||
for _, l := range lines {
|
||||
console.OutStyle("log-entry", l)
|
||||
console.OutStyle(console.LogEntry, l)
|
||||
}
|
||||
}
|
||||
os.Exit(Software)
|
||||
|
@ -101,6 +101,6 @@ func displayError(msg string, err error) {
|
|||
console.Err("\n")
|
||||
console.Fatal(msg+": %v", err)
|
||||
console.Err("\n")
|
||||
console.ErrStyle("sad", "Sorry that minikube crashed. If this was unexpected, we would love to hear from you:")
|
||||
console.ErrStyle("url", "https://github.com/kubernetes/minikube/issues/new")
|
||||
console.ErrStyle(console.Sad, "Sorry that minikube crashed. If this was unexpected, we would love to hear from you:")
|
||||
console.ErrStyle(console.Url, "https://github.com/kubernetes/minikube/issues/new")
|
||||
}
|
||||
|
|
|
@ -99,12 +99,12 @@ func FindProblems(r cruntime.Manager, bs bootstrapper.Bootstrapper, runner boots
|
|||
// OutputProblems outputs discovered problems.
|
||||
func OutputProblems(problems map[string][]string, maxLines int) {
|
||||
for name, lines := range problems {
|
||||
console.OutStyle("failure", "Problems detected in %q:", name)
|
||||
console.OutStyle(console.FailureType, "Problems detected in %q:", name)
|
||||
if len(lines) > maxLines {
|
||||
lines = lines[len(lines)-maxLines:]
|
||||
}
|
||||
for _, l := range lines {
|
||||
console.OutStyle("log-entry", l)
|
||||
console.OutStyle(console.LogEntry, l)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ func CacheBinary(binary, version, osName, archName string) (string, error) {
|
|||
options.Checksum = constants.GetKubernetesReleaseURLSHA1(binary, version, osName, archName)
|
||||
options.ChecksumHash = crypto.SHA1
|
||||
|
||||
console.OutStyle("file-download", "Downloading %s %s", binary, version)
|
||||
console.OutStyle(console.FileDownload, "Downloading %s %s", binary, version)
|
||||
if err := download.ToFile(url, targetFilepath, options); err != nil {
|
||||
return "", errors.Wrapf(err, "Error downloading %s %s", binary, version)
|
||||
}
|
||||
|
|
|
@ -51,21 +51,21 @@ type match struct {
|
|||
|
||||
// Display problem metadata to the console
|
||||
func (p *Problem) Display() {
|
||||
console.ErrStyle("failure", "Error: [%s] %v", p.ID, p.Err)
|
||||
console.ErrStyle("tip", "Advice: %s", p.Advice)
|
||||
console.ErrStyle(console.FailureType, "Error: [%s] %v", p.ID, p.Err)
|
||||
console.ErrStyle(console.Tip, "Advice: %s", p.Advice)
|
||||
if p.URL != "" {
|
||||
console.ErrStyle("documentation", "Documentation: %s", p.URL)
|
||||
console.ErrStyle(console.Documentation, "Documentation: %s", p.URL)
|
||||
}
|
||||
if len(p.Issues) == 0 {
|
||||
return
|
||||
}
|
||||
console.ErrStyle("issues", "Related issues:")
|
||||
console.ErrStyle(console.Issues, "Related issues:")
|
||||
issues := p.Issues
|
||||
if len(issues) > 3 {
|
||||
issues = issues[0:3]
|
||||
}
|
||||
for _, i := range issues {
|
||||
console.ErrStyle("issue", "%s/%d", issueBase, i)
|
||||
console.ErrStyle(console.Issue, "%s/%d", issueBase, i)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -259,7 +259,7 @@ func WaitAndMaybeOpenService(api libmachine.API, namespace string, service strin
|
|||
if urlMode || !isHTTPSchemedURL {
|
||||
console.OutLn(urlString)
|
||||
} else {
|
||||
console.OutStyle("celebrate", "Opening kubernetes service %s/%s in default browser...", namespace, service)
|
||||
console.OutStyle(console.Celebrate, "Opening kubernetes service %s/%s in default browser...", namespace, service)
|
||||
if err := browser.OpenURL(urlString); err != nil {
|
||||
console.Err("browser failed to open url: %v", err)
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ func (f DefaultDownloader) CacheMinikubeISOFromURL(isoURL string) error {
|
|||
options.ChecksumHash = crypto.SHA256
|
||||
}
|
||||
|
||||
console.OutStyle("iso-download", "Downloading Minikube ISO ...")
|
||||
console.OutStyle(console.IsoDownload, "Downloading Minikube ISO ...")
|
||||
if err := download.ToFile(isoURL, f.GetISOCacheFilepath(isoURL), options); err != nil {
|
||||
return errors.Wrap(err, isoURL)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue