rake-chef-syntax 0.0.1 → 0.0.2
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.
- data/lib/rake-chef-syntax.rb +26 -4
- data/lib/rake-chef-syntax/version.rb +1 -1
- metadata +1 -1
data/lib/rake-chef-syntax.rb
CHANGED
@@ -4,11 +4,33 @@ namespace :chef do
|
|
4
4
|
desc "Run knife cookbook test to validate syntax of cookbooks"
|
5
5
|
task :syntax_check do
|
6
6
|
puts "Running knife cookbook test ... "
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
with_knife_rb do |knife_rb|
|
8
|
+
if File.exists?('cookbooks')
|
9
|
+
sh "knife cookbook test -c #{knife_rb} -a -o cookbooks/"
|
10
|
+
else
|
11
|
+
sh "knife cookbook test -c #{knife_rb} -a -o ."
|
12
|
+
end
|
11
13
|
end
|
12
14
|
puts "knife cookbook test FINISHED."
|
13
15
|
end
|
16
|
+
|
17
|
+
def with_knife_rb
|
18
|
+
knife_rb = "tests/knife.rb"
|
19
|
+
cachedir = "tests/knife_test_checksums"
|
20
|
+
|
21
|
+
begin
|
22
|
+
rm_rf cachedir
|
23
|
+
mkdir_p cachedir
|
24
|
+
open(knife_rb, 'w') do |f|
|
25
|
+
f.write <<-EOS
|
26
|
+
cache_type 'BasicFile'
|
27
|
+
cache_options(:path => "#{ENV['HOME']}/.chef/checksums")
|
28
|
+
EOS
|
29
|
+
end
|
30
|
+
yield knife_rb
|
31
|
+
ensure
|
32
|
+
rm_rf knife_rb
|
33
|
+
rm_rf cachedir
|
34
|
+
end
|
35
|
+
end
|
14
36
|
end
|