/
runtime.go
111 lines (107 loc) · 5.27 KB
/
runtime.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// Code generated by entc, DO NOT EDIT.
package ent
import (
"time"
"github.com/direktiv/direktiv/ent/cloudevents"
"github.com/direktiv/direktiv/ent/namespace"
"github.com/direktiv/direktiv/ent/schema"
"github.com/direktiv/direktiv/ent/services"
"github.com/direktiv/direktiv/ent/workflow"
"github.com/google/uuid"
)
// The init function reads all schema descriptors with runtime code
// (default values, validators, hooks and policies) and stitches it
// to their package variables.
func init() {
cloudeventsFields := schema.CloudEvents{}.Fields()
_ = cloudeventsFields
// cloudeventsDescNamespace is the schema descriptor for namespace field.
cloudeventsDescNamespace := cloudeventsFields[1].Descriptor()
// cloudevents.NamespaceValidator is a validator for the "namespace" field. It is called by the builders before save.
cloudevents.NamespaceValidator = cloudeventsDescNamespace.Validators[0].(func(string) error)
// cloudeventsDescFire is the schema descriptor for fire field.
cloudeventsDescFire := cloudeventsFields[3].Descriptor()
// cloudevents.DefaultFire holds the default value on creation for the fire field.
cloudevents.DefaultFire = cloudeventsDescFire.Default.(func() time.Time)
// cloudeventsDescCreated is the schema descriptor for created field.
cloudeventsDescCreated := cloudeventsFields[4].Descriptor()
// cloudevents.DefaultCreated holds the default value on creation for the created field.
cloudevents.DefaultCreated = cloudeventsDescCreated.Default.(func() time.Time)
// cloudeventsDescID is the schema descriptor for id field.
cloudeventsDescID := cloudeventsFields[0].Descriptor()
// cloudevents.IDValidator is a validator for the "id" field. It is called by the builders before save.
cloudevents.IDValidator = cloudeventsDescID.Validators[0].(func(string) error)
namespaceFields := schema.Namespace{}.Fields()
_ = namespaceFields
// namespaceDescCreated is the schema descriptor for created field.
namespaceDescCreated := namespaceFields[1].Descriptor()
// namespace.DefaultCreated holds the default value on creation for the created field.
namespace.DefaultCreated = namespaceDescCreated.Default.(func() time.Time)
// namespaceDescID is the schema descriptor for id field.
namespaceDescID := namespaceFields[0].Descriptor()
// namespace.IDValidator is a validator for the "id" field. It is called by the builders before save.
namespace.IDValidator = func() func(string) error {
validators := namespaceDescID.Validators
fns := [...]func(string) error{
validators[0].(func(string) error),
validators[1].(func(string) error),
validators[2].(func(string) error),
}
return func(id string) error {
for _, fn := range fns {
if err := fn(id); err != nil {
return err
}
}
return nil
}
}()
servicesFields := schema.Services{}.Fields()
_ = servicesFields
// servicesDescName is the schema descriptor for name field.
servicesDescName := servicesFields[0].Descriptor()
// services.NameValidator is a validator for the "name" field. It is called by the builders before save.
services.NameValidator = func() func(string) error {
validators := servicesDescName.Validators
fns := [...]func(string) error{
validators[0].(func(string) error),
validators[1].(func(string) error),
}
return func(name string) error {
for _, fn := range fns {
if err := fn(name); err != nil {
return err
}
}
return nil
}
}()
workflowFields := schema.Workflow{}.Fields()
_ = workflowFields
// workflowDescName is the schema descriptor for name field.
workflowDescName := workflowFields[1].Descriptor()
// workflow.NameValidator is a validator for the "name" field. It is called by the builders before save.
workflow.NameValidator = workflowDescName.Validators[0].(func(string) error)
// workflowDescCreated is the schema descriptor for created field.
workflowDescCreated := workflowFields[2].Descriptor()
// workflow.DefaultCreated holds the default value on creation for the created field.
workflow.DefaultCreated = workflowDescCreated.Default.(func() time.Time)
// workflowDescDescription is the schema descriptor for description field.
workflowDescDescription := workflowFields[3].Descriptor()
// workflow.DefaultDescription holds the default value on creation for the description field.
workflow.DefaultDescription = workflowDescDescription.Default.(string)
// workflow.DescriptionValidator is a validator for the "description" field. It is called by the builders before save.
workflow.DescriptionValidator = workflowDescDescription.Validators[0].(func(string) error)
// workflowDescActive is the schema descriptor for active field.
workflowDescActive := workflowFields[4].Descriptor()
// workflow.DefaultActive holds the default value on creation for the active field.
workflow.DefaultActive = workflowDescActive.Default.(bool)
// workflowDescRevision is the schema descriptor for revision field.
workflowDescRevision := workflowFields[5].Descriptor()
// workflow.DefaultRevision holds the default value on creation for the revision field.
workflow.DefaultRevision = workflowDescRevision.Default.(int)
// workflowDescID is the schema descriptor for id field.
workflowDescID := workflowFields[0].Descriptor()
// workflow.DefaultID holds the default value on creation for the id field.
workflow.DefaultID = workflowDescID.Default.(func() uuid.UUID)
}