From e556a01c9bce0e0d0a2f5133f77dcf39fdd83e69 Mon Sep 17 00:00:00 2001 From: zhangzujian Date: Wed, 20 Nov 2024 05:43:34 +0000 Subject: [PATCH] modelgen: generate constants instead of variables for enums Signed-off-by: zhangzujian --- modelgen/table.go | 2 +- modelgen/table_test.go | 16 +++++++++------- ovsdb/serverdb/database.go | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/modelgen/table.go b/modelgen/table.go index 2c0b301e..08a98917 100644 --- a/modelgen/table.go +++ b/modelgen/table.go @@ -217,7 +217,7 @@ type ( {{- end }} ) -var ( +const ( {{ range index . "Enums" }} {{- $e := . }} {{- range .Sets }} diff --git a/modelgen/table_test.go b/modelgen/table_test.go index 6d4e2711..3683ba95 100644 --- a/modelgen/table_test.go +++ b/modelgen/table_test.go @@ -64,7 +64,7 @@ type ( AtomicTableProtocol = string ) -var ( +const ( AtomicTableEventTypeEmptyLbBackends AtomicTableEventType = "empty_lb_backends" AtomicTableProtocolTCP AtomicTableProtocol = "tcp" AtomicTableProtocolUDP AtomicTableProtocol = "udp" @@ -128,7 +128,7 @@ type ( AtomicTableProtocol = string ) -var ( +const ( AtomicTableEventTypeEmptyLbBackends AtomicTableEventType = "empty_lb_backends" AtomicTableProtocolTCP AtomicTableProtocol = "tcp" AtomicTableProtocolUDP AtomicTableProtocol = "udp" @@ -172,7 +172,7 @@ type ( AtomicTableProtocol = string ) -var ( +const ( AtomicTableEventTypeEmptyLbBackends AtomicTableEventType = "empty_lb_backends" AtomicTableProtocolTCP AtomicTableProtocol = "tcp" AtomicTableProtocolUDP AtomicTableProtocol = "udp" @@ -330,7 +330,7 @@ type ( AtomicTableProtocol = string ) -var ( +const ( AtomicTableEventTypeEmptyLbBackends AtomicTableEventType = "empty_lb_backends" AtomicTableProtocolTCP AtomicTableProtocol = "tcp" AtomicTableProtocolUDP AtomicTableProtocol = "udp" @@ -589,7 +589,7 @@ type ( AtomicTableProtocol = string ) -var ( +const ( AtomicTableEventTypeEmptyLbBackends AtomicTableEventType = "empty_lb_backends" AtomicTableProtocolTCP AtomicTableProtocol = "tcp" AtomicTableProtocolUDP AtomicTableProtocol = "udp" @@ -870,7 +870,7 @@ func buildRandStr() *string { } func buildTestBridge() *vswitchd.Bridge { - return &vswitchd.Bridge{ + bridge := &vswitchd.Bridge{ UUID: *buildRandStr(), AutoAttach: buildRandStr(), Controller: []string{*buildRandStr(), *buildRandStr()}, @@ -878,7 +878,7 @@ func buildTestBridge() *vswitchd.Bridge { 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(), @@ -895,6 +895,8 @@ func buildTestBridge() *vswitchd.Bridge { Status: map[string]string{*buildRandStr(): *buildRandStr(), *buildRandStr(): *buildRandStr()}, STPEnable: false, } + *bridge.FailMode = vswitchd.BridgeFailModeSecure + return bridge } func buildTestInterface() *vswitchd.Interface { diff --git a/ovsdb/serverdb/database.go b/ovsdb/serverdb/database.go index 274a7164..79436318 100644 --- a/ovsdb/serverdb/database.go +++ b/ovsdb/serverdb/database.go @@ -11,7 +11,7 @@ type ( DatabaseModel = string ) -var ( +const ( DatabaseModelStandalone DatabaseModel = "standalone" DatabaseModelClustered DatabaseModel = "clustered" DatabaseModelRelay DatabaseModel = "relay"