chef 12.2.0.rc.1 → 12.2.0.rc.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -107,7 +107,7 @@ class Chef
107
107
  if found[0]['Module'].nil?
108
108
  :none
109
109
  else
110
- found[0]['Module']
110
+ found[0]['Module']['Name']
111
111
  end
112
112
  else
113
113
  raise Chef::Exceptions::MultipleDscResourcesFound, found
@@ -39,10 +39,6 @@ class Chef
39
39
  end
40
40
  end
41
41
 
42
- def additional_remotes
43
- new_resource.additional_remotes || {}
44
- end
45
-
46
42
  def define_resource_requirements
47
43
  # Parent directory of the target must exist.
48
44
  requirements.assert(:checkout, :sync) do |a|
@@ -4,6 +4,7 @@ class Chef
4
4
  class Macports < Chef::Provider::Package
5
5
 
6
6
  provides :macports_package
7
+ provides :package, os: "darwin"
7
8
 
8
9
  def load_current_resource
9
10
  @current_resource = Chef::Resource::Package.new(@new_resource.name)
@@ -996,15 +996,6 @@ class Chef
996
996
  end
997
997
  end
998
998
 
999
- #
1000
- # DSL method used to define attribute on a resource wrapping params_validate
1001
- #
1002
- def self.attribute(attr_name, validation_opts={})
1003
- define_method(attr_name) do |arg=NULL_ARG|
1004
- nillable_set_or_return(attr_name.to_sym, arg, validation_opts)
1005
- end
1006
- end
1007
-
1008
999
  #
1009
1000
  # The cookbook in which this Resource was defined (if any).
1010
1001
  #
@@ -63,7 +63,6 @@ class Chef
63
63
  @deploy_to = name
64
64
  @environment = nil
65
65
  @repository_cache = 'cached-copy'
66
- # XXX: if copy_exclude is a kind_of String why is initialized to an array???
67
66
  @copy_exclude = []
68
67
  @purge_before_symlink = %w{log tmp/pids public/system}
69
68
  @create_dirs_before_symlink = %w{tmp public config}
@@ -79,11 +78,10 @@ class Chef
79
78
  @scm_provider = Chef::Provider::Git
80
79
  @svn_force_export = false
81
80
  @allowed_actions.push(:force_deploy, :deploy, :rollback)
82
- @additional_remotes = {}
81
+ @additional_remotes = Hash[]
83
82
  @keep_releases = 5
84
83
  @enable_checkout = true
85
84
  @checkout_branch = "deploy"
86
- @timeout = nil
87
85
  end
88
86
 
89
87
  # where the checked out/cloned code goes
@@ -106,18 +104,42 @@ class Chef
106
104
  end
107
105
 
108
106
  # note: deploy_to is your application "meta-root."
109
- attribute :deploy_to, :kind_of => [ String ]
107
+ def deploy_to(arg=nil)
108
+ set_or_return(
109
+ :deploy_to,
110
+ arg,
111
+ :kind_of => [ String ]
112
+ )
113
+ end
110
114
 
111
- attribute :repo, :kind_of => [ String ]
115
+ def repo(arg=nil)
116
+ set_or_return(
117
+ :repo,
118
+ arg,
119
+ :kind_of => [ String ]
120
+ )
121
+ end
112
122
  alias :repository :repo
113
123
 
114
- attribute :remote, :kind_of => [ String ]
124
+ def remote(arg=nil)
125
+ set_or_return(
126
+ :remote,
127
+ arg,
128
+ :kind_of => [ String ]
129
+ )
130
+ end
115
131
 
116
- attribute :role, :kind_of => [ String ]
132
+ def role(arg=nil)
133
+ set_or_return(
134
+ :role,
135
+ arg,
136
+ :kind_of => [ String ]
137
+ )
138
+ end
117
139
 
118
- def restart_command(arg=NULL_ARG, &block)
119
- arg = block if block_given?
120
- nillable_set_or_return(
140
+ def restart_command(arg=nil, &block)
141
+ arg ||= block
142
+ set_or_return(
121
143
  :restart_command,
122
144
  arg,
123
145
  :kind_of => [ String, Proc ]
@@ -125,60 +147,155 @@ class Chef
125
147
  end
126
148
  alias :restart :restart_command
127
149
 
128
- attribute :migrate, :kind_of => [ TrueClass, FalseClass ]
150
+ def migrate(arg=nil)
151
+ set_or_return(
152
+ :migrate,
153
+ arg,
154
+ :kind_of => [ TrueClass, FalseClass ]
155
+ )
156
+ end
129
157
 
130
- attribute :migration_command, kind_of: String
158
+ def migration_command(arg=nil)
159
+ set_or_return(
160
+ :migration_command,
161
+ arg,
162
+ :kind_of => [ String ]
163
+ )
164
+ end
131
165
 
132
- attribute :rollback_on_error, :kind_of => [ TrueClass, FalseClass ]
166
+ def rollback_on_error(arg=nil)
167
+ set_or_return(
168
+ :rollback_on_error,
169
+ arg,
170
+ :kind_of => [ TrueClass, FalseClass ]
171
+ )
172
+ end
133
173
 
134
- attribute :user, kind_of: String
174
+ def user(arg=nil)
175
+ set_or_return(
176
+ :user,
177
+ arg,
178
+ :kind_of => [ String ]
179
+ )
180
+ end
135
181
 
136
- attribute :group, kind_of: [ String ]
182
+ def group(arg=nil)
183
+ set_or_return(
184
+ :group,
185
+ arg,
186
+ :kind_of => [ String ]
187
+ )
188
+ end
137
189
 
138
- attribute :enable_submodules, kind_of: [ TrueClass, FalseClass ]
190
+ def enable_submodules(arg=nil)
191
+ set_or_return(
192
+ :enable_submodules,
193
+ arg,
194
+ :kind_of => [ TrueClass, FalseClass ]
195
+ )
196
+ end
139
197
 
140
- attribute :shallow_clone, kind_of: [ TrueClass, FalseClass ]
198
+ def shallow_clone(arg=nil)
199
+ set_or_return(
200
+ :shallow_clone,
201
+ arg,
202
+ :kind_of => [ TrueClass, FalseClass ]
203
+ )
204
+ end
141
205
 
142
- attribute :repository_cache, kind_of: String
206
+ def repository_cache(arg=nil)
207
+ set_or_return(
208
+ :repository_cache,
209
+ arg,
210
+ :kind_of => [ String ]
211
+ )
212
+ end
143
213
 
144
- attribute :copy_exclude, kind_of: String
214
+ def copy_exclude(arg=nil)
215
+ set_or_return(
216
+ :copy_exclude,
217
+ arg,
218
+ :kind_of => [ String ]
219
+ )
220
+ end
145
221
 
146
- attribute :revision, kind_of: String
222
+ def revision(arg=nil)
223
+ set_or_return(
224
+ :revision,
225
+ arg,
226
+ :kind_of => [ String ]
227
+ )
228
+ end
147
229
  alias :branch :revision
148
230
 
149
- attribute :git_ssh_wrapper, kind_of: String
231
+ def git_ssh_wrapper(arg=nil)
232
+ set_or_return(
233
+ :git_ssh_wrapper,
234
+ arg,
235
+ :kind_of => [ String ]
236
+ )
237
+ end
150
238
  alias :ssh_wrapper :git_ssh_wrapper
151
239
 
152
- attribute :svn_username, kind_of: String
240
+ def svn_username(arg=nil)
241
+ set_or_return(
242
+ :svn_username,
243
+ arg,
244
+ :kind_of => [ String ]
245
+ )
246
+ end
153
247
 
154
- attribute :svn_password, kind_of: String
248
+ def svn_password(arg=nil)
249
+ set_or_return(
250
+ :svn_password,
251
+ arg,
252
+ :kind_of => [ String ]
253
+ )
254
+ end
155
255
 
156
- attribute :svn_arguments, kind_of: String
256
+ def svn_arguments(arg=nil)
257
+ set_or_return(
258
+ :svn_arguments,
259
+ arg,
260
+ :kind_of => [ String ]
261
+ )
262
+ end
157
263
 
158
- attribute :svn_info_args, kind_of: String
264
+ def svn_info_args(arg=nil)
265
+ set_or_return(
266
+ :svn_arguments,
267
+ arg,
268
+ :kind_of => [ String ])
269
+ end
159
270
 
160
- def scm_provider(arg=NULL_ARG)
271
+ def scm_provider(arg=nil)
161
272
  klass = if arg.kind_of?(String) || arg.kind_of?(Symbol)
162
273
  lookup_provider_constant(arg)
163
274
  else
164
275
  arg
165
276
  end
166
- nillable_set_or_return(
277
+ set_or_return(
167
278
  :scm_provider,
168
279
  klass,
169
280
  :kind_of => [ Class ]
170
281
  )
171
282
  end
172
283
 
173
- attribute :svn_force_export, kind_of: [ TrueClass, FalseClass ]
284
+ def svn_force_export(arg=nil)
285
+ set_or_return(
286
+ :svn_force_export,
287
+ arg,
288
+ :kind_of => [ TrueClass, FalseClass ]
289
+ )
290
+ end
174
291
 
175
- def environment(arg=NULL_ARG)
292
+ def environment(arg=nil)
176
293
  if arg.is_a?(String)
177
294
  Chef::Log.debug "Setting RAILS_ENV, RACK_ENV, and MERB_ENV to `#{arg}'"
178
295
  Chef::Log.warn "[DEPRECATED] please modify your deploy recipe or attributes to set the environment using a hash"
179
296
  arg = {"RAILS_ENV"=>arg,"MERB_ENV"=>arg,"RACK_ENV"=>arg}
180
297
  end
181
- nillable_set_or_return(
298
+ set_or_return(
182
299
  :environment,
183
300
  arg,
184
301
  :kind_of => [ Hash ]
@@ -186,8 +303,8 @@ class Chef
186
303
  end
187
304
 
188
305
  # The number of old release directories to keep around after cleanup
189
- def keep_releases(arg=NULL_ARG)
190
- [nillable_set_or_return(
306
+ def keep_releases(arg=nil)
307
+ [set_or_return(
191
308
  :keep_releases,
192
309
  arg,
193
310
  :kind_of => [ Integer ]), 1].max
@@ -197,7 +314,13 @@ class Chef
197
314
  # SCM clone/checkout before symlinking. Use this to get rid of files and
198
315
  # directories you want to be shared between releases.
199
316
  # Default: ["log", "tmp/pids", "public/system"]
200
- attribute :purge_before_symlink, kind_of: Array
317
+ def purge_before_symlink(arg=nil)
318
+ set_or_return(
319
+ :purge_before_symlink,
320
+ arg,
321
+ :kind_of => Array
322
+ )
323
+ end
201
324
 
202
325
  # An array of paths, relative to your app's root, where you expect dirs to
203
326
  # exist before symlinking. This runs after #purge_before_symlink, so you
@@ -207,7 +330,13 @@ class Chef
207
330
  # then specify tmp here so that the tmp directory will exist when you
208
331
  # symlink the pids directory in to the current release.
209
332
  # Default: ["tmp", "public", "config"]
210
- attribute :create_dirs_before_symlink, kind_of: Array
333
+ def create_dirs_before_symlink(arg=nil)
334
+ set_or_return(
335
+ :create_dirs_before_symlink,
336
+ arg,
337
+ :kind_of => Array
338
+ )
339
+ end
211
340
 
212
341
  # A Hash of shared/dir/path => release/dir/path. This attribute determines
213
342
  # which files and dirs in the shared directory get symlinked to the current
@@ -215,7 +344,13 @@ class Chef
215
344
  # $shared/pids that you would like to symlink as $current_release/tmp/pids
216
345
  # you specify it as "pids" => "tmp/pids"
217
346
  # Default {"system" => "public/system", "pids" => "tmp/pids", "log" => "log"}
218
- attribute :symlinks, kind_of: Hash
347
+ def symlinks(arg=nil)
348
+ set_or_return(
349
+ :symlinks,
350
+ arg,
351
+ :kind_of => Hash
352
+ )
353
+ end
219
354
 
220
355
  # A Hash of shared/dir/path => release/dir/path. This attribute determines
221
356
  # which files in the shared directory get symlinked to the current release
@@ -224,44 +359,74 @@ class Chef
224
359
  # For a rails/merb app, this is used to link in a known good database.yml
225
360
  # (with the production db password) before running migrate.
226
361
  # Default {"config/database.yml" => "config/database.yml"}
227
- attribute :symlink_before_migrate, kind_of: Hash
362
+ def symlink_before_migrate(arg=nil)
363
+ set_or_return(
364
+ :symlink_before_migrate,
365
+ arg,
366
+ :kind_of => Hash
367
+ )
368
+ end
228
369
 
229
370
  # Callback fires before migration is run.
230
- def before_migrate(arg=NULL_ARG, &block)
231
- arg = block if block_given?
232
- nillable_set_or_return(:before_migrate, arg, kind_of: [Proc, String])
371
+ def before_migrate(arg=nil, &block)
372
+ arg ||= block
373
+ set_or_return(:before_migrate, arg, :kind_of => [Proc, String])
233
374
  end
234
375
 
235
376
  # Callback fires before symlinking
236
- def before_symlink(arg=NULL_ARG, &block)
237
- arg = block if block_given?
238
- nillable_set_or_return(:before_symlink, arg, kind_of: [Proc, String])
377
+ def before_symlink(arg=nil, &block)
378
+ arg ||= block
379
+ set_or_return(:before_symlink, arg, :kind_of => [Proc, String])
239
380
  end
240
381
 
241
382
  # Callback fires before restart
242
- def before_restart(arg=NULL_ARG, &block)
243
- arg = block if block_given?
244
- nillable_set_or_return(:before_restart, arg, kind_of: [Proc, String])
383
+ def before_restart(arg=nil, &block)
384
+ arg ||= block
385
+ set_or_return(:before_restart, arg, :kind_of => [Proc, String])
245
386
  end
246
387
 
247
388
  # Callback fires after restart
248
- def after_restart(arg=NULL_ARG, &block)
249
- arg = block if block_given?
250
- nillable_set_or_return(:after_restart, arg, kind_of: [Proc, String])
389
+ def after_restart(arg=nil, &block)
390
+ arg ||= block
391
+ set_or_return(:after_restart, arg, :kind_of => [Proc, String])
251
392
  end
252
393
 
253
- attribute :additional_remotes, kind_of: Hash
394
+ def additional_remotes(arg=nil)
395
+ set_or_return(
396
+ :additional_remotes,
397
+ arg,
398
+ :kind_of => Hash
399
+ )
400
+ end
254
401
 
255
- attribute :enable_checkout, kind_of: [ TrueClass, FalseClass ]
402
+ def enable_checkout(arg=nil)
403
+ set_or_return(
404
+ :enable_checkout,
405
+ arg,
406
+ :kind_of => [TrueClass, FalseClass]
407
+ )
408
+ end
256
409
 
257
- attribute :checkout_branch, kind_of: String
410
+ def checkout_branch(arg=nil)
411
+ set_or_return(
412
+ :checkout_branch,
413
+ arg,
414
+ :kind_of => String
415
+ )
416
+ end
258
417
 
259
418
  # FIXME The Deploy resource may be passed to an SCM provider as its
260
419
  # resource. The SCM provider knows that SCM resources can specify a
261
420
  # timeout for SCM operations. The deploy resource must therefore support
262
421
  # a timeout method, but the timeout it describes is for SCM operations,
263
422
  # not the overall deployment. This is potentially confusing.
264
- attribute :timeout, kind_of: Integer
423
+ def timeout(arg=nil)
424
+ set_or_return(
425
+ :timeout,
426
+ arg,
427
+ :kind_of => Integer
428
+ )
429
+ end
265
430
 
266
431
  end
267
432
  end
@@ -27,7 +27,7 @@ class Chef
27
27
  def initialize(name, run_context=nil)
28
28
  super
29
29
  @resource_name = :git
30
- @additional_remotes = {}
30
+ @additional_remotes = Hash[]
31
31
  end
32
32
 
33
33
  def additional_remotes(arg=nil)
@@ -70,6 +70,14 @@ class Chef
70
70
  alias_method :resource_name=, :resource_name
71
71
  end
72
72
 
73
+ # Define an attribute on this resource, including optional validation
74
+ # parameters.
75
+ def self.attribute(attr_name, validation_opts={})
76
+ define_method(attr_name) do |arg=nil|
77
+ set_or_return(attr_name.to_sym, arg, validation_opts)
78
+ end
79
+ end
80
+
73
81
  # Sets the default action
74
82
  def self.default_action(action_name=NULL_ARG)
75
83
  unless action_name.equal?(NULL_ARG)