vagrant-chef-zero 0.5.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +2 -2
- data/lib/vagrant-chef-zero/action/upload.rb +34 -2
- data/lib/vagrant-chef-zero/server_helpers.rb +1 -1
- data/lib/vagrant-chef-zero/version.rb +1 -1
- data/spec/lib/action/upload_spec.rb +112 -0
- data/vagrant-chef-zero.gemspec +0 -10
- metadata +6 -101
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
2
|
|
3
|
-
gem 'json', '~> 1.7.7'
|
3
|
+
#gem 'json', '~> 1.7.7'
|
4
4
|
|
5
5
|
gemspec
|
6
6
|
|
@@ -8,7 +8,7 @@ group :development do
|
|
8
8
|
# We depend on Vagrant for development, but we don't add it as a
|
9
9
|
# gem dependency because we expect to be installed within the
|
10
10
|
# Vagrant environment itself using `vagrant plugin`.
|
11
|
-
gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git"
|
11
|
+
gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :tag => "v1.3.5"
|
12
12
|
gem "debugger"
|
13
13
|
gem "vagrant-berkshelf", ">= 1.3.3"
|
14
14
|
end
|
@@ -34,7 +34,7 @@ module VagrantPlugins
|
|
34
34
|
|
35
35
|
def upload_cookbooks(env)
|
36
36
|
path = env[:machine].config.chef_zero.cookbooks
|
37
|
-
cookbooks =
|
37
|
+
cookbooks = select_cookbooks(path)
|
38
38
|
env[:chef_zero].ui.info("Loading cookbooks from #{path}") unless cookbooks.empty?
|
39
39
|
cookbooks.each do |cookbook|
|
40
40
|
name = File.basename(cookbook)
|
@@ -133,6 +133,38 @@ module VagrantPlugins
|
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
136
|
+
def select_cookbooks(path)
|
137
|
+
cookbook_paths = []
|
138
|
+
if path.nil?
|
139
|
+
cookbook_paths = []
|
140
|
+
elsif path.respond_to?('empty?') && path.empty?
|
141
|
+
cookbook_paths = []
|
142
|
+
elsif path.is_a?(Array)
|
143
|
+
cookbook_paths = path
|
144
|
+
elsif path.is_a?(String) && is_valid_cookbook?(path)
|
145
|
+
cookbook_paths = [path]
|
146
|
+
elsif path.is_a?(String) && File.directory?(path) && is_valid_cookbook_directory?(path)
|
147
|
+
cookbook_paths = select_valid_cookbooks(path)
|
148
|
+
else
|
149
|
+
@env[:chef_zero].ui.warn("Warning: Unable to normalize #{path}, skipping")
|
150
|
+
cookbook_paths = []
|
151
|
+
end
|
152
|
+
cookbook_paths
|
153
|
+
end
|
154
|
+
|
155
|
+
def is_valid_cookbook_directory?(path)
|
156
|
+
return ! select_valid_cookbooks(path).empty?
|
157
|
+
end
|
158
|
+
|
159
|
+
def select_valid_cookbooks(path)
|
160
|
+
directories = Dir.glob("#{path}/*")
|
161
|
+
directories.select{ |s| is_valid_cookbook?(s) }
|
162
|
+
end
|
163
|
+
|
164
|
+
def is_valid_cookbook?(path)
|
165
|
+
File.exists?("#{path}/metadata.rb") || File.exists?("#{path}/metadata.json")
|
166
|
+
end
|
167
|
+
|
136
168
|
def select_items(path)
|
137
169
|
if path.nil?
|
138
170
|
path = []
|
@@ -141,7 +173,7 @@ module VagrantPlugins
|
|
141
173
|
elsif path.is_a?(Array)
|
142
174
|
path
|
143
175
|
elsif path.is_a?(String) && File.directory?(path)
|
144
|
-
path = Dir.glob("#{path}/*.json")+Dir.glob("#{path}/*.rb")
|
176
|
+
path = Dir.glob("#{path}/*.json") + Dir.glob("#{path}/*.rb")
|
145
177
|
elsif path.is_a?(String) && File.exists?(path)
|
146
178
|
path = [path]
|
147
179
|
else
|
@@ -45,7 +45,7 @@ module VagrantPlugins
|
|
45
45
|
# Assuming a path from Gem.path
|
46
46
|
#potential_binary = ::File.join(path, "bin", "chef-zero")
|
47
47
|
gems_path = ::File.join(path, "gems")
|
48
|
-
chef_zero_gem = Dir["#{gems_path}/*"].select { |gp| gp.include?('chef-zero')}.first
|
48
|
+
chef_zero_gem = Dir["#{gems_path}/*"].select { |gp| gp.include?('/chef-zero-')}.first
|
49
49
|
if chef_zero_gem
|
50
50
|
return ::File.join(chef_zero_gem, "bin", "chef-zero")
|
51
51
|
else
|
@@ -0,0 +1,112 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
describe "VagrantPlugins::ChefZero::Action::Upload" do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
|
7
|
+
# For now a silly helper to create fake nested env objects
|
8
|
+
ui = double("bar")
|
9
|
+
ui.stub(:warn).and_return(nil)
|
10
|
+
$fake_chef_zero = double("foo")
|
11
|
+
$fake_chef_zero.stub(:ui).and_return(ui)
|
12
|
+
|
13
|
+
class DummyUpload < VagrantPlugins::ChefZero::Action::Upload
|
14
|
+
|
15
|
+
def initialize(app, env)
|
16
|
+
@env = {:chef_zero => $fake_chef_zero}
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "Normalizing Cookbook Path" do
|
23
|
+
|
24
|
+
describe "with a nil path" do
|
25
|
+
|
26
|
+
it "should return an empty array" do
|
27
|
+
path = nil
|
28
|
+
d = DummyUpload.new("foo", "bar")
|
29
|
+
d.select_cookbooks(path).should eql []
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "with an empty array" do
|
35
|
+
|
36
|
+
it "should return an empty array" do
|
37
|
+
path = []
|
38
|
+
d = DummyUpload.new("foo", "bar")
|
39
|
+
d.select_cookbooks(path).should eql []
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "with a non-empty array" do
|
45
|
+
|
46
|
+
it "should return the given array" do
|
47
|
+
path = ["foo"]
|
48
|
+
d = DummyUpload.new("foo", "bar")
|
49
|
+
d.select_cookbooks(path).should eql path
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "with a string that is a path to valid cookbook with metadata.rb" do
|
55
|
+
|
56
|
+
it "should return the given path in an array" do
|
57
|
+
path = "foo"
|
58
|
+
File.stub(:exists?).with("#{path}/metadata.rb").and_return(true)
|
59
|
+
File.stub(:exists?).with("#{path}/metadata.json").and_return(false)
|
60
|
+
|
61
|
+
d = DummyUpload.new("foo", "bar")
|
62
|
+
d.select_cookbooks(path).should eql [path]
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "with a string that is a path to valid cookbook with metadata.json" do
|
68
|
+
|
69
|
+
it "should return the given path in an array" do
|
70
|
+
path = "foo"
|
71
|
+
File.stub(:exists?).with("#{path}/metadata.rb").and_return(false)
|
72
|
+
File.stub(:exists?).with("#{path}/metadata.json").and_return(true)
|
73
|
+
|
74
|
+
d = DummyUpload.new("foo", "bar")
|
75
|
+
d.select_cookbooks(path).should eql [path]
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
describe "with a string that is a path to valid cookbooks directory" do
|
81
|
+
|
82
|
+
it "should return the given path in an array" do
|
83
|
+
path = "./foo/cookbooks"
|
84
|
+
File.stub(:directory?).with(path).and_return(true)
|
85
|
+
Dir.stub(:glob).with("#{path}/*").and_return(["#{path}/bar", "#{path}/baz"])
|
86
|
+
|
87
|
+
File.stub(:exists?).and_return(false)
|
88
|
+
File.stub(:exists?).with("#{path}/bar/metadata.rb").and_return(true)
|
89
|
+
File.stub(:exists?).with("#{path}/baz/metadata.json").and_return(true)
|
90
|
+
|
91
|
+
d = DummyUpload.new("foo", "bar")
|
92
|
+
d.select_cookbooks(path).should eql ["#{path}/bar", "#{path}/baz"]
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
describe "with a string that not a valid path" do
|
98
|
+
|
99
|
+
it "should send a UI warning and return an empty array" do
|
100
|
+
path = "foo"
|
101
|
+
File.stub(:exists?).and_return(false)
|
102
|
+
File.stub(:directory?).and_return(false)
|
103
|
+
|
104
|
+
d = DummyUpload.new("foo", "bar")
|
105
|
+
d.select_cookbooks(path).should eql []
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
data/vagrant-chef-zero.gemspec
CHANGED
@@ -15,20 +15,10 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.rubyforge_project = "vagrant-chef-zero"
|
16
16
|
s.license = "MIT"
|
17
17
|
|
18
|
-
s.add_dependency "json", ">= 1.4.4", "<= 1.7.7"
|
19
18
|
s.add_dependency "chef-zero", "~> 1.3"
|
20
19
|
s.add_dependency "ridley", ">= 1.0.0"
|
21
20
|
s.add_dependency "chef", "~> 11.0"
|
22
21
|
|
23
|
-
# Stolen from Vagrant Berkshelf because Ruby hates dependency resolution
|
24
|
-
# activesupport 3.2.13 contains an incompatible hard lock on i18n (= 0.6.1)
|
25
|
-
s.add_dependency 'activesupport', '>= 3.2.0', '< 3.2.13'
|
26
|
-
|
27
|
-
# Explicit locks to ensure we activate the proper gem versions for Vagrant
|
28
|
-
s.add_dependency 'i18n', '~> 0.6.0'
|
29
|
-
s.add_dependency "net-ssh", ">= 2.6.6", "< 2.8.0"
|
30
|
-
s.add_dependency 'net-scp', '~> 1.1.0'
|
31
|
-
|
32
22
|
s.add_development_dependency "mocha"
|
33
23
|
s.add_development_dependency "simplecov"
|
34
24
|
s.add_development_dependency "rake"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-chef-zero
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,30 +9,8 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-01-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: json
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: 1.4.4
|
22
|
-
- - <=
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version: 1.7.7
|
25
|
-
type: :runtime
|
26
|
-
prerelease: false
|
27
|
-
version_requirements: !ruby/object:Gem::Requirement
|
28
|
-
none: false
|
29
|
-
requirements:
|
30
|
-
- - ! '>='
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 1.4.4
|
33
|
-
- - <=
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version: 1.7.7
|
36
14
|
- !ruby/object:Gem::Dependency
|
37
15
|
name: chef-zero
|
38
16
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,82 +59,6 @@ dependencies:
|
|
81
59
|
- - ~>
|
82
60
|
- !ruby/object:Gem::Version
|
83
61
|
version: '11.0'
|
84
|
-
- !ruby/object:Gem::Dependency
|
85
|
-
name: activesupport
|
86
|
-
requirement: !ruby/object:Gem::Requirement
|
87
|
-
none: false
|
88
|
-
requirements:
|
89
|
-
- - ! '>='
|
90
|
-
- !ruby/object:Gem::Version
|
91
|
-
version: 3.2.0
|
92
|
-
- - <
|
93
|
-
- !ruby/object:Gem::Version
|
94
|
-
version: 3.2.13
|
95
|
-
type: :runtime
|
96
|
-
prerelease: false
|
97
|
-
version_requirements: !ruby/object:Gem::Requirement
|
98
|
-
none: false
|
99
|
-
requirements:
|
100
|
-
- - ! '>='
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
version: 3.2.0
|
103
|
-
- - <
|
104
|
-
- !ruby/object:Gem::Version
|
105
|
-
version: 3.2.13
|
106
|
-
- !ruby/object:Gem::Dependency
|
107
|
-
name: i18n
|
108
|
-
requirement: !ruby/object:Gem::Requirement
|
109
|
-
none: false
|
110
|
-
requirements:
|
111
|
-
- - ~>
|
112
|
-
- !ruby/object:Gem::Version
|
113
|
-
version: 0.6.0
|
114
|
-
type: :runtime
|
115
|
-
prerelease: false
|
116
|
-
version_requirements: !ruby/object:Gem::Requirement
|
117
|
-
none: false
|
118
|
-
requirements:
|
119
|
-
- - ~>
|
120
|
-
- !ruby/object:Gem::Version
|
121
|
-
version: 0.6.0
|
122
|
-
- !ruby/object:Gem::Dependency
|
123
|
-
name: net-ssh
|
124
|
-
requirement: !ruby/object:Gem::Requirement
|
125
|
-
none: false
|
126
|
-
requirements:
|
127
|
-
- - ! '>='
|
128
|
-
- !ruby/object:Gem::Version
|
129
|
-
version: 2.6.6
|
130
|
-
- - <
|
131
|
-
- !ruby/object:Gem::Version
|
132
|
-
version: 2.8.0
|
133
|
-
type: :runtime
|
134
|
-
prerelease: false
|
135
|
-
version_requirements: !ruby/object:Gem::Requirement
|
136
|
-
none: false
|
137
|
-
requirements:
|
138
|
-
- - ! '>='
|
139
|
-
- !ruby/object:Gem::Version
|
140
|
-
version: 2.6.6
|
141
|
-
- - <
|
142
|
-
- !ruby/object:Gem::Version
|
143
|
-
version: 2.8.0
|
144
|
-
- !ruby/object:Gem::Dependency
|
145
|
-
name: net-scp
|
146
|
-
requirement: !ruby/object:Gem::Requirement
|
147
|
-
none: false
|
148
|
-
requirements:
|
149
|
-
- - ~>
|
150
|
-
- !ruby/object:Gem::Version
|
151
|
-
version: 1.1.0
|
152
|
-
type: :runtime
|
153
|
-
prerelease: false
|
154
|
-
version_requirements: !ruby/object:Gem::Requirement
|
155
|
-
none: false
|
156
|
-
requirements:
|
157
|
-
- - ~>
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: 1.1.0
|
160
62
|
- !ruby/object:Gem::Dependency
|
161
63
|
name: mocha
|
162
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -246,6 +148,7 @@ files:
|
|
246
148
|
- pkg/vagrant-chef-zero-0.5.2.gem
|
247
149
|
- Rakefile
|
248
150
|
- README.md
|
151
|
+
- spec/lib/action/upload_spec.rb
|
249
152
|
- spec/lib/config_spec.rb
|
250
153
|
- spec/lib/server_helpers_spec.rb
|
251
154
|
- spec/spec_helper.rb
|
@@ -272,6 +175,8 @@ files:
|
|
272
175
|
- Vagrantfile
|
273
176
|
- .gitignore
|
274
177
|
- .travis.yml
|
178
|
+
- coverage/.last_run.json
|
179
|
+
- coverage/.resultset.json
|
275
180
|
homepage: http://github.com/andrewgross/vagrant-chef-zero
|
276
181
|
licenses:
|
277
182
|
- MIT
|
@@ -287,7 +192,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
287
192
|
version: '0'
|
288
193
|
segments:
|
289
194
|
- 0
|
290
|
-
hash:
|
195
|
+
hash: 4477384969117340887
|
291
196
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
292
197
|
none: false
|
293
198
|
requirements:
|