vagrant-cookbook-fetcher 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +4 -0
- data/lib/vagrant_cookbook_fetcher.rb +46 -25
- metadata +1 -1
data/ChangeLog
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
2013-04-09 0.0.9 Clinton Wolfe <clintoncwolfe at gmail dot com>
|
2
|
+
* Rewrite combined/ linker to be more flexible
|
3
|
+
* Create two spec directories in combined/ - one symlinked from the perspective of
|
4
|
+
the VM host, and one from the perspective of the VM guest
|
1
5
|
|
2
6
|
2013-04-08 0.0.8 Clinton Wolfe <clintoncwolfe at gmail dot com>
|
3
7
|
* Correct rspec directory name specs => spec
|
@@ -142,18 +142,25 @@ module CookbookFetcher
|
|
142
142
|
# already been performed, creates the combined/ directory in the current directory,
|
143
143
|
# and symlinks in the roles, nodes, etc.
|
144
144
|
def update_links (checkouts,logger)
|
145
|
-
things_to_link =
|
146
|
-
|
145
|
+
things_to_link = {
|
146
|
+
"roles" => {:vagrant_pov_link => true, :target_dir => "roles", :step_in => false },
|
147
|
+
"nodes" => {:vagrant_pov_link => true, :target_dir => "nodes", :step_in => false },
|
148
|
+
"handlers" => {:vagrant_pov_link => true, :target_dir => "handlers", :step_in => false },
|
149
|
+
"data_bags" => {:vagrant_pov_link => true, :target_dir => "data_bags", :step_in => true },
|
150
|
+
"spec_ext" => {:vagrant_pov_link => false, :target_dir => "spec", :step_in => false },
|
151
|
+
"spec_int" => {:vagrant_pov_link => true, :target_dir => "spec", :step_in => false },
|
152
|
+
}
|
153
|
+
logger.info "Updating links to #{things_to_link.keys.sort.join(', ')}"
|
147
154
|
|
148
155
|
if !Dir.exists?("combined") then Dir.mkdir("combined") end
|
149
156
|
Dir.chdir("combined") do
|
150
157
|
|
151
158
|
# Create/clear the subdirs
|
152
|
-
things_to_link.each do |thing|
|
159
|
+
things_to_link.keys.each do |thing|
|
153
160
|
if !Dir.exists?(thing) then Dir.mkdir(thing) end
|
154
|
-
if (thing
|
155
|
-
Dir.foreach(thing) do |
|
156
|
-
Dir.foreach(thing + '/' +
|
161
|
+
if (things_to_link[thing][:step_in]) then
|
162
|
+
Dir.foreach(thing) do |top_dir|
|
163
|
+
Dir.foreach(thing + '/' + top_dir) do |file|
|
157
164
|
if FileTest.symlink?(file) then File.delete(file) end
|
158
165
|
end
|
159
166
|
end
|
@@ -168,29 +175,43 @@ module CookbookFetcher
|
|
168
175
|
# Being careful to go in cookbook order, symlink the files
|
169
176
|
checkouts[:cookbook_list].each do |cookbook_dir|
|
170
177
|
checkout_dir = (cookbook_dir.split('/'))[1]
|
171
|
-
things_to_link.each do |thing|
|
172
|
-
|
178
|
+
things_to_link.each do |thing, opts|
|
179
|
+
checkout_thing_dir = "checkouts/#{checkout_dir}/#{opts[:target_dir]}"
|
173
180
|
combined_dir = "combined/#{thing}"
|
174
|
-
if Dir.exists?(
|
175
|
-
if
|
176
|
-
Dir.foreach(
|
177
|
-
next unless File.directory?(
|
178
|
-
next if
|
179
|
-
|
180
|
-
if !Dir.exists?(
|
181
|
-
Dir.entries(
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
181
|
+
if Dir.exists?(checkout_thing_dir) then
|
182
|
+
if opts[:step_in] then
|
183
|
+
Dir.foreach(checkout_thing_dir) do |checkout_top_dir|
|
184
|
+
next unless File.directory?(checkout_thing_dir + '/' + checkout_top_dir)
|
185
|
+
next if checkout_top_dir.start_with?('.')
|
186
|
+
combined_top_dir = combined_dir + '/' + checkout_top_dir
|
187
|
+
if !Dir.exists?(combined_top_dir) then Dir.mkdir(combined_top_dir) end
|
188
|
+
Dir.entries(checkout_thing_dir + '/' + checkout_top_dir).grep(/\.(rb|json)$/).each do |file|
|
189
|
+
if opts[:vagrant_pov_link] then
|
190
|
+
# Under vagrant, we see this directory as /vagrant/checkouts/<checkout>/data_bags/<dbag>/<dbag_entry.json>
|
191
|
+
# Use -f so later checkouts can override earlier ones
|
192
|
+
cmd = "ln -sf /vagrant/#{checkout_thing_dir + '/' + checkout_top_dir}/#{file} combined/#{thing}/#{checkout_top_dir}/#{file}"
|
193
|
+
unless system cmd then raise "Could not '#{cmd}'" end
|
194
|
+
else
|
195
|
+
# Link as visible to the host machine
|
196
|
+
# Use -f so later checkouts can override earlier ones
|
197
|
+
cmd = "ln -sf ../../#{checkout_thing_dir + '/' + checkout_top_dir}/#{file} combined/#{thing}/#{checkout_top_dir}/#{file}"
|
198
|
+
unless system cmd then raise "Could not '#{cmd}'" end
|
199
|
+
end
|
186
200
|
end
|
187
201
|
end
|
188
202
|
else
|
189
|
-
Dir.entries(
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
203
|
+
Dir.entries(checkout_thing_dir).grep(/\.(rb|json)$/).each do |file|
|
204
|
+
if opts[:vagrant_pov_link] then
|
205
|
+
# Under vagrant, we see this directory as /vagrant/checkouts/foo/role/bar.rb
|
206
|
+
# Use -f so later checkouts can override earlier ones
|
207
|
+
cmd = "ln -sf /vagrant/#{checkout_thing_dir}/#{file} combined/#{thing}/#{file}"
|
208
|
+
unless system cmd then raise "Could not '#{cmd}'" end
|
209
|
+
else
|
210
|
+
# Link as visible to the host machine
|
211
|
+
# Use -f so later checkouts can override earlier ones
|
212
|
+
cmd = "ln -sf ../../#{checkout_thing_dir}/#{file} combined/#{thing}/#{file}"
|
213
|
+
unless system cmd then raise "Could not '#{cmd}'" end
|
214
|
+
end
|
194
215
|
end
|
195
216
|
end
|
196
217
|
end
|