Commit acdeb0bf authored by Akzhan's avatar Akzhan

http_settings configuration option added.

Now it supports:

 * self_signed_cert option to allow self-signed certificates over https protocol.
 * user and password options to pass though http auth.
parent 601450c3
# GitLab user. git by default # GitLab user. git by default
user: git user: git
# Url to gitlab instance. Used for api calls # Url to gitlab instance. Used for api calls. Should be ends with slash.
gitlab_url: "http://localhost/" gitlab_url: "http://localhost/"
http_settings:
# user: someone
# password: somepass
self_signed_cert: false
# Repositories path # Repositories path
repos_path: "/home/git/repositories" repos_path: "/home/git/repositories"
......
...@@ -18,4 +18,8 @@ class GitlabConfig ...@@ -18,4 +18,8 @@ class GitlabConfig
def gitlab_url def gitlab_url
@config['gitlab_url'] ||= "http://localhost/" @config['gitlab_url'] ||= "http://localhost/"
end end
def http_settings
@config['http_settings'] ||= {}
end
end end
...@@ -30,15 +30,28 @@ class GitlabNet ...@@ -30,15 +30,28 @@ class GitlabNet
protected protected
def config
@config ||= GitlabConfig.new
end
def host def host
"#{GitlabConfig.new.gitlab_url}/api/v3/internal" "#{config.gitlab_url}/api/v3/internal"
end end
def get(url) def get(url)
url = URI.parse(url) url = URI.parse(url)
http = Net::HTTP.new(url.host, url.port) http = Net::HTTP.new(url.host, url.port)
http.use_ssl = (url.port == 443) http.use_ssl = (url.port == 443)
if config.http_settings['self_signed_cert'] && http.use_ssl?
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
end
request = Net::HTTP::Get.new(url.request_uri) request = Net::HTTP::Get.new(url.request_uri)
if config.http_settings['user'] && config.http_settings['password']
request.basic_auth config.http_settings['user'], config.http_settings['password']
end
http.start {|http| http.request(request) } http.start {|http| http.request(request) }
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment