Skip to content

Commit

Permalink
Merge ffebad0 into 5e304d2
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbellone committed Dec 18, 2013
2 parents 5e304d2 + ffebad0 commit c17f7ff
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/vagrant-proxyconf/action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require_relative 'action/configure_chef_proxy'
require_relative 'action/configure_env_proxy'
require_relative 'action/configure_yum_proxy'
require_relative 'action/configure_git_proxy'
require_relative 'action/is_enabled'
require_relative 'action/only_once'

Expand Down Expand Up @@ -31,6 +32,7 @@ def self.config_actions
b2.use ConfigureChefProxy
b2.use ConfigureEnvProxy
b2.use ConfigureYumProxy
b2.use ConfigureGitProxy
end
end
end
Expand Down
30 changes: 30 additions & 0 deletions lib/vagrant-proxyconf/action/configure_git_proxy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
require_relative 'base'
require_relative '../resource'
require_relative '../userinfo_uri'

module VagrantPlugins
module ProxyConf
class Action
# Action for configuring Git on the guest
class ConfigureGitProxy < Base
def config_name
'git_proxy'
end

private

def configure_machine(machine, config)
uri = escape(config.http)
machine.communicate.tap do |comm|
comm.sudo("git config --system --add http.proxy #{uri}")
end
end

# @param value [String, nil] the string to escape for shell usage
def escape(value)
value.to_s.shellescape
end
end
end
end
end
19 changes: 19 additions & 0 deletions lib/vagrant-proxyconf/config/git_proxy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require 'vagrant'
require_relative 'key_mixin'

module VagrantPlugins
module ProxyConf
module Config
# Proxy configuration for Git
#
# @!parse class GitProxy < Vagrant::Plugin::V2::Config; end
class GitProxy < Vagrant.plugin('2', :config)
include KeyMixin
# @!parse extend KeyMixin::ClassMethods

# @return [String] the HTTP proxy
key :http, env_var: 'VAGRANT_GIT_HTTP_PROXY'
end
end
end
end
9 changes: 9 additions & 0 deletions lib/vagrant-proxyconf/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ def self.load_optional_dependencies
Config::EnvProxy
end

config 'git_proxy' do
require_relative 'config/git_proxy'
Config::GitProxy
end

config 'proxy' do
require_relative 'config/proxy'
Config::Proxy
Expand All @@ -82,6 +87,10 @@ def self.load_optional_dependencies
Cap::Linux::EnvProxyConf
end

guest_capability 'linux', 'git_proxy_conf' do

end

guest_capability 'coreos', 'env_proxy_conf' do
# disabled on CoreOS
end
Expand Down
8 changes: 8 additions & 0 deletions locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ en:
configuring: |-
Configuring proxy for Yum...
git_proxy:
not_enabled: |-
git_proxy not enabled or configured
not_supported: |-
Skipping Git proxy config as the machine does not support it
configuring: |-
Configuring proxy for Git...
errors:
vagrant_version: |-
vagrant-proxyconf plugin requires Vagrant %{min_version} or newer
11 changes: 11 additions & 0 deletions spec/unit/vagrant-proxyconf/action/configure_git_proxy_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'spec_helper'
require 'vagrant-proxyconf/action/configure_git_proxy'

describe VagrantPlugins::ProxyConf::Action::ConfigureGitProxy do

describe '#config_name' do
subject { described_class.new(double, double).config_name }
it { should eq 'git_proxy' }
end

end
5 changes: 5 additions & 0 deletions spec/unit/vagrant-proxyconf/config/git_proxy_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'spec_helper'
require 'vagrant-proxyconf/config/git_proxy'

describe VagrantPlugins::ProxyConf::Config::GitProxy do
end

0 comments on commit c17f7ff

Please sign in to comment.