vagrant-berkshelf-nochefdk 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +39 -0
- data/.travis.yml +19 -0
- data/CHANGELOG.md +8 -0
- data/CONTRIBUTING.md +51 -0
- data/Gemfile +43 -0
- data/Guardfile +16 -0
- data/LICENSE +13 -0
- data/README.md +89 -0
- data/Rakefile +14 -0
- data/lib/vagrant-berkshelf-nochefdk.rb +17 -0
- data/lib/vagrant-berkshelf/action/base.rb +49 -0
- data/lib/vagrant-berkshelf/action/check.rb +49 -0
- data/lib/vagrant-berkshelf/action/clean.rb +29 -0
- data/lib/vagrant-berkshelf/action/install.rb +35 -0
- data/lib/vagrant-berkshelf/action/load.rb +48 -0
- data/lib/vagrant-berkshelf/action/save.rb +27 -0
- data/lib/vagrant-berkshelf/action/share.rb +33 -0
- data/lib/vagrant-berkshelf/action/upload.rb +99 -0
- data/lib/vagrant-berkshelf/config.rb +107 -0
- data/lib/vagrant-berkshelf/env.rb +14 -0
- data/lib/vagrant-berkshelf/errors.rb +49 -0
- data/lib/vagrant-berkshelf/helpers.rb +150 -0
- data/lib/vagrant-berkshelf/plugin.rb +41 -0
- data/lib/vagrant-berkshelf/version.rb +5 -0
- data/spec/spec_helper.rb +18 -0
- data/spec/unit/vagrant-berkshelf/config_spec.rb +158 -0
- data/vagrant-berkshelf-nochefdk.gemspec +37 -0
- metadata +137 -0
@@ -0,0 +1,41 @@
|
|
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/save'
|
8
|
+
require_relative 'action/share'
|
9
|
+
require_relative 'action/upload'
|
10
|
+
require_relative 'env'
|
11
|
+
|
12
|
+
module VagrantPlugins
|
13
|
+
module Berkshelf
|
14
|
+
class Plugin < Vagrant.plugin("2")
|
15
|
+
# Require a particular version of Vagrant
|
16
|
+
Vagrant.require_version(">= 1.5")
|
17
|
+
|
18
|
+
name "berkshelf"
|
19
|
+
description <<-DESC
|
20
|
+
Automatically synchronize cookbooks in the Berksfile to virtual machines
|
21
|
+
provisioned by Chef using Berkshelf.
|
22
|
+
DESC
|
23
|
+
|
24
|
+
[:machine_action_up, :machine_action_reload, :machine_action_provision].each do |action|
|
25
|
+
action_hook(:berkshelf_provision, action) do |hook|
|
26
|
+
hook.after(Vagrant::Action::Builtin::ConfigValidate, Action::Base.setup)
|
27
|
+
hook.before(Vagrant::Action::Builtin::Provision, Action::Base.provision)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
action_hook(:berkshelf_cleanup, :machine_action_destroy) do |hook|
|
32
|
+
hook.before(Vagrant::Action::Builtin::DestroyConfirm, Action::Base.clean)
|
33
|
+
end
|
34
|
+
|
35
|
+
config(:berkshelf) do
|
36
|
+
require_relative "config"
|
37
|
+
Config
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
require 'spork'
|
4
|
+
|
5
|
+
Spork.prefork do
|
6
|
+
require 'rspec'
|
7
|
+
|
8
|
+
RSpec.configure do |config|
|
9
|
+
config.run_all_when_everything_filtered = true
|
10
|
+
config.filter_run focus: true
|
11
|
+
|
12
|
+
config.order = 'random'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
Spork.each_run do
|
17
|
+
require 'vagrant-berkshelf-nochefdk'
|
18
|
+
end
|
@@ -0,0 +1,158 @@
|
|
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
|
+
end
|
14
|
+
|
15
|
+
describe "#enabled" do
|
16
|
+
it "defaults to MAYBE" do
|
17
|
+
subject.finalize!
|
18
|
+
expect(subject.enabled).to be(VagrantPlugins::Berkshelf::Config::MAYBE)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#only" do
|
23
|
+
it "defaults to an empty array" do
|
24
|
+
subject.finalize!
|
25
|
+
expect(subject.only).to be_a(Array)
|
26
|
+
expect(subject.only).to be_empty
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#except" do
|
31
|
+
it "defaults to an empty array" do
|
32
|
+
subject.finalize!
|
33
|
+
expect(subject.except).to be_a(Array)
|
34
|
+
expect(subject.except).to be_empty
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "#args" do
|
39
|
+
it "defaults to an empty array" do
|
40
|
+
subject.finalize!
|
41
|
+
expect(subject.args).to be_a(Array)
|
42
|
+
expect(subject.args).to be_empty
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#validate" do
|
47
|
+
before do
|
48
|
+
allow(machine).to receive(:env)
|
49
|
+
.and_return(double("env",
|
50
|
+
root_path: File.expand_path("..", __FILE__),
|
51
|
+
))
|
52
|
+
|
53
|
+
subject.berksfile_path = "Berksfile"
|
54
|
+
subject.enabled = true
|
55
|
+
subject.only = []
|
56
|
+
subject.except = []
|
57
|
+
subject.args = []
|
58
|
+
end
|
59
|
+
|
60
|
+
let(:result) do
|
61
|
+
subject.finalize!
|
62
|
+
subject.validate(machine)
|
63
|
+
end
|
64
|
+
|
65
|
+
let(:errors) { result["Berkshelf"] }
|
66
|
+
|
67
|
+
context "when enabled is false" do
|
68
|
+
before { subject.enabled = false }
|
69
|
+
|
70
|
+
it "returns no errors" do
|
71
|
+
expect(errors).to be_empty
|
72
|
+
end
|
73
|
+
|
74
|
+
it "remains disabled even if a Berksfile is present" do
|
75
|
+
allow(File).to receive(:exist?).and_return(true)
|
76
|
+
expect(errors).to be_empty
|
77
|
+
expect(subject.enabled).to be(false)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "remains disabled even if a berksfile_path is given" do
|
81
|
+
subject.berksfile_path = "Custom.Berksfile"
|
82
|
+
expect(errors).to be_empty
|
83
|
+
expect(subject.enabled).to be(false)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context "when no berksfile_path is given" do
|
88
|
+
before { subject.berksfile_path = nil }
|
89
|
+
|
90
|
+
context "when a Berksfile is present" do
|
91
|
+
before { allow(File).to receive(:exist?).and_return(true) }
|
92
|
+
|
93
|
+
it "sets the berksfile_path" do
|
94
|
+
expect(errors).to be_empty
|
95
|
+
expect(subject.berksfile_path).to eq(File.expand_path("../Berksfile", __FILE__))
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
context "when a Berksfile is not present" do
|
100
|
+
before { allow(File).to receive(:exist?).and_return(false) }
|
101
|
+
|
102
|
+
context "when the plugin is enabled" do
|
103
|
+
it "returns an error" do
|
104
|
+
subject.enabled = true
|
105
|
+
expect(errors).to include("berksfile_path must be set")
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
context "when the plugin is in MAYBE state" do
|
110
|
+
it "disables the plugin" do
|
111
|
+
subject.enabled = VagrantPlugins::Berkshelf::Config::MAYBE
|
112
|
+
expect(errors).to be_empty
|
113
|
+
expect(subject.enabled).to be(false)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
context "when a berksfile_path is given" do
|
120
|
+
before { subject.berksfile_path = "Custom.Berksfile" }
|
121
|
+
|
122
|
+
let(:expanded_path) { File.expand_path("../Custom.Berksfile", __FILE__) }
|
123
|
+
|
124
|
+
context "when another Berksfile is present" do
|
125
|
+
before { allow(File).to receive(:exist?).and_return(true) }
|
126
|
+
|
127
|
+
it "does not change the berksfile_path" do
|
128
|
+
expect(errors).to be_empty
|
129
|
+
expect(subject.berksfile_path).to eq(expanded_path)
|
130
|
+
end
|
131
|
+
|
132
|
+
it "expands the path relative to the machine root" do
|
133
|
+
subject.finalize!
|
134
|
+
subject.validate(machine)
|
135
|
+
expect(subject.berksfile_path).to eq(expanded_path)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
context "when the given berksfile_path does not exist" do
|
140
|
+
before { allow(File).to receive(:exist?).and_return(false) }
|
141
|
+
|
142
|
+
it "returns an error" do
|
143
|
+
expect(errors).to include("Berksfile at '#{expanded_path}' does not exist")
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
context "when the berksfile_path is nil and no Berksfile exists" do
|
149
|
+
before { allow(File).to receive(:exist?).and_return(false) }
|
150
|
+
|
151
|
+
it "returns an error if enabled" do
|
152
|
+
subject.berksfile_path = ""
|
153
|
+
subject.finalize!
|
154
|
+
expect(errors).to include("berksfile_path must be set")
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'vagrant-berkshelf/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'vagrant-berkshelf-nochefdk'
|
8
|
+
spec.version = VagrantPlugins::Berkshelf::VERSION
|
9
|
+
spec.authors = [
|
10
|
+
'Jamie Winsor',
|
11
|
+
'Michael Ivey',
|
12
|
+
'Seth Vargo',
|
13
|
+
'Tomas Varaneckas',
|
14
|
+
]
|
15
|
+
spec.email = [
|
16
|
+
'jamie@vialstudios.com',
|
17
|
+
'michael.ivey@riotgames.com',
|
18
|
+
'sethvargo@gmail.com',
|
19
|
+
'tomas.varaneckas@gmail.com',
|
20
|
+
]
|
21
|
+
spec.description = %q{A Vagrant plugin to add Berkshelf integration to the Chef provisioners, without need of installing ChefDK}
|
22
|
+
spec.summary = spec.description
|
23
|
+
spec.homepage = 'https://docs.chef.io/berkshelf.html'
|
24
|
+
spec.license = 'Apache 2.0'
|
25
|
+
|
26
|
+
spec.files = `git ls-files`.split($/)
|
27
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
28
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
29
|
+
spec.require_paths = ['lib']
|
30
|
+
spec.required_ruby_version = '>= 2.2.0'
|
31
|
+
|
32
|
+
spec.add_runtime_dependency 'berkshelf'
|
33
|
+
|
34
|
+
spec.add_development_dependency 'spork', '~> 0.9'
|
35
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
36
|
+
spec.add_development_dependency 'rake'
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-berkshelf-nochefdk
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 6.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jamie Winsor
|
8
|
+
- Michael Ivey
|
9
|
+
- Seth Vargo
|
10
|
+
- Tomas Varaneckas
|
11
|
+
autorequire:
|
12
|
+
bindir: bin
|
13
|
+
cert_chain: []
|
14
|
+
date: 2017-11-09 00:00:00.000000000 Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: berkshelf
|
18
|
+
requirement: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: spork
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - "~>"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0.9'
|
37
|
+
type: :development
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0.9'
|
44
|
+
- !ruby/object:Gem::Dependency
|
45
|
+
name: rspec
|
46
|
+
requirement: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - "~>"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '3.0'
|
51
|
+
type: :development
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - "~>"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '3.0'
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: rake
|
60
|
+
requirement: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
type: :development
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
description: A Vagrant plugin to add Berkshelf integration to the Chef provisioners,
|
73
|
+
without need of installing ChefDK
|
74
|
+
email:
|
75
|
+
- jamie@vialstudios.com
|
76
|
+
- michael.ivey@riotgames.com
|
77
|
+
- sethvargo@gmail.com
|
78
|
+
- tomas.varaneckas@gmail.com
|
79
|
+
executables: []
|
80
|
+
extensions: []
|
81
|
+
extra_rdoc_files: []
|
82
|
+
files:
|
83
|
+
- ".gitignore"
|
84
|
+
- ".travis.yml"
|
85
|
+
- CHANGELOG.md
|
86
|
+
- CONTRIBUTING.md
|
87
|
+
- Gemfile
|
88
|
+
- Guardfile
|
89
|
+
- LICENSE
|
90
|
+
- README.md
|
91
|
+
- Rakefile
|
92
|
+
- lib/vagrant-berkshelf-nochefdk.rb
|
93
|
+
- lib/vagrant-berkshelf/action/base.rb
|
94
|
+
- lib/vagrant-berkshelf/action/check.rb
|
95
|
+
- lib/vagrant-berkshelf/action/clean.rb
|
96
|
+
- lib/vagrant-berkshelf/action/install.rb
|
97
|
+
- lib/vagrant-berkshelf/action/load.rb
|
98
|
+
- lib/vagrant-berkshelf/action/save.rb
|
99
|
+
- lib/vagrant-berkshelf/action/share.rb
|
100
|
+
- lib/vagrant-berkshelf/action/upload.rb
|
101
|
+
- lib/vagrant-berkshelf/config.rb
|
102
|
+
- lib/vagrant-berkshelf/env.rb
|
103
|
+
- lib/vagrant-berkshelf/errors.rb
|
104
|
+
- lib/vagrant-berkshelf/helpers.rb
|
105
|
+
- lib/vagrant-berkshelf/plugin.rb
|
106
|
+
- lib/vagrant-berkshelf/version.rb
|
107
|
+
- spec/spec_helper.rb
|
108
|
+
- spec/unit/vagrant-berkshelf/config_spec.rb
|
109
|
+
- vagrant-berkshelf-nochefdk.gemspec
|
110
|
+
homepage: https://docs.chef.io/berkshelf.html
|
111
|
+
licenses:
|
112
|
+
- Apache 2.0
|
113
|
+
metadata: {}
|
114
|
+
post_install_message:
|
115
|
+
rdoc_options: []
|
116
|
+
require_paths:
|
117
|
+
- lib
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: 2.2.0
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
requirements: []
|
129
|
+
rubyforge_project:
|
130
|
+
rubygems_version: 2.6.13
|
131
|
+
signing_key:
|
132
|
+
specification_version: 4
|
133
|
+
summary: A Vagrant plugin to add Berkshelf integration to the Chef provisioners, without
|
134
|
+
need of installing ChefDK
|
135
|
+
test_files:
|
136
|
+
- spec/spec_helper.rb
|
137
|
+
- spec/unit/vagrant-berkshelf/config_spec.rb
|