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

Commit

Permalink
Make the last col of get-classes and get-plans wider so we're at leas…
Browse files Browse the repository at this point in the history
…t 80 cols

Signed-off-by: Doug Davis <dug@us.ibm.com>
  • Loading branch information
Doug Davis committed Jul 24, 2018
1 parent 0a42172 commit 5223376
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 18 deletions.
13 changes: 13 additions & 0 deletions cmd/svcat/output/class.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,31 @@ func getClassStatusText(status v1beta1.ClusterServiceClassStatus) string {

func writeClassListTable(w io.Writer, classes []servicecatalog.Class) {
t := NewListTable(w)

// Pre-parse the data so we allow the last column to be really wide.
// We can't set the MinWidth after data has been loaded
maxNameWidth := 4
for _, class := range classes {
if tmp := len(class.Spec.ExternalName); tmp > maxNameWidth {
maxNameWidth = tmp
}
}
t.SetColMinWidth(1, 80-(maxNameWidth+8))

t.SetHeader([]string{
"Name",
"Namespace",
"Description",
})

for _, class := range classes {
t.Append([]string{
class.GetExternalName(),
class.GetNamespace(),
class.GetDescription(),
})
}

t.Render()
}

Expand Down
18 changes: 18 additions & 0 deletions cmd/svcat/output/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,31 @@ func writePlanListTable(w io.Writer, plans []v1beta1.ClusterServicePlan, classNa
"Class",
"Description",
})

// Pre-parse the data so we allow the last column to be really wide.
// We can't set the MinWidth after data has been loaded
maxNameWidth := 4
maxClassWidth := 5

for _, plan := range plans {
if tmp := len(plan.Spec.ExternalName); tmp > maxNameWidth {
maxNameWidth = tmp
}
tmp := len(classNames[plan.Spec.ClusterServiceClassRef.Name])
if tmp > maxClassWidth {
maxClassWidth = tmp
}
}
t.SetColMinWidth(2, 80-(maxNameWidth+maxClassWidth+11))

for _, plan := range plans {
t.Append([]string{
plan.Spec.ExternalName,
classNames[plan.Spec.ClusterServiceClassRef.Name],
plan.Spec.Description,
})
}

t.Render()
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/svcat/testdata/output/get-class.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
NAME NAMESPACE DESCRIPTION
+-----------------------+-----------+-------------------------+
NAME NAMESPACE DESCRIPTION
+-----------------------+-----------+-----------------------------------------+
user-provided-service A user provided service
4 changes: 2 additions & 2 deletions cmd/svcat/testdata/output/get-classes.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NAME NAMESPACE DESCRIPTION
+--------------------------+-----------+--------------------------+
NAME NAMESPACE DESCRIPTION
+--------------------------+-----------+--------------------------------------+
user-provided-service A user provided service
another-provided-service Another provided service
user-provided-service default A user provided service
Expand Down
6 changes: 3 additions & 3 deletions cmd/svcat/testdata/output/get-plan.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
NAME CLASS DESCRIPTION
+---------+-----------------------+-------------------------+
default user-provided-service Sample plan description
NAME CLASS DESCRIPTION
+---------+-----------------------+-------------------------------------------+
default user-provided-service Sample plan description
8 changes: 4 additions & 4 deletions cmd/svcat/testdata/output/get-plans-by-class.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
NAME CLASS DESCRIPTION
+---------+-----------------------+-------------------------+
default user-provided-service Sample plan description
premium user-provided-service Premium plan
NAME CLASS DESCRIPTION
+---------+-----------------------+-------------------------------------------+
default user-provided-service Sample plan description
premium user-provided-service Premium plan
13 changes: 6 additions & 7 deletions cmd/svcat/testdata/output/get-plans.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
NAME CLASS DESCRIPTION
+---------+--------------------------+--------------------------------+
default user-provided-service Sample plan description
premium user-provided-service Premium plan
default another-provided-service Another sample plan
description
premium another-provided-service Another premium plan
NAME CLASS DESCRIPTION
+---------+--------------------------+----------------------------------------+
default user-provided-service Sample plan description
premium user-provided-service Premium plan
default another-provided-service Another sample plan description
premium another-provided-service Another premium plan

0 comments on commit 5223376

Please sign in to comment.