debian-mirror-gitlab/lib/feature/gitaly.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 lines
875 B
Ruby
Raw Normal View History

2019-09-04 21:01:54 +05:30
# frozen_string_literal: true
class Feature
class Gitaly
2020-03-13 15:44:24 +05:30
PREFIX = "gitaly_"
2019-09-04 21:01:54 +05:30
class << self
2021-03-11 19:13:27 +05:30
def enabled?(feature_flag, project = nil)
2019-09-04 21:01:54 +05:30
return false unless Feature::FlipperFeature.table_exists?
2022-07-16 23:28:13 +05:30
Feature.enabled?("#{PREFIX}#{feature_flag}", project, type: :undefined, default_enabled_if_undefined: false)
2019-12-26 22:10:19 +05:30
rescue ActiveRecord::NoDatabaseError, PG::ConnectionBad
2019-09-04 21:01:54 +05:30
false
end
2021-03-11 19:13:27 +05:30
def server_feature_flags(project = nil)
2020-04-08 14:13:33 +05:30
# We need to check that both the DB connection and table exists
2021-12-11 22:18:48 +05:30
return {} unless FlipperFeature.database.cached_table_exists?
2020-04-08 14:13:33 +05:30
2020-03-13 15:44:24 +05:30
Feature.persisted_names
.select { |f| f.start_with?(PREFIX) }
2021-03-11 19:13:27 +05:30
.to_h do |f|
2020-03-13 15:44:24 +05:30
flag = f.delete_prefix(PREFIX)
2021-03-11 19:13:27 +05:30
["gitaly-feature-#{flag.tr('_', '-')}", enabled?(flag, project).to_s]
end
2019-09-04 21:01:54 +05:30
end
end
end
end