From 3b306dfba35a3afd2bf915ac08e5a3c97b2276ff Mon Sep 17 00:00:00 2001 From: Fabian Ruff Date: Thu, 28 Apr 2016 13:27:24 +0200 Subject: [PATCH] Support no_proxy environment variable octokit uses faraday for making http_request. There is a long standing issue in faraday to add support for the no_proxy environment variable: https://github.com/lostisland/faraday/pull/247 Unfortuantely it seems like this is going nowhere. A workaround is suggested in this issue: https://github.com/berkshelf/berkshelf/issues/1341 The httpclient (and excon) farady adapter picks up proxy settings from the environment automatically. --- Dockerfile | 2 +- Gemfile | 1 + Gemfile.lock | 2 ++ assets/lib/check.rb | 2 +- assets/lib/common.rb | 6 ++++++ assets/lib/in.rb | 2 +- assets/lib/out.rb | 2 +- 7 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0ef37e1..2ec1e18 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ RUN apk add --update \ openssh-client \ ruby-json \ ca-certificates -RUN gem install octokit --no-rdoc --no-ri +RUN gem install octokit httpclient --no-rdoc --no-ri ADD assets/ /opt/resource/ RUN chmod +x /opt/resource/* diff --git a/Gemfile b/Gemfile index d1388f1..deee5d8 100644 --- a/Gemfile +++ b/Gemfile @@ -2,6 +2,7 @@ source 'https://rubygems.org' gem 'octokit' +gem 'httpclient' group :development do gem 'pry' diff --git a/Gemfile.lock b/Gemfile.lock index c03dd16..783cf74 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -21,6 +21,7 @@ GEM faraday (0.9.2) multipart-post (>= 1.2, < 3) http_parser.rb (0.6.0) + httpclient (2.8.0) method_source (0.8.2) multi_json (1.11.2) multipart-post (2.0.0) @@ -73,6 +74,7 @@ PLATFORMS ruby DEPENDENCIES + httpclient octokit pry puffing-billy diff --git a/assets/lib/check.rb b/assets/lib/check.rb index 857b6c6..3951046 100755 --- a/assets/lib/check.rb +++ b/assets/lib/check.rb @@ -3,8 +3,8 @@ require 'rubygems' require 'json' -require 'octokit' require_relative 'common' +require 'octokit' repo = Repository.new(name: input['source']['repo']) diff --git a/assets/lib/common.rb b/assets/lib/common.rb index 231da6b..4a654e0 100644 --- a/assets/lib/common.rb +++ b/assets/lib/common.rb @@ -1,4 +1,10 @@ # encoding: utf-8 + +require 'faraday' +# httpclient and excon are the only Faraday adpater which support +# the no_proxy environment variable atm +::Faraday.default_adapter= :httpclient + require 'octokit' require 'fileutils' diff --git a/assets/lib/in.rb b/assets/lib/in.rb index 885d46d..8088c8c 100755 --- a/assets/lib/in.rb +++ b/assets/lib/in.rb @@ -5,9 +5,9 @@ require 'rubygems' require 'json' +require_relative 'common' require 'octokit' require 'English' -require_relative 'common' def uri input['source']['uri'] || "https://github.com/#{input['source']['repo']}" diff --git a/assets/lib/out.rb b/assets/lib/out.rb index 062840f..82166ae 100755 --- a/assets/lib/out.rb +++ b/assets/lib/out.rb @@ -5,8 +5,8 @@ require 'rubygems' require 'json' -require 'octokit' require_relative 'common' +require 'octokit' raise %(`status` "#{input['params']['status']}" is not supported -- only success, failure, error, or pending) unless %w(success failure error pending).include?(input['params']['status']) raise '`path` required in `params`' unless input['params'].key?('path')