diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 17:34:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 17:34:42 +0300 |
commit | 9f46488805e86b1bc341ea1620b866016c2ce5ed (patch) | |
tree | f9748c7e287041e37d6da49e0a29c9511dc34768 /lib/api/features.rb | |
parent | dfc92d081ea0332d69c8aca2f0e745cb48ae5e6d (diff) |
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'lib/api/features.rb')
-rw-r--r-- | lib/api/features.rb | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/api/features.rb b/lib/api/features.rb index 69b751e9bdb..f507919b055 100644 --- a/lib/api/features.rb +++ b/lib/api/features.rb @@ -16,6 +16,15 @@ module API end end + def gate_key(params) + case params[:key] + when 'percentage_of_actors' + :percentage_of_actors + else + :percentage_of_time + end + end + def gate_targets(params) Feature::Target.new(params).targets end @@ -40,15 +49,22 @@ module API end params do requires :value, type: String, desc: '`true` or `false` to enable/disable, an integer for percentage of time' + optional :key, type: String, desc: '`percentage_of_actors` or the default `percentage_of_time`' optional :feature_group, type: String, desc: 'A Feature group name' optional :user, type: String, desc: 'A GitLab username' optional :group, type: String, desc: "A GitLab group's path, such as 'gitlab-org'" optional :project, type: String, desc: 'A projects path, like gitlab-org/gitlab-ce' + + mutually_exclusive :key, :feature_group + mutually_exclusive :key, :user + mutually_exclusive :key, :group + mutually_exclusive :key, :project end post ':name' do feature = Feature.get(params[:name]) targets = gate_targets(params) value = gate_value(params) + key = gate_key(params) case value when true @@ -64,7 +80,11 @@ module API feature.disable end else - feature.enable_percentage_of_time(value) + if key == :percentage_of_actors + feature.enable_percentage_of_actors(value) + else + feature.enable_percentage_of_time(value) + end end present feature, with: Entities::Feature, current_user: current_user |