This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
/
models.go
412 lines (360 loc) · 9.49 KB
/
models.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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.20.0
package sqlc
import (
"database/sql/driver"
"fmt"
"time"
"github.com/google/uuid"
"github.com/jackc/pgtype"
"github.com/nais/teams-backend/pkg/slug"
)
type ReconcilerConfigKey string
const (
ReconcilerConfigKeyAzureClientID ReconcilerConfigKey = "azure:client_id"
ReconcilerConfigKeyAzureClientSecret ReconcilerConfigKey = "azure:client_secret"
ReconcilerConfigKeyAzureTenantID ReconcilerConfigKey = "azure:tenant_id"
)
func (e *ReconcilerConfigKey) Scan(src interface{}) error {
switch s := src.(type) {
case []byte:
*e = ReconcilerConfigKey(s)
case string:
*e = ReconcilerConfigKey(s)
default:
return fmt.Errorf("unsupported scan type for ReconcilerConfigKey: %T", src)
}
return nil
}
type NullReconcilerConfigKey struct {
ReconcilerConfigKey ReconcilerConfigKey
Valid bool // Valid is true if ReconcilerConfigKey is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullReconcilerConfigKey) Scan(value interface{}) error {
if value == nil {
ns.ReconcilerConfigKey, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.ReconcilerConfigKey.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullReconcilerConfigKey) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return string(ns.ReconcilerConfigKey), nil
}
func (e ReconcilerConfigKey) Valid() bool {
switch e {
case ReconcilerConfigKeyAzureClientID,
ReconcilerConfigKeyAzureClientSecret,
ReconcilerConfigKeyAzureTenantID:
return true
}
return false
}
func AllReconcilerConfigKeyValues() []ReconcilerConfigKey {
return []ReconcilerConfigKey{
ReconcilerConfigKeyAzureClientID,
ReconcilerConfigKeyAzureClientSecret,
ReconcilerConfigKeyAzureTenantID,
}
}
type ReconcilerName string
const (
ReconcilerNameAzureGroup ReconcilerName = "azure:group"
ReconcilerNameGithubTeam ReconcilerName = "github:team"
ReconcilerNameGoogleGcpGar ReconcilerName = "google:gcp:gar"
ReconcilerNameGoogleGcpProject ReconcilerName = "google:gcp:project"
ReconcilerNameGoogleWorkspaceAdmin ReconcilerName = "google:workspace-admin"
ReconcilerNameNaisDependencytrack ReconcilerName = "nais:dependencytrack"
ReconcilerNameNaisDeploy ReconcilerName = "nais:deploy"
ReconcilerNameNaisNamespace ReconcilerName = "nais:namespace"
)
func (e *ReconcilerName) Scan(src interface{}) error {
switch s := src.(type) {
case []byte:
*e = ReconcilerName(s)
case string:
*e = ReconcilerName(s)
default:
return fmt.Errorf("unsupported scan type for ReconcilerName: %T", src)
}
return nil
}
type NullReconcilerName struct {
ReconcilerName ReconcilerName
Valid bool // Valid is true if ReconcilerName is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullReconcilerName) Scan(value interface{}) error {
if value == nil {
ns.ReconcilerName, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.ReconcilerName.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullReconcilerName) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return string(ns.ReconcilerName), nil
}
func (e ReconcilerName) Valid() bool {
switch e {
case ReconcilerNameAzureGroup,
ReconcilerNameGithubTeam,
ReconcilerNameGoogleGcpGar,
ReconcilerNameGoogleGcpProject,
ReconcilerNameGoogleWorkspaceAdmin,
ReconcilerNameNaisDependencytrack,
ReconcilerNameNaisDeploy,
ReconcilerNameNaisNamespace:
return true
}
return false
}
func AllReconcilerNameValues() []ReconcilerName {
return []ReconcilerName{
ReconcilerNameAzureGroup,
ReconcilerNameGithubTeam,
ReconcilerNameGoogleGcpGar,
ReconcilerNameGoogleGcpProject,
ReconcilerNameGoogleWorkspaceAdmin,
ReconcilerNameNaisDependencytrack,
ReconcilerNameNaisDeploy,
ReconcilerNameNaisNamespace,
}
}
type RepositoryAuthorizationEnum string
const (
RepositoryAuthorizationEnumDeploy RepositoryAuthorizationEnum = "deploy"
)
func (e *RepositoryAuthorizationEnum) Scan(src interface{}) error {
switch s := src.(type) {
case []byte:
*e = RepositoryAuthorizationEnum(s)
case string:
*e = RepositoryAuthorizationEnum(s)
default:
return fmt.Errorf("unsupported scan type for RepositoryAuthorizationEnum: %T", src)
}
return nil
}
type NullRepositoryAuthorizationEnum struct {
RepositoryAuthorizationEnum RepositoryAuthorizationEnum
Valid bool // Valid is true if RepositoryAuthorizationEnum is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullRepositoryAuthorizationEnum) Scan(value interface{}) error {
if value == nil {
ns.RepositoryAuthorizationEnum, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.RepositoryAuthorizationEnum.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullRepositoryAuthorizationEnum) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return string(ns.RepositoryAuthorizationEnum), nil
}
func (e RepositoryAuthorizationEnum) Valid() bool {
switch e {
case RepositoryAuthorizationEnumDeploy:
return true
}
return false
}
func AllRepositoryAuthorizationEnumValues() []RepositoryAuthorizationEnum {
return []RepositoryAuthorizationEnum{
RepositoryAuthorizationEnumDeploy,
}
}
type RoleName string
const (
RoleNameAdmin RoleName = "Admin"
RoleNameDeploykeyviewer RoleName = "Deploy key viewer"
RoleNameServiceaccountcreator RoleName = "Service account creator"
RoleNameServiceaccountowner RoleName = "Service account owner"
RoleNameSynchronizer RoleName = "Synchronizer"
RoleNameTeamcreator RoleName = "Team creator"
RoleNameTeammember RoleName = "Team member"
RoleNameTeamowner RoleName = "Team owner"
RoleNameTeamviewer RoleName = "Team viewer"
RoleNameUseradmin RoleName = "User admin"
RoleNameUserviewer RoleName = "User viewer"
)
func (e *RoleName) Scan(src interface{}) error {
switch s := src.(type) {
case []byte:
*e = RoleName(s)
case string:
*e = RoleName(s)
default:
return fmt.Errorf("unsupported scan type for RoleName: %T", src)
}
return nil
}
type NullRoleName struct {
RoleName RoleName
Valid bool // Valid is true if RoleName is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullRoleName) Scan(value interface{}) error {
if value == nil {
ns.RoleName, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.RoleName.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullRoleName) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return string(ns.RoleName), nil
}
func (e RoleName) Valid() bool {
switch e {
case RoleNameAdmin,
RoleNameDeploykeyviewer,
RoleNameServiceaccountcreator,
RoleNameServiceaccountowner,
RoleNameSynchronizer,
RoleNameTeamcreator,
RoleNameTeammember,
RoleNameTeamowner,
RoleNameTeamviewer,
RoleNameUseradmin,
RoleNameUserviewer:
return true
}
return false
}
func AllRoleNameValues() []RoleName {
return []RoleName{
RoleNameAdmin,
RoleNameDeploykeyviewer,
RoleNameServiceaccountcreator,
RoleNameServiceaccountowner,
RoleNameSynchronizer,
RoleNameTeamcreator,
RoleNameTeammember,
RoleNameTeamowner,
RoleNameTeamviewer,
RoleNameUseradmin,
RoleNameUserviewer,
}
}
type ApiKey struct {
ApiKey string
ServiceAccountID uuid.UUID
}
type AuditLog struct {
ID uuid.UUID
CreatedAt time.Time
CorrelationID uuid.UUID
ComponentName string
Actor *string
Action string
Message string
TargetType string
TargetIdentifier string
}
type FirstRun struct {
FirstRun bool
}
type Reconciler struct {
Name ReconcilerName
DisplayName string
Description string
Enabled bool
RunOrder int32
}
type ReconcilerConfig struct {
Reconciler ReconcilerName
Key ReconcilerConfigKey
DisplayName string
Description string
Value *string
Secret bool
}
type ReconcilerError struct {
ID int64
CorrelationID uuid.UUID
Reconciler ReconcilerName
CreatedAt time.Time
ErrorMessage string
TeamSlug slug.Slug
}
type ReconcilerOptOut struct {
TeamSlug slug.Slug
UserID uuid.UUID
ReconcilerName ReconcilerName
}
type ReconcilerState struct {
Reconciler ReconcilerName
State pgtype.JSONB
TeamSlug slug.Slug
}
type RepositoryAuthorization struct {
TeamSlug string
GithubRepository string
RepositoryAuthorization RepositoryAuthorizationEnum
}
type ServiceAccount struct {
ID uuid.UUID
Name string
}
type ServiceAccountRole struct {
ID int32
RoleName RoleName
ServiceAccountID uuid.UUID
TargetTeamSlug *slug.Slug
TargetServiceAccountID *uuid.UUID
}
type Session struct {
ID uuid.UUID
UserID uuid.UUID
Expires time.Time
}
type SlackAlertsChannel struct {
TeamSlug slug.Slug
Environment string
ChannelName string
}
type Team struct {
Slug slug.Slug
Purpose string
LastSuccessfulSync *time.Time
SlackChannel string
}
type TeamDeleteKey struct {
Key uuid.UUID
TeamSlug slug.Slug
CreatedAt time.Time
CreatedBy uuid.UUID
ConfirmedAt *time.Time
}
type User struct {
ID uuid.UUID
Email string
Name string
ExternalID string
}
type UserRole struct {
ID int32
RoleName RoleName
UserID uuid.UUID
TargetTeamSlug *slug.Slug
TargetServiceAccountID *uuid.UUID
}