Skip to content

Commit

Permalink
feat(downloadLimit): release download limit feature - close #2
Browse files Browse the repository at this point in the history
  • Loading branch information
benjohns1 committed Feb 20, 2024
1 parent f5d8e5c commit 4462534
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ func run(ctx context.Context) (err error) {
l := log.New(log.Config{GetRequestID: request.GetID})
l.Printf(ctx, "Running build %q", build)

ff, err := featureflag.New(featureflag.WithFeaturesFromEnvironment("FEATURE_FLAG_"))
ff, err := featureflag.New(
featureflag.WithFeaturesFromEnvironment("FEATURE_FLAG_"),
featureflag.WithReleasedFeatures("DownloadLimit"),
)
if err != nil {
return err
}
Expand Down
9 changes: 9 additions & 0 deletions featureflag/featureflag.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ func WithFeaturesFromEnvironment(prefix string) ConfigOption {
}
}

func WithReleasedFeatures(features ...string) ConfigOption {
return func(ff *FeatureFlags) error {
for _, feature := range features {
ff.features[Name(feature)] = true
}
return nil
}
}

func New(opts ...ConfigOption) (*FeatureFlags, error) {
ff := FeatureFlags{
features: make(map[Name]bool),
Expand Down

0 comments on commit 4462534

Please sign in to comment.