Skip to content

Commit ed23573

Browse files
jjmmetafacebook-github-bot
authored andcommitted
fb_launchd support lazy enumerables
Differential Revision: D73820658 fbshipit-source-id: ee9d0bacf167dbc9b2b34c96b54c03981b2dd359
1 parent 468f8f2 commit ed23573

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

cookbooks/fb_launchd/resources/default.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,21 @@
4343
fail "fb_launchd: prefix '#{prefix}' must not end with a trailing '.'"
4444
end
4545

46+
managed_jobs = FB::Helpers.evaluate_lazy_enumerable(node['fb_launchd']['jobs'].to_hash).reject { |_k, v| v.nil? }
47+
4648
# Delete old jobs first.
4749
managed_plists(prefix).each do |path|
4850
label = ::File.basename(path, '.plist')
4951
name = label.sub(prefix + '.', '')
50-
next if node['fb_launchd']['jobs'].include?(name)
52+
next if managed_jobs.include?(name)
5153

5254
# Delete with 'path' specified to enforce that we delete the right one.
5355
Chef::Log.debug("fb_launchd: deleting #{label}")
5456
launchd_resource(label, :delete, { 'path' => path })
5557
end
5658

5759
# Set up current jobs.
58-
node['fb_launchd']['jobs'].each do |name, attrs|
60+
managed_jobs.each do |name, attrs|
5961
if attrs.keys.any? { |k| BLOCKLISTED_ATTRIBUTES.include?(k) }
6062
fail "fb_launchd[#{name}]: uses a blocklisted attribute (one of " +
6163
"#{BLOCKLISTED_ATTRIBUTES}). If you want to use them, create a " +

0 commit comments

Comments
 (0)