vagrant-proxyconf 1.3.2 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +7 -0
- data/Gemfile +3 -2
- data/README.md +1 -0
- data/lib/vagrant-proxyconf/action.rb +2 -0
- data/lib/vagrant-proxyconf/action/configure_docker_proxy.rb +88 -0
- data/lib/vagrant-proxyconf/cap/coreos/docker_proxy_conf.rb +28 -0
- data/lib/vagrant-proxyconf/cap/linux/docker_proxy_conf.rb +28 -0
- data/lib/vagrant-proxyconf/capability.rb +10 -0
- data/lib/vagrant-proxyconf/version.rb +1 -1
- data/locales/en.yml +8 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/unit/support/shared/apt_proxy_config.rb +9 -9
- data/spec/unit/vagrant-proxyconf/action/configure_apt_proxy_spec.rb +1 -1
- data/spec/unit/vagrant-proxyconf/action/configure_chef_proxy_spec.rb +1 -1
- data/spec/unit/vagrant-proxyconf/action/configure_docker_proxy_spec.rb +10 -0
- data/spec/unit/vagrant-proxyconf/action/configure_env_proxy_spec.rb +1 -1
- data/spec/unit/vagrant-proxyconf/action/configure_git_proxy_spec.rb +1 -1
- data/spec/unit/vagrant-proxyconf/action/configure_npm_proxy_spec.rb +1 -1
- data/spec/unit/vagrant-proxyconf/action/configure_pear_proxy_spec.rb +1 -1
- data/spec/unit/vagrant-proxyconf/action/configure_svn_proxy_spec.rb +1 -1
- data/spec/unit/vagrant-proxyconf/action/configure_yum_proxy_spec.rb +6 -6
- data/spec/unit/vagrant-proxyconf/action/is_enabled_spec.rb +11 -5
- data/spec/unit/vagrant-proxyconf/cap/debian/apt_proxy_conf_spec.rb +1 -1
- data/spec/unit/vagrant-proxyconf/cap/linux/docker_proxy_conf_spec.rb +60 -0
- data/spec/unit/vagrant-proxyconf/cap/linux/env_proxy_conf_spec.rb +1 -1
- data/spec/unit/vagrant-proxyconf/cap/linux/git_proxy_conf_spec.rb +3 -3
- data/spec/unit/vagrant-proxyconf/cap/linux/npm_proxy_conf_spec.rb +3 -3
- data/spec/unit/vagrant-proxyconf/cap/linux/pear_proxy_conf_spec.rb +3 -3
- data/spec/unit/vagrant-proxyconf/cap/linux/svn_proxy_conf_spec.rb +3 -3
- data/spec/unit/vagrant-proxyconf/cap/redhat/yum_proxy_conf_spec.rb +1 -1
- data/spec/unit/vagrant-proxyconf/cap/util_spec.rb +2 -2
- data/spec/unit/vagrant-proxyconf/cap/windows/env_proxy_conf_spec.rb +1 -1
- data/spec/unit/vagrant-proxyconf/config/apt_proxy_spec.rb +2 -2
- data/spec/unit/vagrant-proxyconf/config/env_proxy_spec.rb +4 -4
- data/spec/unit/vagrant-proxyconf/config/key_mixin_spec.rb +8 -2
- data/spec/unit/vagrant-proxyconf/logger_spec.rb +1 -1
- data/spec/unit/vagrant-proxyconf/plugin_spec.rb +8 -8
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01b50f214b87a8c1d79057bce5f6d1b23b0ae19f
|
4
|
+
data.tar.gz: 4e0448369bd0b1d0661523502f262e401680db90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b411ae888f87e672a32e08a3d7e6e0cbfb631dc3ae798daae9f738bbe6e096b4e6ad70c0c7164902b64e23daa8d40c38521ffc4f8d42392bad79564d307fc9f
|
7
|
+
data.tar.gz: af7095bc3dd5765871d17c5066a13bfb49406e0012121569abf2c04f63e80923831b45b12c57dd4643aa472576c98ad9904c79cdb960bf3be6583d98e79ff684
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
# 1.4.0 / 2014-09-28
|
2
|
+
|
3
|
+
Features:
|
4
|
+
|
5
|
+
- Support for configuring Docker ([GH-69][])
|
6
|
+
|
1
7
|
# 1.3.2 / 2014-05-30
|
2
8
|
|
3
9
|
Improvements:
|
@@ -174,3 +180,4 @@ Bug fixes:
|
|
174
180
|
[GH-62]: https://github.com/tmatilai/vagrant-proxyconf/issues/62 "Issue 62"
|
175
181
|
[GH-63]: https://github.com/tmatilai/vagrant-proxyconf/issues/63 "Issue 63"
|
176
182
|
[GH-67]: https://github.com/tmatilai/vagrant-proxyconf/issues/67 "Issue 67"
|
183
|
+
[GH-69]: https://github.com/tmatilai/vagrant-proxyconf/issues/69 "Issue 69"
|
data/Gemfile
CHANGED
@@ -2,12 +2,13 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
gem 'vagrant',
|
4
4
|
git: 'https://github.com/mitchellh/vagrant.git',
|
5
|
-
ref: ENV.fetch('VAGRANT_VERSION', 'v1.6.
|
5
|
+
ref: ENV.fetch('VAGRANT_VERSION', 'v1.6.5')
|
6
6
|
|
7
7
|
gem 'cane', '~> 2.6'
|
8
8
|
gem 'coveralls', require: false
|
9
9
|
gem 'rake'
|
10
|
-
gem 'rspec', '~>
|
10
|
+
gem 'rspec', '~> 3.1'
|
11
|
+
gem 'rspec-its', '~> 1.0'
|
11
12
|
gem 'tailor', '~> 1.4'
|
12
13
|
|
13
14
|
group :development do
|
data/README.md
CHANGED
@@ -21,6 +21,7 @@ The plugin can set:
|
|
21
21
|
* generic `http_proxy` etc. environment variables that many programs support
|
22
22
|
* default proxy configuration for all Chef provisioners
|
23
23
|
* proxy configuration for Apt
|
24
|
+
* proxy configuration for docker
|
24
25
|
* proxy configuration for npm
|
25
26
|
* proxy configuration for Yum
|
26
27
|
* proxy configuration for PEAR
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'vagrant/action/builtin/call'
|
2
2
|
require_relative 'action/configure_apt_proxy'
|
3
3
|
require_relative 'action/configure_chef_proxy'
|
4
|
+
require_relative 'action/configure_docker_proxy'
|
4
5
|
require_relative 'action/configure_env_proxy'
|
5
6
|
require_relative 'action/configure_git_proxy'
|
6
7
|
require_relative 'action/configure_npm_proxy'
|
@@ -51,6 +52,7 @@ module VagrantPlugins
|
|
51
52
|
|
52
53
|
b2.use ConfigureAptProxy
|
53
54
|
b2.use ConfigureChefProxy
|
55
|
+
b2.use ConfigureDockerProxy
|
54
56
|
b2.use ConfigureEnvProxy
|
55
57
|
b2.use ConfigureGitProxy
|
56
58
|
b2.use ConfigureNpmProxy
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require_relative 'base'
|
2
|
+
require_relative '../resource'
|
3
|
+
require_relative '../userinfo_uri'
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module ProxyConf
|
7
|
+
class Action
|
8
|
+
# Action for configuring Docker on the guest
|
9
|
+
class ConfigureDockerProxy < Base
|
10
|
+
def config_name
|
11
|
+
'docker_proxy'
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def config
|
17
|
+
# Use global proxy config
|
18
|
+
@config ||= finalize_config(@machine.config.proxy)
|
19
|
+
end
|
20
|
+
|
21
|
+
def configure_machine
|
22
|
+
logger.info('Writing the proxy configuration to docker config')
|
23
|
+
detect_export
|
24
|
+
write_docker_config
|
25
|
+
end
|
26
|
+
|
27
|
+
def docker
|
28
|
+
if config_path && config_path.include?('docker.io')
|
29
|
+
'docker.io'
|
30
|
+
else
|
31
|
+
'docker'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def write_docker_config
|
36
|
+
tmp = "/tmp/vagrant-proxyconf"
|
37
|
+
path = config_path
|
38
|
+
|
39
|
+
@machine.communicate.tap do |comm|
|
40
|
+
sed_script = docker_sed_script
|
41
|
+
local_tmp = tempfile(docker_config)
|
42
|
+
|
43
|
+
comm.sudo("rm #{tmp}", error_check: false)
|
44
|
+
comm.upload(local_tmp.path, tmp)
|
45
|
+
comm.sudo("touch #{path}")
|
46
|
+
comm.sudo("sed -e '#{sed_script}' #{path} > #{path}.new")
|
47
|
+
comm.sudo("cat #{tmp} >> #{path}.new")
|
48
|
+
comm.sudo("chmod 0644 #{path}.new")
|
49
|
+
comm.sudo("chown root:root #{path}.new")
|
50
|
+
comm.sudo("mv #{path}.new #{path}")
|
51
|
+
comm.sudo("rm #{tmp}")
|
52
|
+
comm.sudo(service_restart_command)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def detect_export
|
57
|
+
@machine.communicate.tap do |comm|
|
58
|
+
comm.test('which systemctl') ? @export = '' : @export = 'export '
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def service_restart_command
|
63
|
+
["systemctl restart #{docker}",
|
64
|
+
"service #{docker} restart",
|
65
|
+
"/etc/init.d/#{docker} restart"].join(' || ')
|
66
|
+
end
|
67
|
+
|
68
|
+
def docker_sed_script
|
69
|
+
<<-SED.gsub(/^\s+/, '')
|
70
|
+
/^#{@export}HTTP_PROXY=/ d
|
71
|
+
/^#{@export}NO_PROXY=/ d
|
72
|
+
/^#{@export}http_proxy=/ d
|
73
|
+
/^#{@export}no_proxy=/ d
|
74
|
+
SED
|
75
|
+
end
|
76
|
+
|
77
|
+
def docker_config
|
78
|
+
<<-CONFIG.gsub(/^\s+/, '')
|
79
|
+
#{@export}HTTP_PROXY=#{config.http || ''}
|
80
|
+
#{@export}NO_PROXY=#{config.no_proxy || ''}
|
81
|
+
#{@export}http_proxy=#{config.http || ''}
|
82
|
+
#{@export}no_proxy=#{config.no_proxy || ''}
|
83
|
+
CONFIG
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require_relative '../util'
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module ProxyConf
|
5
|
+
module Cap
|
6
|
+
module CoreOS
|
7
|
+
# Capability for docker proxy configuration
|
8
|
+
module DockerProxyConf
|
9
|
+
# @return [String, false] the path to docker or `false` if not found
|
10
|
+
def self.docker_proxy_conf(machine)
|
11
|
+
return false unless Util.which(machine, 'docker')
|
12
|
+
|
13
|
+
machine.communicate.tap do |comm|
|
14
|
+
src_file='/usr/lib/systemd/system/docker.service'
|
15
|
+
tmp_file='/tmp/docker.service'
|
16
|
+
env_file='EnvironmentFile=-\/etc\/default\/docker'
|
17
|
+
comm.sudo("sed -e 's/\\[Service\\]/[Service]\\n#{env_file}/g' #{src_file} > #{tmp_file}")
|
18
|
+
|
19
|
+
comm.sudo('mv /tmp/docker.service /etc/systemd/system/')
|
20
|
+
comm.sudo('systemctl daemon-reload')
|
21
|
+
end
|
22
|
+
'/etc/default/docker'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require_relative '../util'
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module ProxyConf
|
5
|
+
module Cap
|
6
|
+
module Linux
|
7
|
+
# Capability for docker proxy configuration
|
8
|
+
module DockerProxyConf
|
9
|
+
# @return [String, false] the path to docker or `false` if not found
|
10
|
+
def self.docker_proxy_conf(machine)
|
11
|
+
docker_command = 'docker' if Util.which(machine, 'docker')
|
12
|
+
docker_command = 'docker.io' if Util.which(machine, 'docker.io')
|
13
|
+
|
14
|
+
return false if docker_command.nil?
|
15
|
+
|
16
|
+
if machine.communicate.test('cat /etc/redhat-release')
|
17
|
+
"/etc/sysconfig/#{docker_command}"
|
18
|
+
elsif machine.communicate.test('ls /var/lib/boot2docker/')
|
19
|
+
"/var/lib/boot2docker/profile"
|
20
|
+
else
|
21
|
+
"/etc/default/#{docker_command}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -8,6 +8,16 @@ module VagrantPlugins
|
|
8
8
|
Cap::Debian::AptProxyConf
|
9
9
|
end
|
10
10
|
|
11
|
+
guest_capability 'linux', 'docker_proxy_conf' do
|
12
|
+
require_relative 'cap/linux/docker_proxy_conf'
|
13
|
+
Cap::Linux::DockerProxyConf
|
14
|
+
end
|
15
|
+
|
16
|
+
guest_capability 'coreos', 'docker_proxy_conf' do
|
17
|
+
require_relative 'cap/coreos/docker_proxy_conf'
|
18
|
+
Cap::CoreOS::DockerProxyConf
|
19
|
+
end
|
20
|
+
|
11
21
|
guest_capability 'linux', 'env_proxy_conf' do
|
12
22
|
require_relative 'cap/linux/env_proxy_conf'
|
13
23
|
Cap::Linux::EnvProxyConf
|
data/locales/en.yml
CHANGED
@@ -8,6 +8,14 @@ en:
|
|
8
8
|
configuring: |-
|
9
9
|
Configuring proxy for Apt...
|
10
10
|
|
11
|
+
docker_proxy:
|
12
|
+
not_enabled: |-
|
13
|
+
docker_proxy not enabled or configured
|
14
|
+
not_supported: |-
|
15
|
+
Skipping Docker proxy config as the machine does not support it
|
16
|
+
configuring: |-
|
17
|
+
Configuring proxy for Docker...
|
18
|
+
|
11
19
|
chef_proxy:
|
12
20
|
no_provisioners: |-
|
13
21
|
No Chef provisioners configured
|
data/spec/spec_helper.rb
CHANGED
@@ -23,44 +23,44 @@ shared_examples "apt proxy config" do |proto|
|
|
23
23
|
|
24
24
|
context "with ip" do
|
25
25
|
subject { config_with(proto => "10.1.2.3") }
|
26
|
-
its(:enabled?) { should
|
26
|
+
its(:enabled?) { should be_truthy }
|
27
27
|
its(:to_s) { should eq conf_line(proto, "10.1.2.3") }
|
28
28
|
end
|
29
29
|
|
30
30
|
context "with name" do
|
31
31
|
subject { config_with(proto => "proxy.example.com") }
|
32
|
-
its(:enabled?) { should
|
32
|
+
its(:enabled?) { should be_truthy }
|
33
33
|
its(:to_s) { should eq conf_line(proto, "proxy.example.com") }
|
34
34
|
end
|
35
35
|
|
36
36
|
context "with name and port" do
|
37
37
|
subject { config_with(proto => "acng:8080") }
|
38
|
-
its(:enabled?) { should
|
38
|
+
its(:enabled?) { should be_truthy }
|
39
39
|
its(:to_s) { should eq conf_line(proto, "acng", 8080) }
|
40
40
|
end
|
41
41
|
|
42
42
|
context "with protocol and name" do
|
43
43
|
subject { config_with(proto => "#{proto}://proxy.foo.tld") }
|
44
|
-
its(:enabled?) { should
|
44
|
+
its(:enabled?) { should be_truthy }
|
45
45
|
its(:to_s) { should eq conf_line(proto, "proxy.foo.tld", nil) }
|
46
46
|
end
|
47
47
|
|
48
48
|
context "with trailing slash" do
|
49
49
|
subject { config_with(proto => "#{proto}://proxy.foo.tld/") }
|
50
|
-
its(:enabled?) { should
|
50
|
+
its(:enabled?) { should be_truthy }
|
51
51
|
its(:to_s) { should eq conf_line(proto, "proxy.foo.tld/", nil) }
|
52
52
|
end
|
53
53
|
|
54
54
|
context "with protocol and name and port" do
|
55
55
|
subject { config_with(proto => "#{proto}://prism.nsa.gov:666") }
|
56
|
-
its(:enabled?) { should
|
56
|
+
its(:enabled?) { should be_truthy }
|
57
57
|
its(:to_s) { should eq conf_line(proto, "prism.nsa.gov", 666) }
|
58
58
|
end
|
59
59
|
|
60
60
|
["DIRECT", "direct"].each do |direct|
|
61
61
|
context "with #{direct.inspect}" do
|
62
62
|
subject { config_with(proto => direct) }
|
63
|
-
its(:enabled?) { should
|
63
|
+
its(:enabled?) { should be_truthy }
|
64
64
|
its(:to_s) { should eq conf_line(proto, :direct) }
|
65
65
|
end
|
66
66
|
end
|
@@ -68,14 +68,14 @@ shared_examples "apt proxy config" do |proto|
|
|
68
68
|
[false, ""].each do |unset|
|
69
69
|
context "with #{unset.inspect}" do
|
70
70
|
subject { config_with(proto => unset) }
|
71
|
-
its(:enabled?) { should
|
71
|
+
its(:enabled?) { should be_truthy }
|
72
72
|
its(:to_s) { should eq "" }
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
76
|
context "with nil" do
|
77
77
|
subject { config_with(proto => nil) }
|
78
|
-
its(:enabled?) { should
|
78
|
+
its(:enabled?) { should be_falsey }
|
79
79
|
its(:to_s) { should eq "" }
|
80
80
|
end
|
81
81
|
|
@@ -10,7 +10,7 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureChefProxy do
|
|
10
10
|
|
11
11
|
def configure_chef
|
12
12
|
action = described_class.new(nil, nil)
|
13
|
-
action.
|
13
|
+
allow(action).to receive(:config) { config }
|
14
14
|
action.send(:configure_chef, chef)
|
15
15
|
end
|
16
16
|
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'vagrant-proxyconf/action/configure_docker_proxy'
|
3
|
+
|
4
|
+
describe VagrantPlugins::ProxyConf::Action::ConfigureDockerProxy do
|
5
|
+
|
6
|
+
describe '#config_name' do
|
7
|
+
subject { described_class.new(double, double).config_name }
|
8
|
+
it { is_expected.to eq 'docker_proxy' }
|
9
|
+
end
|
10
|
+
end
|
@@ -5,35 +5,35 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureYumProxy do
|
|
5
5
|
|
6
6
|
describe '#config_name' do
|
7
7
|
subject { described_class.new(double, double).config_name }
|
8
|
-
it {
|
8
|
+
it { is_expected.to eq 'yum_proxy' }
|
9
9
|
end
|
10
10
|
|
11
11
|
describe '#proxy_params' do
|
12
12
|
subject do
|
13
13
|
action = described_class.new(nil, nil)
|
14
|
-
action.
|
14
|
+
allow(action).to receive(:config) { config }
|
15
15
|
action.send(:proxy_params)
|
16
16
|
end
|
17
17
|
let(:config) { OpenStruct.new(http: http) }
|
18
18
|
|
19
19
|
context "with `false`" do
|
20
20
|
let(:http) { false }
|
21
|
-
it {
|
21
|
+
it { is_expected.to eq %q{-v proxy='' -v user='' -v pass=''} }
|
22
22
|
end
|
23
23
|
|
24
24
|
context "without userinfo" do
|
25
25
|
let(:http) { 'http://proxy:1234/' }
|
26
|
-
it {
|
26
|
+
it { is_expected.to eq %q{-v proxy=http://proxy:1234 -v user='' -v pass=''} }
|
27
27
|
end
|
28
28
|
|
29
29
|
context "with userinfo" do
|
30
30
|
let(:http) { 'http://foo:bar@myproxy:9876' }
|
31
|
-
it {
|
31
|
+
it { is_expected.to eq %q{-v proxy=http://myproxy:9876 -v user=foo -v pass=bar} }
|
32
32
|
end
|
33
33
|
|
34
34
|
context "with special characters" do
|
35
35
|
let(:http) { %q{http://x*y:a(b@proxy.com:8080} }
|
36
|
-
it {
|
36
|
+
it { is_expected.to eq %q{-v proxy=http://proxy.com:8080 -v user=x\\*y -v pass=a\\(b} }
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
@@ -5,13 +5,19 @@ describe VagrantPlugins::ProxyConf::Action::IsEnabled do
|
|
5
5
|
let(:app) { lambda { |env| } }
|
6
6
|
let(:env) { { :machine => machine } }
|
7
7
|
let(:machine) do
|
8
|
-
double('machine').tap
|
8
|
+
double('machine').tap do |machine|
|
9
|
+
allow(machine).to receive(:config) { config }
|
10
|
+
end
|
9
11
|
end
|
10
12
|
let(:config) do
|
11
|
-
double('config').tap
|
13
|
+
double('config').tap do |config|
|
14
|
+
allow(config).to receive(:proxy) { proxy_config }
|
15
|
+
end
|
12
16
|
end
|
13
17
|
let(:proxy_config) do
|
14
|
-
double('proxy_config').tap
|
18
|
+
double('proxy_config').tap do |config|
|
19
|
+
allow(config).to receive(:enabled) { enabled }
|
20
|
+
end
|
15
21
|
end
|
16
22
|
|
17
23
|
[false, ''].each do |value|
|
@@ -20,7 +26,7 @@ describe VagrantPlugins::ProxyConf::Action::IsEnabled do
|
|
20
26
|
|
21
27
|
it "results to falsy" do
|
22
28
|
described_class.new(app, {}).call(env)
|
23
|
-
expect(env[:result]).to
|
29
|
+
expect(env[:result]).to be_falsey
|
24
30
|
end
|
25
31
|
end
|
26
32
|
end
|
@@ -31,7 +37,7 @@ describe VagrantPlugins::ProxyConf::Action::IsEnabled do
|
|
31
37
|
|
32
38
|
it "results to truthy" do
|
33
39
|
described_class.new(app, {}).call(env)
|
34
|
-
expect(env[:result]).to
|
40
|
+
expect(env[:result]).to be_truthy
|
35
41
|
end
|
36
42
|
end
|
37
43
|
end
|
@@ -5,7 +5,7 @@ describe VagrantPlugins::ProxyConf::Cap::Debian::AptProxyConf do
|
|
5
5
|
|
6
6
|
describe '.apt_proxy_conf' do
|
7
7
|
let(:subject) { described_class.apt_proxy_conf(double) }
|
8
|
-
it {
|
8
|
+
it { is_expected.to eq '/etc/apt/apt.conf.d/01proxy' }
|
9
9
|
end
|
10
10
|
|
11
11
|
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'vagrant-proxyconf/cap/linux/docker_proxy_conf'
|
3
|
+
require 'vagrant-proxyconf/cap/util'
|
4
|
+
|
5
|
+
describe VagrantPlugins::ProxyConf::Cap::Linux::DockerProxyConf do
|
6
|
+
|
7
|
+
describe '.docker_proxy_conf' do
|
8
|
+
let(:machine) { double }
|
9
|
+
let(:communicator) { double }
|
10
|
+
|
11
|
+
before do
|
12
|
+
allow(machine).to receive(:communicate) { communicator }
|
13
|
+
end
|
14
|
+
|
15
|
+
it "returns the path when docker is installed on Redhat" do
|
16
|
+
allow(VagrantPlugins::ProxyConf::Cap::Util).to receive(:which) do |_m, c|
|
17
|
+
(c == 'docker') ? '/path/to/docker' : false
|
18
|
+
end
|
19
|
+
allow(communicator).to receive(:test) do |c|
|
20
|
+
c == 'cat /etc/redhat-release'
|
21
|
+
end
|
22
|
+
|
23
|
+
expect(described_class.docker_proxy_conf(machine)).to eq '/etc/sysconfig/docker'
|
24
|
+
end
|
25
|
+
|
26
|
+
it "returns the path when docker is installed on Debian or Ubuntu" do
|
27
|
+
allow(VagrantPlugins::ProxyConf::Cap::Util).to receive(:which) do |_m, c|
|
28
|
+
(c == 'docker') ? '/path/to/docker' : false
|
29
|
+
end
|
30
|
+
allow(communicator).to receive(:test) { false }
|
31
|
+
|
32
|
+
expect(described_class.docker_proxy_conf(machine)).to eq '/etc/default/docker'
|
33
|
+
end
|
34
|
+
|
35
|
+
it "returns the path when docker.io is installed on Ubuntu 14.04 or higher" do
|
36
|
+
allow(VagrantPlugins::ProxyConf::Cap::Util).to receive(:which) do |_m, c|
|
37
|
+
(c == 'docker.io') ? '/path/to/docker.io': false
|
38
|
+
end
|
39
|
+
allow(communicator).to receive(:test) { false }
|
40
|
+
|
41
|
+
expect(described_class.docker_proxy_conf(machine)).to eq '/etc/default/docker.io'
|
42
|
+
end
|
43
|
+
|
44
|
+
it "returns the path when docker is installed on boot2docker" do
|
45
|
+
allow(VagrantPlugins::ProxyConf::Cap::Util).to receive(:which) do |_m, c|
|
46
|
+
(c == 'docker') ? '/path/to/docker' : false
|
47
|
+
end
|
48
|
+
allow(communicator).to receive(:test) do |c|
|
49
|
+
c == 'ls /var/lib/boot2docker'
|
50
|
+
end
|
51
|
+
|
52
|
+
expect(described_class.docker_proxy_conf(machine)).to eq '/etc/default/docker'
|
53
|
+
end
|
54
|
+
|
55
|
+
it "returns false when docker is not installed" do
|
56
|
+
allow(VagrantPlugins::ProxyConf::Cap::Util).to receive(:which) { false }
|
57
|
+
expect(described_class.docker_proxy_conf(machine)).to be_falsey
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -5,7 +5,7 @@ describe VagrantPlugins::ProxyConf::Cap::Linux::EnvProxyConf do
|
|
5
5
|
|
6
6
|
describe '.env_proxy_conf' do
|
7
7
|
let(:subject) { described_class.env_proxy_conf(double) }
|
8
|
-
it {
|
8
|
+
it { is_expected.to eq '/etc/profile.d/proxy.sh' }
|
9
9
|
end
|
10
10
|
|
11
11
|
end
|
@@ -8,13 +8,13 @@ describe VagrantPlugins::ProxyConf::Cap::Linux::GitProxyConf do
|
|
8
8
|
let(:machine) { double }
|
9
9
|
|
10
10
|
it "returns the path when git is installed" do
|
11
|
-
VagrantPlugins::ProxyConf::Cap::Util.
|
11
|
+
allow(VagrantPlugins::ProxyConf::Cap::Util).to receive(:which) { '/path/to/git' }
|
12
12
|
expect(described_class.git_proxy_conf(machine)).to eq '/path/to/git'
|
13
13
|
end
|
14
14
|
|
15
15
|
it "returns false when git is not installed" do
|
16
|
-
VagrantPlugins::ProxyConf::Cap::Util.
|
17
|
-
expect(described_class.git_proxy_conf(machine)).to
|
16
|
+
allow(VagrantPlugins::ProxyConf::Cap::Util).to receive(:which) { false }
|
17
|
+
expect(described_class.git_proxy_conf(machine)).to be_falsey
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -8,13 +8,13 @@ describe VagrantPlugins::ProxyConf::Cap::Linux::NpmProxyConf do
|
|
8
8
|
let(:machine) { double }
|
9
9
|
|
10
10
|
it "returns the path when npm is installed" do
|
11
|
-
VagrantPlugins::ProxyConf::Cap::Util.
|
11
|
+
allow(VagrantPlugins::ProxyConf::Cap::Util).to receive(:which) { '/path/to/npm' }
|
12
12
|
expect(described_class.npm_proxy_conf(machine)).to eq '/path/to/npm'
|
13
13
|
end
|
14
14
|
|
15
15
|
it "returns false when npm is not installed" do
|
16
|
-
VagrantPlugins::ProxyConf::Cap::Util.
|
17
|
-
expect(described_class.npm_proxy_conf(machine)).to
|
16
|
+
allow(VagrantPlugins::ProxyConf::Cap::Util).to receive(:which) { false }
|
17
|
+
expect(described_class.npm_proxy_conf(machine)).to be_falsey
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -8,13 +8,13 @@ describe VagrantPlugins::ProxyConf::Cap::Linux::PearProxyConf do
|
|
8
8
|
let(:machine) { double }
|
9
9
|
|
10
10
|
it "returns the path when pear is installed" do
|
11
|
-
VagrantPlugins::ProxyConf::Cap::Util.
|
11
|
+
allow(VagrantPlugins::ProxyConf::Cap::Util).to receive(:which) { '/path/to/pear' }
|
12
12
|
expect(described_class.pear_proxy_conf(machine)).to eq '/path/to/pear'
|
13
13
|
end
|
14
14
|
|
15
15
|
it "returns false when pear is not installed" do
|
16
|
-
VagrantPlugins::ProxyConf::Cap::Util.
|
17
|
-
expect(described_class.pear_proxy_conf(machine)).to
|
16
|
+
allow(VagrantPlugins::ProxyConf::Cap::Util).to receive(:which) { false }
|
17
|
+
expect(described_class.pear_proxy_conf(machine)).to be_falsey
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -8,13 +8,13 @@ describe VagrantPlugins::ProxyConf::Cap::Linux::SvnProxyConf do
|
|
8
8
|
let(:machine) { double }
|
9
9
|
|
10
10
|
it "returns true when svn is installed" do
|
11
|
-
VagrantPlugins::ProxyConf::Cap::Util.
|
11
|
+
allow(VagrantPlugins::ProxyConf::Cap::Util).to receive(:which) { '/path/to/svn' }
|
12
12
|
expect(described_class.svn_proxy_conf(machine)).to eq '/path/to/svn'
|
13
13
|
end
|
14
14
|
|
15
15
|
it "returns false when pear is not installed" do
|
16
|
-
VagrantPlugins::ProxyConf::Cap::Util.
|
17
|
-
expect(described_class.svn_proxy_conf(machine)).to
|
16
|
+
allow(VagrantPlugins::ProxyConf::Cap::Util).to receive(:which) { false }
|
17
|
+
expect(described_class.svn_proxy_conf(machine)).to be_falsey
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -8,7 +8,7 @@ describe VagrantPlugins::ProxyConf::Cap::Util do
|
|
8
8
|
let(:communicator) { double }
|
9
9
|
|
10
10
|
before do
|
11
|
-
machine.
|
11
|
+
allow(machine).to receive(:communicate) { communicator }
|
12
12
|
end
|
13
13
|
|
14
14
|
it "returns the path when the command is installed" do
|
@@ -25,7 +25,7 @@ describe VagrantPlugins::ProxyConf::Cap::Util do
|
|
25
25
|
expect(communicator).to receive(:execute).
|
26
26
|
with('which bar', error_check: false).
|
27
27
|
and_return(1)
|
28
|
-
expect(described_class.which(machine, 'bar')).to
|
28
|
+
expect(described_class.which(machine, 'bar')).to be_falsey
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -12,7 +12,7 @@ describe VagrantPlugins::ProxyConf::Config::AptProxy do
|
|
12
12
|
|
13
13
|
context "defaults" do
|
14
14
|
subject { config_with({}) }
|
15
|
-
its(:enabled?) { should
|
15
|
+
its(:enabled?) { should be_falsey }
|
16
16
|
its(:to_s) { should eq "" }
|
17
17
|
end
|
18
18
|
|
@@ -22,7 +22,7 @@ describe VagrantPlugins::ProxyConf::Config::AptProxy do
|
|
22
22
|
|
23
23
|
context "with both http and https proxies" do
|
24
24
|
subject { config_with(http: "10.2.3.4", https: "ssl-proxy:8443") }
|
25
|
-
its(:enabled?) { should
|
25
|
+
its(:enabled?) { should be_truthy }
|
26
26
|
its(:to_s) { should match conf_line_pattern("http", "10.2.3.4") }
|
27
27
|
its(:to_s) { should match conf_line_pattern("https", "ssl-proxy", 8443) }
|
28
28
|
end
|
@@ -26,14 +26,14 @@ describe VagrantPlugins::ProxyConf::Config::EnvProxy do
|
|
26
26
|
|
27
27
|
context "defaults" do
|
28
28
|
subject { config_with({}) }
|
29
|
-
its(:enabled?) { should
|
29
|
+
its(:enabled?) { should be_falsey }
|
30
30
|
its(:to_s) { should eq "" }
|
31
31
|
end
|
32
32
|
|
33
33
|
context "with http config" do
|
34
34
|
let(:proxy) { 'http://proxy.example.com:8888' }
|
35
35
|
subject { config_with({ http: proxy }) }
|
36
|
-
its(:enabled?) { should
|
36
|
+
its(:enabled?) { should be_truthy }
|
37
37
|
its(:to_s) { should match_lines [
|
38
38
|
%Q{export HTTP_PROXY=#{proxy}\n},
|
39
39
|
%Q{export http_proxy=#{proxy}\n},
|
@@ -44,7 +44,7 @@ describe VagrantPlugins::ProxyConf::Config::EnvProxy do
|
|
44
44
|
let(:proxy) { 'http://proxy.example.com:8888' }
|
45
45
|
let(:no_proxy) { 'localhost, 127.0.0.1' }
|
46
46
|
subject { config_with({ http: proxy, no_proxy: no_proxy }) }
|
47
|
-
its(:enabled?) { should
|
47
|
+
its(:enabled?) { should be_truthy }
|
48
48
|
its(:to_s) { should match_lines [
|
49
49
|
%Q{export HTTP_PROXY=#{proxy}\n},
|
50
50
|
%Q{export http_proxy=#{proxy}\n},
|
@@ -57,7 +57,7 @@ describe VagrantPlugins::ProxyConf::Config::EnvProxy do
|
|
57
57
|
let(:proxy) { 'http://proxy.example.com:8888' }
|
58
58
|
before(:each) { ENV['VAGRANT_ENV_HTTP_PROXY'] = proxy }
|
59
59
|
subject { config_with({ http: 'http://default:3128' }) }
|
60
|
-
its(:enabled?) { should
|
60
|
+
its(:enabled?) { should be_truthy }
|
61
61
|
its(:to_s) { should match_lines [
|
62
62
|
%Q{export HTTP_PROXY=#{proxy}\n},
|
63
63
|
%Q{export http_proxy=#{proxy}\n},
|
@@ -7,6 +7,12 @@ describe VagrantPlugins::ProxyConf::Config::KeyMixin do
|
|
7
7
|
include VagrantPlugins::ProxyConf::Config::KeyMixin
|
8
8
|
key :foo
|
9
9
|
key :bar
|
10
|
+
|
11
|
+
# Hack to keep rspec 3 description generation happy
|
12
|
+
def respond_to?(method)
|
13
|
+
return false if method == :to_ary
|
14
|
+
super
|
15
|
+
end
|
10
16
|
end
|
11
17
|
|
12
18
|
class TestDefaultConfig < Vagrant.plugin('2', :config)
|
@@ -38,8 +44,8 @@ describe VagrantPlugins::ProxyConf::Config::KeyMixin do
|
|
38
44
|
subject { config.merge_defaults(default) }
|
39
45
|
|
40
46
|
context 'with no configuration' do
|
41
|
-
it {
|
42
|
-
it {
|
47
|
+
it { is_expected.to be_kind_of config.class }
|
48
|
+
it { is_expected.not_to be config }
|
43
49
|
|
44
50
|
its(:foo) { should be_nil }
|
45
51
|
its(:bar) { should be_nil }
|
@@ -6,7 +6,7 @@ describe VagrantPlugins::ProxyConf do
|
|
6
6
|
describe '.logger' do
|
7
7
|
subject { described_class.logger }
|
8
8
|
|
9
|
-
it {
|
9
|
+
it { is_expected.to be_a Log4r::Logger }
|
10
10
|
|
11
11
|
it "always returns the same instance" do
|
12
12
|
expect(subject).to be described_class.logger
|
@@ -9,18 +9,18 @@ describe VagrantPlugins::ProxyConf::Plugin do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
it "accepts single String argument" do
|
12
|
-
expect(described_class.check_vagrant_version('~> 1.1')).to
|
13
|
-
expect(described_class.check_vagrant_version('1.2')).to
|
12
|
+
expect(described_class.check_vagrant_version('~> 1.1')).to be_truthy
|
13
|
+
expect(described_class.check_vagrant_version('1.2')).to be_falsey
|
14
14
|
end
|
15
15
|
|
16
16
|
it "accepts an Array argument" do
|
17
|
-
expect(described_class.check_vagrant_version(['>= 1.1', '< 1.3.0.beta'])).to
|
18
|
-
expect(described_class.check_vagrant_version(['>= 1.3'])).to
|
17
|
+
expect(described_class.check_vagrant_version(['>= 1.1', '< 1.3.0.beta'])).to be_truthy
|
18
|
+
expect(described_class.check_vagrant_version(['>= 1.3'])).to be_falsey
|
19
19
|
end
|
20
20
|
|
21
21
|
it "accepts multiple arguments" do
|
22
|
-
expect(described_class.check_vagrant_version('>= 1.0', '<= 1.3')).to
|
23
|
-
expect(described_class.check_vagrant_version('~> 1.2', '>= 1.2.5')).to
|
22
|
+
expect(described_class.check_vagrant_version('>= 1.0', '<= 1.3')).to be_truthy
|
23
|
+
expect(described_class.check_vagrant_version('~> 1.2', '>= 1.2.5')).to be_falsey
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -34,7 +34,7 @@ describe VagrantPlugins::ProxyConf::Plugin do
|
|
34
34
|
'VagrantPlugins::ProxyConf::Plugin::VAGRANT_VERSION_REQUIREMENT',
|
35
35
|
requirement)
|
36
36
|
stub_const('Vagrant::VERSION', vagrant_version)
|
37
|
-
$stderr.
|
37
|
+
allow($stderr).to receive(:puts)
|
38
38
|
end
|
39
39
|
|
40
40
|
context "on too old Vagrant version" do
|
@@ -43,7 +43,7 @@ describe VagrantPlugins::ProxyConf::Plugin do
|
|
43
43
|
expect { subject }.to raise_error(err_msg)
|
44
44
|
end
|
45
45
|
it "warns" do
|
46
|
-
$stderr.
|
46
|
+
expect($stderr).to receive(:puts).with(err_msg)
|
47
47
|
subject rescue nil
|
48
48
|
end
|
49
49
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-proxyconf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Teemu Matilainen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A Vagrant plugin that configures the virtual machine to use proxy servers
|
14
14
|
email:
|
@@ -34,6 +34,7 @@ files:
|
|
34
34
|
- lib/vagrant-proxyconf/action/base.rb
|
35
35
|
- lib/vagrant-proxyconf/action/configure_apt_proxy.rb
|
36
36
|
- lib/vagrant-proxyconf/action/configure_chef_proxy.rb
|
37
|
+
- lib/vagrant-proxyconf/action/configure_docker_proxy.rb
|
37
38
|
- lib/vagrant-proxyconf/action/configure_env_proxy.rb
|
38
39
|
- lib/vagrant-proxyconf/action/configure_git_proxy.rb
|
39
40
|
- lib/vagrant-proxyconf/action/configure_npm_proxy.rb
|
@@ -42,7 +43,9 @@ files:
|
|
42
43
|
- lib/vagrant-proxyconf/action/configure_yum_proxy.rb
|
43
44
|
- lib/vagrant-proxyconf/action/is_enabled.rb
|
44
45
|
- lib/vagrant-proxyconf/action/only_once.rb
|
46
|
+
- lib/vagrant-proxyconf/cap/coreos/docker_proxy_conf.rb
|
45
47
|
- lib/vagrant-proxyconf/cap/debian/apt_proxy_conf.rb
|
48
|
+
- lib/vagrant-proxyconf/cap/linux/docker_proxy_conf.rb
|
46
49
|
- lib/vagrant-proxyconf/cap/linux/env_proxy_conf.rb
|
47
50
|
- lib/vagrant-proxyconf/cap/linux/git_proxy_conf.rb
|
48
51
|
- lib/vagrant-proxyconf/cap/linux/npm_proxy_conf.rb
|
@@ -86,6 +89,7 @@ files:
|
|
86
89
|
- spec/unit/support/shared/apt_proxy_config.rb
|
87
90
|
- spec/unit/vagrant-proxyconf/action/configure_apt_proxy_spec.rb
|
88
91
|
- spec/unit/vagrant-proxyconf/action/configure_chef_proxy_spec.rb
|
92
|
+
- spec/unit/vagrant-proxyconf/action/configure_docker_proxy_spec.rb
|
89
93
|
- spec/unit/vagrant-proxyconf/action/configure_env_proxy_spec.rb
|
90
94
|
- spec/unit/vagrant-proxyconf/action/configure_git_proxy_spec.rb
|
91
95
|
- spec/unit/vagrant-proxyconf/action/configure_npm_proxy_spec.rb
|
@@ -96,6 +100,7 @@ files:
|
|
96
100
|
- spec/unit/vagrant-proxyconf/action/only_once_spec.rb
|
97
101
|
- spec/unit/vagrant-proxyconf/action_spec.rb
|
98
102
|
- spec/unit/vagrant-proxyconf/cap/debian/apt_proxy_conf_spec.rb
|
103
|
+
- spec/unit/vagrant-proxyconf/cap/linux/docker_proxy_conf_spec.rb
|
99
104
|
- spec/unit/vagrant-proxyconf/cap/linux/env_proxy_conf_spec.rb
|
100
105
|
- spec/unit/vagrant-proxyconf/cap/linux/git_proxy_conf_spec.rb
|
101
106
|
- spec/unit/vagrant-proxyconf/cap/linux/npm_proxy_conf_spec.rb
|
@@ -160,6 +165,7 @@ test_files:
|
|
160
165
|
- spec/unit/support/shared/apt_proxy_config.rb
|
161
166
|
- spec/unit/vagrant-proxyconf/action/configure_apt_proxy_spec.rb
|
162
167
|
- spec/unit/vagrant-proxyconf/action/configure_chef_proxy_spec.rb
|
168
|
+
- spec/unit/vagrant-proxyconf/action/configure_docker_proxy_spec.rb
|
163
169
|
- spec/unit/vagrant-proxyconf/action/configure_env_proxy_spec.rb
|
164
170
|
- spec/unit/vagrant-proxyconf/action/configure_git_proxy_spec.rb
|
165
171
|
- spec/unit/vagrant-proxyconf/action/configure_npm_proxy_spec.rb
|
@@ -170,6 +176,7 @@ test_files:
|
|
170
176
|
- spec/unit/vagrant-proxyconf/action/only_once_spec.rb
|
171
177
|
- spec/unit/vagrant-proxyconf/action_spec.rb
|
172
178
|
- spec/unit/vagrant-proxyconf/cap/debian/apt_proxy_conf_spec.rb
|
179
|
+
- spec/unit/vagrant-proxyconf/cap/linux/docker_proxy_conf_spec.rb
|
173
180
|
- spec/unit/vagrant-proxyconf/cap/linux/env_proxy_conf_spec.rb
|
174
181
|
- spec/unit/vagrant-proxyconf/cap/linux/git_proxy_conf_spec.rb
|
175
182
|
- spec/unit/vagrant-proxyconf/cap/linux/npm_proxy_conf_spec.rb
|