diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2018-03-23 13:20:45 +0300 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-03-23 13:20:45 +0300 |
commit | bb9d360c0a7daed6aa08a0635e084c314c2c8b3e (patch) | |
tree | 2320d72d11cf226ff35ccc5f00c9e4cd8af5fee1 /lib/gitlab/gitaly_client/storage_settings.rb | |
parent | 963e445f58f1cbe03f821167a3bf1d0b8cc8a56d (diff) | |
parent | 008a6a6ce6fa943adcfecf3a606b845cfa282680 (diff) |
Merge branch 'mark-legacy-git-access' into 'master'
Route path lookups through legacy_disk_path
See merge request gitlab-org/gitlab-ce!17743
Diffstat (limited to 'lib/gitlab/gitaly_client/storage_settings.rb')
-rw-r--r-- | lib/gitlab/gitaly_client/storage_settings.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/gitlab/gitaly_client/storage_settings.rb b/lib/gitlab/gitaly_client/storage_settings.rb new file mode 100644 index 00000000000..8668caf0c55 --- /dev/null +++ b/lib/gitlab/gitaly_client/storage_settings.rb @@ -0,0 +1,35 @@ +module Gitlab + module GitalyClient + # This is a chokepoint that is meant to help us stop remove all places + # where production code (app, config, db, lib) touches Git repositories + # directly. + class StorageSettings + DirectPathAccessError = Class.new(StandardError) + + # This class will give easily recognizable NoMethodErrors + Deprecated = Class.new + + attr_reader :legacy_disk_path + + def initialize(storage) + raise "expected a Hash, got a #{storage.class.name}" unless storage.is_a?(Hash) + + # Support a nil 'path' field because some of the circuit breaker tests use it. + @legacy_disk_path = File.expand_path(storage['path'], Rails.root) if storage['path'] + + storage['path'] = Deprecated + @hash = storage + end + + def gitaly_address + @hash.fetch(:gitaly_address) + end + + private + + def method_missing(m, *args, &block) + @hash.public_send(m, *args, &block) # rubocop:disable GitlabSecurity/PublicSend + end + end + end +end |