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>2020-11-19 11:27:35 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-11-19 11:27:35 +0300
commit7e9c479f7de77702622631cff2628a9c8dcbc627 (patch)
treec8f718a08e110ad7e1894510980d2155a6549197 /config/initializers/0_inject_feature_flags.rb
parente852b0ae16db4052c1c567d9efa4facc81146e88 (diff)
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'config/initializers/0_inject_feature_flags.rb')
-rw-r--r--config/initializers/0_inject_feature_flags.rb39
1 files changed, 39 insertions, 0 deletions
diff --git a/config/initializers/0_inject_feature_flags.rb b/config/initializers/0_inject_feature_flags.rb
index 5b33b3bb4ea..74470a6cbfc 100644
--- a/config/initializers/0_inject_feature_flags.rb
+++ b/config/initializers/0_inject_feature_flags.rb
@@ -4,3 +4,42 @@
Feature.register_feature_groups
Feature.register_definitions
Feature.register_hot_reloader unless Rails.configuration.cache_classes
+
+# This disallows usage of licensed feature names with the same name
+# as feature flags. This naming collision creates confusion and it was
+# decided to be removed in favor of explicit check.
+# https://gitlab.com/gitlab-org/gitlab/-/issues/259611
+if Gitlab.ee? && Gitlab.dev_or_test_env?
+ # These are the names of feature flags that do violate the constraint of
+ # being unique to licensed names. These feature flags should be reworked to
+ # be "development" with explicit check
+ IGNORED_FEATURE_FLAGS = %i[
+ swimlanes
+ ].to_set
+
+ # First, we validate a list of overrides to ensure that these overrides
+ # are removed if feature flag is gone
+ missing_feature_flags = IGNORED_FEATURE_FLAGS.reject do |feature_flag|
+ Feature::Definition.definitions[feature_flag]
+ end
+
+ if missing_feature_flags.any?
+ raise "The following feature flags were added as an override for discovering licensed features. " \
+ "Since these feature flags seems to be gone, ensure to remove them from \`IGNORED_FEATURE_FLAGS\` " \
+ "in \`#{__FILE__}'`: #{missing_feature_flags.join(", ")}"
+ end
+
+ # Second, we validate that there's no feature flag under the name as licensed feature
+ # flag, to ensure that the name used, is unique
+ licensed_features = License::PLANS_BY_FEATURE.keys.select do |licensed_feature_name|
+ IGNORED_FEATURE_FLAGS.exclude?(licensed_feature_name) &&
+ Feature::Definition.definitions[licensed_feature_name]
+ end
+
+ if licensed_features.any?
+ raise "The following feature flags do use a licensed feature. " \
+ "To avoid the confusion between their usage it is disallowed to use feature flag " \
+ "with exact the same name as licensed feature name. Use a different name to create " \
+ "a distinction: #{licensed_features.join(", ")}"
+ end
+end