diff --git a/README.md b/README.md index 45bf742..17254e2 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Download the latest binary from the [releases page](https://github.com/cloudoper ```sh # macOS / Linux -curl -Lo cloudctl https://github.com/cloudoperators/cloudctl/releases/latest/download/cloudctl-$(uname -s | tr '[:upper:]' '[:lower:]')-$(uname -m) +curl -L https://github.com/cloudoperators/cloudctl/releases/latest/download/cloudctl_$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m).tar.gz | tar -xz cloudctl chmod +x cloudctl sudo mv cloudctl /usr/local/bin/ ``` diff --git a/cmd/output/interactive_printer.go b/cmd/output/interactive_printer.go index cdc3d45..b14f350 100644 --- a/cmd/output/interactive_printer.go +++ b/cmd/output/interactive_printer.go @@ -191,14 +191,45 @@ func (p *interactivePrinter) printSyncResult(r SyncResult) error { w("\n") } - // Collect only clusters that need attention. + // Collect only clusters that need attention (failed; skipped/not-ready are expected). var issues []ClusterSyncResult for _, c := range r.Clusters { - if c.Status != ClusterSyncStatusSynced { + if c.Status == ClusterSyncStatusFailed { issues = append(issues, c) } } + // Progress bar (or empty-state message). + if total == 0 { + w("%s\n", styleFaint.Render("No clusters found to sync.")) + } else { + const barWidth = 32 + filled := (r.Synced * barWidth) / total + bar := styleGreen.Render(strings.Repeat("█", filled)) + + styleFaint.Render(strings.Repeat("░", barWidth-filled)) + + var annotation string + switch { + case r.Failed > 0 && r.Skipped > 0: + annotation = fmt.Sprintf("%s %s", + styleFaint.Render(fmt.Sprintf("%d clusters skipped (not ready — run with --include-not-ready to force)", r.Skipped)), + styleRed.Render(fmt.Sprintf("%d failed", r.Failed)), + ) + case r.Failed > 0: + annotation = styleRed.Render(fmt.Sprintf("%d failed", r.Failed)) + case r.Skipped > 0: + annotation = styleFaint.Render(fmt.Sprintf("%d clusters skipped (not ready — run with --include-not-ready to force)", r.Skipped)) + default: + annotation = styleGreen.Render("All clusters synced successfully.") + } + + w(" %s %s/%d %s · %s\n\n", bar, + styleGreen.Render(fmt.Sprintf("%d", r.Synced)), total, + styleBold.Render("Synced"), + annotation, + ) + } + if len(issues) > 0 { const ( colCluster = 30 @@ -208,65 +239,21 @@ func (p *interactivePrinter) printSyncResult(r SyncResult) error { w("%s\n", styleHeader.Render(header)) for _, c := range issues { - var icon, statusStr string - switch c.Status { - case ClusterSyncStatusFailed: - icon = styleRed.Render("✗") - statusStr = styleRed.Render("failed") - default: - icon = styleYellow.Render("!") - statusStr = styleYellow.Render("skipped") - } - name := c.Name if len(name) > colCluster-2 { name = name[:colCluster-5] + "..." } reason := c.Reason if reason == "" { - if c.Status == ClusterSyncStatusSkipped { - reason = "not ready" - } else { - reason = "unknown error" - } + reason = "unknown error" } - w("%s %-*s %-*s %s\n", - icon, colCluster-1, name, colStatus, statusStr, reason, + styleRed.Render("✗"), colCluster-1, name, colStatus, styleRed.Render("failed"), reason, ) } w("\n") } - // Summary sentence. - var summary string - switch { - case total == 0: - summary = styleFaint.Render("No clusters found to sync.") - case r.Failed > 0 && r.Skipped > 0: - summary = fmt.Sprintf("%s %s %s", - styleGreen.Render(fmt.Sprintf("Synced %d of %d cluster(s).", r.Synced, total)), - styleYellow.Render(fmt.Sprintf("%d skipped,", r.Skipped)), - styleRed.Render(fmt.Sprintf("%d failed.", r.Failed)), - ) - case r.Failed > 0: - summary = fmt.Sprintf("%s %s", - styleGreen.Render(fmt.Sprintf("Synced %d of %d cluster(s).", r.Synced, total)), - styleRed.Render(fmt.Sprintf("%d failed.", r.Failed)), - ) - case r.Skipped > 0: - summary = fmt.Sprintf("%s %s", - styleGreen.Render(fmt.Sprintf("Synced %d of %d cluster(s).", r.Synced, total)), - styleYellow.Render(fmt.Sprintf("%d skipped (not ready).", r.Skipped)), - ) - default: - if total == 1 { - summary = styleGreen.Render("Synced 1 cluster successfully.") - } else { - summary = styleGreen.Render(fmt.Sprintf("Synced all %d clusters successfully.", total)) - } - } - w("%s\n", summary) return writeErr } diff --git a/cmd/output/output_test.go b/cmd/output/output_test.go index 1393bf4..8517c7b 100644 --- a/cmd/output/output_test.go +++ b/cmd/output/output_test.go @@ -141,13 +141,13 @@ func TestPlainPrinter_SyncResult(t *testing.T) { out := buf.String() // Synced clusters are not listed individually. g.Expect(out).ToNot(ContainSubstring("[+]")) - // Skipped and failed clusters appear with their reason. - g.Expect(out).To(ContainSubstring("[-] b")) + // Skipped (not ready) clusters are not listed — only failed ones appear. + g.Expect(out).ToNot(ContainSubstring("[-] b")) g.Expect(out).To(ContainSubstring("[!] c")) g.Expect(out).To(ContainSubstring("error")) // Summary is a human-readable sentence. g.Expect(out).To(ContainSubstring("Synced 1 of 3")) - g.Expect(out).To(ContainSubstring("1 skipped")) + g.Expect(out).To(ContainSubstring("1 not ready")) g.Expect(out).To(ContainSubstring("1 failed")) } diff --git a/cmd/output/plain_printer.go b/cmd/output/plain_printer.go index 16d88c4..8226051 100644 --- a/cmd/output/plain_printer.go +++ b/cmd/output/plain_printer.go @@ -38,12 +38,6 @@ func (p *plainPrinter) Print(v any) error { // List clusters that need attention first. for _, c := range t.Clusters { switch c.Status { - case ClusterSyncStatusSkipped: - reason := c.Reason - if reason == "" { - reason = "not ready" - } - w(" [-] %s — skipped (%s)\n", c.Name, reason) case ClusterSyncStatusFailed: reason := c.Reason if reason == "" { @@ -61,13 +55,13 @@ func (p *plainPrinter) Print(v any) error { // Summary sentence. switch { case t.Failed > 0 && t.Skipped > 0: - w("Synced %d of %d cluster(s). %d skipped, %d failed.\n", + w("Synced %d of %d cluster(s). %d not ready, %d failed.\n", t.Synced, total, t.Skipped, t.Failed) case t.Failed > 0: w("Synced %d of %d cluster(s). %d failed.\n", t.Synced, total, t.Failed) case t.Skipped > 0: - w("Synced %d of %d cluster(s). %d skipped (not ready).\n", + w("Synced %d of %d cluster(s). %d not ready.\n", t.Synced, total, t.Skipped) default: if total == 1 { diff --git a/cmd/sync_test.go b/cmd/sync_test.go index 3278a09..731ded7 100644 --- a/cmd/sync_test.go +++ b/cmd/sync_test.go @@ -1060,34 +1060,34 @@ func TestResolveDisplaySources(t *testing.T) { sep := string(os.PathListSeparator) tests := []struct { - name string - explicitPath string - kubeconfig string - wantSources string + name string + explicitPath string + kubeconfig string + wantSources string }{ { - name: "explicit path returned as-is", + name: "explicit path returned as-is", explicitPath: "/explicit/kubeconfig", - kubeconfig: "/env/kubeconfig", - wantSources: "/explicit/kubeconfig", + kubeconfig: "/env/kubeconfig", + wantSources: "/explicit/kubeconfig", }, { - name: "single KUBECONFIG entry returned as-is", + name: "single KUBECONFIG entry returned as-is", explicitPath: "", - kubeconfig: "/single/kubeconfig", - wantSources: "/single/kubeconfig", + kubeconfig: "/single/kubeconfig", + wantSources: "/single/kubeconfig", }, { - name: "multi-file KUBECONFIG: full list returned", + name: "multi-file KUBECONFIG: full list returned", explicitPath: "", - kubeconfig: "/first" + sep + "/second" + sep + "/third", - wantSources: "/first" + sep + "/second" + sep + "/third", + kubeconfig: "/first" + sep + "/second" + sep + "/third", + wantSources: "/first" + sep + "/second" + sep + "/third", }, { - name: "empty KUBECONFIG falls back to default", + name: "empty KUBECONFIG falls back to default", explicitPath: "", - kubeconfig: "", - wantSources: clientcmd.RecommendedHomeFile, + kubeconfig: "", + wantSources: clientcmd.RecommendedHomeFile, }, }