generated from datumforge/go-template
-
Notifications
You must be signed in to change notification settings - Fork 7
/
hush.go
257 lines (229 loc) · 9.66 KB
/
hush.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
// Code generated by ent, DO NOT EDIT.
package hush
import (
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
const (
// Label holds the string label denoting the hush type in the database.
Label = "hush"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldCreatedAt holds the string denoting the created_at field in the database.
FieldCreatedAt = "created_at"
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
FieldUpdatedAt = "updated_at"
// FieldCreatedBy holds the string denoting the created_by field in the database.
FieldCreatedBy = "created_by"
// FieldUpdatedBy holds the string denoting the updated_by field in the database.
FieldUpdatedBy = "updated_by"
// FieldMappingID holds the string denoting the mapping_id field in the database.
FieldMappingID = "mapping_id"
// FieldDeletedAt holds the string denoting the deleted_at field in the database.
FieldDeletedAt = "deleted_at"
// FieldDeletedBy holds the string denoting the deleted_by field in the database.
FieldDeletedBy = "deleted_by"
// FieldName holds the string denoting the name field in the database.
FieldName = "name"
// FieldDescription holds the string denoting the description field in the database.
FieldDescription = "description"
// FieldKind holds the string denoting the kind field in the database.
FieldKind = "kind"
// FieldSecretName holds the string denoting the secret_name field in the database.
FieldSecretName = "secret_name"
// FieldSecretValue holds the string denoting the secret_value field in the database.
FieldSecretValue = "secret_value"
// EdgeIntegrations holds the string denoting the integrations edge name in mutations.
EdgeIntegrations = "integrations"
// EdgeOrganization holds the string denoting the organization edge name in mutations.
EdgeOrganization = "organization"
// EdgeEvents holds the string denoting the events edge name in mutations.
EdgeEvents = "events"
// Table holds the table name of the hush in the database.
Table = "hushes"
// IntegrationsTable is the table that holds the integrations relation/edge. The primary key declared below.
IntegrationsTable = "integration_secrets"
// IntegrationsInverseTable is the table name for the Integration entity.
// It exists in this package in order to avoid circular dependency with the "integration" package.
IntegrationsInverseTable = "integrations"
// OrganizationTable is the table that holds the organization relation/edge. The primary key declared below.
OrganizationTable = "organization_secrets"
// OrganizationInverseTable is the table name for the Organization entity.
// It exists in this package in order to avoid circular dependency with the "organization" package.
OrganizationInverseTable = "organizations"
// EventsTable is the table that holds the events relation/edge. The primary key declared below.
EventsTable = "hush_events"
// EventsInverseTable is the table name for the Event entity.
// It exists in this package in order to avoid circular dependency with the "event" package.
EventsInverseTable = "events"
)
// Columns holds all SQL columns for hush fields.
var Columns = []string{
FieldID,
FieldCreatedAt,
FieldUpdatedAt,
FieldCreatedBy,
FieldUpdatedBy,
FieldMappingID,
FieldDeletedAt,
FieldDeletedBy,
FieldName,
FieldDescription,
FieldKind,
FieldSecretName,
FieldSecretValue,
}
var (
// IntegrationsPrimaryKey and IntegrationsColumn2 are the table columns denoting the
// primary key for the integrations relation (M2M).
IntegrationsPrimaryKey = []string{"integration_id", "hush_id"}
// OrganizationPrimaryKey and OrganizationColumn2 are the table columns denoting the
// primary key for the organization relation (M2M).
OrganizationPrimaryKey = []string{"organization_id", "hush_id"}
// EventsPrimaryKey and EventsColumn2 are the table columns denoting the
// primary key for the events relation (M2M).
EventsPrimaryKey = []string{"hush_id", "event_id"}
)
// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
for i := range Columns {
if column == Columns[i] {
return true
}
}
return false
}
// Note that the variables below are initialized by the runtime
// package on the initialization of the application. Therefore,
// it should be imported in the main as follows:
//
// import _ "github.com/datumforge/datum/internal/ent/generated/runtime"
var (
Hooks [3]ent.Hook
Interceptors [2]ent.Interceptor
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
DefaultCreatedAt func() time.Time
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
DefaultUpdatedAt func() time.Time
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
UpdateDefaultUpdatedAt func() time.Time
// DefaultMappingID holds the default value on creation for the "mapping_id" field.
DefaultMappingID func() string
// NameValidator is a validator for the "name" field. It is called by the builders before save.
NameValidator func(string) error
// DefaultID holds the default value on creation for the "id" field.
DefaultID func() string
)
// OrderOption defines the ordering options for the Hush queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByCreatedAt orders the results by the created_at field.
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
}
// ByUpdatedAt orders the results by the updated_at field.
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
}
// ByCreatedBy orders the results by the created_by field.
func ByCreatedBy(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreatedBy, opts...).ToFunc()
}
// ByUpdatedBy orders the results by the updated_by field.
func ByUpdatedBy(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUpdatedBy, opts...).ToFunc()
}
// ByMappingID orders the results by the mapping_id field.
func ByMappingID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldMappingID, opts...).ToFunc()
}
// ByDeletedAt orders the results by the deleted_at field.
func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDeletedAt, opts...).ToFunc()
}
// ByDeletedBy orders the results by the deleted_by field.
func ByDeletedBy(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDeletedBy, opts...).ToFunc()
}
// ByName orders the results by the name field.
func ByName(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldName, opts...).ToFunc()
}
// ByDescription orders the results by the description field.
func ByDescription(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDescription, opts...).ToFunc()
}
// ByKind orders the results by the kind field.
func ByKind(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldKind, opts...).ToFunc()
}
// BySecretName orders the results by the secret_name field.
func BySecretName(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSecretName, opts...).ToFunc()
}
// BySecretValue orders the results by the secret_value field.
func BySecretValue(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSecretValue, opts...).ToFunc()
}
// ByIntegrationsCount orders the results by integrations count.
func ByIntegrationsCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newIntegrationsStep(), opts...)
}
}
// ByIntegrations orders the results by integrations terms.
func ByIntegrations(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newIntegrationsStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
// ByOrganizationCount orders the results by organization count.
func ByOrganizationCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newOrganizationStep(), opts...)
}
}
// ByOrganization orders the results by organization terms.
func ByOrganization(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newOrganizationStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
// ByEventsCount orders the results by events count.
func ByEventsCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newEventsStep(), opts...)
}
}
// ByEvents orders the results by events terms.
func ByEvents(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newEventsStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
func newIntegrationsStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(IntegrationsInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2M, true, IntegrationsTable, IntegrationsPrimaryKey...),
)
}
func newOrganizationStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(OrganizationInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2M, true, OrganizationTable, OrganizationPrimaryKey...),
)
}
func newEventsStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(EventsInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2M, false, EventsTable, EventsPrimaryKey...),
)
}