Skip to content

Commit dc2f117

Browse files
committed
Merge branch 'master' of github.com:opscode/chef
2 parents 360fe30 + 9efbc1e commit dc2f117

14 files changed

Lines changed: 65 additions & 540 deletions

File tree

‎chef-server-api/app/controllers/cookbooks.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def index_latest
6262
def index_recipes
6363
all_cookbooks = Array(Chef::CookbookVersion.cdb_list_latest(true))
6464
all_cookbooks.map! do |cookbook|
65-
cookbook.manifest["recipes"].map { |r| "#{cookbook.name}::#{r['name']}" }
65+
cookbook.manifest["recipes"].map { |r| "#{cookbook.name}::#{File.basename(r['name'], ".rb")}" }
6666
end
6767
all_cookbooks.flatten!
6868
all_cookbooks.sort!

‎chef-server-webui/app/views/nodes/_form.html.haml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
%div.sortable
3737
%ul#node_available_recipes.connectedSortable
3838
- @available_recipes.each do |recipe|
39-
%li{ :id => "recipe[#{File.basename(recipe, ".rb")}]", :class => 'ui-state-default' }= h File.basename(recipe, ".rb")
39+
%li{ :id => "recipe[#{recipe}]",:title => recipe, :class => 'ui-state-default' }= h recipe
4040

4141

4242
%div.group.form{:style => "position:relative;"}

‎chef-server-webui/app/views/nodes/show.html.haml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
%tr
3737
%td{:colspan => 2} This node has no recipes applied.
3838
- else
39-
- full_recipe_list.each do |recipe|
39+
- @node.run_list.each_with_index do |recipe, i|
4040
%tr
4141
%td.position= i
4242
%td= recipe

‎chef-server-webui/app/views/roles/_form.html.haml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
%div.sortable
4141
%ul#node_available_recipes.connectedSortable
4242
- @available_recipes.each do |recipe|
43-
%li{ :id => "recipe[#{File.basename(recipe, ".rb")}]", :class => 'ui-state-default' }= h File.basename(recipe, ".rb")
43+
%li{ :id => "recipe[#{recipe}]", :title => recipe, :class => 'ui-state-default' }= h recipe
4444

4545
%div.group.form{:style => "position:relative;"}
4646
%label.label Default and Override Attributes

‎chef-server-webui/app/views/roles/show.html.haml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
%tr
4040
%td{:colspan => 2} This node has no recipes applied.
4141
- else
42-
- recipes.each do |recipe|
42+
- recipes.each_with_index do |recipe, i|
4343
%tr
4444
%td.position= i
4545
%td= recipes

‎chef/docs/design/HighLevel.graffle‎

-1.87 KB
Binary file not shown.

‎chef/docs/recipe.rb‎

Lines changed: 0 additions & 97 deletions
This file was deleted.

‎chef/lib/chef/knife/cookbook_test.rb‎

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ def run
4545
config[:cookbook_path] = Chef::Config[:cookbook_path]
4646
end
4747

48-
if config[:all]
48+
if config[:all]
4949
cl = Chef::CookbookLoader.new
50-
cl.each do |cookbook|
51-
test_cookbook(cookbook.name.to_s)
50+
cl.each do |key, cookbook|
51+
test_cookbook(key)
5252
end
5353
else
5454
@name_args.each do |cb|
@@ -60,42 +60,21 @@ def run
6060
def test_cookbook(cookbook)
6161
Chef::Log.info("Running syntax check on #{cookbook}")
6262
Array(config[:cookbook_path]).reverse.each do |path|
63-
cookbook_dir = File.expand_path(File.join(path, cookbook))
64-
test_ruby(cookbook_dir)
65-
test_templates(cookbook_dir)
63+
syntax_checker = Chef::Cookbook::SyntaxCheck.for_cookbook(cookbook, path)
64+
test_ruby(syntax_checker)
65+
test_templates(syntax_checker)
6666
end
6767
end
6868

69-
def test_ruby(cookbook_dir)
70-
cache = Chef::Cache::Checksum.instance
71-
Dir[File.join(cookbook_dir, '**', '*.rb')].each do |ruby_file|
72-
key = cache.generate_key(ruby_file, "chef-test")
73-
fstat = File.stat(ruby_file)
7469

75-
if cache.lookup_checksum(key, fstat)
76-
Chef::Log.info("No change in checksum of #{ruby_file}")
77-
else
78-
Chef::Log.info("Testing #{ruby_file} for syntax errors...")
79-
Chef::Mixin::Command.run_command(:command => "ruby -c #{ruby_file}", :output_on_failure => true)
80-
cache.generate_checksum(key, ruby_file, fstat)
81-
end
82-
end
70+
def test_ruby(syntax_checker)
71+
Chef::Log.info("Validating ruby files")
72+
exit(1) unless syntax_checker.validate_ruby_files
8373
end
84-
85-
def test_templates(cookbook_dir)
86-
cache = Chef::Cache::Checksum.instance
87-
Dir[File.join(cookbook_dir, '**', '*.erb')].each do |erb_file|
88-
key = cache.generate_key(erb_file, "chef-test")
89-
fstat = File.stat(erb_file)
90-
91-
if cache.lookup_checksum(key, fstat)
92-
Chef::Log.info("No change in checksum of #{erb_file}")
93-
else
94-
Chef::Log.info("Testing template #{erb_file} for syntax errors...")
95-
Chef::Mixin::Command.run_command(:command => "sh -c 'erubis -x #{erb_file} | ruby -c'", :output_on_failure => true)
96-
cache.generate_checksum(key, erb_file, fstat)
97-
end
98-
end
74+
75+
def test_templates(syntax_checker)
76+
Chef::Log.info("Validating templates")
77+
exit(1) unless syntax_checker.validate_templates
9978
end
10079

10180
end

‎chef/lib/chef/knife/cookbook_upload.rb‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,19 @@ def upload_cookbook(cookbook)
133133
end
134134
sandbox_url = new_sandbox['uri']
135135
Chef::Log.debug("Committing sandbox")
136-
catch_auth_exceptions{ rest.put_rest(sandbox_url, {:is_completed => true}) }
136+
# Retry if S3 is claims a checksum doesn't exist (the eventual
137+
# in eventual consistency)
138+
retries = 0
139+
begin
140+
catch_auth_exceptions{ rest.put_rest(sandbox_url, {:is_completed => true}) }
141+
rescue Net::HTTPServerException => e
142+
if e.to_s =~ /400 "Bad Request"/ && retries += 1 <= 1
143+
sleep 2
144+
retry
145+
else
146+
raise
147+
end
148+
end
137149

138150
# files are uploaded, so save the manifest
139151
catch_auth_exceptions{ build_dir_cookbook.save }

‎chef/lib/chef/knife/data_bag_create.rb‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,16 @@ class DataBagCreate < Knife
2525

2626
banner "Sub-Command: data bag create BAG [ITEM] (options)"
2727

28-
def run
28+
def run
29+
# create the data bag
30+
rest.post_rest("data", { "name" => @name_args[0] })
31+
Chef::Log.info("Created data_bag[#{@name_args[0]}]")
32+
33+
# if an item is specified, create it, as well
2934
if @name_args.length == 2
3035
create_object({ "id" => @name_args[1] }, "data_bag_item[#{@name_args[1]}]") do |output|
3136
rest.post_rest("data/#{@name_args[0]}", output)
3237
end
33-
else
34-
rest.post_rest("data", { "name" => @name_args[0] })
35-
Chef::Log.info("Created data_bag[#{@name_args[0]}]")
3638
end
3739
end
3840
end

0 commit comments

Comments
 (0)