/
namespace.go
290 lines (260 loc) · 9.68 KB
/
namespace.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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"strings"
"time"
"entgo.io/ent/dialect/sql"
"github.com/direktiv/direktiv/pkg/flow/ent/namespace"
"github.com/google/uuid"
)
// Namespace is the model entity for the Namespace schema.
type Namespace struct {
config `json:"-"`
// ID of the ent.
ID uuid.UUID `json:"id,omitempty"`
// CreatedAt holds the value of the "created_at" field.
CreatedAt time.Time `json:"created_at,omitempty"`
// UpdatedAt holds the value of the "updated_at" field.
UpdatedAt time.Time `json:"updated_at,omitempty"`
// Config holds the value of the "config" field.
Config string `json:"config,omitempty"`
// Name holds the value of the "name" field.
Name string `json:"name,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the NamespaceQuery when eager-loading is set.
Edges NamespaceEdges `json:"edges"`
}
// NamespaceEdges holds the relations/edges for other nodes in the graph.
type NamespaceEdges struct {
// Inodes holds the value of the inodes edge.
Inodes []*Inode `json:"inodes,omitempty"`
// Workflows holds the value of the workflows edge.
Workflows []*Workflow `json:"workflows,omitempty"`
// Mirrors holds the value of the mirrors edge.
Mirrors []*Mirror `json:"mirrors,omitempty"`
// MirrorActivities holds the value of the mirror_activities edge.
MirrorActivities []*MirrorActivity `json:"mirror_activities,omitempty"`
// Instances holds the value of the instances edge.
Instances []*Instance `json:"instances,omitempty"`
// Logs holds the value of the logs edge.
Logs []*LogMsg `json:"logs,omitempty"`
// Vars holds the value of the vars edge.
Vars []*VarRef `json:"vars,omitempty"`
// Cloudevents holds the value of the cloudevents edge.
Cloudevents []*CloudEvents `json:"cloudevents,omitempty"`
// Namespacelisteners holds the value of the namespacelisteners edge.
Namespacelisteners []*Events `json:"namespacelisteners,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [9]bool
}
// InodesOrErr returns the Inodes value or an error if the edge
// was not loaded in eager-loading.
func (e NamespaceEdges) InodesOrErr() ([]*Inode, error) {
if e.loadedTypes[0] {
return e.Inodes, nil
}
return nil, &NotLoadedError{edge: "inodes"}
}
// WorkflowsOrErr returns the Workflows value or an error if the edge
// was not loaded in eager-loading.
func (e NamespaceEdges) WorkflowsOrErr() ([]*Workflow, error) {
if e.loadedTypes[1] {
return e.Workflows, nil
}
return nil, &NotLoadedError{edge: "workflows"}
}
// MirrorsOrErr returns the Mirrors value or an error if the edge
// was not loaded in eager-loading.
func (e NamespaceEdges) MirrorsOrErr() ([]*Mirror, error) {
if e.loadedTypes[2] {
return e.Mirrors, nil
}
return nil, &NotLoadedError{edge: "mirrors"}
}
// MirrorActivitiesOrErr returns the MirrorActivities value or an error if the edge
// was not loaded in eager-loading.
func (e NamespaceEdges) MirrorActivitiesOrErr() ([]*MirrorActivity, error) {
if e.loadedTypes[3] {
return e.MirrorActivities, nil
}
return nil, &NotLoadedError{edge: "mirror_activities"}
}
// InstancesOrErr returns the Instances value or an error if the edge
// was not loaded in eager-loading.
func (e NamespaceEdges) InstancesOrErr() ([]*Instance, error) {
if e.loadedTypes[4] {
return e.Instances, nil
}
return nil, &NotLoadedError{edge: "instances"}
}
// LogsOrErr returns the Logs value or an error if the edge
// was not loaded in eager-loading.
func (e NamespaceEdges) LogsOrErr() ([]*LogMsg, error) {
if e.loadedTypes[5] {
return e.Logs, nil
}
return nil, &NotLoadedError{edge: "logs"}
}
// VarsOrErr returns the Vars value or an error if the edge
// was not loaded in eager-loading.
func (e NamespaceEdges) VarsOrErr() ([]*VarRef, error) {
if e.loadedTypes[6] {
return e.Vars, nil
}
return nil, &NotLoadedError{edge: "vars"}
}
// CloudeventsOrErr returns the Cloudevents value or an error if the edge
// was not loaded in eager-loading.
func (e NamespaceEdges) CloudeventsOrErr() ([]*CloudEvents, error) {
if e.loadedTypes[7] {
return e.Cloudevents, nil
}
return nil, &NotLoadedError{edge: "cloudevents"}
}
// NamespacelistenersOrErr returns the Namespacelisteners value or an error if the edge
// was not loaded in eager-loading.
func (e NamespaceEdges) NamespacelistenersOrErr() ([]*Events, error) {
if e.loadedTypes[8] {
return e.Namespacelisteners, nil
}
return nil, &NotLoadedError{edge: "namespacelisteners"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Namespace) scanValues(columns []string) ([]interface{}, error) {
values := make([]interface{}, len(columns))
for i := range columns {
switch columns[i] {
case namespace.FieldConfig, namespace.FieldName:
values[i] = new(sql.NullString)
case namespace.FieldCreatedAt, namespace.FieldUpdatedAt:
values[i] = new(sql.NullTime)
case namespace.FieldID:
values[i] = new(uuid.UUID)
default:
return nil, fmt.Errorf("unexpected column %q for type Namespace", columns[i])
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the Namespace fields.
func (n *Namespace) assignValues(columns []string, values []interface{}) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case namespace.FieldID:
if value, ok := values[i].(*uuid.UUID); !ok {
return fmt.Errorf("unexpected type %T for field id", values[i])
} else if value != nil {
n.ID = *value
}
case namespace.FieldCreatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field created_at", values[i])
} else if value.Valid {
n.CreatedAt = value.Time
}
case namespace.FieldUpdatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
} else if value.Valid {
n.UpdatedAt = value.Time
}
case namespace.FieldConfig:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field config", values[i])
} else if value.Valid {
n.Config = value.String
}
case namespace.FieldName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field name", values[i])
} else if value.Valid {
n.Name = value.String
}
}
}
return nil
}
// QueryInodes queries the "inodes" edge of the Namespace entity.
func (n *Namespace) QueryInodes() *InodeQuery {
return (&NamespaceClient{config: n.config}).QueryInodes(n)
}
// QueryWorkflows queries the "workflows" edge of the Namespace entity.
func (n *Namespace) QueryWorkflows() *WorkflowQuery {
return (&NamespaceClient{config: n.config}).QueryWorkflows(n)
}
// QueryMirrors queries the "mirrors" edge of the Namespace entity.
func (n *Namespace) QueryMirrors() *MirrorQuery {
return (&NamespaceClient{config: n.config}).QueryMirrors(n)
}
// QueryMirrorActivities queries the "mirror_activities" edge of the Namespace entity.
func (n *Namespace) QueryMirrorActivities() *MirrorActivityQuery {
return (&NamespaceClient{config: n.config}).QueryMirrorActivities(n)
}
// QueryInstances queries the "instances" edge of the Namespace entity.
func (n *Namespace) QueryInstances() *InstanceQuery {
return (&NamespaceClient{config: n.config}).QueryInstances(n)
}
// QueryLogs queries the "logs" edge of the Namespace entity.
func (n *Namespace) QueryLogs() *LogMsgQuery {
return (&NamespaceClient{config: n.config}).QueryLogs(n)
}
// QueryVars queries the "vars" edge of the Namespace entity.
func (n *Namespace) QueryVars() *VarRefQuery {
return (&NamespaceClient{config: n.config}).QueryVars(n)
}
// QueryCloudevents queries the "cloudevents" edge of the Namespace entity.
func (n *Namespace) QueryCloudevents() *CloudEventsQuery {
return (&NamespaceClient{config: n.config}).QueryCloudevents(n)
}
// QueryNamespacelisteners queries the "namespacelisteners" edge of the Namespace entity.
func (n *Namespace) QueryNamespacelisteners() *EventsQuery {
return (&NamespaceClient{config: n.config}).QueryNamespacelisteners(n)
}
// Update returns a builder for updating this Namespace.
// Note that you need to call Namespace.Unwrap() before calling this method if this Namespace
// was returned from a transaction, and the transaction was committed or rolled back.
func (n *Namespace) Update() *NamespaceUpdateOne {
return (&NamespaceClient{config: n.config}).UpdateOne(n)
}
// Unwrap unwraps the Namespace entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (n *Namespace) Unwrap() *Namespace {
_tx, ok := n.config.driver.(*txDriver)
if !ok {
panic("ent: Namespace is not a transactional entity")
}
n.config.driver = _tx.drv
return n
}
// String implements the fmt.Stringer.
func (n *Namespace) String() string {
var builder strings.Builder
builder.WriteString("Namespace(")
builder.WriteString(fmt.Sprintf("id=%v, ", n.ID))
builder.WriteString("created_at=")
builder.WriteString(n.CreatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("updated_at=")
builder.WriteString(n.UpdatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("config=")
builder.WriteString(n.Config)
builder.WriteString(", ")
builder.WriteString("name=")
builder.WriteString(n.Name)
builder.WriteByte(')')
return builder.String()
}
// Namespaces is a parsable slice of Namespace.
type Namespaces []*Namespace
func (n Namespaces) config(cfg config) {
for _i := range n {
n[_i].config = cfg
}
}