Allow feature flags to be set per user, or for predefined Flipper groups
In #33929, we're discussing the need to be able to enable the performance bar for a given group of people.
More generally, it can be useful (and probably needed) to be able to enable a feature for:
- a dynamic set of given actors (which will most probably always be users in our case): https://github.com/jnunemaker/flipper/blob/master/docs/Gates.md#3-individual-actor
- a predefined set of users, based on a condition: https://github.com/jnunemaker/flipper/blob/master/docs/Gates.md#2-group
The idea is that you'll be able to check if a feature is enabled for the current_user
, e.g. Feature.enabled?(:gitlab_performance_bar, current_user)
.
Then, you'll be able to activate the feature for:
- a given user, e.g.
POST /api/v4/features/gitlab_performance_bar
with auser=rymai
body - a Flipper group, e.g.
POST /api/v4/features/gitlab_performance_bar
with aflipper_group=performance_team
-
this requires the Flipper group to be registered beforehand in
config/initializers/flipper.rb
:Flipper.register(:performance_team) do |actor| Gitlab::PerformanceBar.allowed_actor?(actor) end
-
I'm going (actually, I already did) to implement that since we need it for the performance bar.
Edited by username-removed-128633