chef 12.5.1-universal-mingw32 → 12.6.0-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +6 -1
- data/README.md +6 -4
- data/Rakefile +1 -4
- data/chef-windows.gemspec +21 -0
- data/chef.gemspec +58 -0
- data/lib/chef/api_client/registration.rb +9 -4
- data/lib/chef/application.rb +3 -84
- data/lib/chef/application/apply.rb +9 -2
- data/lib/chef/application/client.rb +8 -3
- data/lib/chef/application/solo.rb +7 -1
- data/lib/chef/application/windows_service.rb +21 -6
- data/lib/chef/application/windows_service_manager.rb +2 -3
- data/lib/chef/audit/runner.rb +1 -0
- data/lib/chef/chef_class.rb +1 -11
- data/lib/chef/chef_fs/chef_fs_data_store.rb +181 -2
- data/lib/chef/chef_fs/file_system/cookbook_subdir.rb +5 -0
- data/lib/chef/chef_fs/file_system/file_system_entry.rb +11 -7
- data/lib/chef/client.rb +28 -1
- data/lib/chef/cookbook/cookbook_collection.rb +14 -1
- data/lib/chef/cookbook/cookbook_version_loader.rb +1 -1
- data/lib/chef/cookbook/metadata.rb +115 -9
- data/lib/chef/cookbook/remote_file_vendor.rb +1 -1
- data/lib/chef/cookbook_version.rb +6 -2
- data/lib/chef/data_bag.rb +1 -1
- data/lib/chef/data_bag_item.rb +1 -1
- data/lib/chef/digester.rb +5 -1
- data/lib/chef/dsl/chef_provisioning.rb +57 -0
- data/lib/chef/dsl/cheffish.rb +64 -0
- data/lib/chef/dsl/declare_resource.rb +108 -0
- data/lib/chef/dsl/platform_introspection.rb +3 -3
- data/lib/chef/dsl/recipe.rb +3 -73
- data/lib/chef/dsl/resources.rb +27 -1
- data/lib/chef/event_dispatch/base.rb +3 -0
- data/lib/chef/event_dispatch/dispatcher.rb +5 -0
- data/lib/chef/event_dispatch/events_output_stream.rb +8 -0
- data/lib/chef/exceptions.rb +21 -1
- data/lib/chef/file_access_control/unix.rb +12 -12
- data/lib/chef/file_content_management/deploy/cp.rb +2 -2
- data/lib/chef/file_content_management/deploy/mv_unix.rb +4 -4
- data/lib/chef/file_content_management/deploy/mv_windows.rb +1 -1
- data/lib/chef/formatters/base.rb +7 -0
- data/lib/chef/formatters/error_inspectors/compile_error_inspector.rb +2 -2
- data/lib/chef/formatters/indentable_output_stream.rb +5 -0
- data/lib/chef/http.rb +19 -3
- data/lib/chef/http/decompressor.rb +2 -2
- data/lib/chef/json_compat.rb +1 -0
- data/lib/chef/knife.rb +16 -2
- data/lib/chef/knife/bootstrap.rb +55 -10
- data/lib/chef/knife/cookbook_site_install.rb +5 -1
- data/lib/chef/knife/core/bootstrap_context.rb +2 -1
- data/lib/chef/knife/core/node_presenter.rb +1 -1
- data/lib/chef/knife/ssh.rb +30 -16
- data/lib/chef/knife/ssl_check.rb +4 -2
- data/lib/chef/knife/ssl_fetch.rb +3 -2
- data/lib/chef/knife/status.rb +14 -1
- data/lib/chef/log.rb +14 -0
- data/lib/chef/mixin/get_source_from_package.rb +7 -2
- data/lib/chef/mixin/properties.rb +302 -0
- data/lib/chef/mixin/proxified_socket.rb +38 -0
- data/lib/chef/mixin/subclass_directive.rb +37 -0
- data/lib/chef/node.rb +13 -5
- data/lib/chef/platform/query_helpers.rb +14 -3
- data/lib/chef/platform/service_helpers.rb +20 -38
- data/lib/chef/policy_builder/expand_node_object.rb +3 -0
- data/lib/chef/policy_builder/policyfile.rb +1 -0
- data/lib/chef/property.rb +51 -12
- data/lib/chef/provider.rb +40 -35
- data/lib/chef/provider/deploy.rb +1 -1
- data/lib/chef/provider/dsc_resource.rb +54 -20
- data/lib/chef/provider/execute.rb +25 -4
- data/lib/chef/provider/group.rb +1 -1
- data/lib/chef/provider/lwrp_base.rb +1 -0
- data/lib/chef/provider/package.rb +76 -30
- data/lib/chef/provider/package/dpkg.rb +152 -69
- data/lib/chef/provider/package/openbsd.rb +6 -8
- data/lib/chef/provider/package/solaris.rb +2 -0
- data/lib/chef/provider/package/windows.rb +95 -14
- data/lib/chef/provider/package/windows/exe.rb +129 -0
- data/lib/chef/provider/package/windows/msi.rb +37 -13
- data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +89 -0
- data/lib/chef/provider/package/yum.rb +13 -3
- data/lib/chef/provider/powershell_script.rb +3 -0
- data/lib/chef/provider/remote_file/cache_control_data.rb +37 -4
- data/lib/chef/provider/remote_file/http.rb +1 -1
- data/lib/chef/provider/script.rb +1 -0
- data/lib/chef/provider/service.rb +13 -10
- data/lib/chef/provider/service/solaris.rb +43 -17
- data/lib/chef/provider/service/upstart.rb +3 -3
- data/lib/chef/provider/user.rb +1 -1
- data/lib/chef/provider/user/dscl.rb +111 -100
- data/lib/chef/provider/user/windows.rb +5 -3
- data/lib/chef/recipe.rb +3 -5
- data/lib/chef/resource.rb +77 -320
- data/lib/chef/resource/action_class.rb +4 -0
- data/lib/chef/resource/dpkg_package.rb +4 -3
- data/lib/chef/resource/dsc_resource.rb +40 -2
- data/lib/chef/resource/execute.rb +9 -1
- data/lib/chef/resource/ksh.rb +32 -0
- data/lib/chef/resource/lwrp_base.rb +6 -10
- data/lib/chef/resource/package.rb +8 -9
- data/lib/chef/resource/registry_key.rb +1 -1
- data/lib/chef/resource/resource_notification.rb +14 -1
- data/lib/chef/resource/script.rb +1 -1
- data/lib/chef/resource/windows_package.rb +1 -1
- data/lib/chef/resource_builder.rb +14 -7
- data/lib/chef/resource_reporter.rb +6 -0
- data/lib/chef/resources.rb +1 -7
- data/lib/chef/rest.rb +1 -1
- data/lib/chef/run_context.rb +45 -2
- data/lib/chef/run_list/run_list_expansion.rb +47 -0
- data/lib/chef/runner.rb +25 -0
- data/lib/chef/search/query.rb +16 -2
- data/lib/chef/util/diff.rb +2 -2
- data/lib/chef/util/powershell/ps_credential.rb +2 -3
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/api/file.rb +51 -1
- data/lib/chef/win32/file.rb +5 -0
- data/lib/chef/win32/file/version_info.rb +93 -0
- data/lib/chef/win32/mutex.rb +1 -1
- data/spec/data/apt/chef-integration-test2-1.0/debian/changelog +5 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/chef-integration-test2.debhelper.log +45 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/chef-integration-test2.substvars +1 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/chef-integration-test2/DEBIAN/conffiles +1 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/chef-integration-test2/DEBIAN/control +10 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/chef-integration-test2/DEBIAN/md5sums +1 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/compat +1 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/conffiles +1 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/control +13 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/copyright +34 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/files +1 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/rules +13 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/source/format +1 -0
- data/spec/data/apt/chef-integration-test2_1.0-1.debian.tar.gz +0 -0
- data/spec/data/apt/chef-integration-test2_1.0-1.dsc +18 -0
- data/spec/data/apt/chef-integration-test2_1.0-1_amd64.build +91 -0
- data/spec/data/apt/chef-integration-test2_1.0-1_amd64.changes +31 -0
- data/spec/data/apt/chef-integration-test2_1.0-1_amd64.deb +0 -0
- data/spec/data/apt/chef-integration-test2_1.0.orig.tar.gz +0 -0
- data/spec/functional/application_spec.rb +1 -1
- data/spec/functional/audit/runner_spec.rb +4 -0
- data/spec/functional/knife/ssh_spec.rb +5 -5
- data/spec/functional/notifications_spec.rb +74 -4
- data/spec/functional/resource/aix_service_spec.rb +2 -2
- data/spec/functional/resource/dpkg_package_spec.rb +339 -0
- data/spec/functional/resource/ifconfig_spec.rb +3 -1
- data/spec/functional/resource/mount_spec.rb +5 -2
- data/spec/functional/resource/package_spec.rb +1 -1
- data/spec/functional/resource/user/windows_spec.rb +8 -0
- data/spec/functional/resource/windows_package_spec.rb +177 -0
- data/spec/functional/win32/version_info_spec.rb +50 -0
- data/spec/integration/client/client_spec.rb +80 -0
- data/spec/integration/knife/download_spec.rb +9 -0
- data/spec/integration/knife/upload_spec.rb +28 -1
- data/spec/integration/recipes/lwrp_inline_resources_spec.rb +93 -23
- data/spec/integration/recipes/resource_action_spec.rb +211 -116
- data/spec/integration/recipes/resource_converge_if_changed_spec.rb +72 -0
- data/spec/integration/solo/solo_spec.rb +34 -0
- data/spec/spec_helper.rb +11 -1
- data/spec/support/platform_helpers.rb +8 -0
- data/spec/support/shared/integration/integration_helper.rb +6 -0
- data/spec/support/shared/unit/execute_resource.rb +5 -0
- data/spec/support/shared/unit/platform_introspector.rb +7 -0
- data/spec/tiny_server.rb +6 -2
- data/spec/unit/api_client/registration_spec.rb +5 -4
- data/spec/unit/application_spec.rb +1 -181
- data/spec/unit/chef_fs/file_system/cookbook_subdir_spec.rb +34 -0
- data/spec/unit/cookbook/metadata_spec.rb +122 -2
- data/spec/unit/http_spec.rb +102 -0
- data/spec/unit/knife/bootstrap_spec.rb +55 -13
- data/spec/unit/knife/core/bootstrap_context_spec.rb +10 -3
- data/spec/unit/knife/ssl_check_spec.rb +7 -3
- data/spec/unit/knife/ssl_fetch_spec.rb +2 -2
- data/spec/unit/knife/status_spec.rb +13 -13
- data/spec/unit/knife_spec.rb +26 -2
- data/spec/unit/lwrp_spec.rb +1 -1
- data/spec/unit/mixin/properties_spec.rb +97 -0
- data/spec/unit/mixin/proxified_socket_spec.rb +94 -0
- data/spec/unit/mixin/subclass_directive_spec.rb +45 -0
- data/spec/unit/node_spec.rb +9 -1
- data/spec/unit/policy_builder/policyfile_spec.rb +2 -0
- data/spec/unit/property/validation_spec.rb +14 -12
- data/spec/unit/property_spec.rb +56 -0
- data/spec/unit/provider/deploy_spec.rb +1 -1
- data/spec/unit/provider/dsc_resource_spec.rb +63 -24
- data/spec/unit/provider/execute_spec.rb +95 -28
- data/spec/unit/provider/package/dpkg_spec.rb +185 -96
- data/spec/unit/provider/package/windows/exe_spec.rb +251 -0
- data/spec/unit/provider/package/windows/msi_spec.rb +94 -10
- data/spec/unit/provider/package/windows_spec.rb +227 -26
- data/spec/unit/provider/package/yum_spec.rb +6 -0
- data/spec/unit/provider/package_spec.rb +495 -366
- data/spec/unit/provider/remote_file/cache_control_data_spec.rb +62 -36
- data/spec/unit/provider/script_spec.rb +2 -2
- data/spec/unit/provider/service/solaris_smf_service_spec.rb +110 -39
- data/spec/unit/provider/service/upstart_service_spec.rb +19 -0
- data/spec/unit/provider/user/dscl_spec.rb +14 -0
- data/spec/unit/provider/user/windows_spec.rb +2 -2
- data/spec/unit/provider/user_spec.rb +9 -0
- data/spec/unit/provider_resolver_spec.rb +6 -30
- data/spec/unit/recipe_spec.rb +46 -20
- data/spec/unit/resource/chef_gem_spec.rb +1 -1
- data/spec/unit/resource/dsc_resource_spec.rb +14 -3
- data/spec/unit/resource/ksh_spec.rb +40 -0
- data/spec/unit/resource/registry_key_spec.rb +2 -2
- data/spec/unit/resource/resource_notification_spec.rb +44 -45
- data/spec/unit/resource_reporter_spec.rb +7 -0
- data/spec/unit/resource_spec.rb +268 -253
- data/spec/unit/rest_spec.rb +2 -2
- data/spec/unit/run_list/run_list_expansion_spec.rb +18 -3
- data/spec/unit/search/query_spec.rb +19 -1
- data/spec/unit/util/powershell/ps_credential_spec.rb +8 -1
- data/spec/unit/windows_service_spec.rb +83 -38
- data/tasks/external_tests.rb +19 -9
- data/tasks/rspec.rb +1 -1
- metadata +70 -21
- data/spec/support/pedant/Gemfile +0 -3
- data/spec/support/pedant/pedant_config.rb +0 -129
- data/spec/support/pedant/run_pedant.rb +0 -63
- data/spec/support/pedant/stickywicket.pem +0 -27
- data/spec/unit/provider/package_spec.rbe +0 -0
@@ -1,5 +1,8 @@
|
|
1
1
|
require 'support/shared/integration/integration_helper'
|
2
2
|
|
3
|
+
# Houses any classes we declare
|
4
|
+
module ResourceActionSpec
|
5
|
+
|
3
6
|
describe "Resource.action" do
|
4
7
|
include IntegrationSupport
|
5
8
|
|
@@ -85,7 +88,7 @@ describe "Resource.action" do
|
|
85
88
|
converge <<-EOM, __FILE__, __LINE__+1
|
86
89
|
ruby_block 'wow' do
|
87
90
|
block do
|
88
|
-
ActionJackson.ruby_block_converged = 'ruby_block_converged!'
|
91
|
+
ResourceActionSpec::ActionJackson.ruby_block_converged = 'ruby_block_converged!'
|
89
92
|
end
|
90
93
|
end
|
91
94
|
|
@@ -107,7 +110,7 @@ describe "Resource.action" do
|
|
107
110
|
|
108
111
|
ruby_block 'wow' do
|
109
112
|
block do
|
110
|
-
ActionJackson.ruby_block_converged = ActionJackson.succeeded
|
113
|
+
ResourceActionSpec::ActionJackson.ruby_block_converged = ResourceActionSpec::ActionJackson.succeeded
|
111
114
|
end
|
112
115
|
end
|
113
116
|
EOM
|
@@ -118,80 +121,79 @@ describe "Resource.action" do
|
|
118
121
|
end
|
119
122
|
|
120
123
|
context "With resource 'action_jackson'" do
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
end
|
124
|
+
class ActionJackson < Chef::Resource
|
125
|
+
use_automatic_resource_name
|
126
|
+
def foo(value=nil)
|
127
|
+
@foo = value if value
|
128
|
+
@foo
|
129
|
+
end
|
130
|
+
def blarghle(value=nil)
|
131
|
+
@blarghle = value if value
|
132
|
+
@blarghle
|
133
|
+
end
|
132
134
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
135
|
+
class <<self
|
136
|
+
attr_accessor :ran_action
|
137
|
+
attr_accessor :succeeded
|
138
|
+
attr_accessor :ruby_block_converged
|
139
|
+
end
|
138
140
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
141
|
+
public
|
142
|
+
def foo_public
|
143
|
+
'foo_public!'
|
144
|
+
end
|
145
|
+
protected
|
146
|
+
def foo_protected
|
147
|
+
'foo_protected!'
|
148
|
+
end
|
149
|
+
private
|
150
|
+
def foo_private
|
151
|
+
'foo_private!'
|
152
|
+
end
|
151
153
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
end
|
154
|
+
public
|
155
|
+
action :access_recipe_dsl do
|
156
|
+
ActionJackson.ran_action = :access_recipe_dsl
|
157
|
+
ruby_block 'hi there' do
|
158
|
+
block do
|
159
|
+
ActionJackson.succeeded = true
|
159
160
|
end
|
160
161
|
end
|
161
|
-
action :access_attribute do
|
162
|
-
ActionJackson.ran_action = :access_attribute
|
163
|
-
ActionJackson.succeeded = foo
|
164
|
-
ActionJackson.succeeded += " #{blarghle}" if blarghle
|
165
|
-
ActionJackson.succeeded += " #{bar}" if respond_to?(:bar)
|
166
|
-
end
|
167
|
-
action :access_attribute2 do
|
168
|
-
ActionJackson.ran_action = :access_attribute2
|
169
|
-
ActionJackson.succeeded = foo
|
170
|
-
ActionJackson.succeeded += " #{blarghle}" if blarghle
|
171
|
-
ActionJackson.succeeded += " #{bar}" if respond_to?(:bar)
|
172
|
-
end
|
173
|
-
action :access_method do
|
174
|
-
ActionJackson.ran_action = :access_method
|
175
|
-
ActionJackson.succeeded = foo_public
|
176
|
-
end
|
177
|
-
action :access_protected_method do
|
178
|
-
ActionJackson.ran_action = :access_protected_method
|
179
|
-
ActionJackson.succeeded = foo_protected
|
180
|
-
end
|
181
|
-
action :access_private_method do
|
182
|
-
ActionJackson.ran_action = :access_private_method
|
183
|
-
ActionJackson.succeeded = foo_private
|
184
|
-
end
|
185
|
-
action :access_instance_variable do
|
186
|
-
ActionJackson.ran_action = :access_instance_variable
|
187
|
-
ActionJackson.succeeded = @foo
|
188
|
-
end
|
189
|
-
action :access_class_method do
|
190
|
-
ActionJackson.ran_action = :access_class_method
|
191
|
-
ActionJackson.succeeded = ActionJackson.ruby_block_converged
|
192
|
-
end
|
193
162
|
end
|
194
|
-
|
163
|
+
action :access_attribute do
|
164
|
+
ActionJackson.ran_action = :access_attribute
|
165
|
+
ActionJackson.succeeded = foo
|
166
|
+
ActionJackson.succeeded += " #{blarghle}" if blarghle
|
167
|
+
ActionJackson.succeeded += " #{bar}" if respond_to?(:bar)
|
168
|
+
end
|
169
|
+
action :access_attribute2 do
|
170
|
+
ActionJackson.ran_action = :access_attribute2
|
171
|
+
ActionJackson.succeeded = foo
|
172
|
+
ActionJackson.succeeded += " #{blarghle}" if blarghle
|
173
|
+
ActionJackson.succeeded += " #{bar}" if respond_to?(:bar)
|
174
|
+
end
|
175
|
+
action :access_method do
|
176
|
+
ActionJackson.ran_action = :access_method
|
177
|
+
ActionJackson.succeeded = foo_public
|
178
|
+
end
|
179
|
+
action :access_protected_method do
|
180
|
+
ActionJackson.ran_action = :access_protected_method
|
181
|
+
ActionJackson.succeeded = foo_protected
|
182
|
+
end
|
183
|
+
action :access_private_method do
|
184
|
+
ActionJackson.ran_action = :access_private_method
|
185
|
+
ActionJackson.succeeded = foo_private
|
186
|
+
end
|
187
|
+
action :access_instance_variable do
|
188
|
+
ActionJackson.ran_action = :access_instance_variable
|
189
|
+
ActionJackson.succeeded = @foo
|
190
|
+
end
|
191
|
+
action :access_class_method do
|
192
|
+
ActionJackson.ran_action = :access_class_method
|
193
|
+
ActionJackson.succeeded = ActionJackson.ruby_block_converged
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
195
197
|
before(:each) {
|
196
198
|
ActionJackson.ran_action = :error
|
197
199
|
ActionJackson.succeeded = :error
|
@@ -220,33 +222,31 @@ describe "Resource.action" do
|
|
220
222
|
end
|
221
223
|
|
222
224
|
context "And 'action_jackalope' inheriting from ActionJackson with an extra attribute, action and custom method" do
|
223
|
-
|
224
|
-
|
225
|
-
use_automatic_resource_name
|
225
|
+
class ActionJackalope < ActionJackson
|
226
|
+
use_automatic_resource_name
|
226
227
|
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
end
|
231
|
-
def bar(value=nil)
|
232
|
-
@bar = "#{value}alope" if value
|
233
|
-
@bar
|
234
|
-
end
|
235
|
-
class <<self
|
236
|
-
attr_accessor :load_current_resource_ran
|
237
|
-
attr_accessor :jackalope_ran
|
238
|
-
end
|
239
|
-
action :access_jackalope do
|
240
|
-
ActionJackalope.jackalope_ran = :access_jackalope
|
241
|
-
ActionJackalope.succeeded = "#{foo} #{blarghle} #{bar}"
|
242
|
-
end
|
243
|
-
action :access_attribute do
|
244
|
-
super()
|
245
|
-
ActionJackalope.jackalope_ran = :access_attribute
|
246
|
-
ActionJackalope.succeeded = ActionJackson.succeeded
|
247
|
-
end
|
228
|
+
def foo(value=nil)
|
229
|
+
@foo = "#{value}alope" if value
|
230
|
+
@foo
|
248
231
|
end
|
249
|
-
|
232
|
+
def bar(value=nil)
|
233
|
+
@bar = "#{value}alope" if value
|
234
|
+
@bar
|
235
|
+
end
|
236
|
+
class <<self
|
237
|
+
attr_accessor :load_current_resource_ran
|
238
|
+
attr_accessor :jackalope_ran
|
239
|
+
end
|
240
|
+
action :access_jackalope do
|
241
|
+
ActionJackalope.jackalope_ran = :access_jackalope
|
242
|
+
ActionJackalope.succeeded = "#{foo} #{blarghle} #{bar}"
|
243
|
+
end
|
244
|
+
action :access_attribute do
|
245
|
+
super()
|
246
|
+
ActionJackalope.jackalope_ran = :access_attribute
|
247
|
+
ActionJackalope.succeeded = ActionJackson.succeeded
|
248
|
+
end
|
249
|
+
end
|
250
250
|
before do
|
251
251
|
ActionJackalope.jackalope_ran = nil
|
252
252
|
ActionJackalope.load_current_resource_ran = nil
|
@@ -313,20 +313,19 @@ describe "Resource.action" do
|
|
313
313
|
end
|
314
314
|
|
315
315
|
context "With a resource with no actions" do
|
316
|
-
|
317
|
-
|
318
|
-
use_automatic_resource_name
|
316
|
+
class NoActionJackson < Chef::Resource
|
317
|
+
use_automatic_resource_name
|
319
318
|
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
319
|
+
def foo(value=nil)
|
320
|
+
@foo = value if value
|
321
|
+
@foo
|
322
|
+
end
|
324
323
|
|
325
|
-
|
326
|
-
|
327
|
-
end
|
324
|
+
class <<self
|
325
|
+
attr_accessor :action_was
|
328
326
|
end
|
329
|
-
|
327
|
+
end
|
328
|
+
|
330
329
|
it "the default action is :nothing" do
|
331
330
|
converge {
|
332
331
|
no_action_jackson 'hi' do
|
@@ -339,19 +338,17 @@ describe "Resource.action" do
|
|
339
338
|
end
|
340
339
|
|
341
340
|
context "With a resource with action a-b-c d" do
|
342
|
-
|
343
|
-
|
344
|
-
use_automatic_resource_name
|
341
|
+
class WeirdActionJackson < Chef::Resource
|
342
|
+
use_automatic_resource_name
|
345
343
|
|
346
|
-
|
347
|
-
|
348
|
-
|
344
|
+
class <<self
|
345
|
+
attr_accessor :action_was
|
346
|
+
end
|
349
347
|
|
350
|
-
|
351
|
-
|
352
|
-
end
|
348
|
+
action "a-b-c d" do
|
349
|
+
WeirdActionJackson.action_was = action
|
353
350
|
end
|
354
|
-
|
351
|
+
end
|
355
352
|
|
356
353
|
it "Running the action works" do
|
357
354
|
expect_recipe {
|
@@ -360,4 +357,102 @@ describe "Resource.action" do
|
|
360
357
|
expect(WeirdActionJackson.action_was).to eq :"a-b-c d"
|
361
358
|
end
|
362
359
|
end
|
360
|
+
|
361
|
+
context "With a resource with property x" do
|
362
|
+
class ResourceActionSpecWithX < Chef::Resource
|
363
|
+
resource_name :resource_action_spec_with_x
|
364
|
+
property :x, default: 20
|
365
|
+
action :set do
|
366
|
+
# Access x during converge to ensure that we emit no warnings there
|
367
|
+
x
|
368
|
+
end
|
369
|
+
end
|
370
|
+
|
371
|
+
context "And another resource with a property x and an action that sets property x to its value" do
|
372
|
+
class ResourceActionSpecAlsoWithX < Chef::Resource
|
373
|
+
resource_name :resource_action_spec_also_with_x
|
374
|
+
property :x
|
375
|
+
action :set_x_to_x do
|
376
|
+
resource_action_spec_with_x 'hi' do
|
377
|
+
x x
|
378
|
+
end
|
379
|
+
end
|
380
|
+
def self.x_warning_line
|
381
|
+
__LINE__-4
|
382
|
+
end
|
383
|
+
action :set_x_to_x_in_non_initializer do
|
384
|
+
r = resource_action_spec_with_x 'hi' do
|
385
|
+
x 10
|
386
|
+
end
|
387
|
+
x_times_2 = r.x*2
|
388
|
+
end
|
389
|
+
action :set_x_to_10 do
|
390
|
+
resource_action_spec_with_x 'hi' do
|
391
|
+
x 10
|
392
|
+
end
|
393
|
+
end
|
394
|
+
end
|
395
|
+
|
396
|
+
attr_reader :x_warning_line
|
397
|
+
|
398
|
+
it "Using the enclosing resource to set x to x emits a warning that you're using the wrong x" do
|
399
|
+
recipe = converge {
|
400
|
+
resource_action_spec_also_with_x 'hi' do
|
401
|
+
x 1
|
402
|
+
action :set_x_to_x
|
403
|
+
end
|
404
|
+
}
|
405
|
+
warnings = recipe.logs.lines.select { |l| l =~ /warn/i }
|
406
|
+
expect(warnings.size).to eq 1
|
407
|
+
expect(warnings[0]).to match(/property x is declared in both resource_action_spec_with_x\[hi\] and resource_action_spec_also_with_x\[hi\] action :set_x_to_x. Use new_resource.x instead. At #{__FILE__}:#{ResourceActionSpecAlsoWithX.x_warning_line}/)
|
408
|
+
end
|
409
|
+
|
410
|
+
it "Using the enclosing resource to set x to x outside the initializer emits no warning" do
|
411
|
+
expect_recipe {
|
412
|
+
resource_action_spec_also_with_x 'hi' do
|
413
|
+
x 1
|
414
|
+
action :set_x_to_x_in_non_initializer
|
415
|
+
end
|
416
|
+
}.to emit_no_warnings_or_errors
|
417
|
+
end
|
418
|
+
|
419
|
+
it "Using the enclosing resource to set x to 10 emits no warning" do
|
420
|
+
expect_recipe {
|
421
|
+
resource_action_spec_also_with_x 'hi' do
|
422
|
+
x 1
|
423
|
+
action :set_x_to_10
|
424
|
+
end
|
425
|
+
}.to emit_no_warnings_or_errors
|
426
|
+
end
|
427
|
+
|
428
|
+
it "Using the enclosing resource to set x to 10 emits no warning" do
|
429
|
+
expect_recipe {
|
430
|
+
r = resource_action_spec_also_with_x 'hi'
|
431
|
+
r.x 1
|
432
|
+
r.action :set_x_to_10
|
433
|
+
}.to emit_no_warnings_or_errors
|
434
|
+
end
|
435
|
+
end
|
436
|
+
|
437
|
+
end
|
438
|
+
|
439
|
+
context "When a resource has a property with the same name as another resource" do
|
440
|
+
class HasPropertyNamedTemplate < Chef::Resource
|
441
|
+
use_automatic_resource_name
|
442
|
+
property :template
|
443
|
+
action :create do
|
444
|
+
template "x" do
|
445
|
+
'blah'
|
446
|
+
end
|
447
|
+
end
|
448
|
+
end
|
449
|
+
|
450
|
+
it "Raises an error when attempting to use a template in the action" do
|
451
|
+
expect_converge {
|
452
|
+
has_property_named_template 'hi'
|
453
|
+
}.to raise_error(/Property template of has_property_named_template\[hi\] cannot be passed a block! If you meant to create a resource named template instead, you'll need to first rename the property./)
|
454
|
+
end
|
455
|
+
end
|
456
|
+
end
|
457
|
+
|
363
458
|
end
|
@@ -110,6 +110,29 @@ EOM
|
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
113
|
+
context "and state1 and state2 are set to new sensitive values" do
|
114
|
+
let(:converge_recipe) {
|
115
|
+
<<-EOM
|
116
|
+
#{resource_name} 'blah' do
|
117
|
+
sensitive true
|
118
|
+
state1 'new_state1'
|
119
|
+
state2 'new_state2'
|
120
|
+
end
|
121
|
+
EOM
|
122
|
+
}
|
123
|
+
|
124
|
+
it "the resource updates state1 and state2" do
|
125
|
+
expect(resource.converged).to eq 1
|
126
|
+
expect(resource.updated?).to be_truthy
|
127
|
+
expect(converged_recipe.stdout).to eq <<-EOM
|
128
|
+
* #{resource_name}[blah] action create
|
129
|
+
- update default_identity1
|
130
|
+
- set state1 to (suppressed sensitive property)
|
131
|
+
- set state2 to (suppressed sensitive property)
|
132
|
+
EOM
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
113
136
|
context "and state1 is set to its current value but state2 is set to a new value" do
|
114
137
|
let(:converge_recipe) {
|
115
138
|
<<-EOM
|
@@ -246,6 +269,30 @@ EOM
|
|
246
269
|
- set identity1 to "default_identity1" (default value)
|
247
270
|
- set state1 to "new_state1"
|
248
271
|
- set state2 to "new_state2"
|
272
|
+
EOM
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
context "and state1 and state2 are set with sensitive property" do
|
277
|
+
let(:converge_recipe) {
|
278
|
+
<<-EOM
|
279
|
+
#{resource_name} 'blah' do
|
280
|
+
sensitive true
|
281
|
+
state1 'new_state1'
|
282
|
+
state2 'new_state2'
|
283
|
+
end
|
284
|
+
EOM
|
285
|
+
}
|
286
|
+
|
287
|
+
it "the resource is created" do
|
288
|
+
expect(resource.converged).to eq 1
|
289
|
+
expect(resource.updated?).to be_truthy
|
290
|
+
expect(converged_recipe.stdout).to eq <<-EOM
|
291
|
+
* #{resource_name}[blah] action create
|
292
|
+
- create default_identity1
|
293
|
+
- set identity1 to (suppressed sensitive property) (default value)
|
294
|
+
- set state1 to (suppressed sensitive property)
|
295
|
+
- set state2 to (suppressed sensitive property)
|
249
296
|
EOM
|
250
297
|
end
|
251
298
|
end
|
@@ -416,6 +463,31 @@ EOM
|
|
416
463
|
EOM
|
417
464
|
end
|
418
465
|
end
|
466
|
+
|
467
|
+
context "and state1 and state2 are set to new sensitive values" do
|
468
|
+
let(:converge_recipe) {
|
469
|
+
<<-EOM
|
470
|
+
#{resource_name} 'blah' do
|
471
|
+
sensitive true
|
472
|
+
state1 'new_state1'
|
473
|
+
state2 'new_state2'
|
474
|
+
end
|
475
|
+
EOM
|
476
|
+
}
|
477
|
+
|
478
|
+
it "the resource is created" do
|
479
|
+
expect(resource.converged).to eq 2
|
480
|
+
expect(resource.updated?).to be_truthy
|
481
|
+
expect(converged_recipe.stdout).to eq <<-EOM
|
482
|
+
* #{resource_name}[blah] action create
|
483
|
+
- create default_identity1
|
484
|
+
- set state1 to (suppressed sensitive property)
|
485
|
+
- create default_identity1
|
486
|
+
- set state2 to (suppressed sensitive property)
|
487
|
+
EOM
|
488
|
+
end
|
489
|
+
end
|
490
|
+
|
419
491
|
end
|
420
492
|
end
|
421
493
|
|