Skip to content

Commit

Permalink
Merge pull request #3541 from saschagrunert/schedule-builder-fix
Browse files Browse the repository at this point in the history
Fix schedule builder to reflect current format
  • Loading branch information
k8s-ci-robot authored Apr 3, 2024
2 parents b164659 + 0c2cb9e commit 8ae6997
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 39 deletions.
13 changes: 8 additions & 5 deletions cmd/schedule-builder/cmd/markdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,20 @@ func parseSchedule(patchSchedule PatchSchedule) string {
output = append(output, "### Timeline\n")
for _, releaseSchedule := range patchSchedule.Schedules {
output = append(output, fmt.Sprintf("### %s\n", releaseSchedule.Release),
fmt.Sprintf("Next patch release is **%s**\n", releaseSchedule.Next),
fmt.Sprintf("End of Life for **%s** is **%s**\n", releaseSchedule.Release, releaseSchedule.EndOfLifeDate))
fmt.Sprintf("Next patch release is **%s**\n", releaseSchedule.Next.Release),
fmt.Sprintf("**%s** enters maintenance mode on **%s** and End of Life is on **%s**.\n",
releaseSchedule.Release, releaseSchedule.MaintenanceModeStartDate, releaseSchedule.EndOfLifeDate,
),
)

tableString := &strings.Builder{}
table := tablewriter.NewWriter(tableString)
table.SetAutoWrapText(false)
table.SetHeader([]string{"Patch Release", "Cherry Pick Deadline", "Target Date", "Note"})

// Check if the next patch release is in the Previous Patch list, if yes dont read in the output
if !patchReleaseInPreviousList(releaseSchedule.Next, releaseSchedule.PreviousPatches) {
table.Append([]string{strings.TrimSpace(releaseSchedule.Next), strings.TrimSpace(releaseSchedule.CherryPickDeadline), strings.TrimSpace(releaseSchedule.TargetDate), ""})
if !patchReleaseInPreviousList(releaseSchedule.Next.Release, releaseSchedule.PreviousPatches) {
table.Append([]string{strings.TrimSpace(releaseSchedule.Next.Release), strings.TrimSpace(releaseSchedule.Next.CherryPickDeadline), strings.TrimSpace(releaseSchedule.Next.TargetDate), ""})
}

for _, previous := range releaseSchedule.PreviousPatches {
Expand Down Expand Up @@ -113,7 +116,7 @@ func parseReleaseSchedule(releaseSchedule ReleaseSchedule) string {
return scheduleOut
}

func patchReleaseInPreviousList(a string, previousPatches []PreviousPatches) bool {
func patchReleaseInPreviousList(a string, previousPatches []PatchRelease) bool {
for _, b := range previousPatches {
if b.Release == a {
return true
Expand Down
32 changes: 19 additions & 13 deletions cmd/schedule-builder/cmd/markdown_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const expectedPatchSchedule = `### Timeline
Next patch release is **X.Y.ZZZ**
End of Life for **X.Y** is **NOW**
**X.Y** enters maintenance mode on **THEN** and End of Life is on **NOW**.
| PATCH RELEASE | CHERRY PICK DEADLINE | TARGET DATE | NOTE |
|---------------|----------------------|-------------|------|
Expand Down Expand Up @@ -131,12 +131,15 @@ func TestParseSchedule(t *testing.T) {
schedule: PatchSchedule{
Schedules: []Schedule{
{
Release: "X.Y",
Next: "X.Y.ZZZ",
CherryPickDeadline: "2020-06-12",
TargetDate: "2020-06-17",
EndOfLifeDate: "NOW",
PreviousPatches: []PreviousPatches{
Release: "X.Y",
Next: &PatchRelease{
Release: "X.Y.ZZZ",
CherryPickDeadline: "2020-06-12",
TargetDate: "2020-06-17",
},
EndOfLifeDate: "NOW",
MaintenanceModeStartDate: "THEN",
PreviousPatches: []PatchRelease{
{
Release: "X.Y.XXX",
CherryPickDeadline: "2020-05-15",
Expand All @@ -158,12 +161,15 @@ func TestParseSchedule(t *testing.T) {
schedule: PatchSchedule{
Schedules: []Schedule{
{
Release: "X.Y",
Next: "X.Y.ZZZ",
CherryPickDeadline: "2020-06-12",
TargetDate: "2020-06-17",
EndOfLifeDate: "NOW",
PreviousPatches: []PreviousPatches{
Release: "X.Y",
Next: &PatchRelease{
Release: "X.Y.ZZZ",
CherryPickDeadline: "2020-06-12",
TargetDate: "2020-06-17",
},
EndOfLifeDate: "NOW",
MaintenanceModeStartDate: "THEN",
PreviousPatches: []PatchRelease{
{
Release: "X.Y.ZZZ",
CherryPickDeadline: "2020-06-12",
Expand Down
16 changes: 8 additions & 8 deletions cmd/schedule-builder/cmd/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ type PatchSchedule struct {
Schedules []Schedule `yaml:"schedules"`
}

// PreviousPatches struct to define the old patch schedules
type PreviousPatches struct {
// PatchRelease struct to define the patch schedules
type PatchRelease struct {
Release string `yaml:"release"`
CherryPickDeadline string `yaml:"cherryPickDeadline"`
TargetDate string `yaml:"targetDate"`
Expand All @@ -31,12 +31,12 @@ type PreviousPatches struct {

// Schedule struct to define the release schedule for a specific version
type Schedule struct {
Release string `yaml:"release"`
Next string `yaml:"next"`
CherryPickDeadline string `yaml:"cherryPickDeadline"`
TargetDate string `yaml:"targetDate"`
EndOfLifeDate string `yaml:"endOfLifeDate"`
PreviousPatches []PreviousPatches `yaml:"previousPatches"`
Release string `yaml:"release"`
ReleaseDate string `yaml:"releaseDate"`
Next *PatchRelease `yaml:"next"`
EndOfLifeDate string `yaml:"endOfLifeDate"`
MaintenanceModeStartDate string `yaml:"maintenanceModeStartDate"`
PreviousPatches []PatchRelease `yaml:"previousPatches"`
}

type ReleaseSchedule struct {
Expand Down
1 change: 0 additions & 1 deletion cmd/schedule-builder/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ const (

var requiredFlags = []string{
configPathFlag,
typeFlag,
}

// Execute adds all child commands to the root command and sets flags appropriately.
Expand Down
6 changes: 3 additions & 3 deletions cmd/schedule-builder/cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const expectedPatchOut = `### Timeline
Next patch release is **1.18.4**
End of Life for **1.18** is **TBD**
**1.18** enters maintenance mode on **TBD** and End of Life is on **TBD**.
| PATCH RELEASE | CHERRY PICK DEADLINE | TARGET DATE | NOTE |
|---------------|----------------------|-------------|------|
Expand All @@ -47,7 +47,7 @@ End of Life for **1.18** is **TBD**
Next patch release is **1.17.7**
End of Life for **1.17** is **TBD**
**1.17** enters maintenance mode on **TBD** and End of Life is on **TBD**.
| PATCH RELEASE | CHERRY PICK DEADLINE | TARGET DATE | NOTE |
|---------------|----------------------|-------------|------|
Expand All @@ -58,7 +58,7 @@ End of Life for **1.17** is **TBD**
Next patch release is **1.16.11**
End of Life for **1.16** is **TBD**
**1.16** enters maintenance mode on **TBD** and End of Life is on **TBD**.
| PATCH RELEASE | CHERRY PICK DEADLINE | TARGET DATE | NOTE |
|---------------|----------------------|-------------|------|
Expand Down
24 changes: 15 additions & 9 deletions cmd/schedule-builder/cmd/testdata/schedule.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
schedules:
- release: 1.18
next: 1.18.4
cherryPickDeadline: 2020-06-12
targetDate: 2020-06-17
next:
release: 1.18.4
cherryPickDeadline: 2020-06-12
targetDate: 2020-06-17
endOfLifeDate: TBD
maintenanceModeStartDate: TBD
previousPatches:
- release: 1.18.3
cherryPickDeadline: 2020-05-15
Expand All @@ -12,19 +14,23 @@ schedules:
cherryPickDeadline: 2020-04-13
targetDate: 2020-04-16
- release: 1.17
next: 1.17.7
cherryPickDeadline: 2020-06-12
targetDate: 2020-06-17
next:
release: 1.17.7
cherryPickDeadline: 2020-06-12
targetDate: 2020-06-17
endOfLifeDate: TBD
maintenanceModeStartDate: TBD
previousPatches:
- release: 1.17.6
cherryPickDeadline: 2020-05-15
targetDate: 2020-05-20
- release: 1.16
next: 1.16.11
cherryPickDeadline: 2020-06-12
targetDate: 2020-06-17
next:
release: 1.16.11
cherryPickDeadline: 2020-06-12
targetDate: 2020-06-17
endOfLifeDate: TBD
maintenanceModeStartDate: TBD
previousPatches:
- release: 1.16.10
cherryPickDeadline: 2020-05-15
Expand Down

0 comments on commit 8ae6997

Please sign in to comment.