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/feature.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/feature.rb')
-rw-r--r-- | lib/feature.rb | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/lib/feature.rb b/lib/feature.rb index 1f8c530bee5..3d4a919b043 100644 --- a/lib/feature.rb +++ b/lib/feature.rb @@ -68,6 +68,9 @@ class Feature Feature::Definition.valid_usage!(key, type: type, default_enabled: default_enabled) end + # If `default_enabled: :yaml` we fetch the value from the YAML definition instead. + default_enabled = Feature::Definition.default_enabled?(key) if default_enabled == :yaml + # During setup the database does not exist yet. So we haven't stored a value # for the feature yet and return the default. return default_enabled unless Gitlab::Database.exists? @@ -87,40 +90,39 @@ class Feature end def enable(key, thing = true) + log(key: key, action: __method__, thing: thing) get(key).enable(thing) end def disable(key, thing = false) + log(key: key, action: __method__, thing: thing) get(key).disable(thing) end - def enable_group(key, group) - get(key).enable_group(group) - end - - def disable_group(key, group) - get(key).disable_group(group) - end - def enable_percentage_of_time(key, percentage) + log(key: key, action: __method__, percentage: percentage) get(key).enable_percentage_of_time(percentage) end def disable_percentage_of_time(key) + log(key: key, action: __method__) get(key).disable_percentage_of_time end def enable_percentage_of_actors(key, percentage) + log(key: key, action: __method__, percentage: percentage) get(key).enable_percentage_of_actors(percentage) end def disable_percentage_of_actors(key) + log(key: key, action: __method__) get(key).disable_percentage_of_actors end def remove(key) return unless persisted_name?(key) + log(key: key, action: __method__) get(key).remove end @@ -136,8 +138,6 @@ class Feature end def register_definitions - return unless check_feature_flags_definition? - Feature::Definition.reload! end @@ -147,6 +147,10 @@ class Feature Feature::Definition.register_hot_reloader! end + def logger + @logger ||= Feature::Logger.build + end + private def flipper @@ -194,6 +198,14 @@ class Feature def l2_cache_backend Rails.cache end + + def log(key:, action:, **extra) + extra ||= {} + extra = extra.transform_keys { |k| "extra.#{k}" } + extra = extra.transform_values { |v| v.respond_to?(:flipper_id) ? v.flipper_id : v } + extra = extra.transform_values(&:to_s) + logger.info(key: key, action: action, **extra) + end end class Target |