diff --git a/pkg/phase/command.go b/pkg/phase/command.go index be2c981df..9efae238d 100644 --- a/pkg/phase/command.go +++ b/pkg/phase/command.go @@ -166,7 +166,7 @@ type PlanListCommand struct { Writer io.Writer } -// RunE runs a phase plan command +// RunE runs a plan list command func (c *PlanListCommand) RunE() error { cfg, err := c.Factory() if err != nil { @@ -192,7 +192,7 @@ func (c *PlanListCommand) RunE() error { descriptionCol := table.ColumnDef{ ColumnName: "description", ColumnHeader: "DESCRIPTION", - ColumnWidth: 40, + ColumnWidth: 200, PrintResourceFunc: func(w io.Writer, width int, r table.Resource) (int, error) { rs := r.ResourceStatus() if rs == nil { @@ -203,7 +203,12 @@ func (c *PlanListCommand) RunE() error { if err != nil { return 0, err } - return fmt.Fprint(w, plan.Description) + txt := plan.Description + if len(txt) > width { + txt = txt[:width] + } + _, err = fmt.Fprint(w, txt) + return len(txt), err }, } printer.Columns = append(printer.Columns, descriptionCol) diff --git a/pkg/phase/command_test.go b/pkg/phase/command_test.go index 10335b984..352936f47 100644 --- a/pkg/phase/command_test.go +++ b/pkg/phase/command_test.go @@ -111,9 +111,11 @@ func TestRunCommand(t *testing.T) { func TestListCommand(t *testing.T) { outputString1 := "NAMESPACE RESOURCE CLUSTER " + - "NAME EXECUTOR DOC ENTRYPOINT " + "NAME EXECUTOR DOC ENTRYPOINT " + + " " outputString2 := " Phase/phase ephemeral" + - "-cluster KubernetesApply ephemeral/phase " + "-cluster KubernetesApply ephemeral/phase " + + " " yamlOutput := `--- - apiVersion: airshipit.org/v1alpha1 config: @@ -348,8 +350,13 @@ func TestPlanListCommand(t *testing.T) { return conf, nil }, expectedOut: [][]byte{ - []byte("NAMESPACE RESOURCE DESCRIPTION "), - []byte(" PhasePlan/phasePlan Default phase plan "), + []byte("NAMESPACE RESOURCE DESCRIPTION " + + " " + + " "), + []byte(" PhasePlan/phasePlan Default phase plan" + + " " + + " " + + " "), {}, }, }, diff --git a/pkg/phase/printers.go b/pkg/phase/printers.go index 1a3a5712d..3e5352b2a 100644 --- a/pkg/phase/printers.go +++ b/pkg/phase/printers.go @@ -44,7 +44,12 @@ func PrintPhaseListTable(w io.Writer, phases []*v1alpha1.Phase) error { if err != nil { return 0, nil } - return fmt.Fprintf(w, phase.ClusterName) + txt := phase.ClusterName + if len(txt) > width { + txt = txt[:width] + } + _, err = fmt.Fprintf(w, txt) + return len(txt), err }, } executorrefkindCol := table.ColumnDef{ @@ -57,20 +62,30 @@ func PrintPhaseListTable(w io.Writer, phases []*v1alpha1.Phase) error { if err != nil { return 0, nil } - return fmt.Fprintf(w, phase.Config.ExecutorRef.Kind) + txt := phase.Config.ExecutorRef.Kind + if len(txt) > width { + txt = txt[:width] + } + _, err = fmt.Fprintf(w, txt) + return len(txt), err }, } docentrypointCol := table.ColumnDef{ ColumnName: "docentrypoint", ColumnHeader: "DOC ENTRYPOINT", - ColumnWidth: 40, + ColumnWidth: 100, PrintResourceFunc: func(w io.Writer, width int, r table.Resource) (int, error) { phase, err := phaseFromResource(r) if err != nil { return 0, nil } - return fmt.Fprintf(w, phase.Config.DocumentEntryPoint) + txt := phase.Config.DocumentEntryPoint + if len(txt) > width { + txt = txt[:width] + } + _, err = fmt.Fprintf(w, txt) + return len(txt), err }, } printer.Columns = append(printer.Columns, clusternameCol, executorrefkindCol, docentrypointCol)