gitlab-org--gitlab-foss/lib/feature/gitaly.rb
Felipe Artur f7a92ff528 Add GetCommitSignatures feature flag
Adds feature flag for GetCommitSignatures which
got ported to go.

More info: https://gitlab.com/gitlab-org/gitaly/merge_requests/1283
2019-06-28 13:44:01 -03:00

36 lines
903 B
Ruby

# frozen_string_literal: true
require 'set'
class Feature
class Gitaly
# Server feature flags should use '_' to separate words.
# CATFILE_CACHE sets an incorrect example
CATFILE_CACHE = 'catfile-cache'.freeze
SERVER_FEATURE_FLAGS =
[
CATFILE_CACHE,
'get_commit_signatures'.freeze
].freeze
DEFAULT_ON_FLAGS = Set.new([CATFILE_CACHE]).freeze
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