vagrant-proxyconf 0.5.3 → 0.6.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.md +5 -0
- data/Gemfile +1 -1
- data/README.md +1 -2
- data/development/Vagrantfile.example +1 -1
- data/lib/vagrant-proxyconf/action.rb +31 -0
- data/lib/vagrant-proxyconf/action/base.rb +10 -8
- data/lib/vagrant-proxyconf/action/configure_chef_proxy.rb +12 -8
- data/lib/vagrant-proxyconf/action/only_once.rb +61 -0
- data/lib/vagrant-proxyconf/logger.rb +11 -0
- data/lib/vagrant-proxyconf/plugin.rb +36 -20
- data/lib/vagrant-proxyconf/version.rb +1 -1
- data/locales/en.yml +1 -1
- data/spec/unit/vagrant-proxyconf/action/only_once_spec.rb +136 -0
- data/spec/unit/vagrant-proxyconf/action_spec.rb +5 -0
- data/spec/unit/vagrant-proxyconf/logger_spec.rb +16 -0
- data/spec/unit/vagrant-proxyconf/plugin_spec.rb +37 -5
- metadata +13 -4
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Y2NiYWE0Y2MxNWIxYTY0ZjQ1MDIyNjQ1MTQ3NDkxYWM0MDYwZjk1OA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MTNjNmNmYjZhMDQ1MGNlYmU4YmY0MTc5NjAyZWM3ZjY1YzMyNjY0Zg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MDllNDZmOGNlNzU0ZDJlZmJjYjdhMWYwYjgzOTM0OTg4NWUzODExYTM5ZDkz
|
10
|
+
NmI5YTkzYzU3MzAxNGU5MDFjY2QwMzUwNDYxNDVkYjA2ODZkMWRhODUyMWQz
|
11
|
+
ZDUxZTk3YWFlMzg3MDJhODIzOTZmYTJiZjMzYzQ1ZDAxNjBlM2Y=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ODUwZjNlZTQ1MzZhNmFlMmE1NTYzMTAwN2M2NzQxNzRiYzU2ZGQzYjRiY2Ji
|
14
|
+
MjU1ZjllMGJhYWQ3MDdiODg4YWQwOWIzNWE3ODY3MjBjOTQ2OWQyNTBmMTE4
|
15
|
+
YTQ2MmFiN2ExMWM1MTU1ZTdhMjVhNjdlMjlhNWYwYjY5Nzg1OWU=
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
# 0.6.0.rc1 / 2013-10-10
|
2
|
+
|
3
|
+
- Add support for the [vagrant-vbguest](https://github.com/dotless-de/vagrant-vbguest) plugin ([GH-30][])
|
4
|
+
|
1
5
|
# 0.5.3 / 2013-09-30
|
2
6
|
|
3
7
|
- Compatibility with vagrant-aws v0.4.0 ([GH-28][])
|
@@ -77,3 +81,4 @@
|
|
77
81
|
[GH-27]: https://github.com/tmatilai/vagrant-proxyconf/issues/27 "Issue 27"
|
78
82
|
[GH-28]: https://github.com/tmatilai/vagrant-proxyconf/issues/28 "Issue 28"
|
79
83
|
[GH-29]: https://github.com/tmatilai/vagrant-proxyconf/issues/29 "Issue 29"
|
84
|
+
[GH-30]: https://github.com/tmatilai/vagrant-proxyconf/issues/30 "Issue 30"
|
data/Gemfile
CHANGED
@@ -7,7 +7,7 @@ gem 'rake'
|
|
7
7
|
gem 'rspec', '~> 2.11'
|
8
8
|
gem 'simplecov', '~> 0.7', :require => false
|
9
9
|
gem 'tailor', '~> 1.2'
|
10
|
-
gem 'vagrant', github: 'mitchellh/vagrant', ref: 'v1.3.
|
10
|
+
gem 'vagrant', github: 'mitchellh/vagrant', ref: 'v1.3.4'
|
11
11
|
|
12
12
|
group :development do
|
13
13
|
gem 'guard-rspec'
|
data/README.md
CHANGED
@@ -43,8 +43,7 @@ end
|
|
43
43
|
|
44
44
|
This plugin requires Vagrant 1.2 or newer ([downloads](http://downloads.vagrantup.com/)).
|
45
45
|
|
46
|
-
The plugin is supposed to be compatible with all Vagrant providers. Please file an [issue](https://github.com/tmatilai/vagrant-proxyconf/issues) if this is not the case.
|
47
|
-
The following providers are confirmed to work:
|
46
|
+
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:
|
48
47
|
[AWS](https://github.com/mitchellh/vagrant-aws),
|
49
48
|
[Digital Ocean](https://github.com/smdahlen/vagrant-digitalocean),
|
50
49
|
[VirtualBox](http://docs.vagrantup.com/v2/virtualbox),
|
@@ -15,6 +15,6 @@ Vagrant.configure('2') do |config|
|
|
15
15
|
|
16
16
|
config.vm.box = BOX
|
17
17
|
if BOX == 'ubuntu-12.04'
|
18
|
-
|
18
|
+
config.vm.box_url = 'https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_provisionerless.box'
|
19
19
|
end
|
20
20
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require_relative 'action/configure_apt_proxy'
|
2
|
+
require_relative 'action/configure_chef_proxy'
|
3
|
+
require_relative 'action/configure_env_proxy'
|
4
|
+
require_relative 'action/only_once'
|
5
|
+
|
6
|
+
module VagrantPlugins
|
7
|
+
module ProxyConf
|
8
|
+
# Middleware stack builders
|
9
|
+
class Action
|
10
|
+
# Returns an action middleware stack that configures the VM
|
11
|
+
#
|
12
|
+
# @param opts [Hash] the options to be passed to {OnlyOnce}
|
13
|
+
# @option (see OnlyOnce#initialize)
|
14
|
+
def self.configure(opts = {})
|
15
|
+
Vagrant::Action::Builder.build(OnlyOnce, opts, &config_actions)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
# @return [Proc] the block that adds config actions to the specified
|
21
|
+
# middleware builder
|
22
|
+
def self.config_actions
|
23
|
+
@actions ||= Proc.new do |builder|
|
24
|
+
builder.use ConfigureAptProxy
|
25
|
+
builder.use ConfigureChefProxy
|
26
|
+
builder.use ConfigureEnvProxy
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -1,33 +1,30 @@
|
|
1
|
-
require 'log4r'
|
2
1
|
require 'tempfile'
|
3
2
|
require 'vagrant'
|
3
|
+
require_relative '../logger'
|
4
4
|
|
5
5
|
module VagrantPlugins
|
6
6
|
module ProxyConf
|
7
7
|
class Action
|
8
8
|
# Base class for proxy configuration Actions
|
9
9
|
class Base
|
10
|
-
attr_reader :logger
|
11
|
-
|
12
10
|
def initialize(app, env)
|
13
|
-
@app
|
14
|
-
@logger = Log4r::Logger.new('vagrant::proxyconf')
|
11
|
+
@app = app
|
15
12
|
end
|
16
13
|
|
17
14
|
def call(env)
|
18
|
-
@app.call env
|
19
|
-
|
20
15
|
machine = env[:machine]
|
21
16
|
config = config(machine)
|
22
17
|
|
23
18
|
if !config.enabled?
|
24
|
-
logger.
|
19
|
+
logger.info I18n.t("vagrant_proxyconf.#{config_name}.not_enabled")
|
25
20
|
elsif !supported?(machine)
|
26
21
|
env[:ui].info I18n.t("vagrant_proxyconf.#{config_name}.not_supported")
|
27
22
|
else
|
28
23
|
env[:ui].info I18n.t("vagrant_proxyconf.#{config_name}.configuring")
|
29
24
|
configure_machine(machine, config)
|
30
25
|
end
|
26
|
+
|
27
|
+
@app.call env
|
31
28
|
end
|
32
29
|
|
33
30
|
# @return [String] the name of the configuration section
|
@@ -37,6 +34,11 @@ module VagrantPlugins
|
|
37
34
|
|
38
35
|
private
|
39
36
|
|
37
|
+
# @return [Log4r::Logger]
|
38
|
+
def logger
|
39
|
+
ProxyConf.logger
|
40
|
+
end
|
41
|
+
|
40
42
|
# @return [Vagrant::Plugin::V2::Config] the configuration
|
41
43
|
def config(machine)
|
42
44
|
config = machine.config.public_send(config_name.to_sym)
|
@@ -1,33 +1,37 @@
|
|
1
|
+
require_relative '../logger'
|
2
|
+
|
1
3
|
module VagrantPlugins
|
2
4
|
module ProxyConf
|
3
5
|
class Action
|
4
6
|
# Action for configuring Chef provisioners
|
5
7
|
class ConfigureChefProxy
|
6
|
-
attr_reader :logger
|
7
|
-
|
8
8
|
def initialize(app, env)
|
9
|
-
@app
|
10
|
-
@logger = Log4r::Logger.new('vagrant::proxyconf')
|
9
|
+
@app = app
|
11
10
|
end
|
12
11
|
|
13
12
|
def call(env)
|
14
|
-
@app.call env
|
15
|
-
|
16
13
|
machine = env[:machine]
|
17
14
|
config = config(machine)
|
18
15
|
|
19
16
|
if chef_provisioners(machine).empty?
|
20
|
-
logger.
|
17
|
+
logger.info I18n.t("vagrant_proxyconf.chef_proxy.no_provisioners")
|
21
18
|
elsif !config.enabled?
|
22
|
-
logger.
|
19
|
+
logger.info I18n.t("vagrant_proxyconf.chef_proxy.not_enabled")
|
23
20
|
else
|
24
21
|
env[:ui].info I18n.t("vagrant_proxyconf.chef_proxy.configuring")
|
25
22
|
configure_chef_provisioners(machine, config)
|
26
23
|
end
|
24
|
+
|
25
|
+
@app.call env
|
27
26
|
end
|
28
27
|
|
29
28
|
private
|
30
29
|
|
30
|
+
# @return [Log4r::Logger]
|
31
|
+
def logger
|
32
|
+
ProxyConf.logger
|
33
|
+
end
|
34
|
+
|
31
35
|
# @return [Config::Proxy] the `config.proxy` configuration
|
32
36
|
def config(machine)
|
33
37
|
config = machine.config.proxy
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require_relative '../logger'
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module ProxyConf
|
5
|
+
class Action
|
6
|
+
# A middleware class that builds and runs the stack based on the
|
7
|
+
# specified block, but only once.
|
8
|
+
class OnlyOnce
|
9
|
+
# @param opts [Hash] the options
|
10
|
+
# @option opts [Boolean] :before (false) should the block be called
|
11
|
+
# before (instead of after) passing control to the next middleware
|
12
|
+
def initialize(app, env, opts = {}, &block)
|
13
|
+
raise ArgumentError, "A block must be given to OnlyOnce" if !block
|
14
|
+
|
15
|
+
@app = app
|
16
|
+
@before = opts[:before]
|
17
|
+
@block = block
|
18
|
+
end
|
19
|
+
|
20
|
+
def call(env)
|
21
|
+
@app.call(env) if !@before
|
22
|
+
|
23
|
+
if env[@block]
|
24
|
+
logger.debug "Skipping repeated '#{@block}' stack"
|
25
|
+
else
|
26
|
+
logger.debug "'#{@block}' stack invoked first time"
|
27
|
+
env[@block] = true
|
28
|
+
|
29
|
+
new_env = build_and_run_block(env)
|
30
|
+
env.merge!(new_env)
|
31
|
+
end
|
32
|
+
|
33
|
+
@app.call(env) if @before
|
34
|
+
end
|
35
|
+
|
36
|
+
def recover(env)
|
37
|
+
# Call back into our compiled application and recover it.
|
38
|
+
@child_app.recover(env) if @child_app
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
# @return [Log4r::Logger]
|
44
|
+
def logger
|
45
|
+
ProxyConf.logger
|
46
|
+
end
|
47
|
+
|
48
|
+
# Creates and runs a Builder based on the block given in initializer.
|
49
|
+
#
|
50
|
+
# @param env [Hash] the current environment
|
51
|
+
# @return [Hash] the new environment
|
52
|
+
def build_and_run_block(env)
|
53
|
+
builder = Vagrant::Action::Builder.new
|
54
|
+
@block.call(builder)
|
55
|
+
@child_app = builder.to_app(env)
|
56
|
+
Vagrant::Action::Runner.new.run(@child_app, env)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'log4r'
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
# Base module for Vagrant Proxyconf plugin
|
5
|
+
module ProxyConf
|
6
|
+
# @return [Log4r::Logger] the logger instance for this plugin
|
7
|
+
def self.logger
|
8
|
+
@logger ||= Log4r::Logger.new('vagrant::proxyconf')
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -9,6 +9,9 @@ module VagrantPlugins
|
|
9
9
|
# The minimum compatible Vagrant version
|
10
10
|
MIN_VAGRANT_VERSION = '1.2.0'
|
11
11
|
|
12
|
+
# A list of plugins whose action classes we hook to if installed
|
13
|
+
OPTIONAL_PLUGIN_DEPENDENCIES = %w[vagrant-aws vagrant-omnibus vagrant-vbguest]
|
14
|
+
|
12
15
|
# Verifies that the Vagrant version fulfills the requirements
|
13
16
|
#
|
14
17
|
# @raise [VagrantPlugins::ProxyConf::VagrantVersionError] if this plugin
|
@@ -27,8 +30,25 @@ module VagrantPlugins
|
|
27
30
|
I18n.reload!
|
28
31
|
end
|
29
32
|
|
33
|
+
# Ensures a dependent plugin is loaded before us if it is installed.
|
34
|
+
# Ignores {Vagrant::Errors::PluginLoadError} but passes other exceptions.
|
35
|
+
#
|
36
|
+
# @param plugin [String] the plugin name
|
37
|
+
def self.load_optional_dependency(plugin)
|
38
|
+
begin
|
39
|
+
Vagrant.require_plugin plugin
|
40
|
+
rescue Vagrant::Errors::PluginLoadError; end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Loads the plugins to ensure their action hooks are registered before us.
|
44
|
+
# Uses alphabetical order to not change the default behaviour otherwise.
|
45
|
+
def self.load_optional_dependencies
|
46
|
+
OPTIONAL_PLUGIN_DEPENDENCIES.sort.each { |plugin| load_optional_dependency plugin }
|
47
|
+
end
|
48
|
+
|
30
49
|
setup_i18n
|
31
50
|
check_vagrant_version!
|
51
|
+
load_optional_dependencies
|
32
52
|
|
33
53
|
name 'vagrant-proxyconf'
|
34
54
|
|
@@ -58,29 +78,25 @@ module VagrantPlugins
|
|
58
78
|
end
|
59
79
|
|
60
80
|
action_hook 'proxyconf_configure' do |hook|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
register_hooks(hook, Vagrant::Action::Builtin::Provision)
|
66
|
-
|
67
|
-
# vagrant-aws < 0.4.0 uses a non-standard provision action
|
68
|
-
if defined? VagrantPlugins::AWS::Action::TimedProvision
|
69
|
-
register_hooks(hook, VagrantPlugins::AWS::Action::TimedProvision)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
81
|
+
require_relative 'action'
|
82
|
+
|
83
|
+
# the standard provision action
|
84
|
+
hook.after Vagrant::Action::Builtin::Provision, Action.configure
|
73
85
|
|
74
|
-
|
86
|
+
# vagrant-aws < 0.4.0 uses a non-standard provision action
|
87
|
+
if defined?(VagrantPlugins::AWS::Action::TimedProvision)
|
88
|
+
hook.after VagrantPlugins::AWS::Action::TimedProvision, Action.configure
|
89
|
+
end
|
75
90
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
91
|
+
# configure the proxies before vagrant-omnibus
|
92
|
+
if defined?(VagrantPlugins::Omnibus::Action::InstallChef)
|
93
|
+
hook.after VagrantPlugins::Omnibus::Action::InstallChef, Action.configure
|
94
|
+
end
|
80
95
|
|
81
|
-
|
82
|
-
|
83
|
-
|
96
|
+
# configure the proxies before vagrant-vbguest
|
97
|
+
if defined?(VagrantVbguest::Middleware)
|
98
|
+
hook.before VagrantVbguest::Middleware, Action.configure(before: true)
|
99
|
+
end
|
84
100
|
end
|
85
101
|
end
|
86
102
|
end
|
data/locales/en.yml
CHANGED
@@ -0,0 +1,136 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'vagrant-proxyconf/action/only_once'
|
3
|
+
|
4
|
+
describe VagrantPlugins::ProxyConf::Action::OnlyOnce do
|
5
|
+
let(:app) { lambda { |env| } }
|
6
|
+
let(:env) { {} }
|
7
|
+
|
8
|
+
it "runs the stack first time" do
|
9
|
+
received = nil
|
10
|
+
next_step = lambda { |env| received = "value" }
|
11
|
+
|
12
|
+
described_class.new(app, env) do |builder|
|
13
|
+
builder.use next_step
|
14
|
+
end.call({})
|
15
|
+
|
16
|
+
expect(received).to eq "value"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "passes environment to the stack" do
|
20
|
+
received = nil
|
21
|
+
next_step = lambda { |env| received = env[:foo] }
|
22
|
+
|
23
|
+
described_class.new(app, env) do |builder|
|
24
|
+
builder.use next_step
|
25
|
+
end.call({ foo: "value" })
|
26
|
+
|
27
|
+
expect(received).to eq "value"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "updates the original environment" do
|
31
|
+
next_step = lambda { |env| env[:foo] = "value" }
|
32
|
+
|
33
|
+
described_class.new(app, env) do |builder|
|
34
|
+
builder.use next_step
|
35
|
+
end.call(env)
|
36
|
+
|
37
|
+
expect(env[:foo]).to eq "value"
|
38
|
+
end
|
39
|
+
|
40
|
+
it "runs the same stack only once" do
|
41
|
+
count = 0
|
42
|
+
next_step = lambda { |env| count += 1 }
|
43
|
+
stack = lambda { |builder| builder.use next_step }
|
44
|
+
|
45
|
+
described_class.new(app, env, &stack).tap do |instance|
|
46
|
+
instance.call(env)
|
47
|
+
instance.call(env)
|
48
|
+
end
|
49
|
+
described_class.new(app, env, &stack).call(env)
|
50
|
+
|
51
|
+
expect(count).to eq 1
|
52
|
+
end
|
53
|
+
|
54
|
+
it "runs different stacks" do
|
55
|
+
count = 0
|
56
|
+
next_step = lambda { |env| count += 1 }
|
57
|
+
stack1 = lambda { |builder| builder.use next_step }
|
58
|
+
stack2 = lambda { |builder| builder.use next_step }
|
59
|
+
|
60
|
+
described_class.new(app, env, &stack1).call(env)
|
61
|
+
described_class.new(app, env, &stack2).call(env)
|
62
|
+
|
63
|
+
expect(count).to eq 2
|
64
|
+
end
|
65
|
+
|
66
|
+
it "calls the next app defore the block by default" do
|
67
|
+
received = nil
|
68
|
+
next_app = lambda { |env| env[:foo] = "value" }
|
69
|
+
next_step = lambda { |env| received = env[:foo] }
|
70
|
+
|
71
|
+
described_class.new(next_app, env) do |builder|
|
72
|
+
builder.use next_step
|
73
|
+
end.call({})
|
74
|
+
|
75
|
+
expect(received).to eq "value"
|
76
|
+
end
|
77
|
+
|
78
|
+
it "calls the next app after the block if specified" do
|
79
|
+
received = nil
|
80
|
+
next_step = lambda { |env| env[:foo] = "value" }
|
81
|
+
next_app = lambda { |env| received = env[:foo] }
|
82
|
+
|
83
|
+
described_class.new(next_app, env, before: true) do |builder|
|
84
|
+
builder.use next_step
|
85
|
+
end.call({})
|
86
|
+
|
87
|
+
expect(received).to eq "value"
|
88
|
+
end
|
89
|
+
|
90
|
+
it "calls the recover method for the sequence in an error" do
|
91
|
+
# Build the steps for the test
|
92
|
+
basic_step = Class.new do
|
93
|
+
def initialize(app, env)
|
94
|
+
@app = app
|
95
|
+
@env = env
|
96
|
+
end
|
97
|
+
|
98
|
+
def call(env)
|
99
|
+
@app.call(env)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
step_a = Class.new(basic_step) do
|
104
|
+
def call(env)
|
105
|
+
env[:steps] << :call_A
|
106
|
+
super
|
107
|
+
end
|
108
|
+
|
109
|
+
def recover(env)
|
110
|
+
env[:steps] << :recover_A
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
step_b = Class.new(basic_step) do
|
115
|
+
def call(env)
|
116
|
+
env[:steps] << :call_B
|
117
|
+
super
|
118
|
+
end
|
119
|
+
|
120
|
+
def recover(env)
|
121
|
+
env[:steps] << :recover_B
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
instance = described_class.new(app, env) do |builder|
|
126
|
+
builder.use step_a
|
127
|
+
builder.use step_b
|
128
|
+
end
|
129
|
+
|
130
|
+
env[:steps] = []
|
131
|
+
instance.call(env)
|
132
|
+
instance.recover(env)
|
133
|
+
|
134
|
+
expect(env[:steps]).to eq [:call_A, :call_B, :recover_B, :recover_A]
|
135
|
+
end
|
136
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'vagrant-proxyconf/logger'
|
3
|
+
|
4
|
+
describe VagrantPlugins::ProxyConf do
|
5
|
+
|
6
|
+
describe '.logger' do
|
7
|
+
subject { described_class.logger }
|
8
|
+
|
9
|
+
it { should be_a Log4r::Logger }
|
10
|
+
|
11
|
+
it "always returns the same instance" do
|
12
|
+
expect(subject).to be described_class.logger
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -3,7 +3,8 @@ require 'vagrant-proxyconf/plugin'
|
|
3
3
|
|
4
4
|
describe VagrantPlugins::ProxyConf::Plugin do
|
5
5
|
|
6
|
-
describe
|
6
|
+
describe '.check_vagrant_version!' do
|
7
|
+
subject { described_class.check_vagrant_version! }
|
7
8
|
let(:min_vagrant_verision) { '1.2.3' }
|
8
9
|
let(:err_msg) { /requires Vagrant #{min_vagrant_verision}/ }
|
9
10
|
|
@@ -16,27 +17,58 @@ describe VagrantPlugins::ProxyConf::Plugin do
|
|
16
17
|
context "on too old Vagrant version" do
|
17
18
|
let(:vagrant_version) { '1.1.5' }
|
18
19
|
it "raises" do
|
19
|
-
expect {
|
20
|
+
expect { subject }.to raise_error(err_msg)
|
20
21
|
end
|
21
22
|
it "warns" do
|
22
23
|
$stderr.should_receive(:puts).with(err_msg)
|
23
|
-
|
24
|
+
subject rescue nil
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
27
28
|
context "on exact required Vagrant version" do
|
28
29
|
let(:vagrant_version) { min_vagrant_verision }
|
29
30
|
it "does not raise" do
|
30
|
-
expect {
|
31
|
+
expect { subject }.not_to raise_error
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
34
35
|
context "on newer Vagrant version" do
|
35
36
|
let(:vagrant_version) { '1.3.5' }
|
36
37
|
it "does not raise" do
|
37
|
-
expect {
|
38
|
+
expect { subject }.not_to raise_error
|
38
39
|
end
|
39
40
|
end
|
40
41
|
end
|
41
42
|
|
43
|
+
describe '.load_optional_dependency' do
|
44
|
+
subject { described_class.load_optional_dependency(plugin_name) }
|
45
|
+
let(:plugin_name) { 'vagrant-foo' }
|
46
|
+
|
47
|
+
it "loads the specified plugin" do
|
48
|
+
expect(Vagrant).to receive(:require_plugin).with(plugin_name)
|
49
|
+
subject
|
50
|
+
end
|
51
|
+
|
52
|
+
it "ignores PluginLoadError" do
|
53
|
+
expect(Vagrant).to receive(:require_plugin).and_raise(Vagrant::Errors::PluginLoadError, plugin: plugin_name)
|
54
|
+
expect { subject }.not_to raise_error
|
55
|
+
end
|
56
|
+
|
57
|
+
it "won't ignore other error" do
|
58
|
+
expect(Vagrant).to receive(:require_plugin).and_raise(Vagrant::Errors::PluginLoadFailed, plugin: plugin_name)
|
59
|
+
expect { subject }.to raise_error(Vagrant::Errors::PluginLoadFailed)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe '.load_optional_dependencies' do
|
64
|
+
let(:plugins) { %w[vagrant-foo vagrant-bar vagrant-baz] }
|
65
|
+
let(:loaded_plugins) { [] }
|
66
|
+
|
67
|
+
it "loads the plugins in alphabetical order" do
|
68
|
+
stub_const('VagrantPlugins::ProxyConf::Plugin::OPTIONAL_PLUGIN_DEPENDENCIES', plugins)
|
69
|
+
allow(described_class).to receive(:load_optional_dependency) { |plugin| loaded_plugins << plugin }
|
70
|
+
described_class.load_optional_dependencies
|
71
|
+
expect(loaded_plugins).to eq %w[vagrant-bar vagrant-baz vagrant-foo]
|
72
|
+
end
|
73
|
+
end
|
42
74
|
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: 0.
|
4
|
+
version: 0.6.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Teemu Matilainen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-10-10 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:
|
@@ -30,10 +30,12 @@ files:
|
|
30
30
|
- development/README.md
|
31
31
|
- development/Vagrantfile.example
|
32
32
|
- lib/vagrant-proxyconf.rb
|
33
|
+
- lib/vagrant-proxyconf/action.rb
|
33
34
|
- lib/vagrant-proxyconf/action/base.rb
|
34
35
|
- lib/vagrant-proxyconf/action/configure_apt_proxy.rb
|
35
36
|
- lib/vagrant-proxyconf/action/configure_chef_proxy.rb
|
36
37
|
- lib/vagrant-proxyconf/action/configure_env_proxy.rb
|
38
|
+
- lib/vagrant-proxyconf/action/only_once.rb
|
37
39
|
- lib/vagrant-proxyconf/cap/debian/apt_proxy_conf.rb
|
38
40
|
- lib/vagrant-proxyconf/cap/linux/env_proxy_conf.rb
|
39
41
|
- lib/vagrant-proxyconf/config/apt_proxy.rb
|
@@ -41,6 +43,7 @@ files:
|
|
41
43
|
- lib/vagrant-proxyconf/config/key.rb
|
42
44
|
- lib/vagrant-proxyconf/config/key_mixin.rb
|
43
45
|
- lib/vagrant-proxyconf/config/proxy.rb
|
46
|
+
- lib/vagrant-proxyconf/logger.rb
|
44
47
|
- lib/vagrant-proxyconf/plugin.rb
|
45
48
|
- lib/vagrant-proxyconf/version.rb
|
46
49
|
- locales/en.yml
|
@@ -49,6 +52,8 @@ files:
|
|
49
52
|
- spec/unit/vagrant-proxyconf/action/configure_apt_proxy_spec.rb
|
50
53
|
- spec/unit/vagrant-proxyconf/action/configure_chef_proxy_spec.rb
|
51
54
|
- spec/unit/vagrant-proxyconf/action/configure_env_proxy_spec.rb
|
55
|
+
- spec/unit/vagrant-proxyconf/action/only_once_spec.rb
|
56
|
+
- spec/unit/vagrant-proxyconf/action_spec.rb
|
52
57
|
- spec/unit/vagrant-proxyconf/cap/debian/apt_proxy_conf_spec.rb
|
53
58
|
- spec/unit/vagrant-proxyconf/cap/linux/env_proxy_conf_spec.rb
|
54
59
|
- spec/unit/vagrant-proxyconf/config/apt_proxy_spec.rb
|
@@ -56,6 +61,7 @@ files:
|
|
56
61
|
- spec/unit/vagrant-proxyconf/config/key_mixin_spec.rb
|
57
62
|
- spec/unit/vagrant-proxyconf/config/key_spec.rb
|
58
63
|
- spec/unit/vagrant-proxyconf/config/proxy_spec.rb
|
64
|
+
- spec/unit/vagrant-proxyconf/logger_spec.rb
|
59
65
|
- spec/unit/vagrant-proxyconf/plugin_spec.rb
|
60
66
|
- vagrant-proxyconf.gemspec
|
61
67
|
homepage: http://tmatilai.github.io/vagrant-proxyconf/
|
@@ -73,9 +79,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
73
79
|
version: '0'
|
74
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
81
|
requirements:
|
76
|
-
- - ! '
|
82
|
+
- - ! '>'
|
77
83
|
- !ruby/object:Gem::Version
|
78
|
-
version:
|
84
|
+
version: 1.3.1
|
79
85
|
requirements: []
|
80
86
|
rubyforge_project:
|
81
87
|
rubygems_version: 2.1.4
|
@@ -88,6 +94,8 @@ test_files:
|
|
88
94
|
- spec/unit/vagrant-proxyconf/action/configure_apt_proxy_spec.rb
|
89
95
|
- spec/unit/vagrant-proxyconf/action/configure_chef_proxy_spec.rb
|
90
96
|
- spec/unit/vagrant-proxyconf/action/configure_env_proxy_spec.rb
|
97
|
+
- spec/unit/vagrant-proxyconf/action/only_once_spec.rb
|
98
|
+
- spec/unit/vagrant-proxyconf/action_spec.rb
|
91
99
|
- spec/unit/vagrant-proxyconf/cap/debian/apt_proxy_conf_spec.rb
|
92
100
|
- spec/unit/vagrant-proxyconf/cap/linux/env_proxy_conf_spec.rb
|
93
101
|
- spec/unit/vagrant-proxyconf/config/apt_proxy_spec.rb
|
@@ -95,5 +103,6 @@ test_files:
|
|
95
103
|
- spec/unit/vagrant-proxyconf/config/key_mixin_spec.rb
|
96
104
|
- spec/unit/vagrant-proxyconf/config/key_spec.rb
|
97
105
|
- spec/unit/vagrant-proxyconf/config/proxy_spec.rb
|
106
|
+
- spec/unit/vagrant-proxyconf/logger_spec.rb
|
98
107
|
- spec/unit/vagrant-proxyconf/plugin_spec.rb
|
99
108
|
has_rdoc:
|