Skip to content

Commit 69fe1a7

Browse files
committed
feat(ske): show cluster errors in table output
Signed-off-by: Lukas Hoehl <[email protected]>
1 parent 7ba5ffc commit 69fe1a7

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

internal/cmd/ske/cluster/describe/describe.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"encoding/json"
66
"fmt"
7+
"strings"
78

89
"github.com/goccy/go-yaml"
910
"github.com/spf13/cobra"
@@ -136,6 +137,10 @@ func outputResult(p *print.Printer, outputFormat string, cluster *ske.Cluster) e
136137
table.AddRow("VERSION", utils.PtrString(cluster.Kubernetes.Version))
137138
table.AddSeparator()
138139
}
140+
if clusterErrs := cluster.Status.GetErrors(); len(clusterErrs) != 0 {
141+
handleClusterErrors(clusterErrs, &table)
142+
}
143+
139144
table.AddRow("ACL", acl)
140145
err := table.Display(p)
141146
if err != nil {
@@ -145,3 +150,17 @@ func outputResult(p *print.Printer, outputFormat string, cluster *ske.Cluster) e
145150
return nil
146151
}
147152
}
153+
154+
func handleClusterErrors(clusterErrs []ske.ClusterError, table *tables.Table) {
155+
errs := make([]string, 0, len(clusterErrs))
156+
for _, e := range clusterErrs {
157+
b := new(strings.Builder)
158+
fmt.Fprint(b, e.GetCode())
159+
if msg, ok := e.GetMessageOk(); ok {
160+
fmt.Fprintf(b, ": %s", msg)
161+
}
162+
errs = append(errs, b.String())
163+
}
164+
table.AddRow("ERRORS", strings.Join(errs, "\n"))
165+
table.AddSeparator()
166+
}

0 commit comments

Comments
 (0)