Skip to content
This repository was archived by the owner on May 6, 2022. It is now read-only.

Commit 32e637c

Browse files
author
Doug Davis
committed
Make the last col of get-classes and get-plans wider so we're at least 80 cols
Signed-off-by: Doug Davis <[email protected]>
1 parent 0a42172 commit 32e637c

File tree

7 files changed

+48
-18
lines changed

7 files changed

+48
-18
lines changed

cmd/svcat/output/class.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,31 @@ func getClassStatusText(status v1beta1.ClusterServiceClassStatus) string {
3333

3434
func writeClassListTable(w io.Writer, classes []servicecatalog.Class) {
3535
t := NewListTable(w)
36+
37+
// Pre-parse the data so we allow the last column to be really wide.
38+
// We can't set the MinWidth after data has been loaded
39+
maxNameWidth := 4
40+
for _, class := range classes {
41+
if tmp := len(class.GetExternalName()); tmp > maxNameWidth {
42+
maxNameWidth = tmp
43+
}
44+
}
45+
t.SetColMinWidth(1, 80-(maxNameWidth+8))
46+
3647
t.SetHeader([]string{
3748
"Name",
3849
"Namespace",
3950
"Description",
4051
})
52+
4153
for _, class := range classes {
4254
t.Append([]string{
4355
class.GetExternalName(),
4456
class.GetNamespace(),
4557
class.GetDescription(),
4658
})
4759
}
60+
4861
t.Render()
4962
}
5063

cmd/svcat/output/plan.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,31 @@ func writePlanListTable(w io.Writer, plans []v1beta1.ClusterServicePlan, classNa
5757
"Class",
5858
"Description",
5959
})
60+
61+
// Pre-parse the data so we allow the last column to be really wide.
62+
// We can't set the MinWidth after data has been loaded
63+
maxNameWidth := 4
64+
maxClassWidth := 5
65+
66+
for _, plan := range plans {
67+
if tmp := len(plan.Spec.ExternalName); tmp > maxNameWidth {
68+
maxNameWidth = tmp
69+
}
70+
tmp := len(classNames[plan.Spec.ClusterServiceClassRef.Name])
71+
if tmp > maxClassWidth {
72+
maxClassWidth = tmp
73+
}
74+
}
75+
t.SetColMinWidth(2, 80-(maxNameWidth+maxClassWidth+11))
76+
6077
for _, plan := range plans {
6178
t.Append([]string{
6279
plan.Spec.ExternalName,
6380
classNames[plan.Spec.ClusterServiceClassRef.Name],
6481
plan.Spec.Description,
6582
})
6683
}
84+
6785
t.Render()
6886
}
6987

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
NAME NAMESPACE DESCRIPTION
2-
+-----------------------+-----------+-------------------------+
1+
NAME NAMESPACE DESCRIPTION
2+
+-----------------------+-----------+-----------------------------------------+
33
user-provided-service A user provided service

cmd/svcat/testdata/output/get-classes.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
NAME NAMESPACE DESCRIPTION
2-
+--------------------------+-----------+--------------------------+
1+
NAME NAMESPACE DESCRIPTION
2+
+--------------------------+-----------+--------------------------------------+
33
user-provided-service A user provided service
44
another-provided-service Another provided service
55
user-provided-service default A user provided service
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
NAME CLASS DESCRIPTION
2-
+---------+-----------------------+-------------------------+
3-
default user-provided-service Sample plan description
1+
NAME CLASS DESCRIPTION
2+
+---------+-----------------------+-------------------------------------------+
3+
default user-provided-service Sample plan description
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
NAME CLASS DESCRIPTION
2-
+---------+-----------------------+-------------------------+
3-
default user-provided-service Sample plan description
4-
premium user-provided-service Premium plan
1+
NAME CLASS DESCRIPTION
2+
+---------+-----------------------+-------------------------------------------+
3+
default user-provided-service Sample plan description
4+
premium user-provided-service Premium plan
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
NAME CLASS DESCRIPTION
2-
+---------+--------------------------+--------------------------------+
3-
default user-provided-service Sample plan description
4-
premium user-provided-service Premium plan
5-
default another-provided-service Another sample plan
6-
description
7-
premium another-provided-service Another premium plan
1+
NAME CLASS DESCRIPTION
2+
+---------+--------------------------+----------------------------------------+
3+
default user-provided-service Sample plan description
4+
premium user-provided-service Premium plan
5+
default another-provided-service Another sample plan description
6+
premium another-provided-service Another premium plan

0 commit comments

Comments
 (0)