diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 11:59:07 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 11:59:07 +0000 |
commit | 8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch) | |
tree | 544930fb309b30317ae9797a9683768705d664c4 /lib/api/features.rb | |
parent | 4b1de649d0168371549608993deac953eb692019 (diff) | |
download | gitlab-ce-8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca.tar.gz |
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'lib/api/features.rb')
-rw-r--r-- | lib/api/features.rb | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/lib/api/features.rb b/lib/api/features.rb index 2c2e3e3d0c9..57bd7c38ad2 100644 --- a/lib/api/features.rb +++ b/lib/api/features.rb @@ -46,6 +46,15 @@ module API present features, with: Entities::Feature, current_user: current_user end + desc 'Get a list of all feature definitions' do + success Entities::Feature::Definition + end + get :definitions do + definitions = ::Feature::Definition.definitions.values.map(&:to_h) + + present definitions, with: Entities::Feature::Definition, current_user: current_user + end + desc 'Set the gate value for the given feature' do success Entities::Feature end @@ -56,6 +65,7 @@ module API 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' + optional :force, type: Boolean, desc: 'Skip feature flag validation checks, ie. YAML definition' mutually_exclusive :key, :feature_group mutually_exclusive :key, :user @@ -63,9 +73,8 @@ module API mutually_exclusive :key, :project end post ':name' do - validate_feature_flag_name!(params[:name]) + validate_feature_flag_name!(params[:name]) unless params[:force] - feature = Feature.get(params[:name]) # rubocop:disable Gitlab/AvoidFeatureGet targets = gate_targets(params) value = gate_value(params) key = gate_key(params) @@ -73,25 +82,26 @@ module API case value when true if gate_specified?(params) - targets.each { |target| feature.enable(target) } + targets.each { |target| Feature.enable(params[:name], target) } else - feature.enable + Feature.enable(params[:name]) end when false if gate_specified?(params) - targets.each { |target| feature.disable(target) } + targets.each { |target| Feature.disable(params[:name], target) } else - feature.disable + Feature.disable(params[:name]) end else if key == :percentage_of_actors - feature.enable_percentage_of_actors(value) + Feature.enable_percentage_of_actors(params[:name], value) else - feature.enable_percentage_of_time(value) + Feature.enable_percentage_of_time(params[:name], value) end end - present feature, with: Entities::Feature, current_user: current_user + present Feature.get(params[:name]), # rubocop:disable Gitlab/AvoidFeatureGet + with: Entities::Feature, current_user: current_user end desc 'Remove the gate value for the given feature' |