vagrant-proxyconf 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bd98fb4e2a50743cbb753d23a2f3f40c52ccc901
4
- data.tar.gz: 23899ffddd8e8465c4e9a3cfab028218d73bca76
3
+ metadata.gz: 535eb21da37db3d2eebc8a1f785ae2df92159587
4
+ data.tar.gz: 09ed302efc15a97f3cee9f2eb89e657d055d40ad
5
5
  SHA512:
6
- metadata.gz: 9d11fc8b7115f87bf3c593dda1c4c76a9ec2ef228d4993cc40cda00aaea1a4a349b7ddeb320cc67a7978e9cf84443e759ac4954f7ac0f89a536fe4a548880ebb
7
- data.tar.gz: 0143d9c0dc746e84d7f4d9fbc781bce9ccfd827a159e1e54f65bfc9382e641df7a52a70bed9224a8479863a12b4bdf4a6a876e2cac2d212d55e1d443c5d59037
6
+ metadata.gz: b050cb3414bf569dc1938b0cdf631beb2285d00c560621cc93a2a8515240ca2c047e44e74103c1524bfba5e138159cb19a269c4a2f4f63fdea4b4869165152e4
7
+ data.tar.gz: aea65b32cade44afe71f626c81e8efa7aa165bd2a3a534d47b62b23576fdc52e34b8bf33fc106a8a9996758c06bd9a9126a82ac66a3351d17f88f3174ad53db3
@@ -1,14 +1,16 @@
1
1
  language: ruby
2
2
 
3
- before_install: gem install bundler --version '>= 1.5.2'
3
+ before_install:
4
+ - rvm @global do gem uninstall bundler --all --executables
5
+ - gem install bundler --version '~> 1.5.2'
6
+ - bundle --version
4
7
  bundler_args: --without=development
5
8
 
6
- rvm:
7
- - 2.0.0
8
- env:
9
- - VAGRANT_VERSION=v1.4.3
9
+ rvm: 2.0.0
10
+ env: VAGRANT_VERSION=v1.5.4
10
11
  matrix:
11
12
  include:
13
+ - env: VAGRANT_VERSION=v1.4.3
12
14
  - env: VAGRANT_VERSION=v1.3.5
13
15
  rvm: 1.9.3
14
16
  - env: VAGRANT_VERSION=v1.2.7
@@ -1,3 +1,16 @@
1
+ # 1.3.0 / 2014-05-02
2
+
3
+ Features:
4
+
5
+ - Support setting proxy environment variables on Windows guests ([GH-63][])
6
+ - Support setting proxy environment variables on CoreOS guests ([GH-62][])
7
+ * Requires CoreOS 286.0 or later
8
+
9
+ Bug fixes:
10
+
11
+ - Fix https proxy configuration for npm if different to http ([GH-57][])
12
+ - Use absolute paths to `git`, `npm`, and `pear` commands when configuring them using sudo to avoid PATH problems ([GH-59][], [GH-60][])
13
+
1
14
  # 1.2.0 / 2014-03-02
2
15
 
3
16
  Deprecations:
@@ -137,3 +150,8 @@ Bug fixes:
137
150
  [GH-49]: https://github.com/tmatilai/vagrant-proxyconf/issues/49 "Issue 49"
138
151
  [GH-50]: https://github.com/tmatilai/vagrant-proxyconf/issues/50 "Issue 50"
139
152
  [GH-51]: https://github.com/tmatilai/vagrant-proxyconf/issues/51 "Issue 51"
153
+ [GH-57]: https://github.com/tmatilai/vagrant-proxyconf/issues/57 "Issue 57"
154
+ [GH-59]: https://github.com/tmatilai/vagrant-proxyconf/issues/59 "Issue 59"
155
+ [GH-60]: https://github.com/tmatilai/vagrant-proxyconf/issues/60 "Issue 60"
156
+ [GH-62]: https://github.com/tmatilai/vagrant-proxyconf/issues/62 "Issue 62"
157
+ [GH-63]: https://github.com/tmatilai/vagrant-proxyconf/issues/63 "Issue 63"
data/README.md CHANGED
@@ -24,6 +24,7 @@ The plugin can set:
24
24
  * proxy configuration for npm
25
25
  * proxy configuration for Yum
26
26
  * proxy configuration for PEAR
27
+ * simple proxy configuration for Windows
27
28
 
28
29
  ## Quick start
29
30
 
@@ -12,8 +12,21 @@ module VagrantPlugins
12
12
  private
13
13
 
14
14
  def configure_machine
15
- super
16
- write_config(sudo_config, path: '/etc/sudoers.d/proxy', mode: '0440')
15
+ if windows_guest?
16
+ logger.info('Setting the Windows proxy environment variables')
17
+ configure_machine_windows
18
+ else
19
+ logger.info('Writing the proxy configuration to files')
20
+ super
21
+ write_config(sudo_config, path: '/etc/sudoers.d/proxy', mode: '0440')
22
+ end
23
+ end
24
+
25
+ def configure_machine_windows
26
+ set_windows_proxy('http_proxy', config.http)
27
+ set_windows_proxy('https_proxy', config.https)
28
+ set_windows_proxy('ftp_proxy', config.ftp)
29
+ set_windows_proxy('no_proxy', config.no_proxy)
17
30
  end
18
31
 
19
32
  def sudo_config
@@ -22,6 +35,21 @@ module VagrantPlugins
22
35
  Defaults env_keep += "http_proxy https_proxy ftp_proxy no_proxy"
23
36
  CONFIG
24
37
  end
38
+
39
+ def set_windows_proxy(key, value)
40
+ if value
41
+ command = "cmd.exe /c SETX #{key} #{value.inspect} /M"
42
+ logger.info("Setting #{key} to #{value}")
43
+ @machine.communicate.sudo(command)
44
+ else
45
+ logger.info("Not setting #{key}")
46
+ end
47
+ end
48
+
49
+ def windows_guest?
50
+ @machine.config.vm.guest.eql?(:windows)
51
+ end
52
+
25
53
  end
26
54
  end
27
55
  end
@@ -21,13 +21,18 @@ module VagrantPlugins
21
21
  end
22
22
 
23
23
  def configure_machine
24
+ command = "#{git_path} config --system "
24
25
  if config.http
25
- command = "git config --system http.proxy #{config.http}"
26
+ command << "http.proxy #{config.http}"
26
27
  else
27
- command = "git config --system --unset-all http.proxy"
28
+ command << "--unset-all http.proxy"
28
29
  end
29
30
  @machine.communicate.sudo(command)
30
31
  end
32
+
33
+ def git_path
34
+ @machine.guest.capability(cap_name)
35
+ end
31
36
  end
32
37
  end
33
38
  end
@@ -23,13 +23,18 @@ module VagrantPlugins
23
23
  end
24
24
 
25
25
  def set_or_delete_proxy(key, value)
26
+ command = "#{npm_path} config "
26
27
  if value
27
- command = "npm config set #{key} #{escape(config.http)}"
28
+ command << "set #{key} #{escape(value)}"
28
29
  else
29
- command = "npm config delete #{key}"
30
+ command << "delete #{key}"
30
31
  end
31
32
  @machine.communicate.sudo(command)
32
33
  end
34
+
35
+ def npm_path
36
+ @machine.guest.capability(cap_name)
37
+ end
33
38
  end
34
39
  end
35
40
  end
@@ -21,7 +21,11 @@ module VagrantPlugins
21
21
  proxy = config.http || ''
22
22
 
23
23
  @machine.communicate.sudo(
24
- "pear config-set http_proxy #{escape(proxy)} system")
24
+ "#{pear_path} config-set http_proxy #{escape(proxy)} system")
25
+ end
26
+
27
+ def pear_path
28
+ @machine.guest.capability(cap_name)
25
29
  end
26
30
  end
27
31
  end
@@ -1,11 +1,14 @@
1
+ require_relative '../util'
2
+
1
3
  module VagrantPlugins
2
4
  module ProxyConf
3
5
  module Cap
4
6
  module Linux
5
- # Capability for Git command
7
+ # Capability for git proxy configuration
6
8
  module GitProxyConf
9
+ # @return [String, false] the path to git or `false` if not found
7
10
  def self.git_proxy_conf(machine)
8
- machine.communicate.test('which git')
11
+ Util.which(machine, 'git')
9
12
  end
10
13
  end
11
14
  end
@@ -1,12 +1,14 @@
1
+ require_relative '../util'
2
+
1
3
  module VagrantPlugins
2
4
  module ProxyConf
3
5
  module Cap
4
6
  module Linux
5
7
  # Capability for npm proxy configuration
6
8
  module NpmProxyConf
7
- # @return [Boolean] if npm is installed
9
+ # @return [String, false] the path to npm or `false` if not found
8
10
  def self.npm_proxy_conf(machine)
9
- machine.communicate.test('which npm')
11
+ Util.which(machine, 'npm')
10
12
  end
11
13
  end
12
14
  end
@@ -1,12 +1,14 @@
1
+ require_relative '../util'
2
+
1
3
  module VagrantPlugins
2
4
  module ProxyConf
3
5
  module Cap
4
6
  module Linux
5
7
  # Capability for PEAR proxy configuration
6
8
  module PearProxyConf
7
- # @return [Boolean] if PEAR is installed
9
+ # @return [String, false] the path to pear or `false` if not found
8
10
  def self.pear_proxy_conf(machine)
9
- machine.communicate.test("which pear")
11
+ Util.which(machine, 'pear')
10
12
  end
11
13
  end
12
14
  end
@@ -1,11 +1,14 @@
1
+ require_relative '../util'
2
+
1
3
  module VagrantPlugins
2
4
  module ProxyConf
3
5
  module Cap
4
6
  module Linux
5
- # Capability for Svn command
7
+ # Capability for svn proxy configuration
6
8
  module SvnProxyConf
9
+ # @return [String, false] the path to svn or `false` if not found
7
10
  def self.svn_proxy_conf(machine)
8
- machine.communicate.test('which svn')
11
+ Util.which(machine, 'svn')
9
12
  end
10
13
  end
11
14
  end
@@ -0,0 +1,19 @@
1
+ module VagrantPlugins
2
+ module ProxyConf
3
+ module Cap
4
+ # Utility methods for capabilities
5
+ module Util
6
+ # Returns path to the command on the machine, or false if it's not found
7
+ def self.which(machine, cmd)
8
+ path = false
9
+ status = machine.communicate.execute(
10
+ "which #{cmd}", error_check: false) do |type, data|
11
+ # search for the command to work around `ssh.pty = true`
12
+ path = data.chomp if type == :stdout && data =~ /#{cmd}$/
13
+ end
14
+ status == 0 && path
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,15 @@
1
+ module VagrantPlugins
2
+ module ProxyConf
3
+ module Cap
4
+ module Windows
5
+ # Capability for windows host proxy configuration
6
+ module EnvProxyConf
7
+ # @return [String, false]
8
+ def self.env_proxy_conf(machine)
9
+ '/proxy.conf'
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -8,15 +8,16 @@ module VagrantPlugins
8
8
  Cap::Debian::AptProxyConf
9
9
  end
10
10
 
11
- guest_capability 'coreos', 'env_proxy_conf' do
12
- # disabled on CoreOS
13
- end
14
-
15
11
  guest_capability 'linux', 'env_proxy_conf' do
16
12
  require_relative 'cap/linux/env_proxy_conf'
17
13
  Cap::Linux::EnvProxyConf
18
14
  end
19
15
 
16
+ guest_capability 'windows', 'env_proxy_conf' do
17
+ require_relative 'cap/windows/env_proxy_conf'
18
+ Cap::Windows::EnvProxyConf
19
+ end
20
+
20
21
  guest_capability 'linux', 'git_proxy_conf' do
21
22
  require_relative 'cap/linux/git_proxy_conf'
22
23
  Cap::Linux::GitProxyConf
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module ProxyConf
3
- VERSION = '1.2.0'
3
+ VERSION = '1.3.0'
4
4
  end
5
5
  end
@@ -1,24 +1,19 @@
1
1
  require 'spec_helper'
2
2
  require 'vagrant-proxyconf/cap/linux/git_proxy_conf'
3
+ require 'vagrant-proxyconf/cap/util'
3
4
 
4
5
  describe VagrantPlugins::ProxyConf::Cap::Linux::GitProxyConf do
5
6
 
6
7
  describe '.git_proxy_conf' do
7
- let(:subject) { described_class.git_proxy_conf(double) }
8
8
  let(:machine) { double }
9
- let(:communicator) { double }
10
9
 
11
- before do
12
- machine.stub(:communicate => communicator)
10
+ it "returns the path when git is installed" do
11
+ VagrantPlugins::ProxyConf::Cap::Util.stub(which: '/path/to/git')
12
+ expect(described_class.git_proxy_conf(machine)).to eq '/path/to/git'
13
13
  end
14
14
 
15
- it "returns true when git is installed" do
16
- expect(communicator).to receive(:test).with('which git').and_return(true)
17
- expect(described_class.git_proxy_conf(machine)).to be_true
18
- end
19
-
20
- it "returns false when pear is not installed" do
21
- expect(communicator).to receive(:test).with('which git').and_return(false)
15
+ it "returns false when git is not installed" do
16
+ VagrantPlugins::ProxyConf::Cap::Util.stub(which: false)
22
17
  expect(described_class.git_proxy_conf(machine)).to be_false
23
18
  end
24
19
  end
@@ -1,23 +1,19 @@
1
1
  require 'spec_helper'
2
2
  require 'vagrant-proxyconf/cap/linux/npm_proxy_conf'
3
+ require 'vagrant-proxyconf/cap/util'
3
4
 
4
5
  describe VagrantPlugins::ProxyConf::Cap::Linux::NpmProxyConf do
5
6
 
6
7
  describe '.npm_proxy_conf' do
7
8
  let(:machine) { double }
8
- let(:communicator) { double }
9
9
 
10
- before do
11
- machine.stub(:communicate => communicator)
12
- end
13
-
14
- it "returns true when npm is installed" do
15
- expect(communicator).to receive(:test).with('which npm').and_return(true)
16
- expect(described_class.npm_proxy_conf(machine)).to be_true
10
+ it "returns the path when npm is installed" do
11
+ VagrantPlugins::ProxyConf::Cap::Util.stub(which: '/path/to/npm')
12
+ expect(described_class.npm_proxy_conf(machine)).to eq '/path/to/npm'
17
13
  end
18
14
 
19
15
  it "returns false when npm is not installed" do
20
- expect(communicator).to receive(:test).with('which npm').and_return(false)
16
+ VagrantPlugins::ProxyConf::Cap::Util.stub(which: false)
21
17
  expect(described_class.npm_proxy_conf(machine)).to be_false
22
18
  end
23
19
  end
@@ -1,23 +1,19 @@
1
1
  require 'spec_helper'
2
2
  require 'vagrant-proxyconf/cap/linux/pear_proxy_conf'
3
+ require 'vagrant-proxyconf/cap/util'
3
4
 
4
5
  describe VagrantPlugins::ProxyConf::Cap::Linux::PearProxyConf do
5
6
 
6
7
  describe '.pear_proxy_conf' do
7
8
  let(:machine) { double }
8
- let(:communicator) { double }
9
9
 
10
- before do
11
- machine.stub(:communicate => communicator)
12
- end
13
-
14
- it "returns true when pear is installed" do
15
- expect(communicator).to receive(:test).with("which pear").and_return(true)
16
- expect(described_class.pear_proxy_conf(machine)).to be_true
10
+ it "returns the path when pear is installed" do
11
+ VagrantPlugins::ProxyConf::Cap::Util.stub(which: '/path/to/pear')
12
+ expect(described_class.pear_proxy_conf(machine)).to eq '/path/to/pear'
17
13
  end
18
14
 
19
15
  it "returns false when pear is not installed" do
20
- expect(communicator).to receive(:test).with("which pear").and_return(false)
16
+ VagrantPlugins::ProxyConf::Cap::Util.stub(which: false)
21
17
  expect(described_class.pear_proxy_conf(machine)).to be_false
22
18
  end
23
19
  end
@@ -1,24 +1,19 @@
1
1
  require 'spec_helper'
2
2
  require 'vagrant-proxyconf/cap/linux/svn_proxy_conf'
3
+ require 'vagrant-proxyconf/cap/util'
3
4
 
4
5
  describe VagrantPlugins::ProxyConf::Cap::Linux::SvnProxyConf do
5
6
 
6
7
  describe '.svn_proxy_conf' do
7
- let(:subject) { described_class.svn_proxy_conf(double) }
8
8
  let(:machine) { double }
9
- let(:communicator) { double }
10
-
11
- before do
12
- machine.stub(:communicate => communicator)
13
- end
14
9
 
15
10
  it "returns true when svn is installed" do
16
- expect(communicator).to receive(:test).with('which svn').and_return(true)
17
- expect(described_class.svn_proxy_conf(machine)).to be_true
11
+ VagrantPlugins::ProxyConf::Cap::Util.stub(which: '/path/to/svn')
12
+ expect(described_class.svn_proxy_conf(machine)).to eq '/path/to/svn'
18
13
  end
19
14
 
20
15
  it "returns false when pear is not installed" do
21
- expect(communicator).to receive(:test).with('which svn').and_return(false)
16
+ VagrantPlugins::ProxyConf::Cap::Util.stub(which: false)
22
17
  expect(described_class.svn_proxy_conf(machine)).to be_false
23
18
  end
24
19
  end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+ require 'vagrant-proxyconf/cap/util'
3
+
4
+ describe VagrantPlugins::ProxyConf::Cap::Util do
5
+
6
+ describe '.which' do
7
+ let(:machine) { double }
8
+ let(:communicator) { double }
9
+
10
+ before do
11
+ machine.stub(:communicate => communicator)
12
+ end
13
+
14
+ it "returns the path when the command is installed" do
15
+ expect(communicator).to receive(:execute).
16
+ with('which foo', error_check: false).
17
+ and_yield(:stdout, "/path/to/foo\n").
18
+ and_yield(:stdout, "PROMPT\n").
19
+ and_yield(:stderr, "not foo\n").
20
+ and_return(0)
21
+ expect(described_class.which(machine, 'foo')).to eq '/path/to/foo'
22
+ end
23
+
24
+ it "returns false when the command is not installed" do
25
+ expect(communicator).to receive(:execute).
26
+ with('which bar', error_check: false).
27
+ and_return(1)
28
+ expect(described_class.which(machine, 'bar')).to be_false
29
+ end
30
+ end
31
+
32
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+ require 'vagrant-proxyconf/cap/windows/env_proxy_conf'
3
+
4
+ describe VagrantPlugins::ProxyConf::Cap::Windows::EnvProxyConf do
5
+
6
+ describe '.env_proxy_conf' do
7
+ let(:subject) { described_class.env_proxy_conf(double) }
8
+ it { should eq '/proxy.conf' }
9
+ end
10
+
11
+ 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.2.0
4
+ version: 1.3.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-03-02 00:00:00.000000000 Z
11
+ date: 2014-05-02 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:
@@ -17,9 +17,9 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - ".gitignore"
21
- - ".travis.yml"
22
- - ".yardopts"
20
+ - .gitignore
21
+ - .travis.yml
22
+ - .yardopts
23
23
  - CHANGELOG.md
24
24
  - Gemfile
25
25
  - Guardfile
@@ -49,6 +49,8 @@ files:
49
49
  - lib/vagrant-proxyconf/cap/linux/pear_proxy_conf.rb
50
50
  - lib/vagrant-proxyconf/cap/linux/svn_proxy_conf.rb
51
51
  - lib/vagrant-proxyconf/cap/redhat/yum_proxy_conf.rb
52
+ - lib/vagrant-proxyconf/cap/util.rb
53
+ - lib/vagrant-proxyconf/cap/windows/env_proxy_conf.rb
52
54
  - lib/vagrant-proxyconf/capability.rb
53
55
  - lib/vagrant-proxyconf/config.rb
54
56
  - lib/vagrant-proxyconf/config/apt_proxy.rb
@@ -100,6 +102,8 @@ files:
100
102
  - spec/unit/vagrant-proxyconf/cap/linux/pear_proxy_conf_spec.rb
101
103
  - spec/unit/vagrant-proxyconf/cap/linux/svn_proxy_conf_spec.rb
102
104
  - spec/unit/vagrant-proxyconf/cap/redhat/yum_proxy_conf_spec.rb
105
+ - spec/unit/vagrant-proxyconf/cap/util_spec.rb
106
+ - spec/unit/vagrant-proxyconf/cap/windows/env_proxy_conf_spec.rb
103
107
  - spec/unit/vagrant-proxyconf/config/apt_proxy_spec.rb
104
108
  - spec/unit/vagrant-proxyconf/config/env_proxy_spec.rb
105
109
  - spec/unit/vagrant-proxyconf/config/git_proxy_spec.rb
@@ -124,17 +128,17 @@ require_paths:
124
128
  - lib
125
129
  required_ruby_version: !ruby/object:Gem::Requirement
126
130
  requirements:
127
- - - ">="
131
+ - - '>='
128
132
  - !ruby/object:Gem::Version
129
133
  version: '0'
130
134
  required_rubygems_version: !ruby/object:Gem::Requirement
131
135
  requirements:
132
- - - ">="
136
+ - - '>='
133
137
  - !ruby/object:Gem::Version
134
138
  version: '0'
135
139
  requirements: []
136
140
  rubyforge_project:
137
- rubygems_version: 2.2.2
141
+ rubygems_version: 2.0.14
138
142
  signing_key:
139
143
  specification_version: 4
140
144
  summary: A Vagrant plugin that configures the virtual machine to use proxy servers
@@ -172,6 +176,8 @@ test_files:
172
176
  - spec/unit/vagrant-proxyconf/cap/linux/pear_proxy_conf_spec.rb
173
177
  - spec/unit/vagrant-proxyconf/cap/linux/svn_proxy_conf_spec.rb
174
178
  - spec/unit/vagrant-proxyconf/cap/redhat/yum_proxy_conf_spec.rb
179
+ - spec/unit/vagrant-proxyconf/cap/util_spec.rb
180
+ - spec/unit/vagrant-proxyconf/cap/windows/env_proxy_conf_spec.rb
175
181
  - spec/unit/vagrant-proxyconf/config/apt_proxy_spec.rb
176
182
  - spec/unit/vagrant-proxyconf/config/env_proxy_spec.rb
177
183
  - spec/unit/vagrant-proxyconf/config/git_proxy_spec.rb