diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2017-07-17 20:19:22 -0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2017-08-07 13:06:12 -0300 |
commit | a7363d4a54e95dcd417ca1a75ab65265d069e164 (patch) | |
tree | 32f36d057a6a2f7d7a12dbe8a069fcd59e54edb2 /lib/github/client.rb | |
parent | 51186e72c5b06e144960bd0caf9684dbc387920c (diff) | |
download | gitlab-ce-a7363d4a54e95dcd417ca1a75ab65265d069e164.tar.gz |
Move GitHub root endpoint methods to Github::Client
Diffstat (limited to 'lib/github/client.rb')
-rw-r--r-- | lib/github/client.rb | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/github/client.rb b/lib/github/client.rb index e65d908d232..ac4e3a739f9 100644 --- a/lib/github/client.rb +++ b/lib/github/client.rb @@ -3,7 +3,7 @@ module Github attr_reader :connection, :rate_limit def initialize(options) - @connection = Faraday.new(url: options.fetch(:url)) do |faraday| + @connection = Faraday.new(url: options.fetch(:url, root_endpoint)) do |faraday| faraday.options.open_timeout = options.fetch(:timeout, 60) faraday.options.timeout = options.fetch(:timeout, 60) faraday.authorization 'token', options.fetch(:token) @@ -19,5 +19,22 @@ module Github Github::Response.new(connection.get(url, query)) end + + private + + def root_endpoint + custom_endpoint || githup_endpoint + end + + def custom_endpoint + Gitlab.config.omniauth.providers + .find { |provider| provider.name == 'github' } + .to_h + .dig('args', 'client_options', 'site') + end + + def github_endpoint + OmniAuth::Strategies::GitHub.default_options[:client_options][:site] + end end end |