-
Notifications
You must be signed in to change notification settings - Fork 39
/
types.go
473 lines (410 loc) · 11.6 KB
/
types.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
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
package common
import (
"time"
)
type AccessType int
const (
DB_BOTH AccessType = iota
DB_PRIVATE
DB_PUBLIC
)
type ActivityRange string
const (
TODAY ActivityRange = "today"
THIS_WEEK = "week"
THIS_MONTH = "month"
ALL_TIME = "all"
)
type ForkType int
const (
SPACE ForkType = iota
ROOT
STEM
BRANCH
END
)
type ValType int
const (
Binary ValType = iota
Image
Null
Text
Integer
Float
)
// Number of rows to display by default on the database page
const DefaultNumDisplayRows = 25
// The maximum database size accepted for upload (in MB)
const MaxDatabaseSize = 100
// The number of leading characters of a files' sha256 used as the Minio folder name
// eg: When set to 6, then "34f4255a737156147fbd0a44323a895d18ade79d4db521564d1b0dbb8764cbbc"
// -> Minio folder: "34f425"
// -> Minio filename: "5a737156147fbd0a44323a895d18ade79d4db521564d1b0dbb8764cbbc"
const MinioFolderChars = 6
// ************************
// Configuration file types
// Configuration file
type TomlConfig struct {
Admin AdminInfo
Auth0 Auth0Info
DB4S DB4SInfo
Environment EnvInfo
DiskCache DiskCacheInfo
Event EventProcessingInfo
License LicenseInfo
Memcache MemcacheInfo
Minio MinioInfo
Pg PGInfo
Sign SigningInfo
Web WebInfo
}
// Config info for the admin server
type AdminInfo struct {
Certificate string
CertificateKey string `toml:"certificate_key"`
HTTPS bool
Server string
}
// Auth0 connection parameters
type Auth0Info struct {
ClientID string
ClientSecret string
Domain string
}
// Configuration info for the DB4S end point
type DB4SInfo struct {
CAChain string `toml:"ca_chain"`
Certificate string
CertificateKey string `toml:"certificate_key"`
Port int
Server string
}
// Disk cache info
type DiskCacheInfo struct {
Directory string
}
// Environment info
type EnvInfo struct {
Environment string
}
// Event processing loop
type EventProcessingInfo struct {
Delay time.Duration `toml:"delay"`
EmailQueueDir string `toml:"email_queue_dir"`
EmailQueueProcessingDelay time.Duration `toml:"email_queue_processing_delay"`
}
// Path to the license files
type LicenseInfo struct {
LicenseDir string `toml:"license_dir"`
}
// Memcached connection parameters
type MemcacheInfo struct {
DefaultCacheTime int `toml:"default_cache_time"`
Server string `toml:"server"`
ViewCountFlushDelay time.Duration `toml:"view_count_flush_delay"`
}
// Minio connection parameters
type MinioInfo struct {
AccessKey string `toml:"access_key"`
HTTPS bool
Secret string
Server string
}
// PostgreSQL connection parameters
type PGInfo struct {
Database string
NumConnections int `toml:"num_connections"`
Port int
Password string
Server string
SSL bool
Username string
}
// Used for signing DB4S client certificates
type SigningInfo struct {
CertDaysValid int `toml:"cert_days_valid"`
IntermediateCert string `toml:"intermediate_cert"`
IntermediateKey string `toml:"intermediate_key"`
}
type WebInfo struct {
BaseDir string `toml:"base_dir"`
BindAddress string `toml:"bind_address"`
Certificate string `toml:"certificate"`
CertificateKey string `toml:"certificate_key"`
RequestLog string `toml:"request_log"`
ServerName string `toml:"server_name"`
SessionStorePassword string `toml:"session_store_password"`
}
// End of configuration file types
// *******************************
type ActivityRow struct {
Count int `json:"count"`
DBName string `json:"dbname"`
Owner string `json:"owner"`
}
type ActivityStats struct {
Downloads []ActivityRow
Forked []ActivityRow
Starred []ActivityRow
Uploads []UploadRow
Viewed []ActivityRow
}
type Auth0Set struct {
CallbackURL string
ClientID string
Domain string
}
type BranchEntry struct {
Commit string `json:"commit"`
CommitCount int `json:"commit_count"`
Description string `json:"description"`
}
type CommitData struct {
AuthorAvatar string `json:"author_avatar"`
AuthorEmail string `json:"author_email"`
AuthorName string `json:"author_name"`
AuthorUsername string `json:"author_username"`
ID string `json:"id"`
LicenceChange string `json:"licence_change"`
Message string `json:"message"`
Timestamp time.Time `json:"timestamp"`
}
type CommitEntry struct {
AuthorEmail string `json:"author_email"`
AuthorName string `json:"author_name"`
CommitterEmail string `json:"committer_email"`
CommitterName string `json:"committer_name"`
ID string `json:"id"`
Message string `json:"message"`
OtherParents []string `json:"other_parents"`
Parent string `json:"parent"`
Timestamp time.Time `json:"timestamp"`
Tree DBTree `json:"tree"`
}
type DataValue struct {
Name string
Type ValType
Value interface{}
}
type DataRow []DataValue
type DBEntry struct {
Folder string
DateEntry time.Time
DBName string
Owner string
OwnerDisplayName string `json:"display_name"`
}
type DBTreeEntryType string
const (
TREE DBTreeEntryType = "tree"
DATABASE = "db"
LICENCE = "licence"
)
type DBTree struct {
ID string `json:"id"`
Entries []DBTreeEntry `json:"entries"`
}
type DBTreeEntry struct {
EntryType DBTreeEntryType `json:"entry_type"`
LastModified time.Time `json:"last_modified"`
LicenceSHA string `json:"licence"`
Name string `json:"name"`
Sha256 string `json:"sha256"`
Size int `json:"size"`
}
type DBInfo struct {
Branch string
Branches int
BranchList []string
Commits int
CommitID string
Contributors int
Database string
DateCreated time.Time
DBEntry DBTreeEntry
DefaultBranch string
DefaultTable string
Discussions int
Folder string
Forks int
FullDesc string
LastModified time.Time
Licence string
LicenceURL string
MRs int
OneLineDesc string
Public bool
Releases int
SHA256 string
Size int
SourceURL string
Stars int
Tables []string
Tags int
Watchers int
}
type DiscussionCommentType string
const (
TEXT DiscussionCommentType = "txt"
CLOSE = "cls"
REOPEN = "rop"
)
type DiscussionCommentEntry struct {
AvatarURL string `json:"avatar_url"`
Body string `json:"body"`
BodyRendered string `json:"body_rendered"`
Commenter string `json:"commenter"`
DateCreated time.Time `json:"creation_date"`
EntryType DiscussionCommentType `json:"entry_type"`
ID int `json:"com_id"`
}
type DiscussionType int
const (
DISCUSSION DiscussionType = 0 // These are not iota, as it would be seriously bad for these numbers to change
MERGE_REQUEST = 1
)
type DiscussionEntry struct {
AvatarURL string `json:"avatar_url"`
Body string `json:"body"`
BodyRendered string `json:"body_rendered"`
CommentCount int `json:"comment_count"`
Creator string `json:"creator"`
DateCreated time.Time `json:"creation_date"`
ID int `json:"disc_id"`
LastModified time.Time `json:"last_modified"`
MRDetails MergeRequestEntry `json:"mr_details"`
Open bool `json:"open"`
Title string `json:"title"`
Type DiscussionType `json:"discussion_type"`
}
type EventDetails struct {
DBName string `json:"database_name"`
DiscID int `json:"discussion_id"`
Folder string `json:"database_folder"`
ID string `json:"event_id"`
Message string `json:"message"`
Owner string `json:"database_owner"`
Timestamp time.Time `json:"event_timestamp"`
Title string `json:"title"`
Type EventType `json:"event_type"`
URL string `json:"event_url"`
UserName string `json:"username"`
}
type EventType int
const (
EVENT_NEW_DISCUSSION EventType = 0 // These are not iota, as it would be seriously bad for these numbers to change
EVENT_NEW_MERGE_REQUEST = 1
EVENT_NEW_COMMENT = 2
EVENT_NEW_RELEASE = 3
)
type ForkEntry struct {
DBName string `json:"database_name"`
Folder string `json:"database_folder"`
ForkedFrom int `json:"forked_from"`
IconList []ForkType `json:"icon_list"`
ID int `json:"id"`
Owner string `json:"database_owner"`
Processed bool `json:"processed"`
Public bool `json:"public"`
Deleted bool `json:"deleted"`
}
type LicenceEntry struct {
FileFormat string `json:"file_format"`
FullName string `json:"full_name"`
Order int `json:"order"`
Sha256 string `json:"sha256"`
URL string `json:"url"`
}
type MergeRequestState int
const (
OPEN MergeRequestState = 0 // These are not iota, as it would be seriously bad for these numbers to change
CLOSED_WITH_MERGE = 1
CLOSED_WITHOUT_MERGE = 2
)
type MergeRequestEntry struct {
Commits []CommitEntry `json:"commits"`
DestBranch string `json:"destination_branch"`
SourceBranch string `json:"source_branch"`
SourceDBID int64 `json:"source_database_id"`
SourceDBName string `json:"source_database_name"`
SourceFolder string `json:"source_folder"`
SourceOwner string `json:"source_owner"`
State MergeRequestState `json:"state"`
}
type MetaInfo struct {
AvatarURL string
Database string
ForkDatabase string
ForkDeleted bool
ForkFolder string
ForkOwner string
LoggedInUser string
NumStatusUpdates int
Owner string
Protocol string
Server string
Title string
}
type ReleaseEntry struct {
Commit string `json:"commit"`
Date time.Time `json:"date"`
Description string `json:"description"`
ReleaserEmail string `json:"email"`
ReleaserName string `json:"name"`
Size int `json:"size"`
}
type SQLiteDBinfo struct {
Info DBInfo
MaxRows int
MinioBkt string
MinioId string
}
type SQLiteRecordSet struct {
ColCount int
ColNames []string
Offset int
Records []DataRow
RowCount int
SortCol string
SortDir string
Tablename string
TotalRows int
}
type StatusUpdateEntry struct {
DiscID int `json:"discussion_id"`
Title string `json:"title"`
URL string `json:"event_url"`
}
type TagEntry struct {
Commit string `json:"commit"`
Date time.Time `json:"date"`
Description string `json:"description"`
TaggerEmail string `json:"email"`
TaggerName string `json:"name"`
}
type UploadRow struct {
DBName string `json:"dbname"`
Owner string `json:"owner"`
UploadDate time.Time `json:"upload_date"`
}
type WhereClause struct {
Column string
Type string
Value string
}
type UserInfo struct {
FullName string `json:"full_name"`
LastModified time.Time
Username string
}
type UserDetails struct {
AvatarURL string
ClientCert []byte
DateJoined time.Time
DisplayName string
Email string
Password string
PHash []byte
PVerify string
Username string
}