vagrant-proxyconf 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -0
  3. data/Gemfile +1 -1
  4. data/README.md +7 -48
  5. data/lib/vagrant-proxyconf/action.rb +9 -0
  6. data/lib/vagrant-proxyconf/action/configure_git_proxy.rb +34 -0
  7. data/lib/vagrant-proxyconf/action/configure_npm_proxy.rb +36 -0
  8. data/lib/vagrant-proxyconf/action/configure_svn_proxy.rb +43 -0
  9. data/lib/vagrant-proxyconf/cap/linux/git_proxy_conf.rb +14 -0
  10. data/lib/vagrant-proxyconf/cap/linux/npm_proxy_conf.rb +15 -0
  11. data/lib/vagrant-proxyconf/cap/linux/svn_proxy_conf.rb +14 -0
  12. data/lib/vagrant-proxyconf/capability.rb +15 -0
  13. data/lib/vagrant-proxyconf/config.rb +10 -0
  14. data/lib/vagrant-proxyconf/config/apt_proxy.rb +25 -2
  15. data/lib/vagrant-proxyconf/config/env_proxy.rb +10 -0
  16. data/lib/vagrant-proxyconf/config/git_proxy.rb +19 -0
  17. data/lib/vagrant-proxyconf/config/svn_proxy.rb +23 -0
  18. data/lib/vagrant-proxyconf/userinfo_uri.rb +24 -21
  19. data/lib/vagrant-proxyconf/version.rb +1 -1
  20. data/locales/en.yml +24 -0
  21. data/spec/unit/vagrant-proxyconf/action/configure_git_proxy_spec.rb +11 -0
  22. data/spec/unit/vagrant-proxyconf/action/configure_npm_proxy_spec.rb +10 -0
  23. data/spec/unit/vagrant-proxyconf/action/configure_svn_proxy_spec.rb +11 -0
  24. data/spec/unit/vagrant-proxyconf/cap/linux/git_proxy_conf_spec.rb +26 -0
  25. data/spec/unit/vagrant-proxyconf/cap/linux/npm_proxy_conf_spec.rb +25 -0
  26. data/spec/unit/vagrant-proxyconf/cap/linux/svn_proxy_conf_spec.rb +26 -0
  27. data/spec/unit/vagrant-proxyconf/config/git_proxy_spec.rb +7 -0
  28. data/spec/unit/vagrant-proxyconf/config/svn_proxy_spec.rb +7 -0
  29. data/spec/unit/vagrant-proxyconf/userinfo_uri_spec.rb +18 -0
  30. metadata +32 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ccc0113cc7339765e4d71dc0a34b5c4ea9bbf29b
4
- data.tar.gz: 820756398111a78c3e13eaf1412c5e2dc394657c
3
+ metadata.gz: bd98fb4e2a50743cbb753d23a2f3f40c52ccc901
4
+ data.tar.gz: 23899ffddd8e8465c4e9a3cfab028218d73bca76
5
5
  SHA512:
6
- metadata.gz: cfe68c260b981d6e806c9fd0b49ce502cadac5938697903f634c14b4d85d7d0682e09abd587344e4848ab756dae78475fe72e7e289ab11243f655652ecc1f1c3
7
- data.tar.gz: f0add4636c11c68fc4b264fd0454113be6091baa0f5581d32cd3b84eb7b4830b217bef0c8e3d03078ae174b40af55550bbf443546af1b866aef222ac8d5a80cf
6
+ metadata.gz: 9d11fc8b7115f87bf3c593dda1c4c76a9ec2ef228d4993cc40cda00aaea1a4a349b7ddeb320cc67a7978e9cf84443e759ac4954f7ac0f89a536fe4a548880ebb
7
+ data.tar.gz: 0143d9c0dc746e84d7f4d9fbc781bce9ccfd827a159e1e54f65bfc9382e641df7a52a70bed9224a8479863a12b4bdf4a6a876e2cac2d212d55e1d443c5d59037
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # 1.2.0 / 2014-03-02
2
+
3
+ Deprecations:
4
+
5
+ - Deprecate `config.env_proxy` and `VAGRANT_ENV_*_PROXY`, as `config.proxy.*` and `VAGRANT_*_PROXY` should be enough. The env_proxy config options will be removed in v2.0.0.
6
+ - `config.apt_proxy.*` and `VAGRANT_APT_*_PROXY` URIs should explicitly set the scheme and port. In v2.0.0 the scheme will be required, and default port will be scheme's default (currently 3142).
7
+
8
+ Features:
9
+
10
+ - Support for configuring git and svn ([GH-40][], [GH-49][])
11
+ - Support for configuring npm ([GH-50][], [GH-51][])
12
+
1
13
  # 1.1.0 / 2014-02-06
2
14
 
3
15
  Features:
@@ -118,6 +130,10 @@ Bug fixes:
118
130
  [GH-35]: https://github.com/tmatilai/vagrant-proxyconf/issues/35 "Issue 35"
119
131
  [GH-36]: https://github.com/tmatilai/vagrant-proxyconf/issues/36 "Issue 36"
120
132
  [GH-39]: https://github.com/tmatilai/vagrant-proxyconf/issues/39 "Issue 39"
133
+ [GH-40]: https://github.com/tmatilai/vagrant-proxyconf/issues/40 "Issue 40"
121
134
  [GH-42]: https://github.com/tmatilai/vagrant-proxyconf/issues/42 "Issue 42"
122
135
  [GH-44]: https://github.com/tmatilai/vagrant-proxyconf/issues/44 "Issue 44"
123
136
  [GH-45]: https://github.com/tmatilai/vagrant-proxyconf/issues/45 "Issue 45"
137
+ [GH-49]: https://github.com/tmatilai/vagrant-proxyconf/issues/49 "Issue 49"
138
+ [GH-50]: https://github.com/tmatilai/vagrant-proxyconf/issues/50 "Issue 50"
139
+ [GH-51]: https://github.com/tmatilai/vagrant-proxyconf/issues/51 "Issue 51"
data/Gemfile CHANGED
@@ -3,7 +3,7 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  gem 'vagrant',
6
- github: 'mitchellh/vagrant',
6
+ git: 'https://github.com/mitchellh/vagrant.git',
7
7
  ref: ENV.fetch('VAGRANT_VERSION', 'v1.4.3')
8
8
 
9
9
  gem 'cane', '~> 2.6'
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 npm
24
25
  * proxy configuration for Yum
25
26
  * proxy configuration for PEAR
26
27
 
@@ -47,7 +48,7 @@ end
47
48
 
48
49
  ## Compatibility
49
50
 
50
- This plugin requires Vagrant 1.2 or newer ([downloads](http://downloads.vagrantup.com/)).
51
+ This plugin requires Vagrant 1.2 or newer ([downloads](http://www.vagrantup.com/downloads)).
51
52
 
52
53
  The plugin is supposed to be compatible with all Vagrant providers and other plugins. Please file an [issue](https://github.com/tmatilai/vagrant-proxyconf/issues) if this is not the case. The following providers are confirmed to work:
53
54
  [AWS](https://github.com/mitchellh/vagrant-aws),
@@ -73,6 +74,10 @@ It is a good practise to wrap plugin specific configuration with `Vagrant.has_pl
73
74
 
74
75
  It's a common case that you want all possible connections to pass through the same proxy. This will set the default values for all other proxy configuration keys. It also sets default proxy configuration for all Chef Solo and Chef Client provisioners.
75
76
 
77
+ Many programs (wget, curl, yum, etc.) can be configured to use proxies with `http_proxy` or `HTTP_PROXY` etc. environment variables. This configuration will be written to _/etc/profile.d/proxy.sh_ on the guest.
78
+
79
+ Also sudo will be configured to preserve the variables. This requires that sudo in the VM is configured to support "sudoers.d", i.e. _/etc/sudoers_ contains line `#includedir /etc/sudoers.d`.
80
+
76
81
  #### Example Vagrantfile
77
82
 
78
83
  ```ruby
@@ -131,52 +136,6 @@ Vagrant.configure("2") do |config|
131
136
  end
132
137
  ```
133
138
 
134
- ### Global `*_proxy` environment variables
135
-
136
- Many programs (wget, curl, yum, etc.) can be configured to use proxies with `http_proxy` or `HTTP_PROXY` etc. environment variables. This configuration will be written to _/etc/profile.d/proxy.sh_ on the guest.
137
-
138
- Also sudo will be configured to preserve the variables. This requires that sudo in the VM is configured to support "sudoers.d", i.e. _/etc/sudoers_ contains line `#includedir /etc/sudoers.d`.
139
-
140
- #### Example Vagrantfile
141
-
142
- ```ruby
143
- Vagrant.configure("2") do |config|
144
- config.env_proxy.http = "http://192.168.33.200:8888/"
145
- config.env_proxy.https = "http://192.168.33.200:8888/"
146
- config.env_proxy.no_proxy = "localhost,127.0.0.1,.example.com"
147
- # ... other stuff
148
- end
149
- ```
150
-
151
- #### Configuration keys
152
-
153
- * `config.env_proxy.http` - The proxy for HTTP URIs
154
- * `config.env_proxy.https` - The proxy for HTTPS URIs
155
- * `config.env_proxy.ftp` - The proxy for FTP URIs
156
- * `config.env_proxy.no_proxy` - A comma separated list of hosts or domains which do not use proxies.
157
-
158
- #### Possible values
159
-
160
- * If all keys are unset or `nil`, no configuration is written.
161
- * A proxy can be specified in the form of _http://[user:pass@]host:port_.
162
- * The values are used as specified, so you can use for example variables that will be evaluated by the shell on the VM.
163
- * Empty string (`""`) or `false` in any setting also force the configuration file to be written, but without configuration for that key. Can be used to clear the old configuration and/or override a global setting.
164
-
165
- #### Environment variables
166
-
167
- * `VAGRANT_ENV_HTTP_PROXY`
168
- * `VAGRANT_ENV_HTTPS_PROXY`
169
- * `VAGRANT_ENV_FTP_PROXY`
170
- * `VAGRANT_ENV_NO_PROXY`
171
-
172
- These also override the Vagrantfile configuration. To disable or remove the proxy use an empty value.
173
-
174
- For example to spin up a VM, run:
175
-
176
- ```sh
177
- VAGRANT_ENV_HTTP_PROXY="http://proxy.example.com:8080" vagrant up
178
- ```
179
-
180
139
  ### Apt
181
140
 
182
141
  Configures Apt to use the specified proxy settings. The configuration will be written to _/etc/apt/apt.conf.d/01proxy_ on the guest.
@@ -216,7 +175,7 @@ These also override the Vagrantfile configuration. To disable or remove the prox
216
175
  For example to spin up a VM, run:
217
176
 
218
177
  ```sh
219
- VAGRANT_APT_HTTP_PROXY="proxy.example.com:8080" vagrant up
178
+ VAGRANT_APT_HTTP_PROXY="http://proxy.example.com:8080" vagrant up
220
179
  ```
221
180
 
222
181
  #### Running apt-cacher-ng on a Vagrant box
@@ -2,7 +2,10 @@ require 'vagrant/action/builtin/call'
2
2
  require_relative 'action/configure_apt_proxy'
3
3
  require_relative 'action/configure_chef_proxy'
4
4
  require_relative 'action/configure_env_proxy'
5
+ require_relative 'action/configure_git_proxy'
6
+ require_relative 'action/configure_npm_proxy'
5
7
  require_relative 'action/configure_pear_proxy'
8
+ require_relative 'action/configure_svn_proxy'
6
9
  require_relative 'action/configure_yum_proxy'
7
10
  require_relative 'action/is_enabled'
8
11
  require_relative 'action/only_once'
@@ -29,7 +32,10 @@ module VagrantPlugins
29
32
  b.use Builtin::Call, IsEnabled do |env, b2|
30
33
  next if !env[:result]
31
34
 
35
+ b2.use ConfigureGitProxy
36
+ b2.use ConfigureNpmProxy
32
37
  b2.use ConfigurePearProxy
38
+ b2.use ConfigureSvnProxy
33
39
  end
34
40
  end
35
41
  end
@@ -46,7 +52,10 @@ module VagrantPlugins
46
52
  b2.use ConfigureAptProxy
47
53
  b2.use ConfigureChefProxy
48
54
  b2.use ConfigureEnvProxy
55
+ b2.use ConfigureGitProxy
56
+ b2.use ConfigureNpmProxy
49
57
  b2.use ConfigurePearProxy
58
+ b2.use ConfigureSvnProxy
50
59
  b2.use ConfigureYumProxy
51
60
  end
52
61
  end
@@ -0,0 +1,34 @@
1
+ require_relative 'base'
2
+
3
+ module VagrantPlugins
4
+ module ProxyConf
5
+ class Action
6
+ # Action for configuring Git on the guest
7
+ class ConfigureGitProxy < Base
8
+ def config_name
9
+ 'git_proxy'
10
+ end
11
+
12
+ private
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
+ def configure_machine
24
+ if config.http
25
+ command = "git config --system http.proxy #{config.http}"
26
+ else
27
+ command = "git config --system --unset-all http.proxy"
28
+ end
29
+ @machine.communicate.sudo(command)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,36 @@
1
+ require_relative 'base'
2
+
3
+ module VagrantPlugins
4
+ module ProxyConf
5
+ class Action
6
+ # Action for configuring npm on the guest
7
+ class ConfigureNpmProxy < Base
8
+ def config_name
9
+ 'npm_proxy'
10
+ end
11
+
12
+ private
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
+ def configure_machine
21
+ set_or_delete_proxy('proxy', config.http)
22
+ set_or_delete_proxy('https-proxy', config.https)
23
+ end
24
+
25
+ def set_or_delete_proxy(key, value)
26
+ if value
27
+ command = "npm config set #{key} #{escape(config.http)}"
28
+ else
29
+ command = "npm config delete #{key}"
30
+ end
31
+ @machine.communicate.sudo(command)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,43 @@
1
+ require_relative 'base'
2
+ require_relative '../userinfo_uri'
3
+
4
+ module VagrantPlugins
5
+ module ProxyConf
6
+ class Action
7
+ # Action for configuring Svn on the guest
8
+ class ConfigureSvnProxy < Base
9
+ def config_name
10
+ 'svn_proxy'
11
+ end
12
+
13
+ private
14
+
15
+ # @return [Vagrant::Plugin::V2::Config] the configuration
16
+ def config
17
+ return @config if @config
18
+
19
+ # Use only `config.svn_proxy`, don't merge with the default config
20
+ @config = @machine.config.svn_proxy
21
+ finalize_config(@config)
22
+ end
23
+
24
+ def configure_machine
25
+ write_config(svn_config, path: '/etc/subversion/servers')
26
+ end
27
+
28
+ def svn_config
29
+ u = UserinfoURI.new(config.http)
30
+
31
+ <<-CONFIG.gsub(/^. */, '')
32
+ [global]
33
+ http-proxy-host=#{u.host}
34
+ http-proxy-port=#{u.port}
35
+ http-proxy-username=#{u.user}
36
+ http-proxy-password=#{u.pass}
37
+ http-proxy-exceptions=#{config.no_proxy}
38
+ CONFIG
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,14 @@
1
+ module VagrantPlugins
2
+ module ProxyConf
3
+ module Cap
4
+ module Linux
5
+ # Capability for Git command
6
+ module GitProxyConf
7
+ def self.git_proxy_conf(machine)
8
+ machine.communicate.test('which git')
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,15 @@
1
+ module VagrantPlugins
2
+ module ProxyConf
3
+ module Cap
4
+ module Linux
5
+ # Capability for npm proxy configuration
6
+ module NpmProxyConf
7
+ # @return [Boolean] if npm is installed
8
+ def self.npm_proxy_conf(machine)
9
+ machine.communicate.test('which npm')
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,14 @@
1
+ module VagrantPlugins
2
+ module ProxyConf
3
+ module Cap
4
+ module Linux
5
+ # Capability for Svn command
6
+ module SvnProxyConf
7
+ def self.svn_proxy_conf(machine)
8
+ machine.communicate.test('which svn')
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -17,11 +17,26 @@ module VagrantPlugins
17
17
  Cap::Linux::EnvProxyConf
18
18
  end
19
19
 
20
+ guest_capability 'linux', 'git_proxy_conf' do
21
+ require_relative 'cap/linux/git_proxy_conf'
22
+ Cap::Linux::GitProxyConf
23
+ end
24
+
25
+ guest_capability 'linux', 'npm_proxy_conf' do
26
+ require_relative 'cap/linux/npm_proxy_conf'
27
+ Cap::Linux::NpmProxyConf
28
+ end
29
+
20
30
  guest_capability 'linux', 'pear_proxy_conf' do
21
31
  require_relative 'cap/linux/pear_proxy_conf'
22
32
  Cap::Linux::PearProxyConf
23
33
  end
24
34
 
35
+ guest_capability 'linux', 'svn_proxy_conf' do
36
+ require_relative 'cap/linux/svn_proxy_conf'
37
+ Cap::Linux::SvnProxyConf
38
+ end
39
+
25
40
  guest_capability 'redhat', 'yum_proxy_conf' do
26
41
  require_relative 'cap/redhat/yum_proxy_conf'
27
42
  Cap::Redhat::YumProxyConf
@@ -13,11 +13,21 @@ module VagrantPlugins
13
13
  Config::EnvProxy
14
14
  end
15
15
 
16
+ config 'git_proxy' do
17
+ require_relative 'config/git_proxy'
18
+ Config::GitProxy
19
+ end
20
+
16
21
  config 'proxy' do
17
22
  require_relative 'config/proxy'
18
23
  Config::Proxy
19
24
  end
20
25
 
26
+ config 'svn_proxy' do
27
+ require_relative 'config/svn_proxy'
28
+ Config::SvnProxy
29
+ end
30
+
21
31
  config 'yum_proxy' do
22
32
  require_relative 'config/yum_proxy'
23
33
  Config::YumProxy
@@ -64,12 +64,35 @@ module VagrantPlugins
64
64
  'DIRECT' if value.upcase == 'DIRECT'
65
65
  end
66
66
 
67
+ # Hash of deprecation warning sentinels
68
+ @@warned = {}
69
+
67
70
  def prefix
68
- "#{scheme}://" if value !~ %r{^.*://}
71
+ if value !~ %r{^.*://}
72
+ if !@@warned[:scheme]
73
+ @@warned[:scheme] = true
74
+
75
+ puts 'DEPRECATION: Specifying the scheme (http://) for `apt_proxy` URIs'
76
+ puts 'will be mandatory in v2.0.0.'
77
+ puts
78
+ end
79
+
80
+ "#{scheme}://"
81
+ end
69
82
  end
70
83
 
71
84
  def suffix
72
- ':3142' if value !~ %r{:\d+$} && value !~ %r{/}
85
+ if value !~ %r{:\d+$} && value !~ %r{/}
86
+ if !@@warned[:port]
87
+ @@warned[:port] = true
88
+
89
+ puts 'DEPRECATION: Please specify the port (3142) for `apt_proxy` URIs,'
90
+ puts 'as the default will change in v2.0.0.'
91
+ puts
92
+ end
93
+
94
+ ':3142'
95
+ end
73
96
  end
74
97
  end
75
98
  end
@@ -23,6 +23,16 @@ module VagrantPlugins
23
23
  # @return [String] a comma separated list of hosts or domains which do not use proxies
24
24
  key :no_proxy, env_var: 'VAGRANT_ENV_NO_PROXY'
25
25
 
26
+ def validate(machine)
27
+ if enabled?
28
+ puts 'DEPRECATION: `config.env_proxy.*` and `VAGRANT_ENV_*_PROXY`'
29
+ puts 'configuration is deprecated and will be removed in v2.0.0.'
30
+ puts 'Please use `config.proxy.*` and `VAGRANT_*_PROXY` instead.'
31
+ puts
32
+ end
33
+ super
34
+ end
35
+
26
36
  private
27
37
 
28
38
  # (see KeyMixin#config_for)
@@ -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 Git
8
+ #
9
+ # @!parse class GitProxy < Vagrant::Plugin::V2::Config; end
10
+ class GitProxy < 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_GIT_HTTP_PROXY'
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,23 @@
1
+ require 'vagrant'
2
+ require_relative 'key_mixin'
3
+
4
+ module VagrantPlugins
5
+ module ProxyConf
6
+ module Config
7
+ # Proxy configuration for Subversion
8
+ #
9
+ # @!parse class SvnProxy < Vagrant::Plugin::V2::Config; end
10
+ class SvnProxy < 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_SVN_HTTP_PROXY'
16
+
17
+ # @return [String] a comma separated list of hosts or domains which do
18
+ # not use proxies
19
+ key :no_proxy, env_var: 'VAGRANT_SVN_NO_PROXY'
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,39 +1,42 @@
1
+ require 'forwardable'
1
2
  require 'uri'
2
3
 
3
4
  module VagrantPlugins
4
5
  module ProxyConf
5
6
  # Helper class that strips userinfo from the URI to separate attributes
6
7
  class UserinfoURI
7
- # @return [String] the URI without userinfo
8
- attr_reader :uri
9
-
10
- alias_method :to_s, :uri
8
+ extend Forwardable
11
9
 
12
- # @return [String] the username
13
- attr_reader :user
10
+ # @!attribute [r] host
11
+ # @return [String] the host
12
+ # @!attribute [r] port
13
+ # @return [String] the port
14
+ # @!attribute [r] user
15
+ # @return [String] the username
16
+ def_delegators :@uri, :host, :port, :user
14
17
 
15
- # @return [String] the password
16
- attr_reader :pass
18
+ # @!attribute [r] pass
19
+ # @return [String] the password
20
+ def_delegator :@uri, :password, :pass
17
21
 
18
22
  # @param uri [String] the URI including optional userinfo
19
23
  def initialize(uri)
20
- if uri
21
- u = URI.parse(uri)
22
- @uri = strip_userinfo(u)
23
- @user = u.user
24
- @pass = u.password
25
- end
24
+ @set = !!uri
25
+ @uri = URI.parse(uri || '')
26
26
  end
27
27
 
28
- private
29
-
30
- # @param uri [URI::Generic] the URI with optional userinfo
31
28
  # @return [String] the URI without userinfo
32
- def strip_userinfo(uri)
33
- return '' if uri.to_s.empty?
34
-
35
- "#{uri.scheme}://#{uri.host}:#{uri.port}"
29
+ def uri
30
+ if !@set
31
+ nil
32
+ elsif @uri.to_s.empty?
33
+ ""
34
+ else
35
+ "#{@uri.scheme}://#{host}:#{port}"
36
+ end
36
37
  end
38
+
39
+ alias_method :to_s, :uri
37
40
  end
38
41
  end
39
42
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module ProxyConf
3
- VERSION = '1.1.0'
3
+ VERSION = '1.2.0'
4
4
  end
5
5
  end
data/locales/en.yml CHANGED
@@ -24,6 +24,22 @@ en:
24
24
  configuring: |-
25
25
  Configuring proxy environment variables...
26
26
 
27
+ git_proxy:
28
+ not_enabled: |-
29
+ git_proxy not enabled or configured
30
+ not_supported: |-
31
+ Skipping Git proxy config as `git` is not found
32
+ configuring: |-
33
+ Configuring proxy for Git...
34
+
35
+ npm_proxy:
36
+ not_enabled: |-
37
+ npm_proxy not enabled or configured
38
+ not_supported: |-
39
+ Skipping npm proxy config as `npm` is not found
40
+ configuring: |-
41
+ Configuring proxy for npm...
42
+
27
43
  pear_proxy:
28
44
  not_enabled: |-
29
45
  pear_proxy not enabled or configured
@@ -32,6 +48,14 @@ en:
32
48
  configuring: |-
33
49
  Configuring proxy for PEAR...
34
50
 
51
+ svn_proxy:
52
+ not_enabled: |-
53
+ svn_proxy not enabled or configured
54
+ not_supported: |-
55
+ Skipping Subversion proxy config as the machine does not support it
56
+ configuring: |-
57
+ Configuring proxy for Subversion...
58
+
35
59
  yum_proxy:
36
60
  not_enabled: |-
37
61
  yum_proxy not enabled or configured
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+ require 'vagrant-proxyconf/action/configure_git_proxy'
3
+
4
+ describe VagrantPlugins::ProxyConf::Action::ConfigureGitProxy do
5
+
6
+ describe '#config_name' do
7
+ subject { described_class.new(double, double).config_name }
8
+ it { should eq 'git_proxy' }
9
+ end
10
+
11
+ end
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+ require 'vagrant-proxyconf/action/configure_npm_proxy'
3
+
4
+ describe VagrantPlugins::ProxyConf::Action::ConfigureNpmProxy do
5
+
6
+ describe '#config_name' do
7
+ subject { described_class.new(double, double).config_name }
8
+ it { should eq 'npm_proxy' }
9
+ end
10
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+ require 'vagrant-proxyconf/action/configure_svn_proxy'
3
+
4
+ describe VagrantPlugins::ProxyConf::Action::ConfigureSvnProxy do
5
+
6
+ describe '#config_name' do
7
+ subject { described_class.new(double, double).config_name }
8
+ it { should eq 'svn_proxy' }
9
+ end
10
+
11
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+ require 'vagrant-proxyconf/cap/linux/git_proxy_conf'
3
+
4
+ describe VagrantPlugins::ProxyConf::Cap::Linux::GitProxyConf do
5
+
6
+ describe '.git_proxy_conf' do
7
+ let(:subject) { described_class.git_proxy_conf(double) }
8
+ let(:machine) { double }
9
+ let(:communicator) { double }
10
+
11
+ before do
12
+ machine.stub(:communicate => communicator)
13
+ end
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)
22
+ expect(described_class.git_proxy_conf(machine)).to be_false
23
+ end
24
+ end
25
+
26
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+ require 'vagrant-proxyconf/cap/linux/npm_proxy_conf'
3
+
4
+ describe VagrantPlugins::ProxyConf::Cap::Linux::NpmProxyConf do
5
+
6
+ describe '.npm_proxy_conf' do
7
+ let(:machine) { double }
8
+ let(:communicator) { double }
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
17
+ end
18
+
19
+ it "returns false when npm is not installed" do
20
+ expect(communicator).to receive(:test).with('which npm').and_return(false)
21
+ expect(described_class.npm_proxy_conf(machine)).to be_false
22
+ end
23
+ end
24
+
25
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+ require 'vagrant-proxyconf/cap/linux/svn_proxy_conf'
3
+
4
+ describe VagrantPlugins::ProxyConf::Cap::Linux::SvnProxyConf do
5
+
6
+ describe '.svn_proxy_conf' do
7
+ let(:subject) { described_class.svn_proxy_conf(double) }
8
+ let(:machine) { double }
9
+ let(:communicator) { double }
10
+
11
+ before do
12
+ machine.stub(:communicate => communicator)
13
+ end
14
+
15
+ 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
18
+ end
19
+
20
+ it "returns false when pear is not installed" do
21
+ expect(communicator).to receive(:test).with('which svn').and_return(false)
22
+ expect(described_class.svn_proxy_conf(machine)).to be_false
23
+ end
24
+ end
25
+
26
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+ require 'vagrant-proxyconf/config/git_proxy'
3
+
4
+ describe VagrantPlugins::ProxyConf::Config::GitProxy do
5
+ let(:instance) { described_class.new }
6
+ before(:each) { ENV.delete('VAGRANT_GIT_HTTP_PROXY') }
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+ require 'vagrant-proxyconf/config/svn_proxy'
3
+
4
+ describe VagrantPlugins::ProxyConf::Config::SvnProxy do
5
+ let(:instance) { described_class.new }
6
+ before(:each) { ENV.delete('VAGRANT_SVN_HTTP_PROXY') }
7
+ end
@@ -9,6 +9,8 @@ describe VagrantPlugins::ProxyConf::UserinfoURI do
9
9
  let(:uri) { nil }
10
10
  its(:to_s) { should be_nil }
11
11
  its(:uri) { should be_nil }
12
+ its(:host) { should be_nil }
13
+ its(:port) { should be_nil }
12
14
  its(:user) { should be_nil }
13
15
  its(:pass) { should be_nil }
14
16
  end
@@ -17,6 +19,8 @@ describe VagrantPlugins::ProxyConf::UserinfoURI do
17
19
  let(:uri) { false }
18
20
  its(:to_s) { should be_nil }
19
21
  its(:uri) { should be_nil }
22
+ its(:host) { should be_nil }
23
+ its(:port) { should be_nil }
20
24
  its(:user) { should be_nil }
21
25
  its(:pass) { should be_nil }
22
26
  end
@@ -25,6 +29,8 @@ describe VagrantPlugins::ProxyConf::UserinfoURI do
25
29
  let(:uri) { '' }
26
30
  its(:to_s) { should eq '' }
27
31
  its(:uri) { should eq '' }
32
+ its(:host) { should be_nil }
33
+ its(:port) { should be_nil }
28
34
  its(:user) { should be_nil }
29
35
  its(:pass) { should be_nil }
30
36
  end
@@ -33,6 +39,8 @@ describe VagrantPlugins::ProxyConf::UserinfoURI do
33
39
  let(:uri) { 'http://proxy.example.com:8123' }
34
40
  its(:to_s) { should eq 'http://proxy.example.com:8123' }
35
41
  its(:uri) { should eq 'http://proxy.example.com:8123' }
42
+ its(:host) { should eq 'proxy.example.com' }
43
+ its(:port) { should eq 8123 }
36
44
  its(:user) { should be_nil }
37
45
  its(:pass) { should be_nil }
38
46
  end
@@ -41,6 +49,8 @@ describe VagrantPlugins::ProxyConf::UserinfoURI do
41
49
  let(:uri) { 'http://foo@proxy.example.com:8123/' }
42
50
  its(:to_s) { should eq 'http://proxy.example.com:8123' }
43
51
  its(:uri) { should eq 'http://proxy.example.com:8123' }
52
+ its(:host) { should eq 'proxy.example.com' }
53
+ its(:port) { should eq 8123 }
44
54
  its(:user) { should eq 'foo' }
45
55
  its(:pass) { should be_nil }
46
56
  end
@@ -49,6 +59,8 @@ describe VagrantPlugins::ProxyConf::UserinfoURI do
49
59
  let(:uri) { 'http://:bar@proxy.example.com:8123' }
50
60
  its(:to_s) { should eq 'http://proxy.example.com:8123' }
51
61
  its(:uri) { should eq 'http://proxy.example.com:8123' }
62
+ its(:host) { should eq 'proxy.example.com' }
63
+ its(:port) { should eq 8123 }
52
64
  its(:user) { should eq '' }
53
65
  its(:pass) { should eq 'bar' }
54
66
  end
@@ -57,6 +69,8 @@ describe VagrantPlugins::ProxyConf::UserinfoURI do
57
69
  let(:uri) { 'http://foo:bar@proxy.example.com:8123/' }
58
70
  its(:to_s) { should eq 'http://proxy.example.com:8123' }
59
71
  its(:uri) { should eq 'http://proxy.example.com:8123' }
72
+ its(:host) { should eq 'proxy.example.com' }
73
+ its(:port) { should eq 8123 }
60
74
  its(:user) { should eq 'foo' }
61
75
  its(:pass) { should eq 'bar' }
62
76
  end
@@ -65,6 +79,8 @@ describe VagrantPlugins::ProxyConf::UserinfoURI do
65
79
  let(:uri) { 'http://foo:bar@proxy.example.com' }
66
80
  its(:to_s) { should eq 'http://proxy.example.com:80' }
67
81
  its(:uri) { should eq 'http://proxy.example.com:80' }
82
+ its(:host) { should eq 'proxy.example.com' }
83
+ its(:port) { should eq 80 }
68
84
  its(:user) { should eq 'foo' }
69
85
  its(:pass) { should eq 'bar' }
70
86
  end
@@ -73,6 +89,8 @@ describe VagrantPlugins::ProxyConf::UserinfoURI do
73
89
  let(:uri) { 'http://proxy.example.com:80/' }
74
90
  its(:to_s) { should eq 'http://proxy.example.com:80' }
75
91
  its(:uri) { should eq 'http://proxy.example.com:80' }
92
+ its(:host) { should eq 'proxy.example.com' }
93
+ its(:port) { should eq 80 }
76
94
  its(:user) { should be_nil }
77
95
  its(:pass) { should be_nil }
78
96
  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.1.0
4
+ version: 1.2.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-02-06 00:00:00.000000000 Z
11
+ date: 2014-03-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
@@ -35,21 +35,29 @@ files:
35
35
  - lib/vagrant-proxyconf/action/configure_apt_proxy.rb
36
36
  - lib/vagrant-proxyconf/action/configure_chef_proxy.rb
37
37
  - lib/vagrant-proxyconf/action/configure_env_proxy.rb
38
+ - lib/vagrant-proxyconf/action/configure_git_proxy.rb
39
+ - lib/vagrant-proxyconf/action/configure_npm_proxy.rb
38
40
  - lib/vagrant-proxyconf/action/configure_pear_proxy.rb
41
+ - lib/vagrant-proxyconf/action/configure_svn_proxy.rb
39
42
  - lib/vagrant-proxyconf/action/configure_yum_proxy.rb
40
43
  - lib/vagrant-proxyconf/action/is_enabled.rb
41
44
  - lib/vagrant-proxyconf/action/only_once.rb
42
45
  - lib/vagrant-proxyconf/cap/debian/apt_proxy_conf.rb
43
46
  - lib/vagrant-proxyconf/cap/linux/env_proxy_conf.rb
47
+ - lib/vagrant-proxyconf/cap/linux/git_proxy_conf.rb
48
+ - lib/vagrant-proxyconf/cap/linux/npm_proxy_conf.rb
44
49
  - lib/vagrant-proxyconf/cap/linux/pear_proxy_conf.rb
50
+ - lib/vagrant-proxyconf/cap/linux/svn_proxy_conf.rb
45
51
  - lib/vagrant-proxyconf/cap/redhat/yum_proxy_conf.rb
46
52
  - lib/vagrant-proxyconf/capability.rb
47
53
  - lib/vagrant-proxyconf/config.rb
48
54
  - lib/vagrant-proxyconf/config/apt_proxy.rb
49
55
  - lib/vagrant-proxyconf/config/env_proxy.rb
56
+ - lib/vagrant-proxyconf/config/git_proxy.rb
50
57
  - lib/vagrant-proxyconf/config/key.rb
51
58
  - lib/vagrant-proxyconf/config/key_mixin.rb
52
59
  - lib/vagrant-proxyconf/config/proxy.rb
60
+ - lib/vagrant-proxyconf/config/svn_proxy.rb
53
61
  - lib/vagrant-proxyconf/config/yum_proxy.rb
54
62
  - lib/vagrant-proxyconf/hook.rb
55
63
  - lib/vagrant-proxyconf/logger.rb
@@ -77,20 +85,28 @@ files:
77
85
  - spec/unit/vagrant-proxyconf/action/configure_apt_proxy_spec.rb
78
86
  - spec/unit/vagrant-proxyconf/action/configure_chef_proxy_spec.rb
79
87
  - spec/unit/vagrant-proxyconf/action/configure_env_proxy_spec.rb
88
+ - spec/unit/vagrant-proxyconf/action/configure_git_proxy_spec.rb
89
+ - spec/unit/vagrant-proxyconf/action/configure_npm_proxy_spec.rb
80
90
  - spec/unit/vagrant-proxyconf/action/configure_pear_proxy_spec.rb
91
+ - spec/unit/vagrant-proxyconf/action/configure_svn_proxy_spec.rb
81
92
  - spec/unit/vagrant-proxyconf/action/configure_yum_proxy_spec.rb
82
93
  - spec/unit/vagrant-proxyconf/action/is_enabled_spec.rb
83
94
  - spec/unit/vagrant-proxyconf/action/only_once_spec.rb
84
95
  - spec/unit/vagrant-proxyconf/action_spec.rb
85
96
  - spec/unit/vagrant-proxyconf/cap/debian/apt_proxy_conf_spec.rb
86
97
  - spec/unit/vagrant-proxyconf/cap/linux/env_proxy_conf_spec.rb
98
+ - spec/unit/vagrant-proxyconf/cap/linux/git_proxy_conf_spec.rb
99
+ - spec/unit/vagrant-proxyconf/cap/linux/npm_proxy_conf_spec.rb
87
100
  - spec/unit/vagrant-proxyconf/cap/linux/pear_proxy_conf_spec.rb
101
+ - spec/unit/vagrant-proxyconf/cap/linux/svn_proxy_conf_spec.rb
88
102
  - spec/unit/vagrant-proxyconf/cap/redhat/yum_proxy_conf_spec.rb
89
103
  - spec/unit/vagrant-proxyconf/config/apt_proxy_spec.rb
90
104
  - spec/unit/vagrant-proxyconf/config/env_proxy_spec.rb
105
+ - spec/unit/vagrant-proxyconf/config/git_proxy_spec.rb
91
106
  - spec/unit/vagrant-proxyconf/config/key_mixin_spec.rb
92
107
  - spec/unit/vagrant-proxyconf/config/key_spec.rb
93
108
  - spec/unit/vagrant-proxyconf/config/proxy_spec.rb
109
+ - spec/unit/vagrant-proxyconf/config/svn_proxy_spec.rb
94
110
  - spec/unit/vagrant-proxyconf/config/yum_proxy_spec.rb
95
111
  - spec/unit/vagrant-proxyconf/logger_spec.rb
96
112
  - spec/unit/vagrant-proxyconf/plugin_spec.rb
@@ -108,17 +124,17 @@ require_paths:
108
124
  - lib
109
125
  required_ruby_version: !ruby/object:Gem::Requirement
110
126
  requirements:
111
- - - '>='
127
+ - - ">="
112
128
  - !ruby/object:Gem::Version
113
129
  version: '0'
114
130
  required_rubygems_version: !ruby/object:Gem::Requirement
115
131
  requirements:
116
- - - '>='
132
+ - - ">="
117
133
  - !ruby/object:Gem::Version
118
134
  version: '0'
119
135
  requirements: []
120
136
  rubyforge_project:
121
- rubygems_version: 2.0.14
137
+ rubygems_version: 2.2.2
122
138
  signing_key:
123
139
  specification_version: 4
124
140
  summary: A Vagrant plugin that configures the virtual machine to use proxy servers
@@ -141,20 +157,28 @@ test_files:
141
157
  - spec/unit/vagrant-proxyconf/action/configure_apt_proxy_spec.rb
142
158
  - spec/unit/vagrant-proxyconf/action/configure_chef_proxy_spec.rb
143
159
  - spec/unit/vagrant-proxyconf/action/configure_env_proxy_spec.rb
160
+ - spec/unit/vagrant-proxyconf/action/configure_git_proxy_spec.rb
161
+ - spec/unit/vagrant-proxyconf/action/configure_npm_proxy_spec.rb
144
162
  - spec/unit/vagrant-proxyconf/action/configure_pear_proxy_spec.rb
163
+ - spec/unit/vagrant-proxyconf/action/configure_svn_proxy_spec.rb
145
164
  - spec/unit/vagrant-proxyconf/action/configure_yum_proxy_spec.rb
146
165
  - spec/unit/vagrant-proxyconf/action/is_enabled_spec.rb
147
166
  - spec/unit/vagrant-proxyconf/action/only_once_spec.rb
148
167
  - spec/unit/vagrant-proxyconf/action_spec.rb
149
168
  - spec/unit/vagrant-proxyconf/cap/debian/apt_proxy_conf_spec.rb
150
169
  - spec/unit/vagrant-proxyconf/cap/linux/env_proxy_conf_spec.rb
170
+ - spec/unit/vagrant-proxyconf/cap/linux/git_proxy_conf_spec.rb
171
+ - spec/unit/vagrant-proxyconf/cap/linux/npm_proxy_conf_spec.rb
151
172
  - spec/unit/vagrant-proxyconf/cap/linux/pear_proxy_conf_spec.rb
173
+ - spec/unit/vagrant-proxyconf/cap/linux/svn_proxy_conf_spec.rb
152
174
  - spec/unit/vagrant-proxyconf/cap/redhat/yum_proxy_conf_spec.rb
153
175
  - spec/unit/vagrant-proxyconf/config/apt_proxy_spec.rb
154
176
  - spec/unit/vagrant-proxyconf/config/env_proxy_spec.rb
177
+ - spec/unit/vagrant-proxyconf/config/git_proxy_spec.rb
155
178
  - spec/unit/vagrant-proxyconf/config/key_mixin_spec.rb
156
179
  - spec/unit/vagrant-proxyconf/config/key_spec.rb
157
180
  - spec/unit/vagrant-proxyconf/config/proxy_spec.rb
181
+ - spec/unit/vagrant-proxyconf/config/svn_proxy_spec.rb
158
182
  - spec/unit/vagrant-proxyconf/config/yum_proxy_spec.rb
159
183
  - spec/unit/vagrant-proxyconf/logger_spec.rb
160
184
  - spec/unit/vagrant-proxyconf/plugin_spec.rb