ohai 8.26.1 → 13.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +3 -4
  3. data/Rakefile +14 -0
  4. data/lib/ohai/application.rb +1 -0
  5. data/lib/ohai/config.rb +2 -88
  6. data/lib/ohai/dsl/plugin.rb +0 -4
  7. data/lib/ohai/exception.rb +0 -1
  8. data/lib/ohai/loader.rb +11 -2
  9. data/lib/ohai/log.rb +3 -1
  10. data/lib/ohai/mixin/command.rb +1 -318
  11. data/lib/ohai/mixin/do_metadata.rb +47 -0
  12. data/lib/ohai/mixin/ec2_metadata.rb +2 -29
  13. data/lib/ohai/mixin/gce_metadata.rb +0 -37
  14. data/lib/ohai/mixin/http_helper.rb +56 -0
  15. data/lib/ohai/mixin/network_constants.rb +0 -5
  16. data/lib/ohai/plugins/cloud.rb +144 -157
  17. data/lib/ohai/plugins/darwin/filesystem.rb +68 -22
  18. data/lib/ohai/plugins/digital_ocean.rb +24 -42
  19. data/lib/ohai/plugins/dmi.rb +81 -77
  20. data/lib/ohai/plugins/ec2.rb +33 -60
  21. data/lib/ohai/plugins/gce.rb +3 -1
  22. data/lib/ohai/plugins/hostname.rb +1 -16
  23. data/lib/ohai/plugins/linux/filesystem.rb +130 -81
  24. data/lib/ohai/plugins/linux/mdadm.rb +3 -45
  25. data/lib/ohai/plugins/linux/network.rb +1 -26
  26. data/lib/ohai/plugins/linux/platform.rb +4 -2
  27. data/lib/ohai/plugins/linux/virtualization.rb +1 -5
  28. data/lib/ohai/plugins/scala.rb +1 -13
  29. data/lib/ohai/plugins/solaris2/network.rb +1 -2
  30. data/lib/ohai/plugins/uptime.rb +0 -9
  31. data/lib/ohai/plugins/windows/cpu.rb +2 -1
  32. data/lib/ohai/plugins/windows/network.rb +1 -1
  33. data/lib/ohai/runner.rb +0 -5
  34. data/lib/ohai/system.rb +38 -8
  35. data/lib/ohai/version.rb +2 -2
  36. data/ohai.gemspec +1 -1
  37. data/spec/functional/application_spec.rb +0 -40
  38. data/spec/functional/plugins/powershell_spec.rb +1 -1
  39. data/spec/functional/plugins/root_group_spec.rb +1 -1
  40. data/spec/functional/plugins/windows/uptime_spec.rb +1 -1
  41. data/spec/ohai_spec.rb +1 -1
  42. data/spec/support/integration_helper.rb +17 -0
  43. data/spec/support/platform_helpers.rb +17 -0
  44. data/spec/unit/application_spec.rb +0 -1
  45. data/spec/unit/config_spec.rb +0 -111
  46. data/spec/unit/dsl/plugin_spec.rb +1 -1
  47. data/spec/unit/hints_spec.rb +1 -1
  48. data/spec/unit/loader_spec.rb +26 -1
  49. data/spec/unit/mixin/command_spec.rb +1 -69
  50. data/spec/unit/mixin/ec2_metadata_spec.rb +1 -1
  51. data/spec/unit/mixin/softlayer_metadata_spec.rb +1 -1
  52. data/spec/unit/plugin_config_spec.rb +0 -1
  53. data/spec/unit/plugins/abort_spec.rb +1 -1
  54. data/spec/unit/plugins/aix/cpu_spec.rb +1 -1
  55. data/spec/unit/plugins/aix/filesystem_spec.rb +2 -1
  56. data/spec/unit/plugins/aix/hostname_spec.rb +1 -1
  57. data/spec/unit/plugins/aix/kernel_spec.rb +1 -1
  58. data/spec/unit/plugins/aix/memory_spec.rb +1 -1
  59. data/spec/unit/plugins/aix/network_spec.rb +1 -1
  60. data/spec/unit/plugins/aix/os_spec.rb +1 -1
  61. data/spec/unit/plugins/aix/platform_spec.rb +1 -1
  62. data/spec/unit/plugins/aix/uptime_spec.rb +1 -1
  63. data/spec/unit/plugins/aix/virtualization_spec.rb +1 -1
  64. data/spec/unit/plugins/azure_spec.rb +1 -1
  65. data/spec/unit/plugins/bsd/filesystem_spec.rb +1 -1
  66. data/spec/unit/plugins/bsd/virtualization_spec.rb +1 -1
  67. data/spec/unit/plugins/c_spec.rb +1 -1
  68. data/spec/unit/plugins/chef_spec.rb +1 -2
  69. data/spec/unit/plugins/cloud_spec.rb +210 -50
  70. data/spec/unit/plugins/darwin/cpu_spec.rb +1 -1
  71. data/spec/unit/plugins/darwin/filesystem_spec.rb +62 -13
  72. data/spec/unit/plugins/darwin/hardware_spec.rb +2 -2
  73. data/spec/unit/plugins/darwin/hostname_spec.rb +1 -1
  74. data/spec/unit/plugins/darwin/kernel_spec.rb +1 -1
  75. data/spec/unit/plugins/darwin/memory_spec.rb +1 -1
  76. data/spec/unit/plugins/darwin/network_spec.rb +1 -1
  77. data/spec/unit/plugins/darwin/platform_spec.rb +1 -1
  78. data/spec/unit/plugins/darwin/system_profiler_spec.rb +2 -9
  79. data/spec/unit/plugins/darwin/virtualization_spec.rb +1 -1
  80. data/spec/unit/plugins/digital_ocean_spec.rb +39 -110
  81. data/spec/unit/plugins/dmi_spec.rb +1 -1
  82. data/spec/unit/plugins/ec2_spec.rb +10 -62
  83. data/spec/unit/plugins/elixir_spec.rb +1 -1
  84. data/spec/unit/plugins/erlang_spec.rb +1 -1
  85. data/spec/unit/plugins/eucalyptus_spec.rb +1 -1
  86. data/spec/unit/plugins/fail_spec.rb +1 -1
  87. data/spec/unit/plugins/freebsd/cpu_spec.rb +1 -1
  88. data/spec/unit/plugins/freebsd/hostname_spec.rb +1 -1
  89. data/spec/unit/plugins/freebsd/kernel_spec.rb +1 -1
  90. data/spec/unit/plugins/freebsd/os_spec.rb +1 -1
  91. data/spec/unit/plugins/freebsd/platform_spec.rb +1 -1
  92. data/spec/unit/plugins/gce_spec.rb +1 -1
  93. data/spec/unit/plugins/go_spec.rb +1 -1
  94. data/spec/unit/plugins/groovy_spec.rb +1 -1
  95. data/spec/unit/plugins/haskell_spec.rb +1 -1
  96. data/spec/unit/plugins/hostname_spec.rb +16 -41
  97. data/spec/unit/plugins/init_package_spec.rb +1 -1
  98. data/spec/unit/plugins/ip_scopes_spec.rb +18 -6
  99. data/spec/unit/plugins/java_spec.rb +1 -1
  100. data/spec/unit/plugins/joyent_spec.rb +17 -1
  101. data/spec/unit/plugins/kernel_spec.rb +1 -1
  102. data/spec/unit/plugins/linode_spec.rb +1 -1
  103. data/spec/unit/plugins/linux/block_device_spec.rb +1 -1
  104. data/spec/unit/plugins/linux/cpu_spec.rb +1 -2
  105. data/spec/unit/plugins/linux/filesystem_spec.rb +207 -201
  106. data/spec/unit/plugins/linux/fips_spec.rb +1 -1
  107. data/spec/unit/plugins/linux/hostname_spec.rb +1 -1
  108. data/spec/unit/plugins/linux/hostnamectl_spec.rb +1 -1
  109. data/spec/unit/plugins/linux/kernel_spec.rb +1 -1
  110. data/spec/unit/plugins/linux/lsb_spec.rb +1 -1
  111. data/spec/unit/plugins/linux/machineid_spec.rb +1 -1
  112. data/spec/unit/plugins/linux/mdadm_spec.rb +2 -68
  113. data/spec/unit/plugins/linux/memory_spec.rb +1 -1
  114. data/spec/unit/plugins/linux/network_spec.rb +3 -44
  115. data/spec/unit/plugins/linux/platform_spec.rb +4 -4
  116. data/spec/unit/plugins/linux/sessions_spec.rb +1 -1
  117. data/spec/unit/plugins/linux/uptime_spec.rb +1 -1
  118. data/spec/unit/plugins/linux/virtualization_spec.rb +1 -28
  119. data/spec/unit/plugins/lua_spec.rb +1 -1
  120. data/spec/unit/plugins/mono_spec.rb +1 -1
  121. data/spec/unit/plugins/netbsd/hostname_spec.rb +1 -1
  122. data/spec/unit/plugins/netbsd/kernel_spec.rb +1 -1
  123. data/spec/unit/plugins/netbsd/platform_spec.rb +1 -1
  124. data/spec/unit/plugins/network_spec.rb +1 -1
  125. data/spec/unit/plugins/nodejs_spec.rb +1 -1
  126. data/spec/unit/plugins/ohai_spec.rb +1 -1
  127. data/spec/unit/plugins/ohai_time_spec.rb +1 -1
  128. data/spec/unit/plugins/openbsd/hostname_spec.rb +1 -1
  129. data/spec/unit/plugins/openbsd/kernel_spec.rb +1 -1
  130. data/spec/unit/plugins/openbsd/platform_spec.rb +1 -1
  131. data/spec/unit/plugins/openstack_spec.rb +2 -3
  132. data/spec/unit/plugins/os_spec.rb +1 -1
  133. data/spec/unit/plugins/packages_spec.rb +1 -1
  134. data/spec/unit/plugins/passwd_spec.rb +17 -1
  135. data/spec/unit/plugins/perl_spec.rb +1 -1
  136. data/spec/unit/plugins/php_spec.rb +1 -1
  137. data/spec/unit/plugins/platform_spec.rb +1 -1
  138. data/spec/unit/plugins/powershell_spec.rb +1 -1
  139. data/spec/unit/plugins/python_spec.rb +1 -1
  140. data/spec/unit/plugins/rackspace_spec.rb +1 -2
  141. data/spec/unit/plugins/root_group_spec.rb +2 -2
  142. data/spec/unit/plugins/ruby_spec.rb +1 -1
  143. data/spec/unit/plugins/rust_spec.rb +1 -1
  144. data/spec/unit/plugins/scala_spec.rb +3 -37
  145. data/spec/unit/plugins/shard_spec.rb +1 -1
  146. data/spec/unit/plugins/shells_spec.rb +1 -1
  147. data/spec/unit/plugins/softlayer_spec.rb +1 -1
  148. data/spec/unit/plugins/solaris2/cpu_spec.rb +1 -1
  149. data/spec/unit/plugins/solaris2/dmi_spec.rb +1 -1
  150. data/spec/unit/plugins/solaris2/hostname_spec.rb +1 -1
  151. data/spec/unit/plugins/solaris2/kernel_spec.rb +1 -1
  152. data/spec/unit/plugins/solaris2/memory_spec.rb +1 -1
  153. data/spec/unit/plugins/solaris2/network_spec.rb +7 -4
  154. data/spec/unit/plugins/solaris2/platform_spec.rb +1 -1
  155. data/spec/unit/plugins/solaris2/virtualization_spec.rb +1 -1
  156. data/spec/unit/plugins/solaris2/zpools_spec.rb +1 -1
  157. data/spec/unit/plugins/ssh_host_keys_spec.rb +1 -1
  158. data/spec/unit/plugins/sysconf_spec.rb +1 -1
  159. data/spec/unit/plugins/timezone_spec.rb +1 -1
  160. data/spec/unit/plugins/virtualbox_spec.rb +1 -1
  161. data/spec/unit/plugins/vmware_spec.rb +2 -1
  162. data/spec/unit/plugins/windows/cpu_spec.rb +9 -2
  163. data/spec/unit/plugins/windows/fips_spec.rb +1 -1
  164. data/spec/unit/plugins/windows/memory_spec.rb +1 -1
  165. data/spec/unit/plugins/windows/uptime_spec.rb +1 -1
  166. data/spec/unit/plugins/windows/virtualization_spec.rb +1 -1
  167. data/spec/unit/provides_map_spec.rb +1 -1
  168. data/spec/unit/runner_spec.rb +1 -1
  169. data/spec/unit/system_spec.rb +68 -76
  170. data/spec/unit/util/file_helper_spec.rb +1 -1
  171. data/spec/unit/util/ip_helper_spec.rb +1 -1
  172. metadata +6 -20
  173. data/lib/ohai/plugins/cloud_v2.rb +0 -315
  174. data/lib/ohai/plugins/darwin/filesystem2.rb +0 -107
  175. data/lib/ohai/plugins/linux/filesystem2.rb +0 -223
  176. data/lib/ohai/plugins/linux/lspci.rb +0 -76
  177. data/lib/ohai/plugins/network_listeners.rb +0 -60
  178. data/lib/ohai/plugins/sigar/cpu.rb +0 -44
  179. data/lib/ohai/plugins/sigar/filesystem.rb +0 -50
  180. data/lib/ohai/plugins/sigar/memory.rb +0 -39
  181. data/lib/ohai/plugins/sigar/network.rb +0 -168
  182. data/lib/ohai/plugins/sigar/network_route.rb +0 -64
  183. data/lib/ohai/plugins/sigar/platform.rb +0 -30
  184. data/spec/unit/plugins/cloud_v2_spec.rb +0 -389
  185. data/spec/unit/plugins/darwin/filesystem2_spec.rb +0 -139
  186. data/spec/unit/plugins/linux/filesystem2_spec.rb +0 -437
  187. data/spec/unit/plugins/linux/lspci_spec.rb +0 -133
  188. data/spec/unit/plugins/sigar/network_route_spec.rb +0 -148
@@ -26,10 +26,6 @@ Ohai.plugin(:Virtualization) do
26
26
  which("lxc-version")
27
27
  end
28
28
 
29
- def docker_exists?
30
- which("docker")
31
- end
32
-
33
29
  def nova_exists?
34
30
  which("nova")
35
31
  end
@@ -185,7 +181,7 @@ Ohai.plugin(:Virtualization) do
185
181
  if File.exist?("/proc/self/cgroup")
186
182
  cgroup_content = File.read("/proc/self/cgroup")
187
183
  if cgroup_content =~ %r{^\d+:[^:]+:/(lxc|docker)/.+$} ||
188
- cgroup_content =~ %r{^\d+:[^:]+:/[^/]+/(lxc|docker)-?.+$}
184
+ cgroup_content =~ %r{^\d+:[^:]+:/[^/]+/(lxc|docker)-.+$}
189
185
  Ohai::Log.debug("Plugin Virtualization: /proc/self/cgroup indicates #{$1} container. Detecting as #{$1} guest")
190
186
  virtualization[:system] = $1
191
187
  virtualization[:role] = "guest"
@@ -15,7 +15,7 @@
15
15
  # limitations under the License.
16
16
 
17
17
  Ohai.plugin(:Scala) do
18
- provides "languages/scala", "languages/scala/sbt"
18
+ provides "languages/scala"
19
19
  depends "languages"
20
20
 
21
21
  collect_data(:default) do
@@ -32,18 +32,6 @@ Ohai.plugin(:Scala) do
32
32
  Ohai::Log.debug('Plugin Scala: Could not shell_out "scala -version". Skipping data')
33
33
  end
34
34
 
35
- # Check for sbt
36
- begin
37
- # sbt launcher version 0.13.7
38
- so = shell_out("sbt --version", timeout: 5)
39
- if so.exitstatus == 0
40
- scala[:sbt] = Mash.new
41
- scala[:sbt][:version] = so.stdout.split[3]
42
- end
43
- rescue Ohai::Exceptions::Exec
44
- Ohai::Log.debug('Plugin Scala: Could not shell_out "sbt --version". Skipping data')
45
- end
46
-
47
35
  languages[:scala] = scala unless scala.empty?
48
36
  end
49
37
  end
@@ -103,8 +103,7 @@ Ohai.plugin(:Network) do
103
103
  cint = nil
104
104
 
105
105
  so.stdout.lines do |line|
106
- # regex: http://rubular.com/r/Iag7JLVTVe
107
- if line =~ /^([0-9a-zA-Z\.\:\-]+): \S+ mtu (\d+) index (\d+)/
106
+ if line =~ /^([0-9a-zA-Z\.\:\-]+)\S/
108
107
  cint = $1
109
108
  iface[cint] = Mash.new unless iface[cint]
110
109
  iface[cint][:mtu] = $2
@@ -43,15 +43,6 @@ Ohai.plugin(:Uptime) do
43
43
  return [nil, nil]
44
44
  end
45
45
 
46
- collect_data(:hpux, :default) do
47
- require "sigar"
48
-
49
- sigar = Sigar.new
50
- uptime = sigar.uptime.uptime
51
- uptime_seconds uptime.to_i * 1000
52
- uptime seconds_to_human(uptime.to_i)
53
- end
54
-
55
46
  collect_data(:darwin) do
56
47
  data = collect_uptime("/usr/sbin/sysctl")
57
48
  uptime_seconds data.first
@@ -60,7 +60,8 @@ Ohai.plugin(:CPU) do
60
60
  processor["stepping"]
61
61
  end
62
62
  cpu[current_cpu]["physical_id"] = processor["deviceid"]
63
- cpu[current_cpu]["model_name"] = processor["description"]
63
+ cpu[current_cpu]["model_name"] = processor["name"]
64
+ cpu[current_cpu]["description"] = processor["description"]
64
65
  cpu[current_cpu]["mhz"] = processor["maxclockspeed"].to_s
65
66
  cpu[current_cpu]["cache_size"] = "#{processor['l2cachesize']} KB"
66
67
  end
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: James Gartrell (<jgartrel@gmail.com>)
3
- # Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
3
+ # Copyright:: Copyright (c) 2008-2017, Chef Software Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
data/lib/ohai/runner.rb CHANGED
@@ -22,13 +22,11 @@ require "ohai/dsl"
22
22
  module Ohai
23
23
  class Runner
24
24
 
25
- attr_reader :failed_plugins
26
25
  # safe_run: set to true if this runner will run plugins in
27
26
  # safe-mode. default false.
28
27
  def initialize(controller, safe_run = false)
29
28
  @provides_map = controller.provides_map
30
29
  @safe_run = safe_run
31
- @failed_plugins = []
32
30
  end
33
31
 
34
32
  # Runs plugins and any un-run dependencies.
@@ -84,9 +82,6 @@ module Ohai
84
82
 
85
83
  if dependency_providers.empty?
86
84
  @safe_run ? next_plugin.safe_run : next_plugin.run
87
- if next_plugin.failed
88
- @failed_plugins << next_plugin.name
89
- end
90
85
  else
91
86
  visited << next_plugin << dependency_providers.first
92
87
  end
data/lib/ohai/system.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Adam Jacob (<adam@chef.io>)
3
- # Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
3
+ # Copyright:: Copyright (c) 2008-2017, Chef Software Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -39,10 +39,14 @@ module Ohai
39
39
  attr_reader :provides_map
40
40
  attr_reader :v6_dependency_solver
41
41
 
42
+ # the cli flag is used to determine if we're being constructed by
43
+ # something like chef-client (which doesn't not set this flag) and
44
+ # which sets up its own loggers, or if we're coming from Ohai::Application
45
+ # and therefore need to configure Ohai's own logger.
42
46
  def initialize(config = {})
47
+ @cli = config[:invoked_from_cli]
43
48
  @plugin_path = ""
44
49
  @config = config
45
- @failed_plugins = []
46
50
  reset_system
47
51
  end
48
52
 
@@ -52,7 +56,7 @@ module Ohai
52
56
  @v6_dependency_solver = Hash.new
53
57
 
54
58
  configure_ohai
55
- configure_logging
59
+ configure_logging if @cli
56
60
 
57
61
  @loader = Ohai::Loader.new(self)
58
62
  @runner = Ohai::Runner.new(self, true)
@@ -103,11 +107,18 @@ module Ohai
103
107
  Ohai::Log.error("Encountered error while running plugins: #{e.inspect}")
104
108
  raise
105
109
  end
106
- critical_failed = Ohai::Config.ohai[:critical_plugins] & @runner.failed_plugins
107
- unless critical_failed.empty?
108
- msg = "The following Ohai plugins marked as critical failed: #{critical_failed}. Exiting."
109
- raise Ohai::Exceptions::CriticalPluginFailure, msg
110
+
111
+ # Freeze all strings.
112
+ freeze_strings!
113
+ end
114
+
115
+ def run_additional_plugins(plugin_path)
116
+ @loader.load_additional(plugin_path).each do |plugin|
117
+ Ohai::Log.debug "Running plugin #{plugin}"
118
+ @runner.run_plugin(plugin)
110
119
  end
120
+
121
+ freeze_strings!
111
122
  end
112
123
 
113
124
  def have_v6_plugin?(name)
@@ -215,7 +226,6 @@ module Ohai
215
226
  private
216
227
 
217
228
  def configure_ohai
218
- Ohai::Config.merge_deprecated_config
219
229
  Ohai.config.merge!(@config)
220
230
 
221
231
  if Ohai.config[:directory] &&
@@ -233,5 +243,25 @@ module Ohai
233
243
  Ohai::Log.level = Ohai.config[:log_level]
234
244
  end
235
245
  end
246
+
247
+ # Freeze all string values in @data. This makes them immutable and saves
248
+ # a bit of RAM.
249
+ #
250
+ # @api private
251
+ # @return [void]
252
+ def freeze_strings!
253
+ # Recursive visitor pattern helper.
254
+ visitor = lambda do |val|
255
+ case val
256
+ when Hash
257
+ val.each_value { |v| visitor.call(v) }
258
+ when Array
259
+ val.each { |v| visitor.call(v) }
260
+ when String
261
+ val.freeze
262
+ end
263
+ end
264
+ visitor.call(@data)
265
+ end
236
266
  end
237
267
  end
data/lib/ohai/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Adam Jacob (<adam@chef.io>)
3
- # Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
3
+ # Copyright:: Copyright (c) 2008-2017, Chef Software Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,5 +18,5 @@
18
18
 
19
19
  module Ohai
20
20
  OHAI_ROOT = File.expand_path(File.dirname(__FILE__))
21
- VERSION = "8.26.1"
21
+ VERSION = "13.0.0"
22
22
  end
data/ohai.gemspec CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
  s.email = "adam@chef.io"
14
14
  s.homepage = "https://docs.chef.io/ohai.html"
15
15
 
16
- s.required_ruby_version = ">= 2.1.0"
16
+ s.required_ruby_version = ">= 2.3"
17
17
 
18
18
  s.add_dependency "systemu", "~> 2.6.4"
19
19
  s.add_dependency "ffi-yajl", "~> 2.2"
@@ -17,7 +17,6 @@
17
17
  #
18
18
 
19
19
  require_relative "../spec_helper"
20
-
21
20
  require "ohai/application"
22
21
 
23
22
  RSpec.describe "Ohai::Application" do
@@ -86,45 +85,6 @@ RSpec.describe "Ohai::Application" do
86
85
  end
87
86
  end
88
87
 
89
- context "when the configuration file contains deprecated config options" do
90
- # For the purpose of these tests it doesn't matter if the configuration
91
- # file was specified via command line or discovered on the local
92
- # workstation. It's easier if we pass the configuration file as a cli
93
- # argument (there's less to stub).
94
-
95
- let(:argv) { [ "-c", config_location ] }
96
-
97
- let(:config_content) do
98
- <<-CONFIG
99
- log_location "#{log_location}"
100
- log_level :#{log_level}
101
- Ohai::Config[:disabled_plugins] = #{disabled_plugins}
102
- Ohai::Config[:plugin_path] << "#{plugin_path}"
103
- CONFIG
104
- end
105
-
106
- # config settings
107
- let(:disabled_plugins) { [ :Foo, :Baz ] }
108
-
109
- let(:log_level) { :debug }
110
-
111
- let(:log_location) { "path/to/log" }
112
-
113
- let(:plugin_path) { "/path/to/plugins" }
114
-
115
- it "logs warnings for deprecated top-level options" do
116
- # deprecation warnings for options need to be stubbed in the order
117
- # they are received, in this case it's the order they appear in the
118
- # configuration file.
119
- options = [ :log_location, :log_level, :disabled_plugins ]
120
- options.each do |option|
121
- expect(Ohai::Log).to receive(:warn).
122
- with(/Ohai::Config\[:#{option}\] is deprecated/)
123
- end
124
- app.configure_ohai
125
- end
126
- end
127
-
128
88
  context "when the configuration file has a syntax error" do
129
89
  # For the purpose of these tests it doesn't matter if the configuration
130
90
  # file was specified via command line or discovered on the local
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb")
19
+ require_relative "../../spec_helper.rb"
20
20
 
21
21
  describe Ohai::System, "languages plugin" do
22
22
  VERSION_MATCHING_REGEX = /^(?:[\d]+\.)+[\d]+$/
@@ -18,7 +18,7 @@
18
18
  # limitations under the License.
19
19
  #
20
20
 
21
- require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb")
21
+ require_relative "../../spec_helper.rb"
22
22
 
23
23
  describe Ohai::System, "root_group plugin" do
24
24
  let(:plugin) { get_plugin("root_group") }
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb")
19
+ require_relative "../../../spec_helper.rb"
20
20
 
21
21
  describe Ohai::System, "Windows plugin uptime" do
22
22
 
data/spec/ohai_spec.rb CHANGED
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require File.expand_path(File.dirname(__FILE__) + "/spec_helper.rb")
19
+ require_relative "spec_helper.rb"
20
20
 
21
21
  describe Ohai do
22
22
 
@@ -1,3 +1,20 @@
1
+ #
2
+ # License:: Apache License, Version 2.0
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License"); you
5
+ # may not use this file except in compliance with the License. You may
6
+ # obtain a copy of the license at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expressed or
13
+ # implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License
16
+ #
17
+
1
18
  require "tmpdir"
2
19
 
3
20
  module IntegrationSupport
@@ -1,3 +1,20 @@
1
+ #
2
+ # License:: Apache License, Version 2.0
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License"); you
5
+ # may not use this file except in compliance with the License. You may
6
+ # obtain a copy of the license at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expressed or
13
+ # implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License
16
+ #
17
+
1
18
  def windows?
2
19
  !!(RUBY_PLATFORM =~ /mswin|mingw|windows/)
3
20
  end
@@ -17,7 +17,6 @@
17
17
  #
18
18
 
19
19
  require_relative "../spec_helper"
20
-
21
20
  require "ohai/application"
22
21
 
23
22
  RSpec.describe "Ohai::Application" do
@@ -17,79 +17,10 @@
17
17
  #
18
18
 
19
19
  require_relative "../spec_helper"
20
-
21
20
  require "ohai/config"
22
21
 
23
22
  RSpec.describe Ohai::Config do
24
23
 
25
- describe "top-level configuration options" do
26
- shared_examples_for "option" do
27
- it "logs a deprecation warning and sets the value" do
28
- expect(Ohai::Log).to receive(:warn).
29
- with(/Ohai::Config\[:#{option}\] is deprecated/)
30
- Ohai::Config[option] = value
31
- expect(Ohai::Config[option]).to eq(value)
32
- end
33
- end
34
-
35
- shared_examples_for "appendable option" do
36
- it "sets the value" do
37
- expect(Ohai::Log).to_not receive(:warn)
38
- Ohai::Config[option] << value
39
- expect(Ohai::Config[option]).to include(value)
40
- end
41
- end
42
-
43
- describe ":directory" do
44
- include_examples "option" do
45
- let(:option) { :directory }
46
- let(:value) { "/some/fantastic/plugins" }
47
- end
48
- end
49
-
50
- describe ":disabled_plugins" do
51
- include_examples "option" do
52
- let(:option) { :disabled_plugins }
53
- let(:value) { [ :Foo, :Baz ] }
54
- end
55
- end
56
-
57
- describe ":hints_path" do
58
- include_examples "appendable option" do
59
- let(:option) { :hints_path }
60
- let(:value) { "/some/helpful/hints" }
61
- end
62
- end
63
-
64
- describe ":log_level" do
65
- include_examples "option" do
66
- let(:option) { :log_level }
67
- let(:value) { :cheese }
68
- end
69
- end
70
-
71
- describe ":log_location" do
72
- include_examples "option" do
73
- let(:option) { :log_location }
74
- let(:value) { "/etc/chef/cache/loooogs" }
75
- end
76
- end
77
-
78
- describe ":plugin_path" do
79
- include_examples "appendable option" do
80
- let(:option) { :plugin_path }
81
- let(:value) { "/some/fantastic/plugins" }
82
- end
83
- end
84
-
85
- describe ":version" do
86
- include_examples "option" do
87
- let(:option) { :version }
88
- let(:value) { "8.2.0" }
89
- end
90
- end
91
- end
92
-
93
24
  describe "config_context :ohai" do
94
25
  describe "option :plugin" do
95
26
  it "gets configured with a value" do
@@ -118,48 +49,6 @@ RSpec.describe Ohai::Config do
118
49
  end
119
50
  end
120
51
 
121
- describe "::merge_deprecated_config" do
122
- before(:each) do
123
- allow(Ohai::Log).to receive(:warn)
124
- configure_ohai
125
- end
126
-
127
- def configure_ohai
128
- Ohai::Config[:directory] = "/some/fantastic/plugins"
129
- Ohai::Config[:disabled_plugins] = [ :Foo, :Baz ]
130
- Ohai::Config[:log_level] = :debug
131
- end
132
-
133
- it "merges top-level config values into the ohai config context" do
134
- Ohai::Config.merge_deprecated_config
135
- expect(Ohai::Config.ohai.configuration).to eq (Ohai::Config.configuration)
136
- end
137
-
138
- shared_examples_for "delayed warn" do
139
- it "logs a deprecation warning and merges the value" do
140
- expect(Ohai::Log).to receive(:warn).
141
- with(/Ohai::Config\[:#{option}\] is deprecated/)
142
- Ohai::Config[option] << value
143
- Ohai::Config.merge_deprecated_config
144
- expect(Ohai::Config.ohai[option]).to include(value)
145
- end
146
- end
147
-
148
- context "when :hints_path is set" do
149
- include_examples "delayed warn" do
150
- let(:option) { :hints_path }
151
- let(:value) { "/some/helpful/hints" }
152
- end
153
- end
154
-
155
- context "when :plugin_path is set" do
156
- include_examples "delayed warn" do
157
- let(:option) { :plugin_path }
158
- let(:value) { "/some/fantastic/plugins" }
159
- end
160
- end
161
- end
162
-
163
52
  describe "Ohai.config" do
164
53
  it "returns the ohai config context" do
165
54
  expect(Ohai.config).to eq(Ohai::Config.ohai)