summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoah Kantrowitz <noah@coderanger.net>2015-02-19 13:16:02 -0800
committerBryan McLellan <btm@chef.io>2015-05-01 18:46:06 -0400
commitddb82fa280f5259790c7b6c7df08666a3f07b299 (patch)
tree6819b9fb26a621338f9943f086e69ba463ca9ee7
parent49c9146d86a019dd2bdc80c59b62e2c10bcd5412 (diff)
downloadchef-ddb82fa280f5259790c7b6c7df08666a3f07b299.tar.gz
Cache service_resource_providers for the duration of the run.
-rw-r--r--lib/chef/platform/service_helpers.rb42
1 files changed, 21 insertions, 21 deletions
diff --git a/lib/chef/platform/service_helpers.rb b/lib/chef/platform/service_helpers.rb
index dc0a808c06..d50812e687 100644
--- a/lib/chef/platform/service_helpers.rb
+++ b/lib/chef/platform/service_helpers.rb
@@ -42,34 +42,34 @@ class Chef
# different services is NOT a design concern of this module.
#
def service_resource_providers
- service_resource_providers = []
+ @service_resource_providers ||= [].tap do |service_resource_providers|
- if ::File.exist?("/usr/sbin/update-rc.d")
- service_resource_providers << :debian
- end
+ if ::File.exist?("/usr/sbin/update-rc.d")
+ service_resource_providers << :debian
+ end
- if ::File.exist?("/usr/sbin/invoke-rc.d")
- service_resource_providers << :invokercd
- end
+ if ::File.exist?("/usr/sbin/invoke-rc.d")
+ service_resource_providers << :invokercd
+ end
- if ::File.exist?("/sbin/insserv")
- service_resource_providers << :insserv
- end
+ if ::File.exist?("/sbin/insserv")
+ service_resource_providers << :insserv
+ end
- # debian >= 6.0 has /etc/init but does not have upstart
- if ::File.exist?("/etc/init") && ::File.exist?("/sbin/start")
- service_resource_providers << :upstart
- end
+ # debian >= 6.0 has /etc/init but does not have upstart
+ if ::File.exist?("/etc/init") && ::File.exist?("/sbin/start")
+ service_resource_providers << :upstart
+ end
- if ::File.exist?("/sbin/chkconfig")
- service_resource_providers << :redhat
- end
+ if ::File.exist?("/sbin/chkconfig")
+ service_resource_providers << :redhat
+ end
- if systemd_sanity_check?
- service_resource_providers << :systemd
- end
+ if systemd_sanity_check?
+ service_resource_providers << :systemd
+ end
- service_resource_providers
+ end
end
def config_for_service(service_name)