@@ -4,15 +4,14 @@ import (
4
4
"strings"
5
5
6
6
"golang.org/x/exp/slices"
7
- durationpb "google.golang.org/protobuf/types/known/durationpb"
8
7
)
9
8
10
9
type DBConfig struct {
11
10
MaxIdleConns int64
12
11
MaxOpenConns int64
13
12
}
14
13
15
- type ErrorFilter struct {
14
+ type ErrorFilterConfig struct {
16
15
LogLevel int64
17
16
}
18
17
@@ -21,11 +20,6 @@ type MemcachedConfig struct {
21
20
TimeoutMs int64
22
21
}
23
22
24
- type MiddlewareConfig struct {
25
- TeamExemptProcedures map [string ]bool
26
- RequireOauthProcedures map [string ]bool
27
- }
28
-
29
23
type OAuthDeviceConfig struct {
30
24
VerificationUri string
31
25
PollingIntervalSeconds int64
@@ -38,20 +32,24 @@ type RegistrationConfig struct {
38
32
EmailSubject string
39
33
}
40
34
41
- type RolloutConfig struct {
42
- LockTtl * durationpb. Duration
35
+ type RolloutConfiguration struct {
36
+ LockTtl int64
43
37
NumRolloutWorkers int64
44
- RolloutTimeout * durationpb.Duration
38
+ RolloutTimeout int64
39
+ Delay int64
40
+ Jitter int64
45
41
ChanBufferSize int64
46
- Delay * durationpb.Duration
47
- Jitter * durationpb.Duration
48
42
}
49
43
50
44
type RolloutContentsConfig struct {
51
45
Compare bool
52
46
UseGitContents bool
53
47
}
54
48
49
+ type TeamExemptProcedures struct {
50
+ Procedures []string
51
+ }
52
+
55
53
// Whether or not the backend returns the statically parsed feature for a feature of type Proto..
56
54
func getBffShowStaticProto (env string , feature string , owner string , repo string ) bool {
57
55
if repo == "staging-types" && feature == "proto_test" {
@@ -133,9 +131,9 @@ func getContextKeyMetricsLookbackDays() int64 {
133
131
return 3
134
132
}
135
133
136
- // How many hours after creation does a Lekko browser cookie expire
137
- func getCookieExpirationDuration () * durationpb. Duration {
138
- return & durationpb. Duration { Seconds : 86400 }
134
+ // How many seconds after creation does a Lekko browser cookie expire
135
+ func getCookieExpirationDuration () int64 {
136
+ return 86400
139
137
}
140
138
141
139
// Config options for backend DB client
@@ -177,27 +175,27 @@ func getEnableMembershipsByDomainName(env string, username string) bool {
177
175
}
178
176
179
177
// Dynamically change error logs' levels. The context key "message" refers to the "error" field while "log" refers to "msg".
180
- func getErrorFilter (grpcErrorCode float64 , log string , message string ) * ErrorFilter {
178
+ func getErrorFilterConfig (grpcErrorCode float64 , log string , message string ) * ErrorFilterConfig {
181
179
if slices .Contains ([]float64 {3 , 5 , 6 , 7 , 11 , 16 }, grpcErrorCode ) {
182
- return & ErrorFilter {LogLevel : 3 }
180
+ return & ErrorFilterConfig {LogLevel : 3 }
183
181
} else if strings .Contains (message , "unsupported static parsing" ) {
184
- return & ErrorFilter {LogLevel : 3 }
182
+ return & ErrorFilterConfig {LogLevel : 3 }
185
183
} else if strings .Contains (message , "Found feature(s) with compilation or formatting diffs" ) {
186
- return & ErrorFilter {LogLevel : 3 }
184
+ return & ErrorFilterConfig {LogLevel : 3 }
187
185
} else if strings .Contains (message , "deleting invalid in-mem repo" ) {
188
- return & ErrorFilter {LogLevel : 3 }
186
+ return & ErrorFilterConfig {LogLevel : 3 }
189
187
} else if strings .Contains (message , "context canceled" ) {
190
- return & ErrorFilter {LogLevel : 3 }
188
+ return & ErrorFilterConfig {LogLevel : 3 }
191
189
} else if strings .Contains (message , "acquire lock" ) {
192
- return & ErrorFilter {LogLevel : 3 }
190
+ return & ErrorFilterConfig {LogLevel : 3 }
193
191
} else if strings .Contains (log , "unable to get reset_at cache value" ) {
194
- return & ErrorFilter {LogLevel : 3 }
192
+ return & ErrorFilterConfig {LogLevel : 3 }
195
193
} else if strings .Contains (log , "unable to reset quota" ) {
196
- return & ErrorFilter {LogLevel : 3 }
194
+ return & ErrorFilterConfig {LogLevel : 3 }
197
195
} else if strings .Contains (message , "field contextProto not found in type metadata.NamespaceConfigRepoMetadata" ) {
198
- return & ErrorFilter {LogLevel : 3 }
196
+ return & ErrorFilterConfig {LogLevel : 3 }
199
197
}
200
- return & ErrorFilter {LogLevel : 1 }
198
+ return & ErrorFilterConfig {LogLevel : 1 }
201
199
}
202
200
203
201
// example bool config pushed from backend
@@ -265,41 +263,6 @@ func getMetricsBatchSize() int64 {
265
263
return 2000
266
264
}
267
265
268
- // Configuration for the backend rpc middleware
269
- func getMiddleware () * MiddlewareConfig {
270
- return & MiddlewareConfig {
271
- RequireOauthProcedures : map [string ]bool {
272
- "AddFeature" : true ,
273
- "AddNamespace" : true ,
274
- "CreateBranch" : true ,
275
- "CreateRepository" : true ,
276
- "DeleteRepository" : true ,
277
- "GetPR" : true ,
278
- "GetPRInfo" : true ,
279
- "GetUserOAuth" : true ,
280
- "Merge" : true ,
281
- "MergePR" : true ,
282
- "RemoveFeature" : true ,
283
- "RemoveNamespace" : true ,
284
- "Restore" : true ,
285
- "Review" : true ,
286
- "Save" : true ,
287
- },
288
- TeamExemptProcedures : map [string ]bool {
289
- "AuthorizeDevice" : true ,
290
- "ChangePassword" : true ,
291
- "CreateTeam" : true ,
292
- "DeleteUserOAuth" : true ,
293
- "GetUserGitHubInstallations" : true ,
294
- "GetUserLoggedInInfo" : true ,
295
- "GetUserOAuth" : true ,
296
- "ListUserMemberships" : true ,
297
- "OAuthUser" : true ,
298
- "UseTeam" : true ,
299
- },
300
- }
301
- }
302
-
303
266
func getNewButtonThree (env string ) string {
304
267
if env == "production" {
305
268
return "prod"
@@ -314,6 +277,11 @@ func getNewFeatureFlag(env string) bool {
314
277
return false
315
278
}
316
279
280
+ // Whether to only return the default branch info in the ListBranches endpoint. Switching branches and viewing PRs is disabled on the web UI for now, so this should be a quick temp fix for GitHub rate limit issues.
281
+ func getOnlyListDefaultBranch () bool {
282
+ return true
283
+ }
284
+
317
285
// Settings for Lekko registration flow
318
286
func getRegistrationConfig (env string , userExists bool ) * RegistrationConfig {
319
287
if userExists && env == "development" {
@@ -468,11 +436,8 @@ func getRegistrationConfig(env string, userExists bool) *RegistrationConfig {
468
436
}
469
437
}
470
438
471
- func getReturnFdsToFe (username string ) bool {
472
- if username == "jonathan@lekko.com" {
473
- return true
474
- }
475
- return false
439
+ func getReturnFdsToFe () bool {
440
+ return true
476
441
}
477
442
478
443
// log level for rockset client, see https://github.com/rs/zerolog/blob/master/globals.go#L35-L48 for supported values
@@ -488,34 +453,34 @@ func getRocksetRetryMaxElapsedTimeSecs() int64 {
488
453
return 15
489
454
}
490
455
491
- // Controls how config repo contents are derived during rollout. Formerly a JSON config.
492
- func getRolloutContentsProto (env string ) * RolloutContentsConfig {
493
- if slices .Contains ([]string {"staging" , "development" }, env ) {
494
- return & RolloutContentsConfig {UseGitContents : true }
495
- }
496
- return & RolloutContentsConfig {UseGitContents : true }
497
- }
498
-
499
- // Rollout handler configuration
500
- func getRollout (env string ) * RolloutConfig {
456
+ // Rollout handler configuration. All durations are in seconds.
457
+ func getRolloutConfiguration (env string ) * RolloutConfiguration {
501
458
if env == "staging" {
502
- return & RolloutConfig {
459
+ return & RolloutConfiguration {
503
460
ChanBufferSize : 100 ,
504
- Delay : & durationpb. Duration { Seconds : 180 } ,
505
- Jitter : & durationpb. Duration { Seconds : 30 } ,
506
- LockTtl : & durationpb. Duration { Seconds : 60 } ,
461
+ Delay : 300 ,
462
+ Jitter : 30 ,
463
+ LockTtl : 60 ,
507
464
NumRolloutWorkers : 250 ,
508
- RolloutTimeout : & durationpb. Duration { Seconds : 60 } ,
465
+ RolloutTimeout : 120 ,
509
466
}
510
467
}
511
- return & RolloutConfig {
468
+ return & RolloutConfiguration {
512
469
ChanBufferSize : 100 ,
513
- Delay : & durationpb. Duration { Seconds : 900 } ,
514
- Jitter : & durationpb. Duration { Seconds : 60 } ,
515
- LockTtl : & durationpb. Duration { Seconds : 300 } ,
470
+ Delay : 900 ,
471
+ Jitter : 60 ,
472
+ LockTtl : 300 ,
516
473
NumRolloutWorkers : 250 ,
517
- RolloutTimeout : & durationpb.Duration {Seconds : 480 },
474
+ RolloutTimeout : 480 ,
475
+ }
476
+ }
477
+
478
+ // Controls how config repo contents are derived during rollout. Formerly a JSON config.
479
+ func getRolloutContentsProto (env string ) * RolloutContentsConfig {
480
+ if slices .Contains ([]string {"staging" , "development" }, env ) {
481
+ return & RolloutContentsConfig {UseGitContents : true }
518
482
}
483
+ return & RolloutContentsConfig {UseGitContents : true }
519
484
}
520
485
521
486
// Controls whether we sync with GitHub to fetch updated branch information after saving changes through BFF
@@ -544,10 +509,30 @@ func getShouldValidateTeam(procedure string) bool {
544
509
return false
545
510
} else if procedure == "DeleteAPIKey" {
546
511
return false
512
+ } else if slices .Contains ([]string {"CreateBranch" , "Save" , "Review" , "Merge" , "GetRepositoryContents" }, procedure ) {
513
+ return false
547
514
}
548
515
return true
549
516
}
550
517
518
+ // Configuration for BFF procedures that don't need to be checked for team info
519
+ func getTeamExemptProcedures () * TeamExemptProcedures {
520
+ return & TeamExemptProcedures {
521
+ Procedures : []string {
522
+ "AuthorizeDevice" ,
523
+ "ChangePassword" ,
524
+ "CreateTeam" ,
525
+ "DeleteUserOAuth" ,
526
+ "GetUserGitHubInstallations" ,
527
+ "GetUserLoggedInInfo" ,
528
+ "GetUserOAuth" ,
529
+ "ListUserMemberships" ,
530
+ "OAuthUser" ,
531
+ "UseTeam" ,
532
+ },
533
+ }
534
+ }
535
+
551
536
// Whether or not to rely on lekko's custom Any protobuf definition as source of truth..
552
537
func getUseCustomAny () bool {
553
538
return true
0 commit comments