vagrant-proxyconf 1.5.2 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +11 -14
- data/CHANGELOG.md +38 -0
- data/Gemfile +28 -7
- data/LICENSE.txt +1 -1
- data/README.md +147 -18
- data/Rakefile +1 -27
- data/development/Dockerfile +45 -0
- data/development/README.md +2 -0
- data/development/Vagrantfile.example +185 -9
- data/development/install-c7.sh +46 -0
- data/development/install-debian.sh +55 -0
- data/development/tinyproxy.conf +333 -0
- data/lib/vagrant-proxyconf/action.rb +15 -7
- data/lib/vagrant-proxyconf/action/base.rb +47 -5
- data/lib/vagrant-proxyconf/action/configure_apt_proxy.rb +17 -0
- data/lib/vagrant-proxyconf/action/configure_chef_proxy.rb +32 -27
- data/lib/vagrant-proxyconf/action/configure_docker_proxy.rb +132 -14
- data/lib/vagrant-proxyconf/action/configure_env_proxy.rb +58 -11
- data/lib/vagrant-proxyconf/action/configure_git_proxy.rb +25 -9
- data/lib/vagrant-proxyconf/action/configure_npm_proxy.rb +14 -6
- data/lib/vagrant-proxyconf/action/configure_pear_proxy.rb +15 -8
- data/lib/vagrant-proxyconf/action/configure_svn_proxy.rb +15 -8
- data/lib/vagrant-proxyconf/action/configure_yum_proxy.rb +16 -0
- data/lib/vagrant-proxyconf/action/is_enabled.rb +18 -1
- data/lib/vagrant-proxyconf/cap/linux/chef_proxy_conf.rb +17 -0
- data/lib/vagrant-proxyconf/cap/linux/docker_proxy_conf.rb +2 -1
- data/lib/vagrant-proxyconf/cap/linux/yum_proxy_conf.rb +19 -0
- data/lib/vagrant-proxyconf/cap/util.rb +4 -5
- data/lib/vagrant-proxyconf/capability.rb +10 -0
- data/lib/vagrant-proxyconf/config.rb +20 -0
- data/lib/vagrant-proxyconf/config/chef_proxy.rb +25 -0
- data/lib/vagrant-proxyconf/config/docker_proxy.rb +25 -0
- data/lib/vagrant-proxyconf/config/git_proxy.rb +3 -0
- data/lib/vagrant-proxyconf/config/npm_proxy.rb +25 -0
- data/lib/vagrant-proxyconf/config/pear_proxy.rb +19 -0
- data/lib/vagrant-proxyconf/version.rb +1 -1
- data/locales/en.yml +38 -0
- data/resources/yum_config.awk +1 -0
- data/spec/spec_helper.rb +27 -9
- data/spec/unit/fixtures/docker_client_config_json_enabled_proxy +9 -0
- data/spec/unit/fixtures/docker_client_config_json_no_proxy +5 -0
- data/spec/unit/fixtures/etc_environment_only_http_proxy.conf +9 -0
- data/spec/unit/fixtures/yum_with_repository_and_proxy_containing_special_chars.conf +10 -0
- data/spec/unit/vagrant-proxyconf/action/base_spec.rb +191 -0
- data/spec/unit/vagrant-proxyconf/action/configure_apt_proxy_spec.rb +162 -0
- data/spec/unit/vagrant-proxyconf/action/configure_chef_proxy_spec.rb +32 -0
- data/spec/unit/vagrant-proxyconf/action/configure_docker_proxy_spec.rb +491 -0
- data/spec/unit/vagrant-proxyconf/action/configure_env_proxy_spec.rb +105 -4
- data/spec/unit/vagrant-proxyconf/action/configure_git_proxy_spec.rb +116 -0
- data/spec/unit/vagrant-proxyconf/action/configure_npm_proxy_spec.rb +67 -0
- data/spec/unit/vagrant-proxyconf/action/configure_pear_proxy_spec.rb +116 -0
- data/spec/unit/vagrant-proxyconf/action/configure_svn_proxy_spec.rb +85 -0
- data/spec/unit/vagrant-proxyconf/action/configure_yum_proxy_spec.rb +100 -0
- data/spec/unit/vagrant-proxyconf/action/is_enabled_spec.rb +162 -12
- data/spec/unit/vagrant-proxyconf/cap/linux/docker_proxy_conf_spec.rb +1 -1
- data/spec/unit/vagrant-proxyconf/cap/util_spec.rb +2 -2
- data/spec/unit/vagrant-proxyconf/config/key_mixin_spec.rb +1 -1
- data/spec/unit/vagrant-proxyconf/resources/yum_config_spec.rb +14 -0
- data/test/issues/180/.rspec +2 -0
- data/test/issues/180/Dockerfile +47 -0
- data/test/issues/180/README.md +31 -0
- data/test/issues/180/Rakefile +27 -0
- data/test/issues/180/Vagrantfile +31 -0
- data/test/issues/180/entrypoint.sh +50 -0
- data/test/issues/180/spec/default/redhat_spec.rb +15 -0
- data/test/issues/180/spec/docker_host/redhat_spec.rb +165 -0
- data/test/issues/180/spec/spec_helper.rb +43 -0
- data/test/issues/180/tinyproxy.conf +333 -0
- data/travis/before_install +26 -0
- metadata +44 -4
@@ -11,16 +11,9 @@ module VagrantPlugins
|
|
11
11
|
|
12
12
|
private
|
13
13
|
|
14
|
-
# @return [Vagrant::Plugin::V2::Config] the configuration
|
15
|
-
def config
|
16
|
-
return @config if @config
|
17
|
-
|
18
|
-
# Use only `config.git_proxy`, don't merge with the default config
|
19
|
-
@config = @machine.config.git_proxy
|
20
|
-
finalize_config(@config)
|
21
|
-
end
|
22
|
-
|
23
14
|
def configure_machine
|
15
|
+
return if !supported?
|
16
|
+
|
24
17
|
if config.http
|
25
18
|
@machine.communicate.sudo(
|
26
19
|
"#{git_path} config --system http.proxy #{config.http}")
|
@@ -29,6 +22,29 @@ module VagrantPlugins
|
|
29
22
|
"#{git_path} config --system --unset-all http.proxy",
|
30
23
|
error_check: false)
|
31
24
|
end
|
25
|
+
|
26
|
+
if config.https
|
27
|
+
@machine.communicate.sudo(
|
28
|
+
"#{git_path} config --system https.proxy #{config.https}")
|
29
|
+
else
|
30
|
+
@machine.communicate.sudo(
|
31
|
+
"#{git_path} config --system --unset-all https.proxy",
|
32
|
+
error_check: false)
|
33
|
+
end
|
34
|
+
|
35
|
+
true
|
36
|
+
end
|
37
|
+
|
38
|
+
def unconfigure_machine
|
39
|
+
return if !supported?
|
40
|
+
|
41
|
+
# zero out the configuration
|
42
|
+
config.http = nil
|
43
|
+
config.https = nil
|
44
|
+
|
45
|
+
configure_machine
|
46
|
+
|
47
|
+
true
|
32
48
|
end
|
33
49
|
|
34
50
|
def git_path
|
@@ -11,18 +11,24 @@ module VagrantPlugins
|
|
11
11
|
|
12
12
|
private
|
13
13
|
|
14
|
-
# @return [Vagrant::Plugin::V2::Config] the configuration
|
15
|
-
def config
|
16
|
-
# Use global proxy config
|
17
|
-
@config ||= finalize_config(@machine.config.proxy)
|
18
|
-
end
|
19
|
-
|
20
14
|
def configure_machine
|
21
15
|
set_or_delete_proxy('proxy', config.http)
|
22
16
|
set_or_delete_proxy('https-proxy', config.https)
|
17
|
+
set_or_delete_proxy('noproxy', config.no_proxy)
|
18
|
+
end
|
19
|
+
|
20
|
+
def unconfigure_machine
|
21
|
+
config.http = nil
|
22
|
+
config.https = nil
|
23
|
+
config.no_proxy = nil
|
24
|
+
configure_machine
|
25
|
+
|
26
|
+
true
|
23
27
|
end
|
24
28
|
|
25
29
|
def set_or_delete_proxy(key, value)
|
30
|
+
return if !supported?
|
31
|
+
|
26
32
|
command = "#{npm_path} config --global "
|
27
33
|
if value
|
28
34
|
command << "set #{key} #{escape(value)}"
|
@@ -34,6 +40,8 @@ module VagrantPlugins
|
|
34
40
|
@machine.communicate.sudo("#{npm_path} config --global set #{key} foo")
|
35
41
|
end
|
36
42
|
@machine.communicate.sudo(command)
|
43
|
+
|
44
|
+
true
|
37
45
|
end
|
38
46
|
|
39
47
|
def npm_path
|
@@ -11,17 +11,24 @@ module VagrantPlugins
|
|
11
11
|
|
12
12
|
private
|
13
13
|
|
14
|
-
# @return [Vagrant::Plugin::V2::Config] the configuration
|
15
|
-
def config
|
16
|
-
# Use global proxy config
|
17
|
-
@config ||= finalize_config(@machine.config.proxy)
|
18
|
-
end
|
19
|
-
|
20
14
|
def configure_machine
|
15
|
+
return if !supported?
|
16
|
+
|
17
|
+
config.http = nil if disabled?
|
21
18
|
proxy = config.http || ''
|
22
19
|
|
23
|
-
@machine.communicate.sudo(
|
24
|
-
|
20
|
+
@machine.communicate.sudo("#{pear_path} config-set http_proxy #{escape(proxy)} system")
|
21
|
+
|
22
|
+
true
|
23
|
+
end
|
24
|
+
|
25
|
+
def unconfigure_machine
|
26
|
+
return if !supported?
|
27
|
+
|
28
|
+
config.http = nil
|
29
|
+
configure_machine
|
30
|
+
|
31
|
+
true
|
25
32
|
end
|
26
33
|
|
27
34
|
def pear_path
|
@@ -12,17 +12,24 @@ module VagrantPlugins
|
|
12
12
|
|
13
13
|
private
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
def configure_machine
|
16
|
+
return if !supported?
|
17
|
+
|
18
|
+
write_config(svn_config, path: '/etc/subversion/servers')
|
18
19
|
|
19
|
-
|
20
|
-
@config = @machine.config.svn_proxy
|
21
|
-
finalize_config(@config)
|
20
|
+
true
|
22
21
|
end
|
23
22
|
|
24
|
-
def
|
25
|
-
|
23
|
+
def unconfigure_machine
|
24
|
+
return if !supported?
|
25
|
+
|
26
|
+
@machine.communicate.tap do |comm|
|
27
|
+
comm.sudo("touch /etc/subversion/servers")
|
28
|
+
comm.sudo("sed -i.bak -e '/^http-proxy-/d' /etc/subversion/servers")
|
29
|
+
comm.sudo("chown root:root /etc/subversion/servers")
|
30
|
+
comm.sudo("chmod 0644 /etc/subversion/servers")
|
31
|
+
end
|
32
|
+
true
|
26
33
|
end
|
27
34
|
|
28
35
|
def svn_config
|
@@ -14,6 +14,8 @@ module VagrantPlugins
|
|
14
14
|
private
|
15
15
|
|
16
16
|
def configure_machine
|
17
|
+
return if !supported?
|
18
|
+
|
17
19
|
tmp = "/tmp/vagrant-proxyconf"
|
18
20
|
path = config_path
|
19
21
|
|
@@ -27,6 +29,20 @@ module VagrantPlugins
|
|
27
29
|
comm.sudo("mv -f #{path}.new #{path}")
|
28
30
|
comm.sudo("rm -f #{tmp}")
|
29
31
|
end
|
32
|
+
|
33
|
+
true
|
34
|
+
end
|
35
|
+
|
36
|
+
def unconfigure_machine
|
37
|
+
return if !supported?
|
38
|
+
|
39
|
+
@machine.communicate.tap do |comm|
|
40
|
+
if comm.test("grep '^proxy' #{config_path}")
|
41
|
+
comm.sudo("sed -i.bak -e '/^proxy/d' #{config_path}")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
true
|
30
46
|
end
|
31
47
|
|
32
48
|
def proxy_params
|
@@ -15,8 +15,25 @@ module VagrantPlugins
|
|
15
15
|
|
16
16
|
private
|
17
17
|
|
18
|
+
def has_proxy_env_var?(var='HTTP_PROXY')
|
19
|
+
var_not_in_env = ENV[var].nil? || ENV[var] == ''
|
20
|
+
return false if var_not_in_env
|
21
|
+
|
22
|
+
true
|
23
|
+
end
|
24
|
+
|
25
|
+
def plugin_disabled?(config)
|
26
|
+
config.enabled == false || config.enabled == '' || config.enabled.nil? || config.enabled == {}
|
27
|
+
end
|
28
|
+
|
18
29
|
def plugin_enabled?(config)
|
19
|
-
|
30
|
+
return false if plugin_disabled?(config)
|
31
|
+
|
32
|
+
# check for existence of HTTP_PROXY and HTTPS_PROXY environment variables
|
33
|
+
has_proxy_var = has_proxy_env_var?('HTTP_PROXY') || has_proxy_env_var?('HTTPS_PROXY')
|
34
|
+
return false if has_proxy_var == false
|
35
|
+
|
36
|
+
true
|
20
37
|
end
|
21
38
|
end
|
22
39
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require_relative '../util'
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module ProxyConf
|
5
|
+
module Cap
|
6
|
+
module Linux
|
7
|
+
# Capability for chef proxy configuration
|
8
|
+
module ChefProxyConf
|
9
|
+
# @return [String, false] the path to chef or `false` if not found
|
10
|
+
def self.chef_proxy_conf(machine)
|
11
|
+
Util.which(machine, 'chef-client')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -13,7 +13,7 @@ module VagrantPlugins
|
|
13
13
|
|
14
14
|
return false if docker_command.nil?
|
15
15
|
|
16
|
-
if machine.communicate.test('
|
16
|
+
if machine.communicate.test('[ -f /etc/redhat-release ]')
|
17
17
|
"/etc/sysconfig/#{docker_command}"
|
18
18
|
elsif machine.communicate.test('ls /var/lib/boot2docker/')
|
19
19
|
"/var/lib/boot2docker/profile"
|
@@ -21,6 +21,7 @@ module VagrantPlugins
|
|
21
21
|
"/etc/default/#{docker_command}"
|
22
22
|
end
|
23
23
|
end
|
24
|
+
|
24
25
|
end
|
25
26
|
end
|
26
27
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module ProxyConf
|
3
|
+
module Cap
|
4
|
+
module Linux
|
5
|
+
# Capability for Yum proxy configuration
|
6
|
+
module YumProxyConf
|
7
|
+
# @return [String] the path to the configuration file
|
8
|
+
def self.yum_proxy_conf(machine)
|
9
|
+
machine.communicate.tap do |comm|
|
10
|
+
return '/etc/yum.conf' if comm.test('[ -f /etc/yum.conf ]')
|
11
|
+
return '/etc/yum/yum.conf' if comm.test('[ -f /etc/yum/yum.conf ]')
|
12
|
+
end
|
13
|
+
nil
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -6,11 +6,10 @@ module VagrantPlugins
|
|
6
6
|
# Returns path to the command on the machine, or false if it's not found
|
7
7
|
def self.which(machine, cmd)
|
8
8
|
path = false
|
9
|
-
status = machine.communicate.execute(
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
9
|
+
status = machine.communicate.execute("command -v #{cmd}", error_check: false) do |type, data|
|
10
|
+
# search for the command to work around `ssh.pty = true`
|
11
|
+
path = data.chomp if type == :stdout && data =~ /#{cmd}$/
|
12
|
+
end
|
14
13
|
status == 0 && path
|
15
14
|
end
|
16
15
|
end
|
@@ -13,6 +13,11 @@ module VagrantPlugins
|
|
13
13
|
Cap::Linux::DockerProxyConf
|
14
14
|
end
|
15
15
|
|
16
|
+
guest_capability 'linux', 'chef_proxy_conf' do
|
17
|
+
require_relative 'cap/linux/chef_proxy_conf'
|
18
|
+
Cap::Linux::ChefProxyConf
|
19
|
+
end
|
20
|
+
|
16
21
|
guest_capability 'coreos', 'docker_proxy_conf' do
|
17
22
|
require_relative 'cap/coreos/docker_proxy_conf'
|
18
23
|
Cap::CoreOS::DockerProxyConf
|
@@ -57,6 +62,11 @@ module VagrantPlugins
|
|
57
62
|
require_relative 'cap/redhat/yum_proxy_conf'
|
58
63
|
Cap::Redhat::YumProxyConf
|
59
64
|
end
|
65
|
+
|
66
|
+
guest_capability 'linux', 'yum_proxy_conf' do
|
67
|
+
require_relative 'cap/linux/yum_proxy_conf'
|
68
|
+
Cap::Linux::YumProxyConf
|
69
|
+
end
|
60
70
|
end
|
61
71
|
end
|
62
72
|
end
|
@@ -8,6 +8,16 @@ module VagrantPlugins
|
|
8
8
|
Config::AptProxy
|
9
9
|
end
|
10
10
|
|
11
|
+
config 'chef_proxy' do
|
12
|
+
require_relative 'config/chef_proxy'
|
13
|
+
Config::ChefProxy
|
14
|
+
end
|
15
|
+
|
16
|
+
config 'docker_proxy' do
|
17
|
+
require_relative 'config/docker_proxy'
|
18
|
+
Config::DockerProxy
|
19
|
+
end
|
20
|
+
|
11
21
|
config 'env_proxy' do
|
12
22
|
require_relative 'config/env_proxy'
|
13
23
|
Config::EnvProxy
|
@@ -18,6 +28,16 @@ module VagrantPlugins
|
|
18
28
|
Config::GitProxy
|
19
29
|
end
|
20
30
|
|
31
|
+
config 'npm_proxy' do
|
32
|
+
require_relative 'config/npm_proxy'
|
33
|
+
Config::NpmProxy
|
34
|
+
end
|
35
|
+
|
36
|
+
config 'pear_proxy' do
|
37
|
+
require_relative 'config/pear_proxy'
|
38
|
+
Config::PearProxy
|
39
|
+
end
|
40
|
+
|
21
41
|
config 'proxy' do
|
22
42
|
require_relative 'config/proxy'
|
23
43
|
Config::Proxy
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'vagrant'
|
2
|
+
require_relative 'key_mixin'
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module ProxyConf
|
6
|
+
module Config
|
7
|
+
# Configuration for generic `<protocol>_proxy` environment variables
|
8
|
+
#
|
9
|
+
# @!parse class ChefProxy < Vagrant::Plugin::V2::Config; end
|
10
|
+
class ChefProxy < Vagrant.plugin('2', :config)
|
11
|
+
include KeyMixin
|
12
|
+
# @!parse extend KeyMixin::ClassMethods
|
13
|
+
|
14
|
+
# @return [String] the HTTP proxy
|
15
|
+
key :http, env_var: 'VAGRANT_CHEF_HTTP_PROXY'
|
16
|
+
|
17
|
+
# @return [String] the HTTPS proxy
|
18
|
+
key :https, env_var: 'VAGRANT_CHEF_HTTPS_PROXY'
|
19
|
+
|
20
|
+
# @return [String] a comma separated list of hosts or domains which do not use proxies
|
21
|
+
key :no_proxy, env_var: 'VAGRANT_CHEF_NO_PROXY'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'vagrant'
|
2
|
+
require_relative 'key_mixin'
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module ProxyConf
|
6
|
+
module Config
|
7
|
+
# Configuration for generic `<protocol>_proxy` environment variables
|
8
|
+
#
|
9
|
+
# @!parse class DockerProxy < Vagrant::Plugin::V2::Config; end
|
10
|
+
class DockerProxy < Vagrant.plugin('2', :config)
|
11
|
+
include KeyMixin
|
12
|
+
# @!parse extend KeyMixin::ClassMethods
|
13
|
+
|
14
|
+
# @return [String] the HTTP proxy
|
15
|
+
key :http, env_var: 'VAGRANT_DOCKER_HTTP_PROXY'
|
16
|
+
|
17
|
+
# @return [String] the HTTPS proxy
|
18
|
+
key :https, env_var: 'VAGRANT_DOCKER_HTTPS_PROXY'
|
19
|
+
|
20
|
+
# @return [String] a comma separated list of hosts or domains which do not use proxies
|
21
|
+
key :no_proxy, env_var: 'VAGRANT_DOCKER_NO_PROXY'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'vagrant'
|
2
|
+
require_relative 'key_mixin'
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module ProxyConf
|
6
|
+
module Config
|
7
|
+
# Proxy configuration for npm
|
8
|
+
#
|
9
|
+
# @!parse class NpmProxy < Vagrant::Plugin::V2::Config; end
|
10
|
+
class NpmProxy < Vagrant.plugin('2', :config)
|
11
|
+
include KeyMixin
|
12
|
+
# @!parse extend KeyMixin::ClassMethods
|
13
|
+
|
14
|
+
# @return [String] the HTTP proxy
|
15
|
+
key :http, env_var: 'VAGRANT_NPM_HTTP_PROXY'
|
16
|
+
|
17
|
+
# @return [String] the HTTPS proxy
|
18
|
+
key :https, env_var: 'VAGRANT_NPM_HTTPS_PROXY'
|
19
|
+
|
20
|
+
# @return [String] the HTTPS proxy
|
21
|
+
key :no_proxy, env_var: 'VAGRANT_NPM_NO_PROXY'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'vagrant'
|
2
|
+
require_relative 'key_mixin'
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module ProxyConf
|
6
|
+
module Config
|
7
|
+
# Proxy configuration for pear
|
8
|
+
#
|
9
|
+
# @!parse class PearProxy < Vagrant::Plugin::V2::Config; end
|
10
|
+
class PearProxy < Vagrant.plugin('2', :config)
|
11
|
+
include KeyMixin
|
12
|
+
# @!parse extend KeyMixin::ClassMethods
|
13
|
+
|
14
|
+
# @return [String] the HTTP proxy
|
15
|
+
key :http, env_var: 'VAGRANT_PEAR_HTTP_PROXY'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|