Skip to content

Commit 5e3aade

Browse files
committed
rename model.Model interface's Table func name, avoid conflict with sb
https://github.com/ovn-org/ovn/blob/686caaf66d5be811c655ea2938b082564d5f5f75/ovn-sb.ovsschema#L383 Signed-off-by: Yan Zhu <[email protected]>
1 parent 754b46b commit 5e3aade

File tree

12 files changed

+57
-39
lines changed

12 files changed

+57
-39
lines changed

cache/cache_test.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type testModel struct {
2424
Datapath *string `ovsdb:"datapath"`
2525
}
2626

27-
func (t *testModel) Table() string {
27+
func (t *testModel) GetTableName() string {
2828
return "Open_vSwitch"
2929
}
3030

@@ -379,7 +379,7 @@ type testModel1 struct {
379379
Bar map[string]string `ovsdb:"bar"`
380380
}
381381

382-
func (t *testModel1) Table() string {
382+
func (t *testModel1) GetTableName() string {
383383
return "Open_vSwitch"
384384
}
385385

@@ -807,7 +807,7 @@ type testModel2 struct {
807807
Baz string `ovsdb:"baz"`
808808
}
809809

810-
func (t *testModel2) Table() string {
810+
func (t *testModel2) GetTableName() string {
811811
return "Open_vSwitch"
812812
}
813813

@@ -1058,7 +1058,7 @@ type testModel3 struct {
10581058
Bar map[string]string `ovsdb:"bar"`
10591059
}
10601060

1061-
func (t *testModel3) Table() string {
1061+
func (t *testModel3) GetTableName() string {
10621062
return "Open_vSwitch"
10631063
}
10641064

@@ -1922,7 +1922,7 @@ type badModel struct {
19221922
Baz string `ovsdb:"baz"`
19231923
}
19241924

1925-
func (b *badModel) Table() string {
1925+
func (b *badModel) GetTableName() string {
19261926
return "bad"
19271927
}
19281928

@@ -2156,7 +2156,7 @@ type testModel4 struct {
21562156
Baz map[string]string `ovsdb:"baz"`
21572157
}
21582158

2159-
func (t *testModel4) Table() string {
2159+
func (t *testModel4) GetTableName() string {
21602160
return "Open_vSwitch"
21612161
}
21622162

@@ -2331,7 +2331,7 @@ type rowsByConditionTestModel struct {
23312331
Empty string `ovsdb:"empty"`
23322332
}
23332333

2334-
func (r *rowsByConditionTestModel) Table() string {
2334+
func (r *rowsByConditionTestModel) GetTableName() string {
23352335
return "Open_vSwitch"
23362336
}
23372337

@@ -2747,7 +2747,7 @@ type testDBModel struct {
27472747
Set []string `ovsdb:"set"`
27482748
}
27492749

2750-
func (t *testDBModel) Table() string {
2750+
func (t *testDBModel) GetTableName() string {
27512751
return "Open_vSwitch"
27522752
}
27532753

client/api.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ func (a api) Wait(untilConFun ovsdb.WaitCondition, timeout *int, model model.Mod
549549
// getTableFromModel returns the table name from a Model object after performing
550550
// type verifications on the model
551551
func (a api) getTableFromModel(m model.Model) (string, error) {
552-
table := m.Table()
552+
table := m.GetTableName()
553553
if table == "" {
554554
return "", &ErrWrongType{reflect.TypeOf(m), "Model not found in Database Model"}
555555
}

client/api_test_model.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,12 @@ type testLogicalSwitch struct {
123123
Acls []string `ovsdb:"acls"`
124124
}
125125

126-
// Table returns the table name. It's part of the Model interface
127-
func (*testLogicalSwitch) Table() string {
126+
// GetTableName returns the table name. It's part of the Model interface
127+
func (*testLogicalSwitch) GetTableName() string {
128128
return "Logical_Switch"
129129
}
130130

131-
//LogicalSwitchPort struct defines an object in Logical_Switch_Port table
131+
// LogicalSwitchPort struct defines an object in Logical_Switch_Port table
132132
type testLogicalSwitchPort struct {
133133
UUID string `ovsdb:"_uuid"`
134134
Up *bool `ovsdb:"up"`
@@ -148,8 +148,8 @@ type testLogicalSwitchPort struct {
148148
ParentName *string `ovsdb:"parent_name"`
149149
}
150150

151-
// Table returns the table name. It's part of the Model interface
152-
func (*testLogicalSwitchPort) Table() string {
151+
// GetTableName returns the table name. It's part of the Model interface
152+
func (*testLogicalSwitchPort) GetTableName() string {
153153
return "Logical_Switch_Port"
154154
}
155155

client/client_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ type Bridge struct {
8181
STPEnable bool `ovsdb:"stp_enable"`
8282
}
8383

84-
func (b *Bridge) Table() string {
84+
func (b *Bridge) GetTableName() string {
8585
return "Bridge"
8686
}
8787

@@ -107,7 +107,7 @@ type OpenvSwitch struct {
107107
SystemVersion *string `ovsdb:"system_version"`
108108
}
109109

110-
func (o *OpenvSwitch) Table() string {
110+
func (o *OpenvSwitch) GetTableName() string {
111111
return "Open_vSwitch"
112112
}
113113

cmd/stress/stress.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type bridgeType struct {
2929
Status map[string]string `ovsdb:"status"`
3030
}
3131

32-
func (b *bridgeType) Table() string {
32+
func (b *bridgeType) GetTableName() string {
3333
return "Bridge"
3434
}
3535

@@ -39,7 +39,7 @@ type ovsType struct {
3939
Bridges []string `ovsdb:"bridges"`
4040
}
4141

42-
func (o *ovsType) Table() string {
42+
func (o *ovsType) GetTableName() string {
4343
return "Open_vSwitch"
4444
}
4545

model/model.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
// LoadBalancers []string `ovsdb:"load_balancer"`
2525
// }
2626
type Model interface {
27-
Table() string
27+
GetTableName() string
2828
}
2929

3030
type CloneableModel interface {

model/model_test.go

+13-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type modelA struct {
1414
UUID string `ovsdb:"_uuid"`
1515
}
1616

17-
func (m *modelA) Table() string {
17+
func (m *modelA) GetTableName() string {
1818
return "A"
1919
}
2020

@@ -24,15 +24,15 @@ type modelB struct {
2424
Bar string `ovsdb:"baz"`
2525
}
2626

27-
func (m *modelB) Table() string {
27+
func (m *modelB) GetTableName() string {
2828
return "B"
2929
}
3030

3131
type modelInvalid struct {
3232
Foo string
3333
}
3434

35-
func (m *modelInvalid) Table() string {
35+
func (m *modelInvalid) GetTableName() string {
3636
return "Invalid"
3737
}
3838

@@ -107,7 +107,7 @@ type testTable struct {
107107
AMap map[string]string `ovsdb:"aMap"`
108108
}
109109

110-
func (t *testTable) Table() string {
110+
func (t *testTable) GetTableName() string {
111111
return "TestTable"
112112
}
113113

@@ -454,3 +454,12 @@ func TestEqualViaComparable(t *testing.T) {
454454
a.UID = "baz"
455455
assert.False(t, Equal(a, b))
456456
}
457+
458+
func TestGetTableName(t *testing.T) {
459+
a := &testTable{}
460+
func(a interface{}) {
461+
m, ok := a.(Model)
462+
assert.True(t, ok, "is not a model")
463+
assert.Equal(t, m.GetTableName(), "TestTable")
464+
}(a)
465+
}

modelgen/table.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ type {{ index . "StructName" }} struct {
246246
{{ end }}
247247
{{ template "extraFields" . }}
248248
}
249-
func (a *{{ index . "StructName" }}) Table() string {
249+
func (a *{{ index . "StructName" }}) GetTableName() string {
250250
return {{ index . "StructName" }}Table
251251
}
252252
{{ template "postStructDefinitions" . }}

modelgen/table_test.go

+16-7
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ type AtomicTable struct {
8181
Str string ` + "`" + `ovsdb:"str"` + "`" + `
8282
}
8383
84-
func (a *AtomicTable) Table() string {
84+
func (a *AtomicTable) GetTableName() string {
8585
return AtomicTableTable
8686
}
8787
`,
@@ -108,7 +108,7 @@ type AtomicTable struct {
108108
Str string ` + "`" + `ovsdb:"str"` + "`" + `
109109
}
110110
111-
func (a *AtomicTable) Table() string {
111+
func (a *AtomicTable) GetTableName() string {
112112
return AtomicTableTable
113113
}
114114
`,
@@ -160,7 +160,7 @@ type AtomicTable struct {
160160
OtherStr string
161161
}
162162
163-
func (a *AtomicTable) Table() string {
163+
func (a *AtomicTable) GetTableName() string {
164164
return AtomicTableTable
165165
}
166166
`,
@@ -201,7 +201,7 @@ type AtomicTable struct {
201201
Str string ` + "`" + `ovsdb:"str"` + "`" + `
202202
}
203203
204-
func (a *AtomicTable) Table() string {
204+
func (a *AtomicTable) GetTableName() string {
205205
return AtomicTableTable
206206
}
207207
@@ -370,7 +370,7 @@ type AtomicTable struct {
370370
OtherStr string
371371
}
372372
373-
func (a *AtomicTable) Table() string {
373+
func (a *AtomicTable) GetTableName() string {
374374
return AtomicTableTable
375375
}
376376
@@ -503,7 +503,7 @@ type AtomicTable struct {
503503
Str string ` + "`" + `ovsdb:"str"` + "`" + `
504504
}
505505
506-
func (a *AtomicTable) Table() string {
506+
func (a *AtomicTable) GetTableName() string {
507507
return AtomicTableTable
508508
}
509509
@@ -630,7 +630,7 @@ type AtomicTable struct {
630630
Str string ` + "`" + `ovsdb:"str"` + "`" + `
631631
}
632632
633-
func (a *AtomicTable) Table() string {
633+
func (a *AtomicTable) GetTableName() string {
634634
return AtomicTableTable
635635
}
636636
@@ -1020,3 +1020,12 @@ func BenchmarkDeepEqual(b *testing.B) {
10201020
})
10211021
}
10221022
}
1023+
1024+
func TestGetTableName(t *testing.T) {
1025+
bridge := &vswitchd.Bridge{}
1026+
func(bridge interface{}) {
1027+
b, ok := bridge.(model.Model)
1028+
assert.True(t, ok, "is not a model")
1029+
assert.Equal(t, b.GetTableName(), "Bridge")
1030+
}(bridge)
1031+
}

ovsdb/serverdb/database.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/ovs/ovs_integration_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ type bridgeType struct {
166166
DatapathID *string `ovsdb:"datapath_id"`
167167
}
168168

169-
func (b *bridgeType) Table() string {
169+
func (b *bridgeType) GetTableName() string {
170170
return "Bridge"
171171
}
172172

@@ -192,7 +192,7 @@ type ovsType struct {
192192
SystemVersion *string `ovsdb:"system_version"`
193193
}
194194

195-
func (o *ovsType) Table() string {
195+
func (o *ovsType) GetTableName() string {
196196
return "Open_vSwitch"
197197
}
198198

@@ -202,7 +202,7 @@ type ipfixType struct {
202202
Targets []string `ovsdb:"targets"`
203203
}
204204

205-
func (i *ipfixType) Table() string {
205+
func (i *ipfixType) GetTableName() string {
206206
return "IPFIX"
207207
}
208208

@@ -212,7 +212,7 @@ type queueType struct {
212212
DSCP *int `ovsdb:"dscp"`
213213
}
214214

215-
func (q *queueType) Table() string {
215+
func (q *queueType) GetTableName() string {
216216
return "Queue"
217217
}
218218

test/test_data.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ type BridgeType struct {
144144
Status map[string]string `ovsdb:"status"`
145145
}
146146

147-
func (b *BridgeType) Table() string {
147+
func (b *BridgeType) GetTableName() string {
148148
return "Bridge"
149149
}
150150

@@ -154,7 +154,7 @@ type OvsType struct {
154154
Bridges []string `ovsdb:"bridges"`
155155
}
156156

157-
func (o *OvsType) Table() string {
157+
func (o *OvsType) GetTableName() string {
158158
return "Open_vSwitch"
159159
}
160160

@@ -166,7 +166,7 @@ type FlowSampleCollectorSetType struct {
166166
IPFIX *string // `ovsdb:"ipfix"`
167167
}
168168

169-
func (f *FlowSampleCollectorSetType) Table() string {
169+
func (f *FlowSampleCollectorSetType) GetTableName() string {
170170
return "FlowSampleCollectorSet"
171171
}
172172

0 commit comments

Comments
 (0)