@@ -26,6 +26,8 @@ import (
26
26
"time"
27
27
28
28
"github.com/olekukonko/tablewriter"
29
+ "github.com/olekukonko/tablewriter/renderer"
30
+ "github.com/olekukonko/tablewriter/tw"
29
31
"github.com/sirupsen/logrus"
30
32
31
33
"sigs.k8s.io/release-utils/util"
@@ -42,9 +44,30 @@ func parsePatchSchedule(patchSchedule PatchSchedule) string {
42
44
if len (patchSchedule .UpcomingReleases ) > 0 {
43
45
output = append (output , "### Upcoming Monthly Releases\n " )
44
46
tableString := & strings.Builder {}
45
- table := tablewriter .NewWriter (tableString )
46
- table .SetAutoWrapText (false )
47
- table .SetHeader ([]string {"Monthly Patch Release" , "Cherry Pick Deadline" , "Target Date" })
47
+ table := tablewriter .NewTable (tableString ,
48
+ tablewriter .WithConfig (tablewriter.Config {
49
+ Header : tw.CellConfig {
50
+ Alignment : tw.CellAlignment {Global : tw .AlignLeft },
51
+ },
52
+ }),
53
+ tablewriter .WithHeader ([]string {"Monthly Patch Release" , "Cherry Pick Deadline" , "Target Date" }),
54
+ tablewriter .WithRenderer (renderer .NewMarkdown ()),
55
+ tablewriter .WithRendition (tw.Rendition {
56
+ Symbols : tw .NewSymbols (tw .StyleMarkdown ),
57
+ Borders : tw.Border {
58
+ Left : tw .On ,
59
+ Top : tw .Off ,
60
+ Right : tw .On ,
61
+ Bottom : tw .Off ,
62
+ },
63
+ Settings : tw.Settings {
64
+ Separators : tw.Separators {
65
+ BetweenRows : tw .On ,
66
+ },
67
+ },
68
+ }),
69
+ tablewriter .WithRowAutoWrap (tw .WrapNone ),
70
+ )
48
71
49
72
for _ , upcoming := range patchSchedule .UpcomingReleases {
50
73
targetDate , err := time .Parse (refDate , upcoming .TargetDate )
@@ -54,16 +77,14 @@ func parsePatchSchedule(patchSchedule PatchSchedule) string {
54
77
continue
55
78
}
56
79
57
- table .Append ([]string {
80
+ _ = table .Append ([]string {
58
81
targetDate .Format (refDateMonthly ),
59
82
strings .TrimSpace (upcoming .CherryPickDeadline ),
60
83
strings .TrimSpace (upcoming .TargetDate ),
61
84
})
62
85
}
63
86
64
- table .SetBorders (tablewriter.Border {Left : true , Top : false , Right : true , Bottom : false })
65
- table .SetCenterSeparator ("|" )
66
- table .Render ()
87
+ _ = table .Render ()
67
88
68
89
output = append (output , tableString .String ())
69
90
}
@@ -79,22 +100,44 @@ func parsePatchSchedule(patchSchedule PatchSchedule) string {
79
100
)
80
101
81
102
tableString := & strings.Builder {}
82
- table := tablewriter .NewWriter (tableString )
83
- table .SetAutoWrapText (false )
84
- table .SetHeader ([]string {"Patch Release" , "Cherry Pick Deadline" , "Target Date" , "Note" })
103
+ table := tablewriter .NewTable (tableString ,
104
+ tablewriter .WithConfig (tablewriter.Config {
105
+ Header : tw.CellConfig {
106
+ Alignment : tw.CellAlignment {Global : tw .AlignLeft },
107
+ },
108
+ Row : tw.CellConfig {
109
+ Alignment : tw.CellAlignment {Global : tw .AlignLeft },
110
+ },
111
+ }),
112
+ tablewriter .WithHeader ([]string {"Patch Release" , "Cherry Pick Deadline" , "Target Date" , "Note" }),
113
+ tablewriter .WithRenderer (renderer .NewMarkdown ()),
114
+ tablewriter .WithRendition (tw.Rendition {
115
+ Symbols : tw .NewSymbols (tw .StyleMarkdown ),
116
+ Borders : tw.Border {
117
+ Left : tw .On ,
118
+ Top : tw .Off ,
119
+ Right : tw .On ,
120
+ Bottom : tw .Off ,
121
+ },
122
+ Settings : tw.Settings {
123
+ Separators : tw.Separators {
124
+ BetweenRows : tw .On ,
125
+ },
126
+ },
127
+ }),
128
+ tablewriter .WithRowAutoWrap (tw .WrapNone ),
129
+ )
85
130
86
131
// Check if the next patch release is in the Previous Patch list, if yes dont read in the output
87
132
if ! patchReleaseInPreviousList (releaseSchedule .Next .Release , releaseSchedule .PreviousPatches ) {
88
- table .Append ([]string {strings .TrimSpace (releaseSchedule .Next .Release ), strings .TrimSpace (releaseSchedule .Next .CherryPickDeadline ), strings .TrimSpace (releaseSchedule .Next .TargetDate ), "" })
133
+ _ = table .Append ([]string {strings .TrimSpace (releaseSchedule .Next .Release ), strings .TrimSpace (releaseSchedule .Next .CherryPickDeadline ), strings .TrimSpace (releaseSchedule .Next .TargetDate ), "" })
89
134
}
90
135
91
136
for _ , previous := range releaseSchedule .PreviousPatches {
92
- table .Append ([]string {strings .TrimSpace (previous .Release ), strings .TrimSpace (previous .CherryPickDeadline ), strings .TrimSpace (previous .TargetDate ), strings .TrimSpace (previous .Note )})
137
+ _ = table .Append ([]string {strings .TrimSpace (previous .Release ), strings .TrimSpace (previous .CherryPickDeadline ), strings .TrimSpace (previous .TargetDate ), strings .TrimSpace (previous .Note )})
93
138
}
94
139
95
- table .SetBorders (tablewriter.Border {Left : true , Top : false , Right : true , Bottom : false })
96
- table .SetCenterSeparator ("|" )
97
- table .Render ()
140
+ _ = table .Render ()
98
141
99
142
output = append (output , tableString .String ())
100
143
}
@@ -131,17 +174,40 @@ func parseReleaseSchedule(releaseSchedule ReleaseSchedule) string {
131
174
132
175
for _ , releaseSchedule := range releaseSchedule .Releases {
133
176
tableString := & strings.Builder {}
134
- table := tablewriter .NewWriter (tableString )
135
- table .SetAutoWrapText (false )
136
- table .SetHeader ([]string {"**What**" , "**Who**" , "**When**" , "**WEEK**" , "**CI Signal**" })
177
+ table := tablewriter .NewTable (tableString ,
178
+ tablewriter .WithConfig (tablewriter.Config {
179
+ Header : tw.CellConfig {
180
+ Alignment : tw.CellAlignment {Global : tw .AlignCenter },
181
+ },
182
+ Row : tw.CellConfig {
183
+ Alignment : tw.CellAlignment {Global : tw .AlignLeft },
184
+ },
185
+ }),
186
+ tablewriter .WithHeader ([]string {"**What**" , "**Who**" , "**When**" , "**WEEK**" , "**CI Signal**" }),
187
+ tablewriter .WithRenderer (renderer .NewMarkdown ()),
188
+ tablewriter .WithRendition (tw.Rendition {
189
+ Symbols : tw .NewSymbols (tw .StyleMarkdown ),
190
+ Borders : tw.Border {
191
+ Left : tw .On ,
192
+ Top : tw .Off ,
193
+ Right : tw .On ,
194
+ Bottom : tw .Off ,
195
+ },
196
+ Settings : tw.Settings {
197
+ Separators : tw.Separators {
198
+ BetweenRows : tw .On ,
199
+ BetweenColumns : tw .Off ,
200
+ },
201
+ },
202
+ }),
203
+ tablewriter .WithRowAutoWrap (tw .WrapNone ),
204
+ )
137
205
138
206
for _ , timeline := range releaseSchedule .Timeline {
139
- table .Append ([]string {strings .TrimSpace (timeline .What ), strings .TrimSpace (timeline .Who ), strings .TrimSpace (timeline .When ), strings .TrimSpace (timeline .Week ), strings .TrimSpace (timeline .CISignal ), "" })
207
+ _ = table .Append ([]string {strings .TrimSpace (timeline .What ), strings .TrimSpace (timeline .Who ), strings .TrimSpace (timeline .When ), strings .TrimSpace (timeline .Week ), strings .TrimSpace (timeline .CISignal ), "" })
140
208
}
141
209
142
- table .SetBorders (tablewriter.Border {Left : true , Top : false , Right : true , Bottom : false })
143
- table .SetCenterSeparator ("|" )
144
- table .Render ()
210
+ _ = table .Render ()
145
211
146
212
relSched .TimelineOutput = tableString .String ()
147
213
}
0 commit comments