Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-06-16 21:25:58 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-06-16 21:25:58 +0300
commita5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch)
treefb69158581673816a8cd895f9d352dcb3c678b1e /app/services/feature_flags
parentd16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff)
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'app/services/feature_flags')
-rw-r--r--app/services/feature_flags/disable_service.rb46
-rw-r--r--app/services/feature_flags/enable_service.rb93
2 files changed, 0 insertions, 139 deletions
diff --git a/app/services/feature_flags/disable_service.rb b/app/services/feature_flags/disable_service.rb
deleted file mode 100644
index 8a443ac1795..00000000000
--- a/app/services/feature_flags/disable_service.rb
+++ /dev/null
@@ -1,46 +0,0 @@
-# frozen_string_literal: true
-
-module FeatureFlags
- class DisableService < BaseService
- def execute
- return error('Feature Flag not found', 404) unless feature_flag_by_name
- return error('Feature Flag Scope not found', 404) unless feature_flag_scope_by_environment_scope
- return error('Strategy not found', 404) unless strategy_exist_in_persisted_data?
-
- ::FeatureFlags::UpdateService
- .new(project, current_user, update_params)
- .execute(feature_flag_by_name)
- end
-
- private
-
- def update_params
- if remaining_strategies.empty?
- params_to_destroy_scope
- else
- params_to_update_scope
- end
- end
-
- def remaining_strategies
- strong_memoize(:remaining_strategies) do
- feature_flag_scope_by_environment_scope.strategies.reject do |strategy|
- strategy['name'] == params[:strategy]['name'] &&
- strategy['parameters'] == params[:strategy]['parameters']
- end
- end
- end
-
- def strategy_exist_in_persisted_data?
- feature_flag_scope_by_environment_scope.strategies != remaining_strategies
- end
-
- def params_to_destroy_scope
- { scopes_attributes: [{ id: feature_flag_scope_by_environment_scope.id, _destroy: true }] }
- end
-
- def params_to_update_scope
- { scopes_attributes: [{ id: feature_flag_scope_by_environment_scope.id, strategies: remaining_strategies }] }
- end
- end
-end
diff --git a/app/services/feature_flags/enable_service.rb b/app/services/feature_flags/enable_service.rb
deleted file mode 100644
index b4cbb32e003..00000000000
--- a/app/services/feature_flags/enable_service.rb
+++ /dev/null
@@ -1,93 +0,0 @@
-# frozen_string_literal: true
-
-module FeatureFlags
- class EnableService < BaseService
- def execute
- if feature_flag_by_name
- update_feature_flag
- else
- create_feature_flag
- end
- end
-
- private
-
- def create_feature_flag
- ::FeatureFlags::CreateService
- .new(project, current_user, create_params)
- .execute
- end
-
- def update_feature_flag
- ::FeatureFlags::UpdateService
- .new(project, current_user, update_params)
- .execute(feature_flag_by_name)
- end
-
- def create_params
- if params[:environment_scope] == '*'
- params_to_create_flag_with_default_scope
- else
- params_to_create_flag_with_additional_scope
- end
- end
-
- def update_params
- if feature_flag_scope_by_environment_scope
- params_to_update_scope
- else
- params_to_create_scope
- end
- end
-
- def params_to_create_flag_with_default_scope
- {
- name: params[:name],
- scopes_attributes: [
- {
- active: true,
- environment_scope: '*',
- strategies: [params[:strategy]]
- }
- ]
- }
- end
-
- def params_to_create_flag_with_additional_scope
- {
- name: params[:name],
- scopes_attributes: [
- {
- active: false,
- environment_scope: '*'
- },
- {
- active: true,
- environment_scope: params[:environment_scope],
- strategies: [params[:strategy]]
- }
- ]
- }
- end
-
- def params_to_create_scope
- {
- scopes_attributes: [{
- active: true,
- environment_scope: params[:environment_scope],
- strategies: [params[:strategy]]
- }]
- }
- end
-
- def params_to_update_scope
- {
- scopes_attributes: [{
- id: feature_flag_scope_by_environment_scope.id,
- active: true,
- strategies: feature_flag_scope_by_environment_scope.strategies | [params[:strategy]]
- }]
- }
- end
- end
-end