summaryrefslogtreecommitdiff
path: root/lib/github/client.rb
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2017-10-18 21:46:05 +0200
committerYorick Peterse <yorickpeterse@gmail.com>2017-11-07 23:25:03 +0100
commit6e242e82237ad2cf362098f3f42f4a9dd1a4ad27 (patch)
tree415639ff14183a4914dac69fcc400806cb477525 /lib/github/client.rb
parent4dfe26cd8b6863b7e6c81f5c280cdafe9b6e17b6 (diff)
downloadgitlab-ce-github-importer-refactor.tar.gz
Replace old GH importer with the parallel importergithub-importer-refactor
Diffstat (limited to 'lib/github/client.rb')
-rw-r--r--lib/github/client.rb54
1 files changed, 0 insertions, 54 deletions
diff --git a/lib/github/client.rb b/lib/github/client.rb
deleted file mode 100644
index 29bd9c1f39e..00000000000
--- a/lib/github/client.rb
+++ /dev/null
@@ -1,54 +0,0 @@
-module Github
- class Client
- TIMEOUT = 60
- DEFAULT_PER_PAGE = 100
-
- attr_reader :connection, :rate_limit
-
- def initialize(options)
- @connection = Faraday.new(url: options.fetch(:url, root_endpoint)) do |faraday|
- faraday.options.open_timeout = options.fetch(:timeout, TIMEOUT)
- faraday.options.timeout = options.fetch(:timeout, TIMEOUT)
- faraday.authorization 'token', options.fetch(:token)
- faraday.adapter :net_http
- faraday.ssl.verify = verify_ssl
- end
-
- @rate_limit = RateLimit.new(connection)
- end
-
- def get(url, query = {})
- exceed, reset_in = rate_limit.get
- sleep reset_in if exceed
-
- Github::Response.new(connection.get(url, { per_page: DEFAULT_PER_PAGE }.merge(query)))
- end
-
- private
-
- def root_endpoint
- custom_endpoint || github_endpoint
- end
-
- def custom_endpoint
- github_omniauth_provider.dig('args', 'client_options', 'site')
- end
-
- def verify_ssl
- # If there is no config, we're connecting to github.com
- # and we should verify ssl.
- github_omniauth_provider.fetch('verify_ssl', true)
- end
-
- def github_endpoint
- OmniAuth::Strategies::GitHub.default_options[:client_options][:site]
- end
-
- def github_omniauth_provider
- @github_omniauth_provider ||=
- Gitlab.config.omniauth.providers
- .find { |provider| provider.name == 'github' }
- .to_h
- end
- end
-end