MCPcopy Create free account
hub / github.com/crowdsecurity/crowdsec / init

Function init

pkg/database/ent/runtime.go:24–203  ·  view source on GitHub ↗

The init function reads all schema descriptors with runtime code (default values, validators, hooks and policies) and stitches it to their package variables.

()

Source from the content-addressed store, hash-verified

22// (default values, validators, hooks and policies) and stitches it
23// to their package variables.
24func init() {
25 alertFields := schema.Alert{}.Fields()
26 _ = alertFields
27 // alertDescCreatedAt is the schema descriptor for created_at field.
28 alertDescCreatedAt := alertFields[0].Descriptor()
29 // alert.DefaultCreatedAt holds the default value on creation for the created_at field.
30 alert.DefaultCreatedAt = alertDescCreatedAt.Default.(func() time.Time)
31 // alertDescUpdatedAt is the schema descriptor for updated_at field.
32 alertDescUpdatedAt := alertFields[1].Descriptor()
33 // alert.DefaultUpdatedAt holds the default value on creation for the updated_at field.
34 alert.DefaultUpdatedAt = alertDescUpdatedAt.Default.(func() time.Time)
35 // alert.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
36 alert.UpdateDefaultUpdatedAt = alertDescUpdatedAt.UpdateDefault.(func() time.Time)
37 // alertDescBucketId is the schema descriptor for bucketId field.
38 alertDescBucketId := alertFields[3].Descriptor()
39 // alert.DefaultBucketId holds the default value on creation for the bucketId field.
40 alert.DefaultBucketId = alertDescBucketId.Default.(string)
41 // alertDescMessage is the schema descriptor for message field.
42 alertDescMessage := alertFields[4].Descriptor()
43 // alert.DefaultMessage holds the default value on creation for the message field.
44 alert.DefaultMessage = alertDescMessage.Default.(string)
45 // alertDescEventsCount is the schema descriptor for eventsCount field.
46 alertDescEventsCount := alertFields[5].Descriptor()
47 // alert.DefaultEventsCount holds the default value on creation for the eventsCount field.
48 alert.DefaultEventsCount = alertDescEventsCount.Default.(int32)
49 // alertDescStartedAt is the schema descriptor for startedAt field.
50 alertDescStartedAt := alertFields[6].Descriptor()
51 // alert.DefaultStartedAt holds the default value on creation for the startedAt field.
52 alert.DefaultStartedAt = alertDescStartedAt.Default.(func() time.Time)
53 // alertDescStoppedAt is the schema descriptor for stoppedAt field.
54 alertDescStoppedAt := alertFields[7].Descriptor()
55 // alert.DefaultStoppedAt holds the default value on creation for the stoppedAt field.
56 alert.DefaultStoppedAt = alertDescStoppedAt.Default.(func() time.Time)
57 // alertDescSimulated is the schema descriptor for simulated field.
58 alertDescSimulated := alertFields[21].Descriptor()
59 // alert.DefaultSimulated holds the default value on creation for the simulated field.
60 alert.DefaultSimulated = alertDescSimulated.Default.(bool)
61 allowlistFields := schema.AllowList{}.Fields()
62 _ = allowlistFields
63 // allowlistDescCreatedAt is the schema descriptor for created_at field.
64 allowlistDescCreatedAt := allowlistFields[0].Descriptor()
65 // allowlist.DefaultCreatedAt holds the default value on creation for the created_at field.
66 allowlist.DefaultCreatedAt = allowlistDescCreatedAt.Default.(func() time.Time)
67 // allowlistDescUpdatedAt is the schema descriptor for updated_at field.
68 allowlistDescUpdatedAt := allowlistFields[1].Descriptor()
69 // allowlist.DefaultUpdatedAt holds the default value on creation for the updated_at field.
70 allowlist.DefaultUpdatedAt = allowlistDescUpdatedAt.Default.(func() time.Time)
71 // allowlist.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
72 allowlist.UpdateDefaultUpdatedAt = allowlistDescUpdatedAt.UpdateDefault.(func() time.Time)
73 allowlistitemFields := schema.AllowListItem{}.Fields()
74 _ = allowlistitemFields
75 // allowlistitemDescCreatedAt is the schema descriptor for created_at field.
76 allowlistitemDescCreatedAt := allowlistitemFields[0].Descriptor()
77 // allowlistitem.DefaultCreatedAt holds the default value on creation for the created_at field.
78 allowlistitem.DefaultCreatedAt = allowlistitemDescCreatedAt.Default.(func() time.Time)
79 // allowlistitemDescUpdatedAt is the schema descriptor for updated_at field.
80 allowlistitemDescUpdatedAt := allowlistitemFields[1].Descriptor()
81 // allowlistitem.DefaultUpdatedAt holds the default value on creation for the updated_at field.

Callers 6

loadDecisionsMethod · 0.70
loadEventsMethod · 0.70
loadMetasMethod · 0.70
loadAllowlistItemsMethod · 0.70
loadAlertsMethod · 0.70
loadAllowlistMethod · 0.70

Calls 2

FieldsMethod · 0.45
DescriptorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…