chef 12.0.1 → 12.0.3
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.
- checksums.yaml +4 -4
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb +1 -1
- data/lib/chef/digester.rb +1 -0
- data/lib/chef/dsl/recipe.rb +2 -1
- data/lib/chef/exceptions.rb +5 -0
- data/lib/chef/knife.rb +7 -0
- data/lib/chef/knife/cookbook_site_install.rb +34 -10
- data/lib/chef/provider/link.rb +1 -1
- data/lib/chef/provider/package/apt.rb +2 -2
- data/lib/chef/provider/package/homebrew.rb +11 -2
- data/lib/chef/provider/package/windows/msi.rb +2 -0
- data/lib/chef/provider/subversion.rb +3 -3
- data/lib/chef/resource.rb +23 -91
- data/lib/chef/resource/homebrew_package.rb +2 -1
- data/lib/chef/resource/resource_notification.rb +109 -0
- data/lib/chef/resource_collection/resource_set.rb +8 -8
- data/lib/chef/run_context.rb +4 -4
- data/lib/chef/version.rb +1 -1
- data/lib/chef/whitelist.rb +3 -1
- data/lib/chef/win32/api/file.rb +17 -3
- data/spec/functional/notifications_spec.rb +169 -0
- data/spec/functional/resource/link_spec.rb +31 -32
- data/spec/support/platform_helpers.rb +5 -2
- data/spec/unit/knife/cookbook_site_install_spec.rb +157 -116
- data/spec/unit/knife_spec.rb +108 -78
- data/spec/unit/mixin/shell_out_spec.rb +39 -40
- data/spec/unit/node_spec.rb +34 -0
- data/spec/unit/provider/link_spec.rb +5 -5
- data/spec/unit/provider/package/apt_spec.rb +264 -257
- data/spec/unit/provider/package/homebrew_spec.rb +26 -0
- data/spec/unit/provider/package/windows/msi_spec.rb +18 -3
- data/spec/unit/provider/subversion_spec.rb +5 -5
- data/spec/unit/provider_resolver_spec.rb +2 -2
- data/spec/unit/recipe_spec.rb +1 -0
- data/spec/unit/resource/apt_package_spec.rb +3 -5
- data/spec/unit/resource/resource_notification_spec.rb +170 -0
- data/spec/unit/resource_spec.rb +0 -151
- data/spec/unit/run_context_spec.rb +94 -55
- metadata +5 -2
@@ -24,23 +24,26 @@ require 'support/lib/library_load_order'
|
|
24
24
|
Chef::Log.level = :debug
|
25
25
|
|
26
26
|
describe Chef::RunContext do
|
27
|
-
|
28
|
-
|
29
|
-
cl = Chef::CookbookLoader.new(
|
27
|
+
let(:chef_repo_path) { File.expand_path(File.join(CHEF_SPEC_DATA, "run_context", "cookbooks")) }
|
28
|
+
let(:cookbook_collection) {
|
29
|
+
cl = Chef::CookbookLoader.new(chef_repo_path)
|
30
30
|
cl.load_cookbooks
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
31
|
+
Chef::CookbookCollection.new(cl)
|
32
|
+
}
|
33
|
+
let(:node) {
|
34
|
+
node = Chef::Node.new
|
35
|
+
node.run_list << "test" << "test::one" << "test::two"
|
36
|
+
node
|
37
|
+
}
|
38
|
+
let(:events) { Chef::EventDispatch::Dispatcher.new }
|
39
|
+
let(:run_context) { Chef::RunContext.new(node, cookbook_collection, events) }
|
37
40
|
|
38
41
|
it "has a cookbook collection" do
|
39
|
-
|
42
|
+
run_context.cookbook_collection.should == cookbook_collection
|
40
43
|
end
|
41
44
|
|
42
45
|
it "has a node" do
|
43
|
-
|
46
|
+
run_context.node.should == node
|
44
47
|
end
|
45
48
|
|
46
49
|
describe "loading cookbooks for a run list" do
|
@@ -52,44 +55,44 @@ describe Chef::RunContext do
|
|
52
55
|
Chef::Provider.send(:remove_const, :TestProvider)
|
53
56
|
end
|
54
57
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
58
|
+
node.run_list << "test" << "test::one" << "test::two"
|
59
|
+
node.should_receive(:loaded_recipe).with(:test, "default")
|
60
|
+
node.should_receive(:loaded_recipe).with(:test, "one")
|
61
|
+
node.should_receive(:loaded_recipe).with(:test, "two")
|
62
|
+
run_context.load(node.run_list.expand('_default'))
|
60
63
|
end
|
61
64
|
|
62
65
|
it "should load all the definitions in the cookbooks for this node" do
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
+
run_context.definitions.should have_key(:new_cat)
|
67
|
+
run_context.definitions.should have_key(:new_badger)
|
68
|
+
run_context.definitions.should have_key(:new_dog)
|
66
69
|
end
|
67
70
|
|
68
71
|
it "should load all the recipes specified for this node" do
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
72
|
+
run_context.resource_collection[0].to_s.should == "cat[einstein]"
|
73
|
+
run_context.resource_collection[1].to_s.should == "cat[loulou]"
|
74
|
+
run_context.resource_collection[2].to_s.should == "cat[birthday]"
|
75
|
+
run_context.resource_collection[3].to_s.should == "cat[peanut]"
|
76
|
+
run_context.resource_collection[4].to_s.should == "cat[fat peanut]"
|
74
77
|
end
|
75
78
|
|
76
79
|
it "loads all the attribute files in the cookbook collection" do
|
77
|
-
|
78
|
-
|
80
|
+
run_context.loaded_fully_qualified_attribute?("test", "george").should be_true
|
81
|
+
node[:george].should == "washington"
|
79
82
|
end
|
80
83
|
|
81
84
|
it "registers attributes files as loaded so they won't be reloaded" do
|
82
85
|
# This test unfortunately is pretty tightly intertwined with the
|
83
86
|
# implementation of how nodes load attribute files, but is the only
|
84
87
|
# convenient way to test this behavior.
|
85
|
-
|
86
|
-
|
88
|
+
node.should_not_receive(:from_file)
|
89
|
+
node.include_attribute("test::george")
|
87
90
|
end
|
88
91
|
|
89
92
|
it "raises an error when attempting to include_recipe from a cookbook not reachable by run list or dependencies" do
|
90
|
-
|
93
|
+
node.should_receive(:loaded_recipe).with(:ancient, "aliens")
|
91
94
|
lambda do
|
92
|
-
|
95
|
+
run_context.include_recipe("ancient::aliens")
|
93
96
|
# In CHEF-5120, this becomes a Chef::Exceptions::MissingCookbookDependency error:
|
94
97
|
end.should raise_error(Chef::Exceptions::CookbookNotFound)
|
95
98
|
end
|
@@ -97,39 +100,34 @@ describe Chef::RunContext do
|
|
97
100
|
end
|
98
101
|
|
99
102
|
describe "querying the contents of cookbooks" do
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
@node.name("testing")
|
109
|
-
@events = Chef::EventDispatch::Dispatcher.new
|
110
|
-
@run_context = Chef::RunContext.new(@node, @cookbook_collection, @events)
|
111
|
-
end
|
112
|
-
|
103
|
+
let(:chef_repo_path) { File.expand_path(File.join(CHEF_SPEC_DATA, "cookbooks")) }
|
104
|
+
let(:node) {
|
105
|
+
node = Chef::Node.new
|
106
|
+
node.set[:platform] = "ubuntu"
|
107
|
+
node.set[:platform_version] = "13.04"
|
108
|
+
node.name("testing")
|
109
|
+
node
|
110
|
+
}
|
113
111
|
|
114
112
|
it "queries whether a given cookbook has a specific template" do
|
115
|
-
|
116
|
-
|
113
|
+
run_context.should have_template_in_cookbook("openldap", "test.erb")
|
114
|
+
run_context.should_not have_template_in_cookbook("openldap", "missing.erb")
|
117
115
|
end
|
118
116
|
|
119
117
|
it "errors when querying for a template in a not-available cookbook" do
|
120
118
|
expect do
|
121
|
-
|
119
|
+
run_context.has_template_in_cookbook?("no-such-cookbook", "foo.erb")
|
122
120
|
end.to raise_error(Chef::Exceptions::CookbookNotFound)
|
123
121
|
end
|
124
122
|
|
125
123
|
it "queries whether a given cookbook has a specific cookbook_file" do
|
126
|
-
|
127
|
-
|
124
|
+
run_context.should have_cookbook_file_in_cookbook("java", "java.response")
|
125
|
+
run_context.should_not have_cookbook_file_in_cookbook("java", "missing.txt")
|
128
126
|
end
|
129
127
|
|
130
128
|
it "errors when querying for a cookbook_file in a not-available cookbook" do
|
131
129
|
expect do
|
132
|
-
|
130
|
+
run_context.has_cookbook_file_in_cookbook?("no-such-cookbook", "foo.txt")
|
133
131
|
end.to raise_error(Chef::Exceptions::CookbookNotFound)
|
134
132
|
end
|
135
133
|
end
|
@@ -140,13 +138,54 @@ describe Chef::RunContext do
|
|
140
138
|
end
|
141
139
|
|
142
140
|
it "stores and deletes the reboot request" do
|
143
|
-
|
144
|
-
expect(
|
145
|
-
expect(
|
141
|
+
run_context.request_reboot(expected)
|
142
|
+
expect(run_context.reboot_info).to eq(expected)
|
143
|
+
expect(run_context.reboot_requested?).to be_true
|
144
|
+
|
145
|
+
run_context.cancel_reboot
|
146
|
+
expect(run_context.reboot_info).to eq({})
|
147
|
+
expect(run_context.reboot_requested?).to be_false
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
describe "notifications" do
|
152
|
+
let(:notification) { Chef::Resource::Notification.new(nil, nil, notifying_resource) }
|
153
|
+
|
154
|
+
shared_context "notifying resource is a Chef::Resource" do
|
155
|
+
let(:notifying_resource) { Chef::Resource.new("gerbil") }
|
156
|
+
|
157
|
+
it "should be keyed off the resource name" do
|
158
|
+
run_context.send(setter, notification)
|
159
|
+
expect(run_context.send(getter, notifying_resource)).to eq([notification])
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
shared_context "notifying resource is a subclass of Chef::Resource" do
|
164
|
+
let(:declared_type) { :alpaca }
|
165
|
+
let(:notifying_resource) {
|
166
|
+
r = Class.new(Chef::Resource).new("guinea pig")
|
167
|
+
r.declared_type = declared_type
|
168
|
+
r
|
169
|
+
}
|
170
|
+
|
171
|
+
it "should be keyed off the resource declared key" do
|
172
|
+
run_context.send(setter, notification)
|
173
|
+
expect(run_context.send(getter, notifying_resource)).to eq([notification])
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
describe "of the immediate kind" do
|
178
|
+
let(:setter) { :notifies_immediately }
|
179
|
+
let(:getter) { :immediate_notifications }
|
180
|
+
include_context "notifying resource is a Chef::Resource"
|
181
|
+
include_context "notifying resource is a subclass of Chef::Resource"
|
182
|
+
end
|
146
183
|
|
147
|
-
|
148
|
-
|
149
|
-
|
184
|
+
describe "of the delayed kind" do
|
185
|
+
let(:setter) { :notifies_delayed }
|
186
|
+
let(:getter) { :delayed_notifications }
|
187
|
+
include_context "notifying resource is a Chef::Resource"
|
188
|
+
include_context "notifying resource is a subclass of Chef::Resource"
|
150
189
|
end
|
151
190
|
end
|
152
191
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 12.0.
|
4
|
+
version: 12.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Jacob
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mixlib-config
|
@@ -1025,6 +1025,7 @@ files:
|
|
1025
1025
|
- lib/chef/resource/registry_key.rb
|
1026
1026
|
- lib/chef/resource/remote_directory.rb
|
1027
1027
|
- lib/chef/resource/remote_file.rb
|
1028
|
+
- lib/chef/resource/resource_notification.rb
|
1028
1029
|
- lib/chef/resource/route.rb
|
1029
1030
|
- lib/chef/resource/rpm_package.rb
|
1030
1031
|
- lib/chef/resource/ruby.rb
|
@@ -1425,6 +1426,7 @@ files:
|
|
1425
1426
|
- spec/functional/knife/smoke_test.rb
|
1426
1427
|
- spec/functional/knife/ssh_spec.rb
|
1427
1428
|
- spec/functional/mixin/shell_out_spec.rb
|
1429
|
+
- spec/functional/notifications_spec.rb
|
1428
1430
|
- spec/functional/provider/remote_file/cache_control_data_spec.rb
|
1429
1431
|
- spec/functional/provider/whyrun_safe_ruby_block_spec.rb
|
1430
1432
|
- spec/functional/rebooter_spec.rb
|
@@ -1860,6 +1862,7 @@ files:
|
|
1860
1862
|
- spec/unit/resource/registry_key_spec.rb
|
1861
1863
|
- spec/unit/resource/remote_directory_spec.rb
|
1862
1864
|
- spec/unit/resource/remote_file_spec.rb
|
1865
|
+
- spec/unit/resource/resource_notification_spec.rb
|
1863
1866
|
- spec/unit/resource/route_spec.rb
|
1864
1867
|
- spec/unit/resource/rpm_package_spec.rb
|
1865
1868
|
- spec/unit/resource/ruby_block_spec.rb
|