diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-08 12:09:56 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-08 12:09:56 +0300 |
commit | e612fbe905cf0eacf7e34dbd72d8be98ce5d4eb7 (patch) | |
tree | ab64e82813abf51c9fa5f0a8e55a0354151772fb /lib | |
parent | fe30598cbd0756ba0c6326178f64b68e5ae8a30d (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/feature_flags.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/api/feature_flags.rb b/lib/api/feature_flags.rb index 6fdc4535be3..a08933583fb 100644 --- a/lib/api/feature_flags.rb +++ b/lib/api/feature_flags.rb @@ -90,6 +90,7 @@ module API end get do authorize_read_feature_flag! + exclude_legacy_flags_check! present_entity(feature_flag) end @@ -104,6 +105,7 @@ module API end post :enable do not_found! unless Feature.enabled?(:feature_flag_api, user_project) + exclude_legacy_flags_check! render_api_error!('Version 2 flags not supported', :unprocessable_entity) if new_version_flag_present? result = ::FeatureFlags::EnableService @@ -127,6 +129,7 @@ module API end post :disable do not_found! unless Feature.enabled?(:feature_flag_api, user_project) + exclude_legacy_flags_check! render_api_error!('Version 2 flags not supported', :unprocessable_entity) if feature_flag.new_version_flag? result = ::FeatureFlags::DisableService @@ -162,6 +165,7 @@ module API end put do authorize_update_feature_flag! + exclude_legacy_flags_check! render_api_error!('PUT operations are not supported for legacy feature flags', :unprocessable_entity) if feature_flag.legacy_flag? attrs = declared_params(include_missing: false) @@ -232,6 +236,10 @@ module API @feature_flag ||= user_project.operations_feature_flags.find_by_name!(params[:feature_flag_name]) end + def project + @project ||= feature_flag.project + end + def new_version_flag_present? user_project.operations_feature_flags.new_version_flag.find_by_name(params[:name]).present? end @@ -245,6 +253,14 @@ module API hash[key] = yield(hash[key]) if hash.key?(key) hash end + + def exclude_legacy_flags_check! + if Feature.enabled?(:remove_legacy_flags, project, default_enabled: :yaml) && + Feature.disabled?(:remove_legacy_flags_override, project, default_enabled: :yaml) && + feature_flag.legacy_flag? + not_found! + end + end end end end |