Skip to content

Commit ab665a2

Browse files
committed
more fixes
Signed-off-by: Carlos Panato <[email protected]>
1 parent 0520255 commit ab665a2

File tree

3 files changed

+39
-11
lines changed

3 files changed

+39
-11
lines changed

cmd/ci-reporter/cmd/root.go

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import (
2525
"time"
2626

2727
"github.com/olekukonko/tablewriter"
28+
"github.com/olekukonko/tablewriter/renderer"
29+
"github.com/olekukonko/tablewriter/tw"
2830
"github.com/shurcooL/githubv4"
2931
"github.com/spf13/cobra"
3032
"github.com/tj/go-spin"
@@ -244,19 +246,40 @@ func PrintReporterData(cfg *Config, reports *CIReportDataFields) error {
244246
if err != nil {
245247
return fmt.Errorf("could not write to output stream: %w", err)
246248
}
247-
248-
table := tablewriter.NewWriter(out)
249249
data := [][]string{}
250250

251+
table := tablewriter.NewTable(out,
252+
tablewriter.WithConfig(tablewriter.Config{
253+
Header: tw.CellConfig{
254+
Alignment: tw.CellAlignment{Global: tw.AlignLeft},
255+
},
256+
}),
257+
tablewriter.WithHeader([]string{"TESTGRID BOARD", "TITLE", "STATUS", "STATUS DETAILS"}),
258+
tablewriter.WithRenderer(renderer.NewMarkdown()),
259+
tablewriter.WithRendition(tw.Rendition{
260+
Symbols: tw.NewSymbols(tw.StyleMarkdown),
261+
Borders: tw.Border{
262+
Left: tw.On,
263+
Top: tw.Off,
264+
Right: tw.On,
265+
Bottom: tw.Off,
266+
},
267+
Settings: tw.Settings{
268+
Separators: tw.Separators{
269+
BetweenRows: tw.On,
270+
},
271+
},
272+
}),
273+
tablewriter.WithRowAutoWrap(tw.WrapNone),
274+
)
275+
251276
// table in short version differs from regular table
252277
if cfg.ShortReport {
253-
table.SetHeader([]string{"TESTGRID BOARD", "TITLE", "STATUS", "STATUS DETAILS"})
254-
255278
for _, record := range r.Records {
256279
data = append(data, []string{record.TestgridBoard, record.Title, record.Status, record.StatusDetails})
257280
}
258281
} else {
259-
table.SetHeader([]string{"TESTGRID BOARD", "TITLE", "STATUS", "STATUS DETAILS", "URL", "UPDATED AT"})
282+
table.Options(tablewriter.WithHeader([]string{"TESTGRID BOARD", "TITLE", "STATUS", "STATUS DETAILS", "URL", "UPDATED AT"}))
260283

261284
for _, record := range r.Records {
262285
data = append(data, []string{
@@ -269,9 +292,7 @@ func PrintReporterData(cfg *Config, reports *CIReportDataFields) error {
269292
}
270293
}
271294

272-
table.SetBorders(tablewriter.Border{Left: true, Top: false, Right: true, Bottom: false})
273-
table.AppendBulk(data)
274-
table.SetCenterSeparator("|")
295+
table.Append(data)
275296
table.Render()
276297

277298
// write a summary

cmd/schedule-builder/cmd/markdown.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ func parsePatchSchedule(patchSchedule PatchSchedule) string {
105105
Header: tw.CellConfig{
106106
Alignment: tw.CellAlignment{Global: tw.AlignLeft},
107107
},
108+
Row: tw.CellConfig{
109+
Alignment: tw.CellAlignment{Global: tw.AlignLeft},
110+
},
108111
}),
109112
tablewriter.WithHeader([]string{"Patch Release", "Cherry Pick Deadline", "Target Date", "Note"}),
110113
tablewriter.WithRenderer(renderer.NewMarkdown()),
@@ -174,6 +177,9 @@ func parseReleaseSchedule(releaseSchedule ReleaseSchedule) string {
174177
table := tablewriter.NewTable(tableString,
175178
tablewriter.WithConfig(tablewriter.Config{
176179
Header: tw.CellConfig{
180+
Alignment: tw.CellAlignment{Global: tw.AlignCenter},
181+
},
182+
Row: tw.CellConfig{
177183
Alignment: tw.CellAlignment{Global: tw.AlignLeft},
178184
},
179185
}),
@@ -189,7 +195,8 @@ func parseReleaseSchedule(releaseSchedule ReleaseSchedule) string {
189195
},
190196
Settings: tw.Settings{
191197
Separators: tw.Separators{
192-
BetweenRows: tw.On,
198+
BetweenRows: tw.On,
199+
BetweenColumns: tw.Off,
193200
},
194201
},
195202
}),

cmd/schedule-builder/cmd/markdown_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
const expectedPatchSchedule = `### Upcoming Monthly Releases
3232
3333
| MONTHLY PATCH RELEASE | CHERRY PICK DEADLINE | TARGET DATE |
34-
|-----------------------|----------------------|-------------|
34+
|:----------------------|:---------------------|:------------|
3535
| June 2020 | 2020-06-12 | 2020-06-17 |
3636
3737
### Timeline
@@ -43,7 +43,7 @@ Next patch release is **X.Y.ZZZ**
4343
**X.Y** enters maintenance mode on **THEN** and End of Life is on **NOW**.
4444
4545
| PATCH RELEASE | CHERRY PICK DEADLINE | TARGET DATE | NOTE |
46-
|---------------|----------------------|-------------|------|
46+
|:--------------|:---------------------|:------------|:-----|
4747
| X.Y.ZZZ | 2020-06-12 | 2020-06-17 | |
4848
| X.Y.XXX | 2020-05-15 | 2020-05-20 | honk |
4949
| X.Y.YYY | 2020-04-13 | 2020-04-16 | |

0 commit comments

Comments
 (0)