forked from goadesign/gorma
/
runner.go
72 lines (64 loc) · 2.31 KB
/
runner.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package dsl
import (
"github.com/goadesign/goa/design"
"github.com/goadesign/goa/dslengine"
"github.com/kaizenplatform/gorma"
)
func init() {
gorma.GormaDesign = gorma.NewStorageGroupDefinition()
dslengine.Register(gorma.GormaDesign)
}
// storageDefinition returns true and current context if it is an StorageGroupDefinition,
// nil and false otherwise.
func storageGroupDefinition(failIfNotSD bool) (*gorma.StorageGroupDefinition, bool) {
a, ok := dslengine.CurrentDefinition().(*gorma.StorageGroupDefinition)
if !ok && failIfNotSD {
dslengine.IncompatibleDSL()
}
return a, ok
}
// relationalStoreDefinition returns true and current context if it is an RelationalStoreDefinition,
// nil and false otherwise.
func relationalStoreDefinition(failIfNotSD bool) (*gorma.RelationalStoreDefinition, bool) {
a, ok := dslengine.CurrentDefinition().(*gorma.RelationalStoreDefinition)
if !ok && failIfNotSD {
dslengine.IncompatibleDSL()
}
return a, ok
}
// relationalModelDefinition returns true and current context if it is an RelationalModelDefinition,
// nil and false otherwise.
func relationalModelDefinition(failIfNotSD bool) (*gorma.RelationalModelDefinition, bool) {
a, ok := dslengine.CurrentDefinition().(*gorma.RelationalModelDefinition)
if !ok && failIfNotSD {
dslengine.IncompatibleDSL()
}
return a, ok
}
// relationalFieldDefinition returns true and current context if it is an RelationalFieldDefinition,
// nil and false otherwise.
func relationalFieldDefinition(failIfNotSD bool) (*gorma.RelationalFieldDefinition, bool) {
a, ok := dslengine.CurrentDefinition().(*gorma.RelationalFieldDefinition)
if !ok && failIfNotSD {
dslengine.IncompatibleDSL()
}
return a, ok
}
// buildSourceDefinition returns true and current context if it is an BuildSource
// nil and false otherwise.
func buildSourceDefinition(failIfNotSD bool) (*gorma.BuildSource, bool) {
a, ok := dslengine.CurrentDefinition().(*gorma.BuildSource)
if !ok && failIfNotSD {
dslengine.IncompatibleDSL()
}
return a, ok
}
// attributeDefinition returns true and current context if it is an AttributeDefinition
// nil and false otherwise.
func attributeDefinition(failIfNotSD bool) (*design.AttributeDefinition, bool) {
a, ok := dslengine.CurrentDefinition().(*design.AttributeDefinition)
if !ok && failIfNotSD {
dslengine.IncompatibleDSL()
}
return a, ok
}