Skip to content

Commit

Permalink
modelgen: generate constants instead of variables for enums
Browse files Browse the repository at this point in the history
Signed-off-by: zhangzujian <zhangzujian.7@gmail.com>
  • Loading branch information
zhangzujian committed Nov 20, 2024
1 parent ce19516 commit e0af5e5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion modelgen/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ type (
{{- end }}
)
var (
const (
{{ range index . "Enums" }}
{{- $e := . }}
{{- range .Sets }}
Expand Down
16 changes: 9 additions & 7 deletions modelgen/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type (
AtomicTableProtocol = string
)
var (
const (
AtomicTableEventTypeEmptyLbBackends AtomicTableEventType = "empty_lb_backends"
AtomicTableProtocolTCP AtomicTableProtocol = "tcp"
AtomicTableProtocolUDP AtomicTableProtocol = "udp"
Expand Down Expand Up @@ -128,7 +128,7 @@ type (
AtomicTableProtocol = string
)
var (
const (
AtomicTableEventTypeEmptyLbBackends AtomicTableEventType = "empty_lb_backends"
AtomicTableProtocolTCP AtomicTableProtocol = "tcp"
AtomicTableProtocolUDP AtomicTableProtocol = "udp"
Expand Down Expand Up @@ -172,7 +172,7 @@ type (
AtomicTableProtocol = string
)
var (
const (
AtomicTableEventTypeEmptyLbBackends AtomicTableEventType = "empty_lb_backends"
AtomicTableProtocolTCP AtomicTableProtocol = "tcp"
AtomicTableProtocolUDP AtomicTableProtocol = "udp"
Expand Down Expand Up @@ -330,7 +330,7 @@ type (
AtomicTableProtocol = string
)
var (
const (
AtomicTableEventTypeEmptyLbBackends AtomicTableEventType = "empty_lb_backends"
AtomicTableProtocolTCP AtomicTableProtocol = "tcp"
AtomicTableProtocolUDP AtomicTableProtocol = "udp"
Expand Down Expand Up @@ -589,7 +589,7 @@ type (
AtomicTableProtocol = string
)
var (
const (
AtomicTableEventTypeEmptyLbBackends AtomicTableEventType = "empty_lb_backends"
AtomicTableProtocolTCP AtomicTableProtocol = "tcp"
AtomicTableProtocolUDP AtomicTableProtocol = "udp"
Expand Down Expand Up @@ -870,15 +870,15 @@ func buildRandStr() *string {
}

func buildTestBridge() *vswitchd.Bridge {
return &vswitchd.Bridge{
br := &vswitchd.Bridge{
UUID: *buildRandStr(),
AutoAttach: buildRandStr(),
Controller: []string{*buildRandStr(), *buildRandStr()},
DatapathID: buildRandStr(),
DatapathType: *buildRandStr(),
DatapathVersion: *buildRandStr(),
ExternalIDs: map[string]string{*buildRandStr(): *buildRandStr(), *buildRandStr(): *buildRandStr()},
FailMode: &vswitchd.BridgeFailModeSecure,
FailMode: new(string),
FloodVLANs: []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
FlowTables: map[int]string{1: *buildRandStr(), 2: *buildRandStr()},
IPFIX: buildRandStr(),
Expand All @@ -895,6 +895,8 @@ func buildTestBridge() *vswitchd.Bridge {
Status: map[string]string{*buildRandStr(): *buildRandStr(), *buildRandStr(): *buildRandStr()},
STPEnable: false,
}
*br.FailMode = vswitchd.BridgeFailModeSecure
return br
}

func buildTestInterface() *vswitchd.Interface {
Expand Down
2 changes: 1 addition & 1 deletion ovsdb/serverdb/database.go

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

0 comments on commit e0af5e5

Please sign in to comment.