vagrant-berkshelf 3.0.1 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +36 -17
  3. data/.travis.yml +6 -4
  4. data/CONTRIBUTING.md +4 -4
  5. data/Gemfile +2 -2
  6. data/{LICENSE.txt → LICENSE} +1 -1
  7. data/README.md +67 -24
  8. data/Rakefile +14 -0
  9. data/lib/vagrant-berkshelf.rb +17 -1
  10. data/lib/vagrant-berkshelf/action/base.rb +48 -0
  11. data/lib/vagrant-berkshelf/action/check.rb +44 -0
  12. data/lib/vagrant-berkshelf/action/clean.rb +29 -0
  13. data/lib/vagrant-berkshelf/action/install.rb +35 -0
  14. data/lib/vagrant-berkshelf/action/load.rb +59 -0
  15. data/lib/vagrant-berkshelf/action/share.rb +38 -0
  16. data/lib/vagrant-berkshelf/action/upload.rb +99 -0
  17. data/lib/vagrant-berkshelf/config.rb +87 -0
  18. data/lib/vagrant-berkshelf/env.rb +14 -0
  19. data/lib/vagrant-berkshelf/errors.rb +79 -0
  20. data/lib/vagrant-berkshelf/helpers.rb +180 -0
  21. data/lib/vagrant-berkshelf/plugin.rb +40 -0
  22. data/lib/vagrant-berkshelf/version.rb +5 -0
  23. data/spec/spec_helper.rb +1 -4
  24. data/spec/unit/vagrant-berkshelf/config_spec.rb +119 -0
  25. data/vagrant-berkshelf.gemspec +26 -14
  26. metadata +35 -52
  27. data/Thorfile +0 -59
  28. data/integration/Berksfile +0 -3
  29. data/integration/Gemfile +0 -10
  30. data/integration/Vagrantfile +0 -19
  31. data/lib/berkshelf/vagrant.rb +0 -68
  32. data/lib/berkshelf/vagrant/action.rb +0 -64
  33. data/lib/berkshelf/vagrant/action/clean.rb +0 -27
  34. data/lib/berkshelf/vagrant/action/configure_chef.rb +0 -27
  35. data/lib/berkshelf/vagrant/action/install.rb +0 -69
  36. data/lib/berkshelf/vagrant/action/load_shelf.rb +0 -52
  37. data/lib/berkshelf/vagrant/action/upload.rb +0 -53
  38. data/lib/berkshelf/vagrant/berks_config.rb +0 -48
  39. data/lib/berkshelf/vagrant/chef_config.rb +0 -88
  40. data/lib/berkshelf/vagrant/config.rb +0 -113
  41. data/lib/berkshelf/vagrant/env.rb +0 -16
  42. data/lib/berkshelf/vagrant/env_helpers.rb +0 -160
  43. data/lib/berkshelf/vagrant/errors.rb +0 -71
  44. data/lib/berkshelf/vagrant/plugin.rb +0 -41
  45. data/lib/berkshelf/vagrant/version.rb +0 -5
  46. data/spec/unit/berkshelf/vagrant/config_spec.rb +0 -97
  47. data/spec/unit/berkshelf/vagrant/errors_spec.rb +0 -12
  48. data/spec/unit/berkshelf/vagrant_spec.rb +0 -31
@@ -1,41 +0,0 @@
1
- module Berkshelf
2
- module Vagrant
3
- class Plugin < ::Vagrant.plugin("2")
4
- class << self
5
- def provision(hook)
6
- hook.after(::Vagrant::Action::Builtin::Provision, Berkshelf::Vagrant::Action.upload)
7
- hook.after(::Vagrant::Action::Builtin::Provision, Berkshelf::Vagrant::Action.install)
8
-
9
- # vagrant-aws < 0.4.0 uses a non-standard provision action
10
- if defined?(VagrantPlugins::AWS::Action::TimedProvision)
11
- hook.after(VagrantPlugins::AWS::Action::TimedProvision, Berkshelf::Vagrant::Action.upload)
12
- hook.after(VagrantPlugins::AWS::Action::TimedProvision, Berkshelf::Vagrant::Action.install)
13
- end
14
-
15
- hook.before(::Vagrant::Action::Builtin::ConfigValidate, Berkshelf::Vagrant::Action.setup)
16
- end
17
- end
18
-
19
- name "berkshelf"
20
- description <<-DESC
21
- Automatically make available cookbooks to virtual machines provisioned by Chef Solo
22
- or Chef Client using Berkshelf.
23
- DESC
24
-
25
- action_hook(:berkshelf_provision, :machine_action_up, &method(:provision))
26
- action_hook(:berkshelf_provision, :machine_action_reload, &method(:provision))
27
- action_hook(:berkshelf_provision, :machine_action_provision, &method(:provision))
28
-
29
- action_hook(:berkshelf_cleanup, :machine_action_destroy) do |hook|
30
- # @todo this should be appended to the middleware stack instead of hooked in after the
31
- # Virtualbox specific destroy step but there is a bug in Vagrant (1.1.0) which
32
- # causes appended middleware to run multiple times.
33
- hook.after(VagrantPlugins::ProviderVirtualBox::Action::DestroyUnusedNetworkInterfaces, Berkshelf::Vagrant::Action.clean)
34
- end
35
-
36
- config(:berkshelf) do
37
- Berkshelf::Vagrant::Config
38
- end
39
- end
40
- end
41
- end
@@ -1,5 +0,0 @@
1
- module Berkshelf
2
- module Vagrant
3
- VERSION = "3.0.1"
4
- end
5
- end
@@ -1,97 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Berkshelf::Vagrant::Config do
4
- let(:unset_value) { described_class::UNSET_VALUE }
5
- subject { described_class.new.tap {|s| s.finalize! } }
6
-
7
- it "sets a path to a Berksfile in the current working directory for berksfile_path" do
8
- subject.berksfile_path.should eql(File.join(Dir.pwd, "Berksfile"))
9
- end
10
-
11
- context "when the Berksfile exists" do
12
- before do
13
- File.should_receive(:exist?).with(File.join(Dir.pwd, "Berksfile")).and_return(true)
14
- end
15
-
16
- it "it sets the value of enabled to true" do
17
- subject.enabled.should be true
18
- end
19
- end
20
-
21
- context "when the Berksfile doesn't exist" do
22
- before do
23
- File.should_receive(:exist?).with(File.join(Dir.pwd, "Berksfile")).and_return(false)
24
- end
25
-
26
- it "set the value of enabled to false" do
27
- subject.enabled.should be false
28
- end
29
- end
30
-
31
- it "sets the value of only to an empty array" do
32
- subject.only.should be_a(Array)
33
- subject.only.should be_empty
34
- end
35
-
36
- it "sets the value of except to an empty array" do
37
- subject.except.should be_a(Array)
38
- subject.except.should be_empty
39
- end
40
-
41
- it "sets the value of node_name to the value in the Berkshelf::Vagrant::BerksConfig.instance" do
42
- subject.node_name.should eql(Berkshelf::Vagrant::BerksConfig.instance.chef.node_name)
43
- end
44
-
45
- it "sets the value of client_key to the value in Berkshelf::Vagrant::BerksConfig.instance" do
46
- subject.client_key.should eql(Berkshelf::Vagrant::BerksConfig.instance.chef.client_key)
47
- end
48
-
49
- describe "#validate" do
50
- let(:env) { double('env', root_path: Dir.pwd ) }
51
- let(:config) { double('config', berkshelf: subject) }
52
- let(:machine) { double('machine', config: config, env: env) }
53
-
54
- before do
55
- subject.finalize!
56
- end
57
-
58
- context "when the plugin is enabled" do
59
- before(:each) do
60
- subject.stub(enabled: true)
61
- env.stub_chain(:vagrantfile, :config, :vm, :provisioners, :any?)
62
- end
63
-
64
- let(:result) { subject.validate(machine) }
65
-
66
- it "returns a Hash with a 'berkshelf configuration' key" do
67
- result.should be_a(Hash)
68
- result.should have_key("berkshelf configuration")
69
- end
70
-
71
- context "when all validations pass" do
72
- before(:each) do
73
- File.should_receive(:exist?).with(subject.berksfile_path).and_return(true)
74
- end
75
-
76
- it "contains an empty Array for the 'berkshelf configuration' key" do
77
- result["berkshelf configuration"].should be_a(Array)
78
- result["berkshelf configuration"].should be_empty
79
- end
80
- end
81
- end
82
-
83
- context "when the plugin is disabled" do
84
- let(:machine) { double('machine', env: env) }
85
-
86
- before do
87
- subject.stub(enabled: false)
88
- end
89
-
90
- it "does not perform any validations" do
91
- machine.should_not_receive(:config)
92
-
93
- subject.validate(machine)
94
- end
95
- end
96
- end
97
- end
@@ -1,12 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Berkshelf::VagrantWrapperError do
4
- subject { described_class }
5
-
6
- it "proxies messages to the original exception" do
7
- original = double('original_error')
8
- original.should_receive(:a_message)
9
-
10
- subject.new(original).a_message
11
- end
12
- end
@@ -1,31 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Berkshelf::Vagrant do
4
- describe "ClassMethods" do
5
- describe "::shelf_path" do
6
- it "returns a String" do
7
- subject.shelf_path.should be_a(String)
8
- end
9
-
10
- it "is a pathname including the berkshelf_path" do
11
- subject.shelf_path.should include(Berkshelf.berkshelf_path)
12
- end
13
- end
14
-
15
- describe "::mkshelf" do
16
- it "returns a String" do
17
- subject.mkshelf().should be_a(String)
18
- end
19
-
20
- it "is a pathname including the shelf_path" do
21
- subject.mkshelf().should include(subject.shelf_path)
22
- end
23
-
24
- it "is a pathname including machine name" do
25
-
26
- machine_name = 'fantastic_machine'
27
- subject.mkshelf(machine_name).should include(machine_name)
28
- end
29
- end
30
- end
31
- end