-
Notifications
You must be signed in to change notification settings - Fork 38
/
templateversion.go
274 lines (247 loc) · 10.5 KB
/
templateversion.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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
// SPDX-FileCopyrightText: 2024 Seal, Inc
// SPDX-License-Identifier: Apache-2.0
// Code generated by "walrus". DO NOT EDIT.
package templateversion
import (
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"golang.org/x/exp/slices"
"github.com/seal-io/walrus/pkg/dao/types"
)
const (
// Label holds the string label denoting the templateversion type in the database.
Label = "template_version"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldCreateTime holds the string denoting the create_time field in the database.
FieldCreateTime = "create_time"
// FieldUpdateTime holds the string denoting the update_time field in the database.
FieldUpdateTime = "update_time"
// FieldTemplateID holds the string denoting the template_id field in the database.
FieldTemplateID = "template_id"
// FieldName holds the string denoting the name field in the database.
FieldName = "name"
// FieldVersion holds the string denoting the version field in the database.
FieldVersion = "version"
// FieldSource holds the string denoting the source field in the database.
FieldSource = "source"
// FieldSchema holds the string denoting the schema field in the database.
FieldSchema = "schema"
// FieldOriginalUISchema holds the string denoting the original_ui_schema field in the database.
FieldOriginalUISchema = "original_ui_schema"
// FieldUISchema holds the string denoting the ui_schema field in the database.
FieldUISchema = "ui_schema"
// FieldSchemaDefaultValue holds the string denoting the schema_default_value field in the database.
FieldSchemaDefaultValue = "schema_default_value"
// FieldProjectID holds the string denoting the project_id field in the database.
FieldProjectID = "project_id"
// EdgeTemplate holds the string denoting the template edge name in mutations.
EdgeTemplate = "template"
// EdgeResources holds the string denoting the resources edge name in mutations.
EdgeResources = "resources"
// EdgeResourceDefinitions holds the string denoting the resource_definitions edge name in mutations.
EdgeResourceDefinitions = "resource_definitions"
// EdgeProject holds the string denoting the project edge name in mutations.
EdgeProject = "project"
// Table holds the table name of the templateversion in the database.
Table = "template_versions"
// TemplateTable is the table that holds the template relation/edge.
TemplateTable = "template_versions"
// TemplateInverseTable is the table name for the Template entity.
// It exists in this package in order to avoid circular dependency with the "template" package.
TemplateInverseTable = "templates"
// TemplateColumn is the table column denoting the template relation/edge.
TemplateColumn = "template_id"
// ResourcesTable is the table that holds the resources relation/edge.
ResourcesTable = "resources"
// ResourcesInverseTable is the table name for the Resource entity.
// It exists in this package in order to avoid circular dependency with the "resource" package.
ResourcesInverseTable = "resources"
// ResourcesColumn is the table column denoting the resources relation/edge.
ResourcesColumn = "template_id"
// ResourceDefinitionsTable is the table that holds the resource_definitions relation/edge.
ResourceDefinitionsTable = "resource_definition_matching_rules"
// ResourceDefinitionsInverseTable is the table name for the ResourceDefinitionMatchingRule entity.
// It exists in this package in order to avoid circular dependency with the "resourcedefinitionmatchingrule" package.
ResourceDefinitionsInverseTable = "resource_definition_matching_rules"
// ResourceDefinitionsColumn is the table column denoting the resource_definitions relation/edge.
ResourceDefinitionsColumn = "template_id"
// ProjectTable is the table that holds the project relation/edge.
ProjectTable = "template_versions"
// ProjectInverseTable is the table name for the Project entity.
// It exists in this package in order to avoid circular dependency with the "project" package.
ProjectInverseTable = "projects"
// ProjectColumn is the table column denoting the project relation/edge.
ProjectColumn = "project_id"
)
// Columns holds all SQL columns for templateversion fields.
var Columns = []string{
FieldID,
FieldCreateTime,
FieldUpdateTime,
FieldTemplateID,
FieldName,
FieldVersion,
FieldSource,
FieldSchema,
FieldOriginalUISchema,
FieldUISchema,
FieldSchemaDefaultValue,
FieldProjectID,
}
// 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/seal-io/walrus/pkg/dao/model/runtime"
var (
Hooks [1]ent.Hook
Interceptors [1]ent.Interceptor
// DefaultCreateTime holds the default value on creation for the "create_time" field.
DefaultCreateTime func() time.Time
// DefaultUpdateTime holds the default value on creation for the "update_time" field.
DefaultUpdateTime func() time.Time
// UpdateDefaultUpdateTime holds the default value on update for the "update_time" field.
UpdateDefaultUpdateTime func() time.Time
// TemplateIDValidator is a validator for the "template_id" field. It is called by the builders before save.
TemplateIDValidator func(string) error
// NameValidator is a validator for the "name" field. It is called by the builders before save.
NameValidator func(string) error
// VersionValidator is a validator for the "version" field. It is called by the builders before save.
VersionValidator func(string) error
// SourceValidator is a validator for the "source" field. It is called by the builders before save.
SourceValidator func(string) error
// DefaultSchema holds the default value on creation for the "schema" field.
DefaultSchema types.TemplateVersionSchema
// DefaultOriginalUISchema holds the default value on creation for the "original_ui_schema" field.
DefaultOriginalUISchema types.UISchema
// DefaultUISchema holds the default value on creation for the "ui_schema" field.
DefaultUISchema types.UISchema
)
// OrderOption defines the ordering options for the TemplateVersion 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()
}
// ByCreateTime orders the results by the create_time field.
func ByCreateTime(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreateTime, opts...).ToFunc()
}
// ByUpdateTime orders the results by the update_time field.
func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUpdateTime, opts...).ToFunc()
}
// ByTemplateID orders the results by the template_id field.
func ByTemplateID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTemplateID, opts...).ToFunc()
}
// ByName orders the results by the name field.
func ByName(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldName, opts...).ToFunc()
}
// ByVersion orders the results by the version field.
func ByVersion(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldVersion, opts...).ToFunc()
}
// BySource orders the results by the source field.
func BySource(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSource, opts...).ToFunc()
}
// ByProjectID orders the results by the project_id field.
func ByProjectID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldProjectID, opts...).ToFunc()
}
// ByTemplateField orders the results by template field.
func ByTemplateField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newTemplateStep(), sql.OrderByField(field, opts...))
}
}
// ByResourcesCount orders the results by resources count.
func ByResourcesCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newResourcesStep(), opts...)
}
}
// ByResources orders the results by resources terms.
func ByResources(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newResourcesStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
// ByResourceDefinitionsCount orders the results by resource_definitions count.
func ByResourceDefinitionsCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newResourceDefinitionsStep(), opts...)
}
}
// ByResourceDefinitions orders the results by resource_definitions terms.
func ByResourceDefinitions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newResourceDefinitionsStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
// ByProjectField orders the results by project field.
func ByProjectField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newProjectStep(), sql.OrderByField(field, opts...))
}
}
func newTemplateStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(TemplateInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, TemplateTable, TemplateColumn),
)
}
func newResourcesStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(ResourcesInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, ResourcesTable, ResourcesColumn),
)
}
func newResourceDefinitionsStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(ResourceDefinitionsInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, true, ResourceDefinitionsTable, ResourceDefinitionsColumn),
)
}
func newProjectStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(ProjectInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, ProjectTable, ProjectColumn),
)
}
// WithoutFields returns the fields ignored the given list.
func WithoutFields(ignores ...string) []string {
if len(ignores) == 0 {
return slices.Clone(Columns)
}
var s = make(map[string]bool, len(ignores))
for i := range ignores {
s[ignores[i]] = true
}
var r = make([]string, 0, len(Columns)-len(s))
for i := range Columns {
if s[Columns[i]] {
continue
}
r = append(r, Columns[i])
}
return r
}