Skip to content

Commit

Permalink
pkg/kmsg: annotate max version, min-max version
Browse files Browse the repository at this point in the history
Previously, only non-zero min versions were commented and they had no
upper bound. We now comment all possible ranges.
  • Loading branch information
twmb committed Nov 6, 2022
1 parent a07b8c8 commit ba55f7d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 32 deletions.
10 changes: 8 additions & 2 deletions generate/gen.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"fmt"
"strconv"
"strings"
)
Expand Down Expand Up @@ -608,8 +609,13 @@ func (s Struct) WriteDefn(l *LineWriter) {
l.Write("%s", f.Comment)
}
versionTag := ""
if f.MinVersion > 0 {
versionTag = " // v" + strconv.Itoa(f.MinVersion) + "+"
switch {
case f.MinVersion > 0 && f.MaxVersion > 0:
versionTag = fmt.Sprintf(" // v%d-v%d", f.MinVersion, f.MaxVersion)
case f.MinVersion > 0:
versionTag = fmt.Sprintf(" // v%d+", f.MinVersion)
case f.MaxVersion > 0:
versionTag = fmt.Sprintf(" // v0-v%d", f.MaxVersion)
}
if f.Tag >= 0 {
if versionTag == "" {
Expand Down
60 changes: 30 additions & 30 deletions pkg/kmsg/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ba55f7d

Please sign in to comment.