chef 12.2.0.rc.1-x86-mingw32 → 12.2.0.rc.2-x86-mingw32

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4172090a1bea401568ce1a36c82d3c73e03f83aa
4
- data.tar.gz: a098a84fd70719f4a02cb32bc60f236ca479e43a
3
+ metadata.gz: 95f1fc26dcbb0acd2ff639fbd4351c9b1db84230
4
+ data.tar.gz: 9612d865502926406abf76a144d370f2099e56ec
5
5
  SHA512:
6
- metadata.gz: a2aa2b79501b758720d2119b4a87ddad983cfe074de8f7d52f92fc1f1e14473208355687ffc9b75c48568ff60989001bceda831e4515f09c66dbfafca85ec06d
7
- data.tar.gz: 7f3920491e869c05c0b15be8ed6f45eadf7979615fddf969b117e0c8c14c77a72595675d7f6d6ff3848a40baa41fe923d81293b5ee43ecfa4a084c83b1e914e3
6
+ metadata.gz: 86b701ae07c18f297733774d4bae5266256f7f5d2b944a6313f19f76559cd7c36f779d935922bc5c600fd94485ef9107c725374ad143b8cd187ea84a40be384b
7
+ data.tar.gz: d7a2bb01f542028be6852cbefa05058f5d24ec4fd43715d485d17a7bb07cfea3fe81b334d9b5a7bf965ae72803caff3e9f3ff020d520c559eb049ecabd520c21
@@ -30,7 +30,7 @@ class Chef
30
30
 
31
31
  def initialize(manifest, rest)
32
32
  @manifest = manifest
33
- @cookbook_name = @manifest[:cookbook_name]
33
+ @cookbook_name = @manifest[:cookbook_name] || @manifest[:name]
34
34
  @rest = rest
35
35
  end
36
36
 
@@ -36,6 +36,7 @@ class Chef
36
36
  def_delegator :@cookbook_version, :root_paths
37
37
  def_delegator :@cookbook_version, :segment_filenames
38
38
  def_delegator :@cookbook_version, :name
39
+ def_delegator :@cookbook_version, :identifier
39
40
  def_delegator :@cookbook_version, :metadata
40
41
  def_delegator :@cookbook_version, :full_name
41
42
  def_delegator :@cookbook_version, :version
@@ -141,9 +142,16 @@ class Chef
141
142
  # REST api. If there is an existing document on the server and it
142
143
  # is marked frozen, a PUT will result in a 409 Conflict.
143
144
  def save_url
144
- "#{cookbook_url_path}/#{name}/#{version}"
145
+ if policy_mode?
146
+ "#{named_cookbook_url}/#{identifier}"
147
+ else
148
+ "#{named_cookbook_url}/#{version}"
149
+ end
145
150
  end
146
151
 
152
+ def named_cookbook_url
153
+ "#{cookbook_url_path}/#{name}"
154
+ end
147
155
  # Adds the `force=true` parameter to the upload URL. This allows
148
156
  # the user to overwrite a frozen cookbook (a PUT against the
149
157
  # normal #save_url raises a 409 Conflict in this case).
@@ -214,10 +222,16 @@ class Chef
214
222
  end
215
223
  end
216
224
 
217
- manifest[:cookbook_name] = name.to_s
218
225
  manifest[:metadata] = metadata
219
226
  manifest[:version] = metadata.version
220
- manifest[:name] = full_name
227
+
228
+ if policy_mode?
229
+ manifest[:name] = name.to_s
230
+ manifest[:identifier] = identifier
231
+ else
232
+ manifest[:name] = full_name
233
+ manifest[:cookbook_name] = name.to_s
234
+ end
221
235
 
222
236
  @manifest_records_by_path = extract_manifest_records_by_path(manifest)
223
237
  @manifest = manifest
@@ -78,6 +78,16 @@ class Chef
78
78
 
79
79
  attr_accessor :chef_server_rest
80
80
 
81
+ # The `identifier` field is used for cookbook_artifacts, which are
82
+ # organized on the chef server according to their content. If the
83
+ # policy_mode option to CookbookManifest is set to true it will include
84
+ # this field in the manifest Hash and in the upload URL.
85
+ #
86
+ # This field may be removed or have different behavior in the future, don't
87
+ # use it in 3rd party code.
88
+ # @api private
89
+ attr_accessor :identifier
90
+
81
91
  # The first root path is the primary cookbook dir, from which metadata is loaded
82
92
  def root_dir
83
93
  root_paths[0]
@@ -458,6 +468,15 @@ class Chef
458
468
  cookbook_version
459
469
  end
460
470
 
471
+ def self.from_cb_artifact_data(o)
472
+ cookbook_version = new(o["name"])
473
+ # We want the Chef::Cookbook::Metadata object to always be inflated
474
+ cookbook_version.metadata = Chef::Cookbook::Metadata.from_hash(o["metadata"])
475
+ cookbook_version.manifest = o
476
+ cookbook_version.identifier = o["identifier"]
477
+ cookbook_version
478
+ end
479
+
461
480
  # @deprecated This method was used by the Ruby Chef Server and is no longer
462
481
  # needed. There is no replacement.
463
482
  def generate_manifest_with_urls(&url_generator)
@@ -81,58 +81,34 @@ class Chef
81
81
  DelayedEvaluator.new(&block)
82
82
  end
83
83
 
84
- NULL_ARG = Object.new
85
-
86
- def nillable_set_or_return(symbol, arg, validation)
84
+ def set_or_return(symbol, arg, validation)
87
85
  iv_symbol = "@#{symbol.to_s}".to_sym
88
- if NULL_ARG.equal?(arg)
89
- if self.instance_variable_defined?(iv_symbol) == true
90
- get_ivar(iv_symbol, symbol, validation)
86
+ if arg == nil && self.instance_variable_defined?(iv_symbol) == true
87
+ ivar = self.instance_variable_get(iv_symbol)
88
+ if(ivar.is_a?(DelayedEvaluator))
89
+ validate({ symbol => ivar.call }, { symbol => validation })[symbol]
91
90
  else
92
- # on access we create the iv and set it to nil for back-compat
93
- set_ivar(iv_symbol, symbol, nil, validation)
91
+ ivar
94
92
  end
95
93
  else
96
- set_ivar(iv_symbol, symbol, arg, validation)
97
- end
98
- end
94
+ if(arg.is_a?(DelayedEvaluator))
95
+ val = arg
96
+ else
97
+ val = validate({ symbol => arg }, { symbol => validation })[symbol]
99
98
 
100
- def set_or_return(symbol, arg, validation)
101
- iv_symbol = "@#{symbol.to_s}".to_sym
102
- if arg == nil && self.instance_variable_defined?(iv_symbol) == true
103
- get_ivar(iv_symbol, symbol, validation)
104
- else
105
- set_ivar(iv_symbol, symbol, arg, validation)
99
+ # Handle the case where the "default" was a DelayedEvaluator. In
100
+ # this case, the block yields an optional parameter of +self+,
101
+ # which is the equivalent of "new_resource"
102
+ if val.is_a?(DelayedEvaluator)
103
+ val = val.call(self)
104
+ end
105
+ end
106
+ self.instance_variable_set(iv_symbol, val)
106
107
  end
107
108
  end
108
109
 
109
110
  private
110
111
 
111
- def get_ivar(iv_symbol, symbol, validation)
112
- ivar = self.instance_variable_get(iv_symbol)
113
- if(ivar.is_a?(DelayedEvaluator))
114
- validate({ symbol => ivar.call }, { symbol => validation })[symbol]
115
- else
116
- ivar
117
- end
118
- end
119
-
120
- def set_ivar(iv_symbol, symbol, arg, validation)
121
- if(arg.is_a?(DelayedEvaluator))
122
- val = arg
123
- else
124
- val = validate({ symbol => arg }, { symbol => validation })[symbol]
125
-
126
- # Handle the case where the "default" was a DelayedEvaluator. In
127
- # this case, the block yields an optional parameter of +self+,
128
- # which is the equivalent of "new_resource"
129
- if val.is_a?(DelayedEvaluator)
130
- val = val.call(self)
131
- end
132
- end
133
- self.instance_variable_set(iv_symbol, val)
134
- end
135
-
136
112
  # Return the value of a parameter, or nil if it doesn't exist.
137
113
  def _pv_opts_lookup(opts, key)
138
114
  if opts.has_key?(key.to_s)
@@ -263,3 +239,4 @@ class Chef
263
239
  end
264
240
  end
265
241
  end
242
+
@@ -67,6 +67,7 @@ class Chef
67
67
  #
68
68
 
69
69
  priority :service, Chef::Provider::Service::Macosx, os: "darwin"
70
+ priority :package, Chef::Provider::Package::Homebrew, os: "darwin"
70
71
  end
71
72
 
72
73
  def priority_map
@@ -239,7 +239,7 @@ class Chef
239
239
  def policyfile_location
240
240
  if Chef::Config[:policy_document_native_api]
241
241
  validate_policy_config!
242
- "policies/#{policy_group}/#{policy_name}"
242
+ "policy_groups/#{policy_group}/policies/#{policy_name}"
243
243
  else
244
244
  "data/policyfiles/#{deployment_group}"
245
245
  end
@@ -368,16 +368,20 @@ class Chef
368
368
  end
369
369
 
370
370
  def artifact_manifest_for(cookbook_name, lock_data)
371
- xyz_version = lock_data["dotted_decimal_identifier"]
372
- rel_url = "cookbook_artifacts/#{cookbook_name}/#{xyz_version}"
373
- http_api.get(rel_url)
371
+ identifier = lock_data["identifier"]
372
+ rel_url = "cookbook_artifacts/#{cookbook_name}/#{identifier}"
373
+ inflate_cbv_object(http_api.get(rel_url))
374
374
  rescue Exception => e
375
- message = "Error loading cookbook #{cookbook_name} at version #{xyz_version} from #{rel_url}: #{e.class} - #{e.message}"
375
+ message = "Error loading cookbook #{cookbook_name} with identifier #{identifier} from #{rel_url}: #{e.class} - #{e.message}"
376
376
  err = Chef::Exceptions::CookbookNotFound.new(message)
377
377
  err.set_backtrace(e.backtrace)
378
378
  raise err
379
379
  end
380
380
 
381
+ def inflate_cbv_object(raw_manifest)
382
+ Chef::CookbookVersion.from_cb_artifact_data(raw_manifest)
383
+ end
384
+
381
385
  end
382
386
  end
383
387
  end
@@ -42,38 +42,18 @@ class Chef
42
42
 
43
43
  # @configuration is not used by Deploy, it is only for backwards compat with
44
44
  # chef-deploy or capistrano hooks that might use it to get environment information
45
- @configuration = new_resource.to_hash
45
+ @configuration = @new_resource.to_hash
46
46
  @configuration[:environment] = @configuration[:environment] && @configuration[:environment]["RAILS_ENV"]
47
47
  end
48
48
 
49
- # @return [Array] create_dirs_before_symlink parameter set on the resource
50
- def create_dirs_before_symlink
51
- new_resource.create_dirs_before_symlink || []
52
- end
53
-
54
- # @return [Array] purge_before_symlink paremeter set on the resource
55
- def purge_before_symlink
56
- new_resource.purge_before_symlink || []
57
- end
58
-
59
- # @return [Hash] symlinks parameter set on the resource
60
- def symlinks
61
- new_resource.symlinks || {}
62
- end
63
-
64
- # @return [Hash] symlink_before_migrate parameter set on the resource
65
- def symlink_before_migrate
66
- new_resource.symlink_before_migrate || {}
67
- end
68
-
69
49
  def whyrun_supported?
70
50
  true
71
51
  end
72
52
 
73
53
  def load_current_resource
74
- scm_provider.load_current_resource
75
- @release_path = new_resource.deploy_to + "/releases/#{release_slug}"
76
- @shared_path = new_resource.shared_path
54
+ @scm_provider.load_current_resource
55
+ @release_path = @new_resource.deploy_to + "/releases/#{release_slug}"
56
+ @shared_path = @new_resource.shared_path
77
57
  end
78
58
 
79
59
  def sudo(command,&block)
@@ -82,10 +62,10 @@ class Chef
82
62
 
83
63
  def run(command, &block)
84
64
  exec = execute(command, &block)
85
- exec.user(new_resource.user) if new_resource.user
86
- exec.group(new_resource.group) if new_resource.group
65
+ exec.user(@new_resource.user) if @new_resource.user
66
+ exec.group(@new_resource.group) if @new_resource.group
87
67
  exec.cwd(release_path) unless exec.cwd
88
- exec.environment(new_resource.environment) unless exec.environment
68
+ exec.environment(@new_resource.environment) unless exec.environment
89
69
  converge_by("execute #{command}") do
90
70
  exec
91
71
  end
@@ -98,8 +78,8 @@ class Chef
98
78
  #There is no reason to assume 2 deployments in a single chef run, hence fails in whyrun.
99
79
  end
100
80
 
101
- [ new_resource.before_migrate, new_resource.before_symlink,
102
- new_resource.before_restart, new_resource.after_restart ].each do |script|
81
+ [ @new_resource.before_migrate, @new_resource.before_symlink,
82
+ @new_resource.before_restart, @new_resource.after_restart ].each do |script|
103
83
  requirements.assert(:deploy, :force_deploy) do |a|
104
84
  callback_file = "#{release_path}/#{script}"
105
85
  a.assertion do
@@ -120,7 +100,7 @@ class Chef
120
100
  save_release_state
121
101
  if deployed?(release_path )
122
102
  if current_release?(release_path )
123
- Chef::Log.debug("#{new_resource} is the latest version")
103
+ Chef::Log.debug("#{@new_resource} is the latest version")
124
104
  else
125
105
  rollback_to release_path
126
106
  end
@@ -137,7 +117,7 @@ class Chef
137
117
  converge_by("delete deployed app at #{release_path} prior to force-deploy") do
138
118
  Chef::Log.info("Already deployed app at #{release_path}, forcing.")
139
119
  FileUtils.rm_rf(release_path)
140
- Chef::Log.info("#{new_resource} forcing deploy of already deployed app at #{release_path}")
120
+ Chef::Log.info("#{@new_resource} forcing deploy of already deployed app at #{release_path}")
141
121
  end
142
122
  end
143
123
 
@@ -163,7 +143,7 @@ class Chef
163
143
 
164
144
  releases_to_nuke.each do |i|
165
145
  converge_by("roll back by removing release #{i}") do
166
- Chef::Log.info "#{new_resource} removing release: #{i}"
146
+ Chef::Log.info "#{@new_resource} removing release: #{i}"
167
147
  FileUtils.rm_rf i
168
148
  end
169
149
  release_deleted(i)
@@ -177,21 +157,21 @@ class Chef
177
157
  copy_cached_repo
178
158
  install_gems
179
159
  enforce_ownership
180
- callback(:before_migrate, new_resource.before_migrate)
160
+ callback(:before_migrate, @new_resource.before_migrate)
181
161
  migrate
182
- callback(:before_symlink, new_resource.before_symlink)
162
+ callback(:before_symlink, @new_resource.before_symlink)
183
163
  symlink
184
- callback(:before_restart, new_resource.before_restart)
164
+ callback(:before_restart, @new_resource.before_restart)
185
165
  restart
186
- callback(:after_restart, new_resource.after_restart)
166
+ callback(:after_restart, @new_resource.after_restart)
187
167
  cleanup!
188
- Chef::Log.info "#{new_resource} deployed to #{new_resource.deploy_to}"
168
+ Chef::Log.info "#{@new_resource} deployed to #{@new_resource.deploy_to}"
189
169
  end
190
170
 
191
171
  def rollback
192
- Chef::Log.info "#{new_resource} rolling back to previous release #{release_path}"
172
+ Chef::Log.info "#{@new_resource} rolling back to previous release #{release_path}"
193
173
  symlink
194
- Chef::Log.info "#{new_resource} restarting with previous release"
174
+ Chef::Log.info "#{@new_resource} restarting with previous release"
195
175
  restart
196
176
  end
197
177
 
@@ -199,7 +179,7 @@ class Chef
199
179
  @collection = Chef::ResourceCollection.new
200
180
  case callback_code
201
181
  when Proc
202
- Chef::Log.info "#{new_resource} running callback #{what}"
182
+ Chef::Log.info "#{@new_resource} running callback #{what}"
203
183
  recipe_eval(&callback_code)
204
184
  when String
205
185
  run_callback_from_file("#{release_path}/#{callback_code}")
@@ -211,17 +191,17 @@ class Chef
211
191
  def migrate
212
192
  run_symlinks_before_migrate
213
193
 
214
- if new_resource.migrate
194
+ if @new_resource.migrate
215
195
  enforce_ownership
216
196
 
217
- environment = new_resource.environment
197
+ environment = @new_resource.environment
218
198
  env_info = environment && environment.map do |key_and_val|
219
199
  "#{key_and_val.first}='#{key_and_val.last}'"
220
200
  end.join(" ")
221
201
 
222
- converge_by("execute migration command #{new_resource.migration_command}") do
223
- Chef::Log.info "#{new_resource} migrating #{new_resource.user} with environment #{env_info}"
224
- run_command(run_options(:command => new_resource.migration_command, :cwd=>release_path, :log_level => :info))
202
+ converge_by("execute migration command #{@new_resource.migration_command}") do
203
+ Chef::Log.info "#{@new_resource} migrating #{@new_resource.user} with environment #{env_info}"
204
+ run_command(run_options(:command => @new_resource.migration_command, :cwd=>release_path, :log_level => :info))
225
205
  end
226
206
  end
227
207
  end
@@ -230,18 +210,18 @@ class Chef
230
210
  purge_tempfiles_from_current_release
231
211
  link_tempfiles_to_current_release
232
212
  link_current_release_to_production
233
- Chef::Log.info "#{new_resource} updated symlinks"
213
+ Chef::Log.info "#{@new_resource} updated symlinks"
234
214
  end
235
215
 
236
216
  def restart
237
- if restart_cmd = new_resource.restart_command
217
+ if restart_cmd = @new_resource.restart_command
238
218
  if restart_cmd.kind_of?(Proc)
239
- Chef::Log.info("#{new_resource} restarting app with embedded recipe")
219
+ Chef::Log.info("#{@new_resource} restarting app with embedded recipe")
240
220
  recipe_eval(&restart_cmd)
241
221
  else
242
- converge_by("restart app using command #{new_resource.restart_command}") do
243
- Chef::Log.info("#{new_resource} restarting app")
244
- run_command(run_options(:command => new_resource.restart_command, :cwd => new_resource.current_path))
222
+ converge_by("restart app using command #{@new_resource.restart_command}") do
223
+ Chef::Log.info("#{@new_resource} restarting app")
224
+ run_command(run_options(:command => @new_resource.restart_command, :cwd => @new_resource.current_path))
245
225
  end
246
226
  end
247
227
  end
@@ -252,10 +232,10 @@ class Chef
252
232
  release_created(release_path)
253
233
  end
254
234
 
255
- chop = -1 - new_resource.keep_releases
235
+ chop = -1 - @new_resource.keep_releases
256
236
  all_releases[0..chop].each do |old_release|
257
237
  converge_by("remove old release #{old_release}") do
258
- Chef::Log.info "#{new_resource} removing old release #{old_release}"
238
+ Chef::Log.info "#{@new_resource} removing old release #{old_release}"
259
239
  FileUtils.rm_rf(old_release)
260
240
  end
261
241
  release_deleted(old_release)
@@ -263,11 +243,11 @@ class Chef
263
243
  end
264
244
 
265
245
  def all_releases
266
- Dir.glob(Chef::Util::PathHelper.escape_glob(new_resource.deploy_to) + "/releases/*").sort
246
+ Dir.glob(Chef::Util::PathHelper.escape_glob(@new_resource.deploy_to) + "/releases/*").sort
267
247
  end
268
248
 
269
249
  def update_cached_repo
270
- if new_resource.svn_force_export
250
+ if @new_resource.svn_force_export
271
251
  # TODO assertion, non-recoverable - @scm_provider must be svn if force_export?
272
252
  svn_force_export
273
253
  else
@@ -276,92 +256,95 @@ class Chef
276
256
  end
277
257
 
278
258
  def run_scm_sync
279
- scm_provider.run_action(:sync)
259
+ @scm_provider.run_action(:sync)
280
260
  end
281
261
 
282
262
  def svn_force_export
283
- Chef::Log.info "#{new_resource} exporting source repository"
284
- scm_provider.run_action(:force_export)
263
+ Chef::Log.info "#{@new_resource} exporting source repository"
264
+ @scm_provider.run_action(:force_export)
285
265
  end
286
266
 
287
267
  def copy_cached_repo
288
- target_dir_path = new_resource.deploy_to + "/releases"
268
+ target_dir_path = @new_resource.deploy_to + "/releases"
289
269
  converge_by("deploy from repo to #{target_dir_path} ") do
290
270
  FileUtils.rm_rf(release_path) if ::File.exist?(release_path)
291
271
  FileUtils.mkdir_p(target_dir_path)
292
- FileUtils.cp_r(::File.join(new_resource.destination, "."), release_path, :preserve => true)
293
- Chef::Log.info "#{new_resource} copied the cached checkout to #{release_path}"
272
+ FileUtils.cp_r(::File.join(@new_resource.destination, "."), release_path, :preserve => true)
273
+ Chef::Log.info "#{@new_resource} copied the cached checkout to #{release_path}"
294
274
  end
295
275
  end
296
276
 
297
277
  def enforce_ownership
298
- converge_by("force ownership of #{new_resource.deploy_to} to #{new_resource.group}:#{new_resource.user}") do
299
- FileUtils.chown_R(new_resource.user, new_resource.group, new_resource.deploy_to)
300
- Chef::Log.info("#{new_resource} set user to #{new_resource.user}") if new_resource.user
301
- Chef::Log.info("#{new_resource} set group to #{new_resource.group}") if new_resource.group
278
+ converge_by("force ownership of #{@new_resource.deploy_to} to #{@new_resource.group}:#{@new_resource.user}") do
279
+ FileUtils.chown_R(@new_resource.user, @new_resource.group, @new_resource.deploy_to)
280
+ Chef::Log.info("#{@new_resource} set user to #{@new_resource.user}") if @new_resource.user
281
+ Chef::Log.info("#{@new_resource} set group to #{@new_resource.group}") if @new_resource.group
302
282
  end
303
283
  end
304
284
 
305
285
  def verify_directories_exist
306
- create_dir_unless_exists(new_resource.deploy_to)
307
- create_dir_unless_exists(new_resource.shared_path)
286
+ create_dir_unless_exists(@new_resource.deploy_to)
287
+ create_dir_unless_exists(@new_resource.shared_path)
308
288
  end
309
289
 
310
290
  def link_current_release_to_production
311
- converge_by(["remove existing link at #{new_resource.current_path}",
312
- "link release #{release_path} into production at #{new_resource.current_path}"]) do
313
- FileUtils.rm_f(new_resource.current_path)
291
+ converge_by(["remove existing link at #{@new_resource.current_path}",
292
+ "link release #{release_path} into production at #{@new_resource.current_path}"]) do
293
+ FileUtils.rm_f(@new_resource.current_path)
314
294
  begin
315
- FileUtils.ln_sf(release_path, new_resource.current_path)
295
+ FileUtils.ln_sf(release_path, @new_resource.current_path)
316
296
  rescue => e
317
297
  raise Chef::Exceptions::FileNotFound.new("Cannot symlink current release to production: #{e.message}")
318
298
  end
319
- Chef::Log.info "#{new_resource} linked release #{release_path} into production at #{new_resource.current_path}"
299
+ Chef::Log.info "#{@new_resource} linked release #{release_path} into production at #{@new_resource.current_path}"
320
300
  end
321
301
  enforce_ownership
322
302
  end
323
303
 
324
304
  def run_symlinks_before_migrate
325
- links_info = symlink_before_migrate.map { |src, dst| "#{src} => #{dst}" }.join(", ")
305
+ links_info = @new_resource.symlink_before_migrate.map { |src, dst| "#{src} => #{dst}" }.join(", ")
326
306
  converge_by("make pre-migration symlinks: #{links_info}") do
327
- symlink_before_migrate.each do |src, dest|
307
+ @new_resource.symlink_before_migrate.each do |src, dest|
328
308
  begin
329
- FileUtils.ln_sf(new_resource.shared_path + "/#{src}", release_path + "/#{dest}")
309
+ FileUtils.ln_sf(@new_resource.shared_path + "/#{src}", release_path + "/#{dest}")
330
310
  rescue => e
331
- raise Chef::Exceptions::FileNotFound.new("Cannot symlink #{new_resource.shared_path}/#{src} to #{release_path}/#{dest} before migrate: #{e.message}")
311
+ raise Chef::Exceptions::FileNotFound.new("Cannot symlink #{@new_resource.shared_path}/#{src} to #{release_path}/#{dest} before migrate: #{e.message}")
332
312
  end
333
313
  end
334
- Chef::Log.info "#{new_resource} made pre-migration symlinks"
314
+ Chef::Log.info "#{@new_resource} made pre-migration symlinks"
335
315
  end
336
316
  end
337
317
 
338
318
  def link_tempfiles_to_current_release
339
- dirs_info = create_dirs_before_symlink.join(",")
340
- create_dirs_before_symlink.each do |dir|
319
+ dirs_info = @new_resource.create_dirs_before_symlink.join(",")
320
+ @new_resource.create_dirs_before_symlink.each do |dir|
341
321
  create_dir_unless_exists(release_path + "/#{dir}")
342
322
  end
343
- Chef::Log.info("#{new_resource} created directories before symlinking: #{dirs_info}")
323
+ Chef::Log.info("#{@new_resource} created directories before symlinking: #{dirs_info}")
344
324
 
345
- links_info = symlinks.map { |src, dst| "#{src} => #{dst}" }.join(", ")
325
+ links_info = @new_resource.symlinks.map { |src, dst| "#{src} => #{dst}" }.join(", ")
346
326
  converge_by("link shared paths into current release: #{links_info}") do
347
- symlinks.each do |src, dest|
327
+ @new_resource.symlinks.each do |src, dest|
348
328
  begin
349
- FileUtils.ln_sf(::File.join(new_resource.shared_path, src), ::File.join(release_path, dest))
329
+ FileUtils.ln_sf(::File.join(@new_resource.shared_path, src), ::File.join(release_path, dest))
350
330
  rescue => e
351
- raise Chef::Exceptions::FileNotFound.new("Cannot symlink shared data #{::File.join(new_resource.shared_path, src)} to #{::File.join(release_path, dest)}: #{e.message}")
331
+ raise Chef::Exceptions::FileNotFound.new("Cannot symlink shared data #{::File.join(@new_resource.shared_path, src)} to #{::File.join(release_path, dest)}: #{e.message}")
352
332
  end
353
333
  end
354
- Chef::Log.info("#{new_resource} linked shared paths into current release: #{links_info}")
334
+ Chef::Log.info("#{@new_resource} linked shared paths into current release: #{links_info}")
355
335
  end
356
336
  run_symlinks_before_migrate
357
337
  enforce_ownership
358
338
  end
359
339
 
340
+ def create_dirs_before_symlink
341
+ end
342
+
360
343
  def purge_tempfiles_from_current_release
361
- log_info = purge_before_symlink.join(", ")
344
+ log_info = @new_resource.purge_before_symlink.join(", ")
362
345
  converge_by("purge directories in checkout #{log_info}") do
363
- purge_before_symlink.each { |dir| FileUtils.rm_rf(release_path + "/#{dir}") }
364
- Chef::Log.info("#{new_resource} purged directories in checkout #{log_info}")
346
+ @new_resource.purge_before_symlink.each { |dir| FileUtils.rm_rf(release_path + "/#{dir}") }
347
+ Chef::Log.info("#{@new_resource} purged directories in checkout #{log_info}")
365
348
  end
366
349
  end
367
350
 
@@ -411,10 +394,10 @@ class Chef
411
394
  end
412
395
 
413
396
  def run_options(run_opts={})
414
- run_opts[:user] = new_resource.user if new_resource.user
415
- run_opts[:group] = new_resource.group if new_resource.group
416
- run_opts[:environment] = new_resource.environment if new_resource.environment
417
- run_opts[:log_tag] = new_resource.to_s
397
+ run_opts[:user] = @new_resource.user if @new_resource.user
398
+ run_opts[:group] = @new_resource.group if @new_resource.group
399
+ run_opts[:environment] = @new_resource.environment if @new_resource.environment
400
+ run_opts[:log_tag] = @new_resource.to_s
418
401
  run_opts[:log_level] ||= :debug
419
402
  if run_opts[:log_level] == :info
420
403
  if STDOUT.tty? && !Chef::Config[:daemon] && Chef::Log.info?
@@ -425,7 +408,7 @@ class Chef
425
408
  end
426
409
 
427
410
  def run_callback_from_file(callback_file)
428
- Chef::Log.info "#{new_resource} queueing checkdeploy hook #{callback_file}"
411
+ Chef::Log.info "#{@new_resource} queueing checkdeploy hook #{callback_file}"
429
412
  recipe_eval do
430
413
  Dir.chdir(release_path) do
431
414
  from_file(callback_file) if ::File.exist?(callback_file)
@@ -435,20 +418,20 @@ class Chef
435
418
 
436
419
  def create_dir_unless_exists(dir)
437
420
  if ::File.directory?(dir)
438
- Chef::Log.debug "#{new_resource} not creating #{dir} because it already exists"
421
+ Chef::Log.debug "#{@new_resource} not creating #{dir} because it already exists"
439
422
  return false
440
423
  end
441
424
  converge_by("create new directory #{dir}") do
442
425
  begin
443
426
  FileUtils.mkdir_p(dir)
444
- Chef::Log.debug "#{new_resource} created directory #{dir}"
445
- if new_resource.user
446
- FileUtils.chown(new_resource.user, nil, dir)
447
- Chef::Log.debug("#{new_resource} set user to #{new_resource.user} for #{dir}")
427
+ Chef::Log.debug "#{@new_resource} created directory #{dir}"
428
+ if @new_resource.user
429
+ FileUtils.chown(@new_resource.user, nil, dir)
430
+ Chef::Log.debug("#{@new_resource} set user to #{@new_resource.user} for #{dir}")
448
431
  end
449
- if new_resource.group
450
- FileUtils.chown(nil, new_resource.group, dir)
451
- Chef::Log.debug("#{new_resource} set group to #{new_resource.group} for #{dir}")
432
+ if @new_resource.group
433
+ FileUtils.chown(nil, @new_resource.group, dir)
434
+ Chef::Log.debug("#{@new_resource} set group to #{@new_resource.group} for #{dir}")
452
435
  end
453
436
  rescue => e
454
437
  raise Chef::Exceptions::FileNotFound.new("Cannot create directory #{dir}: #{e.message}")
@@ -459,7 +442,7 @@ class Chef
459
442
  def with_rollback_on_error
460
443
  yield
461
444
  rescue ::Exception => e
462
- if new_resource.rollback_on_error
445
+ if @new_resource.rollback_on_error
463
446
  Chef::Log.warn "Error on deploying #{release_path}: #{e.message}"
464
447
  failed_release = release_path
465
448
 
@@ -478,8 +461,8 @@ class Chef
478
461
  end
479
462
 
480
463
  def save_release_state
481
- if ::File.exists?(new_resource.current_path)
482
- release = ::File.readlink(new_resource.current_path)
464
+ if ::File.exists?(@new_resource.current_path)
465
+ release = ::File.readlink(@new_resource.current_path)
483
466
  @previous_release_path = release if ::File.exists?(release)
484
467
  end
485
468
  end