2019-09-04 21:01:54 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'set'
|
|
|
|
|
|
|
|
class Feature
|
|
|
|
class Gitaly
|
|
|
|
# Server feature flags should use '_' to separate words.
|
2019-09-30 21:07:59 +05:30
|
|
|
SERVER_FEATURE_FLAGS =
|
|
|
|
[
|
2019-10-12 21:52:04 +05:30
|
|
|
# 'get_commit_signatures'.freeze
|
2019-09-30 21:07:59 +05:30
|
|
|
].freeze
|
2019-09-04 21:01:54 +05:30
|
|
|
|
2019-09-30 21:07:59 +05:30
|
|
|
DEFAULT_ON_FLAGS = Set.new([]).freeze
|
2019-09-04 21:01:54 +05:30
|
|
|
|
|
|
|
class << self
|
|
|
|
def enabled?(feature_flag)
|
|
|
|
return false unless Feature::FlipperFeature.table_exists?
|
|
|
|
|
|
|
|
default_on = DEFAULT_ON_FLAGS.include?(feature_flag)
|
|
|
|
Feature.enabled?("gitaly_#{feature_flag}", default_enabled: default_on)
|
|
|
|
rescue ActiveRecord::NoDatabaseError
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
def server_feature_flags
|
|
|
|
SERVER_FEATURE_FLAGS.map do |f|
|
|
|
|
["gitaly-feature-#{f.tr('_', '-')}", enabled?(f).to_s]
|
|
|
|
end.to_h
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|