change more false by constant

pull/9855/head
alonyb 2020-12-09 18:31:21 -05:00
parent 42aac91acd
commit e7ca2921fa
12 changed files with 38 additions and 38 deletions

View File

@ -198,7 +198,7 @@ func purgeMinikubeDirectory() {
if err := os.RemoveAll(localpath.MiniPath()); err != nil {
exit.Error(reason.HostPurge, "unable to delete minikube config folder", err)
}
out.Step(style.Deleted, false, "Successfully purged minikube directory located at - [{{.minikubeDirectory}}]", out.V{"minikubeDirectory": localpath.MiniPath()})
out.Step(style.Deleted, out.NoSpinner, "Successfully purged minikube directory located at - [{{.minikubeDirectory}}]", out.V{"minikubeDirectory": localpath.MiniPath()})
}
// DeleteProfiles deletes one or more profiles
@ -246,7 +246,7 @@ func deletePossibleKicLeftOver(cname string, driverName string) {
cs, err := oci.ListContainersByLabel(bin, delLabel)
if err == nil && len(cs) > 0 {
for _, c := range cs {
out.Step(style.DeletingHost, false, `Deleting container "{{.name}}" ...`, out.V{"name": cname})
out.Step(style.DeletingHost, out.NoSpinner, `Deleting container "{{.name}}" ...`, out.V{"name": cname})
err := oci.DeleteContainer(bin, c)
if err != nil { // it will error if there is no container to delete
klog.Errorf("error deleting container %q. You may want to delete it manually :\n%v", cname, err)
@ -286,7 +286,7 @@ func deleteProfile(profile *config.Profile) error {
// if driver is oci driver, delete containers and volumes
if driver.IsKIC(profile.Config.Driver) {
out.Step(style.DeletingHost, false, `Deleting "{{.profile_name}}" in {{.driver_name}} ...`, out.V{"profile_name": profile.Name, "driver_name": profile.Config.Driver})
out.Step(style.DeletingHost, out.NoSpinner, `Deleting "{{.profile_name}}" in {{.driver_name}} ...`, out.V{"profile_name": profile.Name, "driver_name": profile.Config.Driver})
for _, n := range profile.Config.Nodes {
machineName := driver.MachineName(*profile.Config, n)
deletePossibleKicLeftOver(machineName, profile.Config.Driver)
@ -337,7 +337,7 @@ func deleteProfile(profile *config.Profile) error {
if err := deleteContext(profile.Name); err != nil {
return err
}
out.Step(style.Deleted, false, `Removed all traces of the "{{.name}}" cluster.`, out.V{"name": profile.Name})
out.Step(style.Deleted, out.NoSpinner, `Removed all traces of the "{{.name}}" cluster.`, out.V{"name": profile.Name})
return nil
}
@ -353,7 +353,7 @@ func deleteHosts(api libmachine.API, cc *config.ClusterConfig) {
klog.Infof("Host %s does not exist. Proceeding ahead with cleanup.", machineName)
default:
out.FailureT("Failed to delete cluster: {{.error}}", out.V{"error": err})
out.Step(style.Notice, false, `You may need to manually remove the "{{.name}}" VM from your hypervisor`, out.V{"name": machineName})
out.Step(style.Notice, out.NoSpinner, `You may need to manually remove the "{{.name}}" VM from your hypervisor`, out.V{"name": machineName})
}
}
}
@ -384,7 +384,7 @@ func deleteContext(machineName string) error {
}
func deleteInvalidProfile(profile *config.Profile) []error {
out.Step(style.DeletingHost, false, "Trying to delete invalid profile {{.profile}}", out.V{"profile": profile.Name})
out.Step(style.DeletingHost, out.NoSpinner, "Trying to delete invalid profile {{.profile}}", out.V{"profile": profile.Name})
var errs []error
pathToProfile := config.ProfileFolderPath(profile.Name, localpath.MiniPath())
@ -410,7 +410,7 @@ func profileDeletionErr(cname string, additionalInfo string) error {
}
func uninstallKubernetes(api libmachine.API, cc config.ClusterConfig, n config.Node, bsName string) error {
out.Step(style.Resetting, false, "Uninstalling Kubernetes {{.kubernetes_version}} using {{.bootstrapper_name}} ...", out.V{"kubernetes_version": cc.KubernetesConfig.KubernetesVersion, "bootstrapper_name": bsName})
out.Step(style.Resetting, out.NoSpinner, "Uninstalling Kubernetes {{.kubernetes_version}} using {{.bootstrapper_name}} ...", out.V{"kubernetes_version": cc.KubernetesConfig.KubernetesVersion, "bootstrapper_name": bsName})
host, err := machine.LoadHost(api, driver.MachineName(cc, n))
if err != nil {
return DeletionError{Err: fmt.Errorf("unable to load host: %v", err), Errtype: MissingCluster}
@ -488,7 +488,7 @@ func handleMultipleDeletionErrors(errors []error) {
func deleteProfileDirectory(profile string) {
machineDir := filepath.Join(localpath.MiniPath(), "machines", profile)
if _, err := os.Stat(machineDir); err == nil {
out.Step(style.DeletingHost, false, `Removing {{.directory}} ...`, out.V{"directory": machineDir})
out.Step(style.DeletingHost, out.NoSpinner, `Removing {{.directory}} ...`, out.V{"directory": machineDir})
err := os.RemoveAll(machineDir)
if err != nil {
exit.Error(reason.GuestProfileDeletion, "Unable to remove machine directory", err)

View File

@ -170,7 +170,7 @@ var mountCmd = &cobra.Command{
go func() {
out.Step(style.Fileserver, out.NoSpinner, "Userspace file server: ")
ufs.StartServer(net.JoinHostPort(bindIP, strconv.Itoa(port)), debugVal, hostPath)
out.Step(style.Stopped, false, "Userspace file server is shutdown")
out.Step(style.Stopped, out.NoSpinner, "Userspace file server is shutdown")
wg.Done()
}()
}

View File

@ -50,7 +50,7 @@ var nodeDeleteCmd = &cobra.Command{
deletePossibleKicLeftOver(machineName, co.Config.Driver)
}
out.Step(style.Deleted, false, "Node {{.name}} was successfully deleted.", out.V{"name": name})
out.Step(style.Deleted, out.NoSpinner, "Node {{.name}} was successfully deleted.", out.V{"name": name})
},
}

View File

@ -702,7 +702,7 @@ func validateDriver(ds registry.DriverState, existing *config.ClusterConfig) {
klog.Infof("status for %s: %+v", name, st)
if st.NeedsImprovement {
out.Step(style.Improvement, false, `For improved {{.driver}} performance, {{.fix}}`, out.V{"driver": driver.FullName(ds.Name), "fix": translate.T(st.Fix)})
out.Step(style.Improvement, out.NoSpinner, `For improved {{.driver}} performance, {{.fix}}`, out.V{"driver": driver.FullName(ds.Name), "fix": translate.T(st.Fix)})
}
if st.Error == nil {
@ -967,7 +967,7 @@ func validateCPUCount(drvName string) {
si, err := oci.CachedDaemonInfo(drvName)
if err != nil {
out.Step(style.Confused, false, "Failed to verify '{{.driver_name}} info' will try again ...", out.V{"driver_name": drvName})
out.Step(style.Confused, out.NoSpinner, "Failed to verify '{{.driver_name}} info' will try again ...", out.V{"driver_name": drvName})
si, err = oci.DaemonInfo(drvName)
if err != nil {
exit.Message(reason.Usage, "Ensure your {{.driver_name}} is running and is healthy.", out.V{"driver_name": driver.FullName(drvName)})
@ -1219,7 +1219,7 @@ func validateKubernetesVersion(old *config.ClusterConfig) {
}
if defaultVersion.GT(nvs) {
out.Step(style.New, false, "Kubernetes {{.new}} is now available. If you would like to upgrade, specify: --kubernetes-version={{.prefix}}{{.new}}", out.V{"prefix": version.VersionPrefix, "new": defaultVersion})
out.Step(style.New, out.NoSpinner, "Kubernetes {{.new}} is now available. If you would like to upgrade, specify: --kubernetes-version={{.prefix}}{{.new}}", out.V{"prefix": version.VersionPrefix, "new": defaultVersion})
}
}

View File

@ -278,7 +278,7 @@ func generateClusterConfig(cmd *cobra.Command, existing *config.ClusterConfig, k
}
if cmd.Flags().Changed(imageRepository) || cmd.Flags().Changed(imageMirrorCountry) {
out.Step(style.Success, false, "Using image repository {{.name}}", out.V{"name": repository})
out.Step(style.Success, out.NoSpinner, "Using image repository {{.name}}", out.V{"name": repository})
}
// Backwards compatibility with --enable-default-cni

View File

@ -195,8 +195,8 @@ https://github.com/kubernetes/minikube/issues/7332`, out.V{"driver_name": cc.Dri
if err != nil {
return errors.Wrap(err, "registry port")
}
out.Step(style.Tip, false, `Registry addon on with {{.driver}} uses {{.port}} please use that instead of default 5000`, out.V{"driver": cc.Driver, "port": port})
out.Step(style.Documentation, false, `For more information see: https://minikube.sigs.k8s.io/docs/drivers/{{.driver}}`, out.V{"driver": cc.Driver})
out.Step(style.Tip, out.NoSpinner, `Registry addon on with {{.driver}} uses {{.port}} please use that instead of default 5000`, out.V{"driver": cc.Driver, "port": port})
out.Step(style.Documentation, out.NoSpinner, `For more information see: https://minikube.sigs.k8s.io/docs/drivers/{{.driver}}`, out.V{"driver": cc.Driver})
}
}
@ -331,8 +331,8 @@ func verifyGCPAuthAddon(cc *config.ClusterConfig, name string, val string) error
err = verifyAddonStatusInternal(cc, name, val, "gcp-auth")
if enable && err == nil {
out.Step(style.Notice, false, "Your GCP credentials will now be mounted into every pod created in the {{.name}} cluster.", out.V{"name": cc.Name})
out.Step(style.Notice, false, "If you don't want your credentials mounted into a specific pod, add a label with the `gcp-auth-skip-secret` key to your pod configuration.")
out.Step(style.Notice, out.NoSpinner, "Your GCP credentials will now be mounted into every pod created in the {{.name}} cluster.", out.V{"name": cc.Name})
out.Step(style.Notice, out.NoSpinner, "If you don't want your credentials mounted into a specific pod, add a label with the `gcp-auth-skip-secret` key to your pod configuration.")
}
return err
@ -347,7 +347,7 @@ func verifyAddonStatusInternal(cc *config.ClusterConfig, name string, val string
label, ok := addonPodLabels[name]
if ok && enable {
out.Step(style.HealthCheck, false, "Verifying {{.addon_name}} addon...", out.V{"addon_name": name})
out.Step(style.HealthCheck, out.NoSpinner, "Verifying {{.addon_name}} addon...", out.V{"addon_name": name})
client, err := kapi.Client(viper.GetString(config.ProfileName))
if err != nil {
return errors.Wrapf(err, "get kube-client to validate %s addon: %v", name, err)
@ -410,7 +410,7 @@ func Start(wg *sync.WaitGroup, cc *config.ClusterConfig, toEnable map[string]boo
defer func() { // making it show after verifications (see #7613)
register.Reg.SetStep(register.EnablingAddons)
out.Step(style.AddonEnable, false, "Enabled addons: {{.addons}}", out.V{"addons": strings.Join(enabledAddons, ", ")})
out.Step(style.AddonEnable, out.NoSpinner, "Enabled addons: {{.addons}}", out.V{"addons": strings.Join(enabledAddons, ", ")})
}()
for _, a := range toEnableList {
awg.Add(1)

View File

@ -968,16 +968,16 @@ func adviseNodePressure(err error, name string, drv string) {
klog.Warning(diskErr)
out.WarningT("The node {{.name}} has ran out of disk space.", out.V{"name": name})
// generic advice for all drivers
out.Step(style.Tip, false, "Please free up disk or prune images.")
out.Step(style.Tip, out.NoSpinner, "Please free up disk or prune images.")
if driver.IsVM(drv) {
out.Step(style.Stopped, false, "Please create a cluster with bigger disk size: `minikube start --disk SIZE_MB` ")
out.Step(style.Stopped, out.NoSpinner, "Please create a cluster with bigger disk size: `minikube start --disk SIZE_MB` ")
} else if drv == oci.Docker && runtime.GOOS != "linux" {
out.Step(style.Stopped, false, "Please increse Desktop's disk size.")
out.Step(style.Stopped, out.NoSpinner, "Please increse Desktop's disk size.")
if runtime.GOOS == "darwin" {
out.Step(style.Documentation, false, "Documentation: {{.url}}", out.V{"url": "https://docs.docker.com/docker-for-mac/space/"})
out.Step(style.Documentation, out.NoSpinner, "Documentation: {{.url}}", out.V{"url": "https://docs.docker.com/docker-for-mac/space/"})
}
if runtime.GOOS == "windows" {
out.Step(style.Documentation, false, "Documentation: {{.url}}", out.V{"url": "https://docs.docker.com/docker-for-windows/"})
out.Step(style.Documentation, out.NoSpinner, "Documentation: {{.url}}", out.V{"url": "https://docs.docker.com/docker-for-windows/"})
}
}
out.ErrLn("")
@ -988,16 +988,16 @@ func adviseNodePressure(err error, name string, drv string) {
out.ErrLn("")
klog.Warning(memErr)
out.WarningT("The node {{.name}} has ran out of memory.", out.V{"name": name})
out.Step(style.Tip, false, "Check if you have unnecessary pods running by running 'kubectl get po -A")
out.Step(style.Tip, out.NoSpinner, "Check if you have unnecessary pods running by running 'kubectl get po -A")
if driver.IsVM(drv) {
out.Step(style.Stopped, false, "Consider creating a cluster with larger memory size using `minikube start --memory SIZE_MB` ")
out.Step(style.Stopped, out.NoSpinner, "Consider creating a cluster with larger memory size using `minikube start --memory SIZE_MB` ")
} else if drv == oci.Docker && runtime.GOOS != "linux" {
out.Step(style.Stopped, false, "Consider increasing Docker Desktop's memory size.")
out.Step(style.Stopped, out.NoSpinner, "Consider increasing Docker Desktop's memory size.")
if runtime.GOOS == "darwin" {
out.Step(style.Documentation, false, "Documentation: {{.url}}", out.V{"url": "https://docs.docker.com/docker-for-mac/space/"})
out.Step(style.Documentation, out.NoSpinner, "Documentation: {{.url}}", out.V{"url": "https://docs.docker.com/docker-for-mac/space/"})
}
if runtime.GOOS == "windows" {
out.Step(style.Documentation, false, "Documentation: {{.url}}", out.V{"url": "https://docs.docker.com/docker-for-windows/"})
out.Step(style.Documentation, out.NoSpinner, "Documentation: {{.url}}", out.V{"url": "https://docs.docker.com/docker-for-windows/"})
}
}
out.ErrLn("")

View File

@ -127,7 +127,7 @@ func downloadISO(isoURL string, skipChecksum bool) error {
return nil
}
out.Step(style.ISODownload, false, "Downloading VM boot image ...")
out.Step(style.ISODownload, out.NoSpinner, "Downloading VM boot image ...")
urlWithChecksum := isoURL + "?checksum=file:" + isoURL + ".sha256"
if skipChecksum {

View File

@ -138,7 +138,7 @@ func Preload(k8sVersion, containerRuntime string) error {
return nil
}
out.Step(style.FileDownload, false, "Downloading Kubernetes {{.version}} preload ...", out.V{"version": k8sVersion})
out.Step(style.FileDownload, out.NoSpinner, "Downloading Kubernetes {{.version}} preload ...", out.V{"version": k8sVersion})
url := remoteTarballURL(k8sVersion, containerRuntime)
if err := download(url, targetPath); err != nil {

View File

@ -91,7 +91,7 @@ func fixDriverPermissions(name string, path string, interactive bool) error {
example.WriteString(fmt.Sprintf(" $ %s \n", strings.Join(c.Args, " ")))
}
out.Step(style.Permissions, false, "The '{{.driver}}' driver requires elevated permissions. The following commands will be executed:\n\n{{ .example }}\n", out.V{"driver": name, "example": example.String()})
out.Step(style.Permissions, out.NoSpinner, "The '{{.driver}}' driver requires elevated permissions. The following commands will be executed:\n\n{{ .example }}\n", out.V{"driver": name, "example": example.String()})
for _, c := range cmds {
testArgs := append([]string{"-n"}, c.Args[1:]...)
test := exec.Command("sudo", testArgs...)

View File

@ -102,7 +102,7 @@ func Step(st style.Enum, spinner bool, format string, a ...V) {
// Infof is used for informational logs (options, env variables, etc)
func Infof(format string, a ...V) {
outStyled := stylized(style.Option, useColor, false, format, a...)
outStyled := stylized(style.Option, useColor, NoSpinner, format, a...)
if JSON {
register.PrintInfo(outStyled)
return
@ -193,7 +193,7 @@ func ErrLn(format string, a ...interface{}) {
// SuccessT is a shortcut for writing a templated success message to stdout
func SuccessT(format string, a ...V) {
Step(style.Success, false, format, a...)
Step(style.Success, NoSpinner, format, a...)
}
// FatalT is a shortcut for writing a templated fatal message to stderr
@ -278,12 +278,12 @@ func LogEntries(msg string, err error, entries map[string][]string) {
DisplayError(msg, err)
for name, lines := range entries {
Step(style.Failure, false, "Problems detected in {{.entry}}:", V{"entry": name})
Step(style.Failure, NoSpinner, "Problems detected in {{.entry}}:", V{"entry": name})
if len(lines) > MaxLogEntries {
lines = lines[:MaxLogEntries]
}
for _, l := range lines {
Step(style.LogEntry, false, l)
Step(style.LogEntry, NoSpinner, l)
}
}
}

View File

@ -57,7 +57,7 @@ func TestOutT(t *testing.T) {
os.Setenv(OverrideEnv, strconv.FormatBool(override))
f := tests.NewFakeFile()
SetOutFile(f)
Step(tc.style, false, tc.message, tc.params)
Step(tc.style, NoSpinner, tc.message, tc.params)
got := f.String()
want := tc.wantASCII
if override {