Skip to content

Commit

Permalink
Generate Table() func in model.Model interface via modelgen
Browse files Browse the repository at this point in the history
  • Loading branch information
halfcrazy committed Sep 18, 2023
1 parent 239822f commit 8883b97
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
3 changes: 3 additions & 0 deletions modelgen/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ type {{ index . "StructName" }} struct {
{{ end }}
{{ template "extraFields" . }}
}
func (a *{{ index . "StructName" }}) Table() string {
return {{ index . "StructName" }}Table
}
{{ template "postStructDefinitions" . }}
{{ template "extraDefinitions" . }}
{{ template "extendedGen" . }}
Expand Down
28 changes: 28 additions & 0 deletions modelgen/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ type AtomicTable struct {
Protocol *AtomicTableProtocol ` + "`" + `ovsdb:"protocol"` + "`" + `
Str string ` + "`" + `ovsdb:"str"` + "`" + `
}
func (a *AtomicTable) Table() string {
return AtomicTableTable
}
`,
},
{
Expand All @@ -103,6 +107,10 @@ type AtomicTable struct {
Protocol *string ` + "`" + `ovsdb:"protocol"` + "`" + `
Str string ` + "`" + `ovsdb:"str"` + "`" + `
}
func (a *AtomicTable) Table() string {
return AtomicTableTable
}
`,
},
{
Expand Down Expand Up @@ -151,6 +159,10 @@ type AtomicTable struct {
OtherProtocol *string
OtherStr string
}
func (a *AtomicTable) Table() string {
return AtomicTableTable
}
`,
},
{
Expand Down Expand Up @@ -189,6 +201,10 @@ type AtomicTable struct {
Str string ` + "`" + `ovsdb:"str"` + "`" + `
}
func (a *AtomicTable) Table() string {
return AtomicTableTable
}
func (a *AtomicTable) GetUUID() string {
return a.UUID
}
Expand Down Expand Up @@ -354,6 +370,10 @@ type AtomicTable struct {
OtherStr string
}
func (a *AtomicTable) Table() string {
return AtomicTableTable
}
func copyAtomicTableOtherProtocol(a *AtomicTableProtocol) *AtomicTableProtocol {
if a == nil {
return nil
Expand Down Expand Up @@ -483,6 +503,10 @@ type AtomicTable struct {
Str string ` + "`" + `ovsdb:"str"` + "`" + `
}
func (a *AtomicTable) Table() string {
return AtomicTableTable
}
func (a *AtomicTable) GetUUID() string {
return a.UUID
}
Expand Down Expand Up @@ -606,6 +630,10 @@ type AtomicTable struct {
Str string ` + "`" + `ovsdb:"str"` + "`" + `
}
func (a *AtomicTable) Table() string {
return AtomicTableTable
}
func TestFunc() string {
return "AtomicTable"
}
Expand Down
4 changes: 4 additions & 0 deletions 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 8883b97

Please sign in to comment.