-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
spec/unit/vagrant-proxyconf/action/configure_git_proxy_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |