Skip to content

Commit 74bf32c

Browse files
Chris Walters, Tim Hinderliterdanielsdeleo
authored andcommitted
Post-merge fixup
1 parent 76e525f commit 74bf32c

4 files changed

Lines changed: 61 additions & 17 deletions

File tree

‎chef-server-api/config/init.rb‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
require 'chef/certificate'
4040
require 'chef/data_bag'
4141
require 'chef/data_bag_item'
42+
require 'chef/cookbook'
43+
require 'chef/sandbox'
44+
require 'chef/checksum'
4245

4346
require 'mixlib/authentication'
4447

@@ -67,6 +70,9 @@
6770
Chef::DataBag.create_design_document
6871
Chef::ApiClient.create_design_document
6972
Chef::WebUIUser.create_design_document
73+
Chef::Cookbook.create_design_document
74+
Chef::Sandbox.create_design_document
75+
Chef::Checksum.create_design_document
7076

7177
# Create the signing key and certificate
7278
Chef::Certificate.generate_signing_ca

‎chef-server-api/config/router.rb‎

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
# Nodes
55
resources :nodes, :id => /[^\/]+/
66
match('/nodes/:id/cookbooks',
7-
:id => /[^\/]+/,
8-
:method => 'get').
9-
to(:controller => "nodes", :action => "cookbooks")
7+
:id => /[^\/]+/,
8+
:method => 'get').
9+
to(:controller => "nodes", :action => "cookbooks")
1010
# Roles
1111
resources :roles
1212

@@ -27,10 +27,48 @@
2727
# Cookbooks
2828
match('/nodes/:id/cookbooks', :method => 'get').to(:controller => "nodes", :action => "cookbooks")
2929

30-
resources :cookbooks
31-
match("/cookbooks/:cookbook_id/_content", :method => 'get', :cookbook_id => /[\w\.]+/).to(:controller => "cookbooks", :action => "get_tarball")
32-
match("/cookbooks/:cookbook_id/_content", :method => 'put', :cookbook_id => /[\w\.]+/).to(:controller => "cookbooks", :action => "update")
33-
match("/cookbooks/:cookbook_id/:segment", :cookbook_id => /[\w\.]+/).to(:controller => "cookbooks", :action => "show_segment").name(:cookbook_segment)
30+
scope.match("/cookbooks",
31+
:method => 'get'
32+
).to(:controller => "cookbooks", :action => "index")
33+
34+
scope.match("/cookbooks/:cookbook_name/:cookbook_version",
35+
:method => 'put',
36+
:cookbook_name => /[\w\.]+/,
37+
:cookbook_version => /\d+\.\d+\.\d+/
38+
).to(:controller => "cookbooks", :action => "update")
39+
40+
scope.match("/cookbooks/:cookbook_name/:cookbook_version",
41+
:method => 'get',
42+
:cookbook_name => /[\w\.]+/,
43+
:cookbook_version => /(\d+\.\d+\.\d+|_latest)/
44+
).to(:controller => "cookbooks", :action => "show")
45+
46+
scope.match("/cookbooks/:cookbook_name/:cookbook_version",
47+
:method => 'delete',
48+
:cookbook_name => /[\w\.]+/,
49+
:cookbook_version => /(\d+\.\d+\.\d+|_latest)/
50+
).to(:controller => "cookbooks", :action => "destroy")
51+
52+
scope.match("/cookbooks/:cookbook_name",
53+
:method => 'get',
54+
:cookbook_name => /[\w\.]+/
55+
).to(:controller => "cookbooks", :action => "show_versions").name(:cookbook)
56+
57+
scope.match("/cookbooks/:cookbook_name/:cookbook_version/files/:checksum",
58+
:cookbook_name => /[\w\.]+/,
59+
:cookbook_version => /(\d+\.\d+\.\d+|_latest)/
60+
).to(
61+
:controller => "cookbooks",
62+
:action => "show_file"
63+
).name(:cookbook_file)
64+
65+
# Sandbox
66+
scope.match('/sandboxes', :method => 'get').to(:controller => "sandboxes", :action => "index").name(:sandboxes)
67+
scope.match('/sandboxes', :method => 'post').to(:controller => "sandboxes", :action => "create")
68+
scope.match('/sandboxes/:sandbox_id', :method => 'get', :sandbox_id => /[\w\.]+/).to(:controller => "sandboxes", :action => "show").name(:sandbox)
69+
scope.match('/sandboxes/:sandbox_id', :method => 'put', :sandbox_id => /[\w\.]+/).to(:controller => "sandboxes", :action => "update")
70+
scope.match('/sandboxes/:sandbox_id/:checksum', :method => 'put', :sandbox_id => /[\w\.]+/, :checksum => /[\w\.]+/).to(:controller => "sandboxes", :action => "upload_checksum").name(:sandbox_checksum)
71+
scope.match('/sandboxes/:sandbox_id/:checksum', :method => 'get', :sandbox_id => /[\w\.]+/, :checksum => /[\w\.]+/).to(:controller => "sandboxes", :action => "download_checksum")
3472

3573
# Data
3674
match("/data/:data_bag_id/:id", :method => 'get').to(:controller => "data_item", :action => "show").name("data_bag_item")

‎chef/lib/chef/client.rb‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ def run
8383
if Chef::Config[:solo]
8484
build_node
8585
self.run_context = Chef::RunContext.new(node, Chef::CookbookCollection.new(Chef::CookbookLoader.new))
86+
assert_cookbook_path_not_empty
8687
converge
8788
else
8889
register
@@ -95,6 +96,7 @@ def run
9596
# and feeds them to the node's lazy-loading cookbook
9697
# collection. [cw/tim-5/11/2010]
9798
sync_cookbooks
99+
assert_cookbook_path_not_empty
98100
self.run_context = Chef::RunContext.new(node, Chef::CookbookCollection.new(Chef::CookbookLoader.new))
99101
save_node
100102

@@ -329,12 +331,8 @@ def is_last_element?(index, object)
329331
object.kind_of?(Array) ? index == object.size - 1 : true
330332
end
331333

332-
# TODO: call this method in run after rebase conflicts are resolved
333334
def assert_cookbook_path_not_empty
334-
unless Chef::Config[:solo]
335-
Chef::Config[:cookbook_path] = File.join(Chef::Config[:file_cache_path], "cookbooks")
336-
Chef::Log.warn("Node #{@node_name} has an empty run list.") if @node.run_list.empty?
337-
else
335+
if Chef::Config[:solo]
338336
# Check for cookbooks in the path given
339337
# Chef::Config[:cookbook_path] can be a string or an array
340338
# if it's an array, go through it and check each one, raise error at the last one if no files are found
@@ -348,6 +346,8 @@ def assert_cookbook_path_not_empty
348346
raise Chef::Exceptions::CookbookNotFound, msg if is_last_element?(index, Chef::Config[:cookbook_path])
349347
end
350348
end
349+
else
350+
Chef::Log.warn("Node #{node_name} has an empty run list.") if node.run_list.empty?
351351
end
352352

353353
end

‎chef/lib/chef/node.rb‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ class Node
3939
attr_accessor :recipe_list, :couchdb, :couchdb_rev, :run_state, :run_list, :override_attrs, :default_attrs, :normal_attrs, :automatic_attrs, :cookbook_collection
4040
attr_reader :couchdb_id
4141

42-
# This looks weird at first, but it allows the components of the
43-
# DSL to refer to the node as "node".
44-
attr_reader :node
45-
4642
include Chef::Mixin::CheckHelper
4743
include Chef::Mixin::FromFile
4844
include Chef::Mixin::ParamsValidate
@@ -135,7 +131,6 @@ class Node
135131
# Create a new Chef::Node object.
136132
def initialize(couchdb=nil)
137133
@name = nil
138-
@node = self
139134

140135
@normal_attrs = Mash.new
141136
@override_attrs = Mash.new
@@ -158,6 +153,11 @@ def couchdb_id=(value)
158153
self.couchdb_id = value
159154
self.index_id = value
160155
end
156+
157+
# Used by DSL
158+
def node
159+
self
160+
end
161161

162162
def chef_server_rest
163163
Chef::REST.new(Chef::Config[:chef_server_url])

0 commit comments

Comments
 (0)