summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2015-09-28 17:34:31 -0700
committerJohn Keiser <john@johnkeiser.com>2015-09-28 17:34:55 -0700
commit6d08f7dd73b11394c0c899f285dbb7ff21bb1b89 (patch)
tree484fa2156a3b13238bb378aff0f891cf8d14ee3a
parentb8cffc2e35c662585acff290b27f072c60105479 (diff)
downloadchef-jk/systemctl-shenanigans.tar.gz
Get rid of state-keeping and reset in ServiceHelpersjk/systemctl-shenanigans
-rw-r--r--lib/chef/platform/service_helpers.rb50
-rw-r--r--spec/spec_helper.rb1
2 files changed, 19 insertions, 32 deletions
diff --git a/lib/chef/platform/service_helpers.rb b/lib/chef/platform/service_helpers.rb
index 8a840b91c3..39457a5d17 100644
--- a/lib/chef/platform/service_helpers.rb
+++ b/lib/chef/platform/service_helpers.rb
@@ -43,33 +43,29 @@ class Chef
# different services is NOT a design concern of this module.
#
def service_resource_providers
- @service_resource_providers ||= [].tap do |service_resource_providers|
-
- if ::File.exist?(Chef.path_to("/usr/sbin/update-rc.d"))
- service_resource_providers << :debian
- end
-
- if ::File.exist?(Chef.path_to("/usr/sbin/invoke-rc.d"))
- service_resource_providers << :invokercd
- end
+ if ::File.exist?(Chef.path_to("/usr/sbin/update-rc.d"))
+ service_resource_providers << :debian
+ end
- if ::File.exist?(Chef.path_to("/sbin/insserv"))
- service_resource_providers << :insserv
- end
+ if ::File.exist?(Chef.path_to("/usr/sbin/invoke-rc.d"))
+ service_resource_providers << :invokercd
+ end
- # debian >= 6.0 has /etc/init but does not have upstart
- if ::File.exist?(Chef.path_to("/etc/init")) && ::File.exist?(Chef.path_to("/sbin/start"))
- service_resource_providers << :upstart
- end
+ if ::File.exist?(Chef.path_to("/sbin/insserv"))
+ service_resource_providers << :insserv
+ end
- if ::File.exist?(Chef.path_to("/sbin/chkconfig"))
- service_resource_providers << :redhat
- end
+ # debian >= 6.0 has /etc/init but does not have upstart
+ if ::File.exist?(Chef.path_to("/etc/init")) && ::File.exist?(Chef.path_to("/sbin/start"))
+ service_resource_providers << :upstart
+ end
- if systemd_sanity_check?
- service_resource_providers << :systemd
- end
+ if ::File.exist?(Chef.path_to("/sbin/chkconfig"))
+ service_resource_providers << :redhat
+ end
+ if systemd_sanity_check?
+ service_resource_providers << :systemd
end
end
@@ -103,18 +99,10 @@ class Chef
configs
end
- def reset
- @service_resource_providers = nil
- @systemctl_path = nil
- end
-
private
def systemctl_path
- if @systemctl_path.nil?
- @systemctl_path = which("systemctl")
- end
- @systemctl_path
+ which("systemctl")
end
def systemd_sanity_check?
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index f4bb1a6819..92a4daf6d5 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -190,7 +190,6 @@ RSpec.configure do |config|
Chef.reset!
Chef::Config.reset
- Chef::Platform::ServiceHelpers.reset
# By default, treat deprecation warnings as errors in tests.
Chef::Config.treat_deprecation_warnings_as_errors(true)