Skip to content

Commit 2c21a41

Browse files
feat: only print "running preflights" if preflights exist (#386)
* feat: only print "running preflights" if preflights exist only print "running preflights" if preflights exist. * feat: rename progressbar to spinner it is neither a bar neither indicates progress.
1 parent bcc99e2 commit 2c21a41

File tree

7 files changed

+17
-21
lines changed

7 files changed

+17
-21
lines changed

cmd/embedded-cluster/install.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ import (
2121
"github.com/replicatedhq/embedded-cluster/pkg/helpers"
2222
"github.com/replicatedhq/embedded-cluster/pkg/metrics"
2323
"github.com/replicatedhq/embedded-cluster/pkg/preflights"
24-
"github.com/replicatedhq/embedded-cluster/pkg/progressbar"
2524
"github.com/replicatedhq/embedded-cluster/pkg/prompts"
2625
"github.com/replicatedhq/embedded-cluster/pkg/release"
26+
"github.com/replicatedhq/embedded-cluster/pkg/spinner"
2727
)
2828

2929
// ErrNothingElseToAdd is an error returned when there is nothing else to add to the
@@ -70,17 +70,15 @@ func runPostInstall() error {
7070
// on all configured hosts. We attempt to read HostPreflights from all the
7171
// embedded Helm Charts and from the Kots Application Release files.
7272
func runHostPreflights(c *cli.Context) error {
73-
pb := progressbar.Start()
74-
pb.Infof("Running host preflights on node")
7573
hpf, err := addons.NewApplier().HostPreflights()
7674
if err != nil {
77-
pb.CloseWithError()
7875
return fmt.Errorf("unable to read host preflights: %w", err)
7976
}
8077
if len(hpf.Collectors) == 0 && len(hpf.Analyzers) == 0 {
81-
pb.Close()
8278
return nil
8379
}
80+
pb := spinner.Start()
81+
pb.Infof("Running host preflights on node")
8482
output, err := preflights.Run(c.Context, hpf)
8583
if err != nil {
8684
pb.CloseWithError()
@@ -213,9 +211,9 @@ func installK0s(c *cli.Context) error {
213211
// waitForK0s waits for the k0s API to be available. We wait for the k0s socket to
214212
// appear in the system and until the k0s status command to finish.
215213
func waitForK0s(ctx context.Context) error {
216-
pb := progressbar.Start()
217-
defer pb.Close()
218-
pb.Infof("Waiting for %s node to be ready", defaults.BinaryName())
214+
loading := spinner.Start()
215+
defer loading.Close()
216+
loading.Infof("Waiting for %s node to be ready", defaults.BinaryName())
219217
var success bool
220218
for i := 0; i < 30; i++ {
221219
time.Sleep(2 * time.Second)
@@ -232,7 +230,7 @@ func waitForK0s(ctx context.Context) error {
232230
if _, err := runCommand(defaults.K0sBinaryPath(), "status"); err != nil {
233231
return fmt.Errorf("unable to get status: %w", err)
234232
}
235-
pb.Infof("Node installation finished")
233+
loading.Infof("Node installation finished")
236234
return nil
237235
}
238236

pkg/addons/adminconsole/adminconsole.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ import (
2020
"github.com/replicatedhq/embedded-cluster/pkg/defaults"
2121
"github.com/replicatedhq/embedded-cluster/pkg/kubeutils"
2222
"github.com/replicatedhq/embedded-cluster/pkg/metrics"
23-
pb "github.com/replicatedhq/embedded-cluster/pkg/progressbar"
2423
"github.com/replicatedhq/embedded-cluster/pkg/prompts"
2524
"github.com/replicatedhq/embedded-cluster/pkg/release"
25+
"github.com/replicatedhq/embedded-cluster/pkg/spinner"
2626
)
2727

2828
const (
@@ -239,7 +239,7 @@ func (a *AdminConsole) GenerateHelmConfig(onlyDefaults bool) ([]v1beta1.Chart, [
239239

240240
// Outro waits for the adminconsole to be ready.
241241
func (a *AdminConsole) Outro(ctx context.Context, cli client.Client) error {
242-
loading := pb.Start()
242+
loading := spinner.Start()
243243
backoff := wait.Backoff{Steps: 60, Duration: 5 * time.Second, Factor: 1.0, Jitter: 0.1}
244244
loading.Infof("Waiting for Admin Console to deploy: 0/3 ready")
245245

pkg/addons/applier.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
"github.com/replicatedhq/embedded-cluster/pkg/addons/embeddedclusteroperator"
2020
"github.com/replicatedhq/embedded-cluster/pkg/addons/openebs"
2121
"github.com/replicatedhq/embedded-cluster/pkg/kubeutils"
22-
pb "github.com/replicatedhq/embedded-cluster/pkg/progressbar"
22+
"github.com/replicatedhq/embedded-cluster/pkg/spinner"
2323
)
2424

2525
// AddOn is the interface that all addons must implement.
@@ -169,7 +169,7 @@ func (a *Applier) Versions(additionalCharts []v1beta1.Chart) (map[string]string,
169169
// waitForKubernetes waits until we manage to make a successful connection to the
170170
// Kubernetes API server.
171171
func (a *Applier) waitForKubernetes(ctx context.Context) error {
172-
loading := pb.Start()
172+
loading := spinner.Start()
173173
defer func() {
174174
loading.Closef("Kubernetes API server is ready")
175175
}()

pkg/addons/embeddedclusteroperator/embeddedclusteroperator.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import (
1919
"github.com/replicatedhq/embedded-cluster/pkg/defaults"
2020
"github.com/replicatedhq/embedded-cluster/pkg/kubeutils"
2121
"github.com/replicatedhq/embedded-cluster/pkg/metrics"
22-
pb "github.com/replicatedhq/embedded-cluster/pkg/progressbar"
2322
"github.com/replicatedhq/embedded-cluster/pkg/release"
23+
"github.com/replicatedhq/embedded-cluster/pkg/spinner"
2424
)
2525

2626
const (
@@ -96,7 +96,7 @@ func (e *EmbeddedClusterOperator) GenerateHelmConfig(onlyDefaults bool) ([]v1bet
9696

9797
// Outro is executed after the cluster deployment.
9898
func (e *EmbeddedClusterOperator) Outro(ctx context.Context, cli client.Client) error {
99-
loading := pb.Start()
99+
loading := spinner.Start()
100100
loading.Infof("Waiting for Embedded Cluster Operator to be ready")
101101
if err := kubeutils.WaitForDeployment(ctx, cli, e.namespace, e.deployName); err != nil {
102102
loading.Close()

pkg/progressbar/options.go renamed to pkg/spinner/options.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package progressbar
1+
package spinner
22

33
// Option is a function that sets an option on a MessageWriter.
44
type Option func(*MessageWriter)

pkg/progressbar/progressbar.go renamed to pkg/spinner/spinner.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
// Package progressbar provides a simple progress bar for the CLI. This
2-
// should have been called "loadingbar" instead as there is no progress
3-
// at all.
4-
package progressbar
1+
// Package spinner provides a simple spinner for the CLI.
2+
package spinner
53

64
import (
75
"fmt"

pkg/progressbar/progressbar_test.go renamed to pkg/spinner/spinner_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package progressbar
1+
package spinner
22

33
import (
44
"bytes"

0 commit comments

Comments
 (0)