summaryrefslogtreecommitdiff
path: root/lib/feature
diff options
context:
space:
mode:
Diffstat (limited to 'lib/feature')
-rw-r--r--lib/feature/definition.rb16
-rw-r--r--lib/feature/gitaly.rb2
-rw-r--r--lib/feature/shared.rb12
3 files changed, 17 insertions, 13 deletions
diff --git a/lib/feature/definition.rb b/lib/feature/definition.rb
index 61f7e395769..1551af730db 100644
--- a/lib/feature/definition.rb
+++ b/lib/feature/definition.rb
@@ -63,19 +63,13 @@ class Feature
end
end
- def valid_usage!(type_in_code:, default_enabled_in_code:)
+ def valid_usage!(type_in_code:)
unless Array(type).include?(type_in_code.to_s)
# Raise exception in test and dev
raise Feature::InvalidFeatureFlagError, "The `type:` of `#{key}` is not equal to config: " \
"#{type_in_code} vs #{type}. Ensure to use valid type in #{path} or ensure that you use " \
"a valid syntax: #{TYPES.dig(type, :example)}"
end
-
- unless default_enabled_in_code == :yaml || default_enabled == default_enabled_in_code
- # Raise exception in test and dev
- raise Feature::InvalidFeatureFlagError, "The `default_enabled:` of `#{key}` is not equal to config: " \
- "#{default_enabled_in_code} vs #{default_enabled}. Ensure to update #{path}"
- end
end
def to_h
@@ -124,9 +118,9 @@ class Feature
feature.force_log_state_changes? || feature.for_upcoming_milestone?
end
- def valid_usage!(key, type:, default_enabled:)
+ def valid_usage!(key, type:)
if definition = get(key)
- definition.valid_usage!(type_in_code: type, default_enabled_in_code: default_enabled)
+ definition.valid_usage!(type_in_code: type)
elsif type_definition = self::TYPES[type]
raise InvalidFeatureFlagError, "Missing feature definition for `#{key}`" unless type_definition[:optional]
else
@@ -134,9 +128,11 @@ class Feature
end
end
- def default_enabled?(key)
+ def default_enabled?(key, default_enabled_if_undefined: nil)
if definition = get(key)
definition.default_enabled
+ elsif !default_enabled_if_undefined.nil?
+ default_enabled_if_undefined
else
Gitlab::ErrorTracking.track_and_raise_for_dev_exception(
InvalidFeatureFlagError.new("The feature flag YAML definition for '#{key}' does not exist"))
diff --git a/lib/feature/gitaly.rb b/lib/feature/gitaly.rb
index a1f7dc0ee39..04ed78b8a51 100644
--- a/lib/feature/gitaly.rb
+++ b/lib/feature/gitaly.rb
@@ -8,7 +8,7 @@ class Feature
def enabled?(feature_flag, project = nil)
return false unless Feature::FlipperFeature.table_exists?
- Feature.enabled?("#{PREFIX}#{feature_flag}", project)
+ Feature.enabled?("#{PREFIX}#{feature_flag}", project, type: :undefined, default_enabled_if_undefined: false)
rescue ActiveRecord::NoDatabaseError, PG::ConnectionBad
false
end
diff --git a/lib/feature/shared.rb b/lib/feature/shared.rb
index 2ce078b2f02..40f21fc4f50 100644
--- a/lib/feature/shared.rb
+++ b/lib/feature/shared.rb
@@ -28,8 +28,8 @@ class Feature
},
ops: {
description: "Long-lived feature flags that control operational aspects of GitLab's behavior",
- optional: true,
- rollout_issue: false,
+ optional: false,
+ rollout_issue: true,
ee_only: false,
default_enabled: false,
example: <<-EOS
@@ -37,6 +37,14 @@ class Feature
push_frontend_feature_flag(:my_ops_flag, project, type: :ops)
EOS
},
+ undefined: {
+ description: "Feature flags that are undefined in GitLab codebase (should not be used)",
+ optional: true,
+ rollout_issue: false,
+ ee_only: false,
+ default_enabled: false,
+ example: ''
+ },
experiment: {
description: 'Short lived, used specifically to run A/B/n experiments.',
optional: true,