Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add spinner at preparing Kubernetes... #9855

Merged
merged 33 commits into from
Dec 11, 2020
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
df37c78
change config func call
ruben-baez-seagull-com Dec 2, 2020
2e3e0ab
add new method to print spinner
ruben-baez-seagull-com Dec 2, 2020
7a0a2b0
remove break line in spinner line
ruben-baez-seagull-com Dec 2, 2020
65dc5b8
add spinner library to mod
ruben-baez-seagull-com Dec 2, 2020
88947d6
add break line in windows case
ruben-baez-seagull-com Dec 4, 2020
ead02fd
remove unnecesary file
ruben-baez-seagull-com Dec 4, 2020
f37a4aa
remove windows break line
ruben-baez-seagull-com Dec 4, 2020
6e37ffb
change spinner module version
ruben-baez-seagull-com Dec 4, 2020
994ff36
restore break line
ruben-baez-seagull-com Dec 4, 2020
b6ee8f2
remove old versions of the spinner
ruben-baez-seagull-com Dec 4, 2020
33b6e9a
add spinner param in step func
ruben-baez-seagull-com Dec 7, 2020
f7abca6
remove comment line
ruben-baez-seagull-com Dec 7, 2020
23dc03c
fix delete unittest
ruben-baez-seagull-com Dec 7, 2020
64f4895
fix lint if statement
ruben-baez-seagull-com Dec 7, 2020
32bb174
fix lint goimports
ruben-baez-seagull-com Dec 7, 2020
7a9979b
restore go sum
ruben-baez-seagull-com Dec 7, 2020
6b89930
add older lines in go sum
ruben-baez-seagull-com Dec 8, 2020
b330cdb
Merge branch 'master' into w/add-spinner
ruben-baez-seagull-com Dec 8, 2020
a763e05
change bool to second parameter
ruben-baez-seagull-com Dec 8, 2020
e09dcaa
Merge branch 'w/add-spinner' of https://github.com/alonyb/minikube in…
ruben-baez-seagull-com Dec 8, 2020
8d11d8b
Merge branch 'master' of https://github.com/alonyb/minikube into w/ad…
ruben-baez-seagull-com Dec 9, 2020
291ea78
fix repo with upstream
ruben-baez-seagull-com Dec 9, 2020
73ea4f2
add comment and fix bool param
ruben-baez-seagull-com Dec 9, 2020
032b43c
fix lint
ruben-baez-seagull-com Dec 9, 2020
e45b42f
fix unittest
ruben-baez-seagull-com Dec 9, 2020
c24eda6
change false to constant
ruben-baez-seagull-com Dec 9, 2020
42aac91
remove bool var from String func
ruben-baez-seagull-com Dec 9, 2020
e7ca292
change more false by constant
ruben-baez-seagull-com Dec 9, 2020
f729145
fix lint
ruben-baez-seagull-com Dec 9, 2020
277e096
remove param && add spin bool to style enum
ruben-baez-seagull-com Dec 10, 2020
d474058
restore unittest
ruben-baez-seagull-com Dec 10, 2020
8ee8989
move spinner character const to style
ruben-baez-seagull-com Dec 10, 2020
2d80cfc
fix lint
ruben-baez-seagull-com Dec 10, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
github.com/VividCortex/godaemon v0.0.0-20201030160542-15e3f4925a21
github.com/blang/semver v3.5.0+incompatible
github.com/briandowns/spinner v1.11.1
github.com/c4milo/gotoolkit v0.0.0-20170318115440-bcc06269efa9 // indirect
github.com/cenkalti/backoff v2.2.1+incompatible
github.com/cenkalti/backoff/v4 v4.1.0
Expand Down Expand Up @@ -75,7 +76,6 @@ require (
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v0.0.0-20180618132009-1d523034197f
github.com/zchee/go-vmnet v0.0.0-20161021174912-97ebf9174097
go.opencensus.io v0.22.4
go.opentelemetry.io/otel v0.13.0
go.opentelemetry.io/otel/sdk v0.13.0
golang.org/x/build v0.0.0-20190927031335-2835ba2e683f
Expand Down Expand Up @@ -103,6 +103,7 @@ require (

replace (
git.apache.org/thrift.git => github.com/apache/thrift v0.0.0-20180902110319-2566ecd5d999
github.com/briandowns/spinner => github.com/alonyb/spinner v1.12.1
github.com/docker/docker => github.com/docker/docker v1.4.2-0.20190924003213-a8608b5b67c7
github.com/docker/machine => github.com/machine-drivers/machine v0.7.1-0.20200810185219-7d42fed1b770
github.com/google/go-containerregistry => github.com/afbjorklund/go-containerregistry v0.0.0-20200902152226-fbad78ec2813
Expand Down
9 changes: 7 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ github.com/Djarvur/go-err113 v0.0.0-20200410182137-af658d038157/go.mod h1:4UJr5H
github.com/Djarvur/go-err113 v0.1.0/go.mod h1:4UJr5HIiMZrwgkSPdsjy2uOQExX/WEILpIrO9UPGuXs=
github.com/GoogleCloudPlatform/cloudsql-proxy v0.0.0-20191009163259-e802c2cb94ae/go.mod h1:mjwGPas4yKduTyubHvD1Atl9r1rUq8DfVy+gkVvZ+oo=
github.com/GoogleCloudPlatform/k8s-cloud-provider v0.0.0-20190822182118-27a4ced34534/go.mod h1:iroGtC8B3tQiqtds1l+mgk/BBOrxbqjH+eUfFQYRc14=
github.com/GoogleCloudPlatform/opentelemetry-operations-go v0.13.0 h1:Gx9IxOjR9ug5Ad8YbafxJ6N2g6oDj/Q419tYHdd1od4=
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace v0.13.0 h1:fjKUtfldCPIF4nIzAAj3LzP8Lrd3DuRIMiFdOsj4fLc=
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/trace v0.13.0/go.mod h1:q/paYxLXKVhwfC3lzLfhtL54fAx14wzMN9DundQOBMc=
github.com/JeffAshton/win_pdh v0.0.0-20161109143554-76bb4ee9f0ab/go.mod h1:3VYc5hodBMJ5+l/7J4xAyMeuM2PNuepvHlGs8yilUCA=
Expand Down Expand Up @@ -143,6 +142,8 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZq
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
github.com/alonyb/spinner v1.12.1 h1:zB6IQ29/kTR/NWHJhIgU2tXW+fhXa3K5zrDQMddd9H0=
github.com/alonyb/spinner v1.12.1/go.mod h1:QOuQk7x+EaDASo80FEXwlwiA+j/PPIcX3FScO+3/ZPQ=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
github.com/apex/log v1.1.4/go.mod h1:AlpoD9aScyQfJDVHmLMEcx4oU6LqzkWp4Mg9GdAcEvQ=
Expand Down Expand Up @@ -555,6 +556,7 @@ github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPg
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/martian v2.1.1-0.20190517191504-25dcb96d9e51+incompatible h1:xmapqc1AyLoB+ddYT6r04bD9lIjlOqGaREovi0SzFaE=
github.com/google/martian v2.1.1-0.20190517191504-25dcb96d9e51+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/martian/v3 v3.0.0 h1:pMen7vLs8nvgEYhywH3KDWJIJTeEr2ULsVWHWYHQyBs=
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f h1:Jnx61latede7zDD3DiiP4gmNz33uK0U5HDUaF0a/HVQ=
Expand Down Expand Up @@ -585,6 +587,7 @@ github.com/googleapis/gnostic v0.1.0/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTV
github.com/googleapis/gnostic v0.2.2/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY=
github.com/googleapis/gnostic v0.3.0 h1:CcQijm0XKekKjP/YCz28LXVSpgguuB+nCxaSjCe09y0=
github.com/googleapis/gnostic v0.3.0/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY=
github.com/googleinterns/cloud-operations-api-mock v0.0.0-20200709193332-a1e58c29bdd3 h1:eHv/jVY/JNop1xg2J9cBb4EzyMpWZoNCP1BslSAIkOI=
github.com/googleinterns/cloud-operations-api-mock v0.0.0-20200709193332-a1e58c29bdd3/go.mod h1:h/KNeRx7oYU4SpA4SoY7W2/NxDKEEVuwA6j9A27L4OI=
github.com/gookit/color v1.2.4/go.mod h1:AhIE+pS6D4Ql0SQWbBeXPHw7gY0/sjHoA4s/n1KB7xg=
github.com/gophercloud/gophercloud v0.1.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEoIEcSTewFxm1c5g8=
Expand Down Expand Up @@ -1105,6 +1108,7 @@ github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJy
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
Expand Down Expand Up @@ -1190,7 +1194,6 @@ go.opencensus.io v0.22.3 h1:8sGtKOrtQqkN1bp2AtX+misvLIlOmsEsNd+9NIcPEm8=
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.4 h1:LYy1Hy3MJdrCdMwwzxA/dRok4ejH+RwNGbuoD9fCjto=
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opentelemetry.io v0.1.0 h1:EANZoRCOP+A3faIlw/iN6YEWoYb1vleZRKm1EvH8T48=
go.opentelemetry.io/otel v0.13.0 h1:2isEnyzjjJZq6r2EKMsFj4TxiQiexsM04AVhwbR/oBA=
go.opentelemetry.io/otel v0.13.0/go.mod h1:dlSNewoRYikTkotEnxdmuBHgzT+k/idJSfDv/FxEnOY=
go.opentelemetry.io/otel/sdk v0.13.0 h1:4VCfpKamZ8GtnepXxMRurSpHpMKkcxhtO33z1S4rGDQ=
Expand Down Expand Up @@ -1503,6 +1506,7 @@ golang.org/x/tools v0.0.0-20200527183253-8e7acdbce89d h1:SR+e35rACZFBohNb4Om1ibX
golang.org/x/tools v0.0.0-20200527183253-8e7acdbce89d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200701151220-7cb253f4c4f8/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200713011307-fd294ab11aed h1:+qzWo37K31KxduIYaBeMqJ8MUOyTayOQKpH9aDPLMSY=
golang.org/x/tools v0.0.0-20200713011307-fd294ab11aed/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA=
Expand Down Expand Up @@ -1661,6 +1665,7 @@ gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools v2.1.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
Expand Down
13 changes: 6 additions & 7 deletions pkg/minikube/node/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ package node

import (
"fmt"
"os"
"os/exec"
"path/filepath"
"strconv"
"sync"

"github.com/spf13/viper"
"k8s.io/klog/v2"
"k8s.io/minikube/pkg/minikube/config"
Expand All @@ -36,12 +30,17 @@ import (
"k8s.io/minikube/pkg/minikube/reason"
"k8s.io/minikube/pkg/minikube/style"
"k8s.io/minikube/pkg/util/lock"
"os"
"os/exec"
"path/filepath"
"strconv"
"sync"
)

func showVersionInfo(k8sVersion string, cr cruntime.Manager) {
version, _ := cr.Version()
register.Reg.SetStep(register.PreparingKubernetes)
out.Step(cr.Style(), "Preparing Kubernetes {{.k8sVersion}} on {{.runtime}} {{.runtimeVersion}} ...", out.V{"k8sVersion": k8sVersion, "runtime": cr.Name(), "runtimeVersion": version})
out.SpinnerStep(cr.Style(), "Preparing Kubernetes {{.k8sVersion}} on {{.runtime}} {{.runtimeVersion}} ...", out.V{"k8sVersion": k8sVersion, "runtime": cr.Name(), "runtimeVersion": version})
for _, v := range config.DockerOpt {
out.Infof("opt {{.docker_option}}", out.V{"docker_option": v})
}
Expand Down
43 changes: 41 additions & 2 deletions pkg/minikube/out/out.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ package out
import (
"bytes"
"fmt"
"github.com/briandowns/spinner"
isatty "github.com/mattn/go-isatty"
"html"
"html/template"
"io"
"os"
"strconv"
"strings"

isatty "github.com/mattn/go-isatty"
"time"

"k8s.io/klog/v2"
"k8s.io/minikube/pkg/minikube/out/register"
Expand Down Expand Up @@ -58,6 +59,8 @@ var (
OverrideEnv = "MINIKUBE_IN_STYLE"
// JSON is whether or not we should output stdout in JSON format. Set using SetJSON()
JSON = false
// spin is spinner showed at starting minikube
spin = spinner.New(spinner.CharSets[9], 100*time.Millisecond)
)

// MaxLogEntries controls the number of log entries to show for each source
Expand Down Expand Up @@ -87,6 +90,21 @@ func Step(st style.Enum, format string, a ...V) {
String(outStyled)
}

// Step writes a stylized and templated message to stdout
func SpinnerStep(st style.Enum, format string, a ...V) {
alonyb marked this conversation as resolved.
Show resolved Hide resolved
if st == style.Option {
Infof(format, a...)
return
}
outStyled := spinnerStylized(st, useColor, format, a...)
if JSON {
register.PrintStep(outStyled)
return
}
register.RecordStep(outStyled)
SpinnerString(outStyled)
}

// Infof is used for informational logs (options, env variables, etc)
func Infof(format string, a ...V) {
outStyled := stylized(style.Option, useColor, format, a...)
Expand All @@ -108,11 +126,32 @@ func String(format string, a ...interface{}) {
}

klog.Infof(format, a...)
if spin.Active() == true {
alonyb marked this conversation as resolved.
Show resolved Hide resolved
spin.Stop()
}
_, err := fmt.Fprintf(outFile, format, a...)
if err != nil {
klog.Errorf("Fprintf failed: %v", err)
}
}

// SpinnerString writes a basic formatted string and spinner to stdout
func SpinnerString(format string, a ...interface{}) {
alonyb marked this conversation as resolved.
Show resolved Hide resolved
// Flush log buffer so that output order makes sense
klog.Flush()

if outFile == nil {
klog.Warningf("[unset outFile]: %s", fmt.Sprintf(format, a...))
return
}

klog.Infof(format, a...)
_, err := fmt.Fprintf(outFile, format, a...)
if err != nil {
klog.Errorf("Fprintf failed: %v", err)
}
spin.Start()

}

// Ln writes a basic formatted string with a newline to stdout
Expand Down
15 changes: 12 additions & 3 deletions pkg/minikube/out/out_style.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ func applyPrefix(prefix, format string) string {
}

// applyStyle translates the given string if necessary then adds any appropriate style prefix.
func applyStyle(st style.Enum, useColor bool, format string) string {
func applyStyle(st style.Enum, useColor bool, format string, spinner bool) string {
format = translate.T(format)

s, ok := style.Config[st]
if !s.OmitNewline {
if !s.OmitNewline && !spinner {
format += "\n"
}

Expand All @@ -55,6 +55,15 @@ func stylized(st style.Enum, useColor bool, format string, a ...V) string {
if a == nil {
a = []V{{}}
}
format = applyStyle(st, useColor, format)
format = applyStyle(st, useColor, format, false)
return Fmt(format, a...)
}

// spinnerStylized applies formatting to the provided template
func spinnerStylized(st style.Enum, useColor bool, format string, a ...V) string {
if a == nil {
a = []V{{}}
}
format = applyStyle(st, useColor, format, true)
return Fmt(format, a...)
}