diff --git a/cmd/preflight/cli/run_nocrd.go b/cmd/preflight/cli/run_nocrd.go index eece5187e..33866db41 100644 --- a/cmd/preflight/cli/run_nocrd.go +++ b/cmd/preflight/cli/run_nocrd.go @@ -19,6 +19,7 @@ import ( collectrunner "github.com/replicatedhq/troubleshoot/pkg/collect" "github.com/replicatedhq/troubleshoot/pkg/logger" "github.com/spf13/viper" + "github.com/tj/go-spin" "gopkg.in/yaml.v2" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -69,6 +70,22 @@ func runPreflightsNoCRD(v *viper.Viper, arg string) error { return fmt.Errorf("unable to parse %s as a preflight", arg) } + s := spin.New() + finishedCh := make(chan bool, 1) + go func() { + for { + select { + case <-finishedCh: + return + case <-time.After(time.Millisecond * 100): + fmt.Printf("\r \033[36mRunning Preflight checks\033[m %s ", s.Next()) + } + } + }() + defer func() { + finishedCh <- true + }() + allCollectedData, err := runCollectors(v, preflight) if err != nil { return err @@ -104,6 +121,8 @@ func runPreflightsNoCRD(v *viper.Viper, arg string) error { analyzeResults = append(analyzeResults, analyzeResult) } + finishedCh <- true + if preflight.Spec.UploadResultsTo != "" { tryUploadResults(preflight.Spec.UploadResultsTo, preflight.Name, analyzeResults) } diff --git a/go.mod b/go.mod index e1aef6ef0..c8622ffcd 100644 --- a/go.mod +++ b/go.mod @@ -31,6 +31,7 @@ require ( github.com/spf13/cobra v0.0.3 github.com/spf13/viper v1.4.0 github.com/stretchr/testify v1.3.0 + github.com/tj/go-spin v1.1.0 github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect github.com/xo/dburl v0.0.0-20190203050942-98997a05b24f // indirect golang.org/x/net v0.0.0-20190522155817-f3200d17e092 diff --git a/go.sum b/go.sum index c2ddae485..94f9d0850 100644 --- a/go.sum +++ b/go.sum @@ -420,6 +420,8 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA= +github.com/tj/go-spin v1.1.0 h1:lhdWZsvImxvZ3q1C5OIB7d72DuOwP4O2NdBg9PyzNds= +github.com/tj/go-spin v1.1.0/go.mod h1:Mg1mzmePZm4dva8Qz60H2lHwmJ2loum4VIrLgVnKwh4= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tsenart/deadcode v0.0.0-20160724212837-210d2dc333e9/go.mod h1:q+QjxYvZ+fpjMXqs+XEriussHjSYqeXVnAdSV1tkMYk= github.com/ugorji/go v1.1.4 h1:j4s+tAvLfL3bZyefP2SEWmhBzmuIlH/eqNuPdFPgngw=