vagrant-berkshelf 3.0.1 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1,40 @@
1
+ require 'vagrant/action'
2
+
3
+ require_relative 'action/check'
4
+ require_relative 'action/clean'
5
+ require_relative 'action/install'
6
+ require_relative 'action/load'
7
+ require_relative 'action/share'
8
+ require_relative 'action/upload'
9
+ require_relative 'env'
10
+
11
+ module VagrantPlugins
12
+ module Berkshelf
13
+ class Plugin < Vagrant.plugin("2")
14
+ # Require a particular version of Vagrant
15
+ Vagrant.require_version("~> 1.5")
16
+
17
+ name "berkshelf"
18
+ description <<-DESC
19
+ Automatically synchronize cookbooks in the Berksfile to virtual machines
20
+ provisioned by Chef using Berkshelf.
21
+ DESC
22
+
23
+ [:machine_action_up, :machine_action_reload, :machine_action_provision].each do |action|
24
+ action_hook(:berkshelf_provision, action) do |hook|
25
+ hook.before(Vagrant::Action::Builtin::ConfigValidate, Action::Base.setup)
26
+ hook.before(Vagrant::Action::Builtin::Provision, Action::Base.provision)
27
+ end
28
+ end
29
+
30
+ action_hook(:berkshelf_cleanup, :machine_action_destroy) do |hook|
31
+ hook.before(Vagrant::Action::Builtin::DestroyConfirm, Action::Base.clean)
32
+ end
33
+
34
+ config(:berkshelf) do
35
+ require_relative "config"
36
+ Config
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,5 @@
1
+ module VagrantPlugins
2
+ module Berkshelf
3
+ VERSION = "4.0.0"
4
+ end
5
+ end
data/spec/spec_helper.rb CHANGED
@@ -3,9 +3,6 @@ require 'bundler/setup'
3
3
  require 'spork'
4
4
 
5
5
  Spork.prefork do
6
- APP_ROOT = File.expand_path('../../', __FILE__)
7
- ENV["BERKSHELF_PATH"] = File.join(APP_ROOT, 'spec', 'tmp', 'berkshelf')
8
-
9
6
  require 'rspec'
10
7
 
11
8
  RSpec.configure do |config|
@@ -18,5 +15,5 @@ Spork.prefork do
18
15
  end
19
16
 
20
17
  Spork.each_run do
21
- require 'berkshelf/vagrant'
18
+ require 'vagrant-berkshelf'
22
19
  end
@@ -0,0 +1,119 @@
1
+ require "spec_helper"
2
+
3
+ describe VagrantPlugins::Berkshelf::Config do
4
+ subject { described_class.new }
5
+
6
+ let(:machine) { double("machine") }
7
+
8
+ describe "#berksfile_path" do
9
+ it "defaults to nil" do
10
+ subject.finalize!
11
+ expect(subject.berksfile_path).to be(nil)
12
+ end
13
+
14
+ it "sets the value if it exists" do
15
+ allow(File).to receive(:exist?)
16
+ .with("Berksfile")
17
+ .and_return(true)
18
+ subject.finalize!
19
+ expect(subject.berksfile_path).to eq("Berksfile")
20
+ end
21
+ end
22
+
23
+ describe "#enabled" do
24
+ it "is true when there is a Berksfile present" do
25
+ allow(File).to receive(:exist?)
26
+ .with("Berksfile")
27
+ .and_return(true)
28
+ subject.finalize!
29
+ expect(subject.enabled).to be(true)
30
+ end
31
+
32
+ it "is false when there is a Berksfile present but it is disabled" do
33
+ allow(File).to receive(:exist?)
34
+ .with("Berksfile")
35
+ .and_return(true)
36
+ subject.enabled = false
37
+ subject.finalize!
38
+ expect(subject.enabled).to be(false)
39
+ end
40
+
41
+ it "is true when a berksfile_path is given" do
42
+ subject.berksfile_path = "Berksfile"
43
+ subject.finalize!
44
+ expect(subject.enabled).to be(true)
45
+ end
46
+
47
+ it "is false when the berksfile_path is given but it is disabled" do
48
+ subject.berksfile_path = "Berksfile"
49
+ subject.enabled = false
50
+ subject.finalize!
51
+ expect(subject.enabled).to be(false)
52
+ end
53
+
54
+ it "defaults to false" do
55
+ allow(File).to receive(:exist?)
56
+ .with("Berksfile")
57
+ .and_return(false)
58
+ subject.finalize!
59
+ expect(subject.enabled).to be(false)
60
+ end
61
+ end
62
+
63
+ describe "#only" do
64
+ it "defaults to an empty array" do
65
+ subject.finalize!
66
+ expect(subject.only).to be_a(Array)
67
+ expect(subject.only).to be_empty
68
+ end
69
+ end
70
+
71
+ describe "#except" do
72
+ it "defaults to an empty array" do
73
+ subject.finalize!
74
+ expect(subject.except).to be_a(Array)
75
+ expect(subject.except).to be_empty
76
+ end
77
+ end
78
+
79
+ describe "#args" do
80
+ it "defaults to an empty array" do
81
+ subject.finalize!
82
+ expect(subject.args).to be_a(Array)
83
+ expect(subject.args).to be_empty
84
+ end
85
+ end
86
+
87
+ describe "#validate" do
88
+ before do
89
+ allow(machine).to receive(:env)
90
+ .and_return(double("env",
91
+ root_path: "",
92
+ ))
93
+
94
+ subject.berksfile_path = "Berksfile"
95
+ subject.enabled = true
96
+ subject.only = []
97
+ subject.except = []
98
+ subject.args = []
99
+ end
100
+
101
+ let(:result) { subject.validate(machine) }
102
+ let(:errors) { result["Berkshelf"] }
103
+
104
+ context "when the berksfile_path is nil" do
105
+ it "returns an error if enabled" do
106
+ subject.berksfile_path = ""
107
+ subject.finalize!
108
+ expect(errors).to include("berksfile_path must be set")
109
+ end
110
+
111
+ it "does not returns an error if disabled" do
112
+ subject.berksfile_path = ""
113
+ subject.enabled = false
114
+ subject.finalize!
115
+ expect(errors).to eq([])
116
+ end
117
+ end
118
+ end
119
+ end
@@ -1,30 +1,42 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'berkshelf/vagrant/version'
4
+ require 'vagrant-berkshelf/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = 'vagrant-berkshelf'
8
- spec.version = Berkshelf::Vagrant::VERSION
9
- spec.authors = [ 'Jamie Winsor', 'Michael Ivey' ]
10
- spec.email = [ 'jamie@vialstudios.com', 'michael.ivey@riotgames.com' ]
11
- spec.description = %q{A Vagrant plugin to add Berkshelf integration to the Chef provisioners}
12
- spec.summary = spec.description
13
- spec.homepage = 'http://berkshelf.com'
14
- spec.license = 'Apache 2.0'
7
+ spec.name = 'vagrant-berkshelf'
8
+ spec.version = VagrantPlugins::Berkshelf::VERSION
9
+ spec.authors = [
10
+ 'Jamie Winsor',
11
+ 'Michael Ivey',
12
+ 'Seth Vargo',
13
+ ]
14
+ spec.email = [
15
+ 'jamie@vialstudios.com',
16
+ 'michael.ivey@riotgames.com',
17
+ 'sethvargo@gmail.com',
18
+ ]
19
+ spec.description = %q{A Vagrant plugin to add Berkshelf integration to the Chef provisioners}
20
+ spec.summary = spec.description
21
+ spec.homepage = 'https://berkshelf.com'
22
+ spec.license = 'Apache 2.0'
15
23
 
16
24
  spec.files = `git ls-files`.split($/)
17
25
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
26
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
27
  spec.require_paths = ['lib']
20
- spec.required_ruby_version = '>= 1.9.1'
28
+ spec.required_ruby_version = '>= 1.9.3'
21
29
 
22
- spec.post_install_message = "In order to use the Vagrant-Berkshelf plugin, you must have ChefDK installed.\n" +
23
- "To download the latest ChefDK visit http://getchef.com/downloads/chef-dk."
30
+ spec.post_install_message = <<-EOH
31
+ The Vagrant Berkshelf plugin requires Berkshelf from the Chef Development Kit.
32
+ You can download the latest version of the Chef Development Kit from:
24
33
 
25
- spec.add_dependency "buff-shell_out"
34
+ https://downloads.getchef.com/chef-dk
35
+
36
+ Installing Berkshelf via other methods is not officially supported.
37
+ EOH
26
38
 
27
39
  spec.add_development_dependency 'spork', '~> 0.9'
28
40
  spec.add_development_dependency 'rspec', '~> 2.13'
29
- spec.add_development_dependency 'thor', '~> 0.18'
41
+ spec.add_development_dependency 'rake'
30
42
  end
metadata CHANGED
@@ -1,30 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-berkshelf
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamie Winsor
8
8
  - Michael Ivey
9
+ - Seth Vargo
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2014-07-30 00:00:00.000000000 Z
13
+ date: 2014-11-13 00:00:00.000000000 Z
13
14
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: buff-shell_out
16
- requirement: !ruby/object:Gem::Requirement
17
- requirements:
18
- - - ">="
19
- - !ruby/object:Gem::Version
20
- version: '0'
21
- type: :runtime
22
- prerelease: false
23
- version_requirements: !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- version: '0'
28
15
  - !ruby/object:Gem::Dependency
29
16
  name: spork
30
17
  requirement: !ruby/object:Gem::Requirement
@@ -54,23 +41,24 @@ dependencies:
54
41
  - !ruby/object:Gem::Version
55
42
  version: '2.13'
56
43
  - !ruby/object:Gem::Dependency
57
- name: thor
44
+ name: rake
58
45
  requirement: !ruby/object:Gem::Requirement
59
46
  requirements:
60
- - - "~>"
47
+ - - ">="
61
48
  - !ruby/object:Gem::Version
62
- version: '0.18'
49
+ version: '0'
63
50
  type: :development
64
51
  prerelease: false
65
52
  version_requirements: !ruby/object:Gem::Requirement
66
53
  requirements:
67
- - - "~>"
54
+ - - ">="
68
55
  - !ruby/object:Gem::Version
69
- version: '0.18'
56
+ version: '0'
70
57
  description: A Vagrant plugin to add Berkshelf integration to the Chef provisioners
71
58
  email:
72
59
  - jamie@vialstudios.com
73
60
  - michael.ivey@riotgames.com
61
+ - sethvargo@gmail.com
74
62
  executables: []
75
63
  extensions: []
76
64
  extra_rdoc_files: []
@@ -81,40 +69,37 @@ files:
81
69
  - CONTRIBUTING.md
82
70
  - Gemfile
83
71
  - Guardfile
84
- - LICENSE.txt
72
+ - LICENSE
85
73
  - README.md
86
- - Thorfile
87
- - integration/Berksfile
88
- - integration/Gemfile
89
- - integration/Vagrantfile
90
- - lib/berkshelf/vagrant.rb
91
- - lib/berkshelf/vagrant/action.rb
92
- - lib/berkshelf/vagrant/action/clean.rb
93
- - lib/berkshelf/vagrant/action/configure_chef.rb
94
- - lib/berkshelf/vagrant/action/install.rb
95
- - lib/berkshelf/vagrant/action/load_shelf.rb
96
- - lib/berkshelf/vagrant/action/upload.rb
97
- - lib/berkshelf/vagrant/berks_config.rb
98
- - lib/berkshelf/vagrant/chef_config.rb
99
- - lib/berkshelf/vagrant/config.rb
100
- - lib/berkshelf/vagrant/env.rb
101
- - lib/berkshelf/vagrant/env_helpers.rb
102
- - lib/berkshelf/vagrant/errors.rb
103
- - lib/berkshelf/vagrant/plugin.rb
104
- - lib/berkshelf/vagrant/version.rb
74
+ - Rakefile
105
75
  - lib/vagrant-berkshelf.rb
76
+ - lib/vagrant-berkshelf/action/base.rb
77
+ - lib/vagrant-berkshelf/action/check.rb
78
+ - lib/vagrant-berkshelf/action/clean.rb
79
+ - lib/vagrant-berkshelf/action/install.rb
80
+ - lib/vagrant-berkshelf/action/load.rb
81
+ - lib/vagrant-berkshelf/action/share.rb
82
+ - lib/vagrant-berkshelf/action/upload.rb
83
+ - lib/vagrant-berkshelf/config.rb
84
+ - lib/vagrant-berkshelf/env.rb
85
+ - lib/vagrant-berkshelf/errors.rb
86
+ - lib/vagrant-berkshelf/helpers.rb
87
+ - lib/vagrant-berkshelf/plugin.rb
88
+ - lib/vagrant-berkshelf/version.rb
106
89
  - spec/spec_helper.rb
107
- - spec/unit/berkshelf/vagrant/config_spec.rb
108
- - spec/unit/berkshelf/vagrant/errors_spec.rb
109
- - spec/unit/berkshelf/vagrant_spec.rb
90
+ - spec/unit/vagrant-berkshelf/config_spec.rb
110
91
  - vagrant-berkshelf.gemspec
111
- homepage: http://berkshelf.com
92
+ homepage: https://berkshelf.com
112
93
  licenses:
113
94
  - Apache 2.0
114
95
  metadata: {}
115
- post_install_message: |-
116
- In order to use the Vagrant-Berkshelf plugin, you must have ChefDK installed.
117
- To download the latest ChefDK visit http://getchef.com/downloads/chef-dk.
96
+ post_install_message: |
97
+ The Vagrant Berkshelf plugin requires Berkshelf from the Chef Development Kit.
98
+ You can download the latest version of the Chef Development Kit from:
99
+
100
+ https://downloads.getchef.com/chef-dk
101
+
102
+ Installing Berkshelf via other methods is not officially supported.
118
103
  rdoc_options: []
119
104
  require_paths:
120
105
  - lib
@@ -122,7 +107,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
122
107
  requirements:
123
108
  - - ">="
124
109
  - !ruby/object:Gem::Version
125
- version: 1.9.1
110
+ version: 1.9.3
126
111
  required_rubygems_version: !ruby/object:Gem::Requirement
127
112
  requirements:
128
113
  - - ">="
@@ -136,7 +121,5 @@ specification_version: 4
136
121
  summary: A Vagrant plugin to add Berkshelf integration to the Chef provisioners
137
122
  test_files:
138
123
  - spec/spec_helper.rb
139
- - spec/unit/berkshelf/vagrant/config_spec.rb
140
- - spec/unit/berkshelf/vagrant/errors_spec.rb
141
- - spec/unit/berkshelf/vagrant_spec.rb
124
+ - spec/unit/vagrant-berkshelf/config_spec.rb
142
125
  has_rdoc:
data/Thorfile DELETED
@@ -1,59 +0,0 @@
1
- # encoding: utf-8
2
- $:.push File.expand_path("../lib", __FILE__)
3
-
4
- require 'bundler'
5
- require 'bundler/setup'
6
- require 'thor/rake_compat'
7
- require 'berkshelf/vagrant'
8
-
9
- GEM_PKG = "vagrant-berkshelf-#{Berkshelf::Vagrant::VERSION}.gem".freeze
10
-
11
- class Gem < Thor
12
- include Thor::RakeCompat
13
- Bundler::GemHelper.install_tasks
14
-
15
- desc "build", "Build #{GEM_PKG} into the pkg directory"
16
- def build
17
- Rake::Task["build"].execute
18
- end
19
-
20
- desc "release", "Create tag v#{Berkshelf::Vagrant::VERSION} and build and push #{GEM_PKG} to Rubygems"
21
- def release
22
- Rake::Task["release"].execute
23
- end
24
-
25
- desc "install", "Build and install #{GEM_PKG} into system gems"
26
- def install
27
- Rake::Task["install"].execute
28
- end
29
- end
30
-
31
- class Spec < Thor
32
- include Thor::Actions
33
- default_task :unit
34
-
35
- desc "plug", "Install #{GEM_PKG} into vagrant"
36
- def plug
37
- build
38
- run "vagrant plugin install pkg/#{GEM_PKG}"
39
- end
40
-
41
- desc "ci", "Run all possible tests on Travis-CI"
42
- def ci
43
- ENV['CI'] = 'true' # Travis-CI also sets this, but set it here for local testing
44
- invoke(:unit)
45
- end
46
-
47
- desc "unit", "Run unit tests"
48
- def unit
49
- unless run_unit
50
- exit 1
51
- end
52
- end
53
-
54
- no_tasks do
55
- def run_unit(*flags)
56
- run "rspec --color --format=documentation #{flags.join(' ')} spec"
57
- end
58
- end
59
- end