Skip to content

Commit 782b2f8

Browse files
committed
🧹 Add feature flag for new upload path
1 parent 5bf069b commit 782b2f8

4 files changed

Lines changed: 32 additions & 3 deletions

File tree

feature_string.go

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

featureflags.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,23 @@ func SetFeatures(ctx context.Context, fts Features) context.Context {
6262
return context.WithValue(ctx, featureContextID{}, fts)
6363
}
6464

65+
func WithFeature(ctx context.Context, feature Feature) context.Context {
66+
existingFeatures := GetFeatures(ctx)
67+
if existingFeatures.IsActive(feature) {
68+
return ctx
69+
}
70+
// clone existing features
71+
features := make(Features, len(existingFeatures)+1)
72+
copy(features, existingFeatures)
73+
features[len(existingFeatures)] = byte(feature)
74+
return SetFeatures(ctx, features)
75+
}
76+
77+
func IsFeatureActive(ctx context.Context, f Feature) bool {
78+
features := GetFeatures(ctx)
79+
return features.IsActive(f)
80+
}
81+
6582
// GetFeatures from a given context
6683
func GetFeatures(ctx context.Context) Features {
6784
f, ok := ctx.Value(featureContextID{}).(Features)

features.go

Lines changed: 8 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

features.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,7 @@ Features:
7474
idx: 12
7575
start: v11.x
7676
status: new, we still need to fix a few more tests
77+
- id: UploadResultsV2
78+
idx: 13
79+
start: v12.x
80+
status: new

0 commit comments

Comments
 (0)