Skip to content

Commit

Permalink
modelgen: Add constraints to sets
Browse files Browse the repository at this point in the history
Sets with min 1 and max 1 are a type
Sets with min 0 and max 1 are a pointer to a type
Sets with a max > 1 (non-default) are an array
Otherwise a set is represented by a slice

Signed-off-by: Dave Tucker <[email protected]>
  • Loading branch information
dave-tucker committed Jul 13, 2021
1 parent 39f8796 commit 900b625
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 29 deletions.
24 changes: 23 additions & 1 deletion modelgen/table.go

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

56 changes: 28 additions & 28 deletions modelgen/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ type (
AtomicTableProtocol string
)
const (
var (
AtomicTableEventTypeEmptyLbBackends AtomicTableEventType = "empty_lb_backends"
AtomicTableProtocolTCP AtomicTableProtocol = "tcp"
AtomicTableProtocolUDP AtomicTableProtocol = "udp"
Expand All @@ -67,12 +67,12 @@ const (
// AtomicTable defines an object in atomicTable table
type AtomicTable struct {
UUID string ` + "`" + `ovsdb:"_uuid"` + "`" + `
EventType AtomicTableEventType ` + "`" + `ovsdb:"event_type"` + "`" + `
Float float64 ` + "`" + `ovsdb:"float"` + "`" + `
Int int ` + "`" + `ovsdb:"int"` + "`" + `
Protocol []AtomicTableProtocol ` + "`" + `ovsdb:"protocol"` + "`" + `
Str string ` + "`" + `ovsdb:"str"` + "`" + `
UUID string ` + "`" + `ovsdb:"_uuid"` + "`" + `
EventType AtomicTableEventType ` + "`" + `ovsdb:"event_type"` + "`" + `
Float float64 ` + "`" + `ovsdb:"float"` + "`" + `
Int int ` + "`" + `ovsdb:"int"` + "`" + `
Protocol *AtomicTableProtocol ` + "`" + `ovsdb:"protocol"` + "`" + `
Str string ` + "`" + `ovsdb:"str"` + "`" + `
}
`,
},
Expand All @@ -88,12 +88,12 @@ package test
// AtomicTable defines an object in atomicTable table
type AtomicTable struct {
UUID string ` + "`" + `ovsdb:"_uuid"` + "`" + `
EventType string ` + "`" + `ovsdb:"event_type"` + "`" + `
Float float64 ` + "`" + `ovsdb:"float"` + "`" + `
Int int ` + "`" + `ovsdb:"int"` + "`" + `
Protocol []string ` + "`" + `ovsdb:"protocol"` + "`" + `
Str string ` + "`" + `ovsdb:"str"` + "`" + `
UUID string ` + "`" + `ovsdb:"_uuid"` + "`" + `
EventType string ` + "`" + `ovsdb:"event_type"` + "`" + `
Float float64 ` + "`" + `ovsdb:"float"` + "`" + `
Int int ` + "`" + `ovsdb:"int"` + "`" + `
Protocol *string ` + "`" + `ovsdb:"protocol"` + "`" + `
Str string ` + "`" + `ovsdb:"str"` + "`" + `
}
`,
},
Expand All @@ -118,7 +118,7 @@ type (
AtomicTableProtocol string
)
const (
var (
AtomicTableEventTypeEmptyLbBackends AtomicTableEventType = "empty_lb_backends"
AtomicTableProtocolTCP AtomicTableProtocol = "tcp"
AtomicTableProtocolUDP AtomicTableProtocol = "udp"
Expand All @@ -127,18 +127,18 @@ const (
// AtomicTable defines an object in atomicTable table
type AtomicTable struct {
UUID string ` + "`" + `ovsdb:"_uuid"` + "`" + `
EventType AtomicTableEventType ` + "`" + `ovsdb:"event_type"` + "`" + `
Float float64 ` + "`" + `ovsdb:"float"` + "`" + `
Int int ` + "`" + `ovsdb:"int"` + "`" + `
Protocol []AtomicTableProtocol ` + "`" + `ovsdb:"protocol"` + "`" + `
Str string ` + "`" + `ovsdb:"str"` + "`" + `
UUID string ` + "`" + `ovsdb:"_uuid"` + "`" + `
EventType AtomicTableEventType ` + "`" + `ovsdb:"event_type"` + "`" + `
Float float64 ` + "`" + `ovsdb:"float"` + "`" + `
Int int ` + "`" + `ovsdb:"int"` + "`" + `
Protocol *AtomicTableProtocol ` + "`" + `ovsdb:"protocol"` + "`" + `
Str string ` + "`" + `ovsdb:"str"` + "`" + `
OtherUUID string
OtherEventType string
OtherFloat float64
OtherInt int
OtherProtocol []string
OtherProtocol *string
OtherStr string
}
`,
Expand Down Expand Up @@ -167,7 +167,7 @@ type (
AtomicTableProtocol string
)
const (
var (
AtomicTableEventTypeEmptyLbBackends AtomicTableEventType = "empty_lb_backends"
AtomicTableProtocolTCP AtomicTableProtocol = "tcp"
AtomicTableProtocolUDP AtomicTableProtocol = "udp"
Expand All @@ -176,12 +176,12 @@ const (
// AtomicTable defines an object in atomicTable table
type AtomicTable struct {
UUID string ` + "`" + `ovsdb:"_uuid"` + "`" + `
EventType AtomicTableEventType ` + "`" + `ovsdb:"event_type"` + "`" + `
Float float64 ` + "`" + `ovsdb:"float"` + "`" + `
Int int ` + "`" + `ovsdb:"int"` + "`" + `
Protocol []AtomicTableProtocol ` + "`" + `ovsdb:"protocol"` + "`" + `
Str string ` + "`" + `ovsdb:"str"` + "`" + `
UUID string ` + "`" + `ovsdb:"_uuid"` + "`" + `
EventType AtomicTableEventType ` + "`" + `ovsdb:"event_type"` + "`" + `
Float float64 ` + "`" + `ovsdb:"float"` + "`" + `
Int int ` + "`" + `ovsdb:"int"` + "`" + `
Protocol *AtomicTableProtocol ` + "`" + `ovsdb:"protocol"` + "`" + `
Str string ` + "`" + `ovsdb:"str"` + "`" + `
}
func TestFunc() string {
Expand Down

0 comments on commit 900b625

Please sign in to comment.