diff options
author | John McCrae <john.mccrae@progress.com> | 2022-04-07 15:45:49 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-07 15:45:49 -0700 |
commit | 3ccfc28cdf9d6320f0e576026c27dd51cfb28240 (patch) | |
tree | 6e95b1dd6e975cbf646737a6d43407b7717cfcfb | |
parent | db6480f47f37954b9d3ac1fbb7837fbdb474646a (diff) | |
parent | bc545a24c0b76ba9281ec733cc42e8f440b01c0f (diff) | |
download | ohai-3ccfc28cdf9d6320f0e576026c27dd51cfb28240.tar.gz |
Merge pull request #1744 from chef/jfm/ohai_ruby3.1
-rw-r--r-- | .github/CODEOWNERS | 2 | ||||
-rw-r--r-- | .github/workflows/unit.yml | 4 | ||||
-rw-r--r-- | lib/ohai/mixin/os.rb | 2 | ||||
-rw-r--r-- | lib/ohai/plugins/azure.rb | 6 | ||||
-rw-r--r-- | lib/ohai/plugins/ec2.rb | 2 | ||||
-rw-r--r-- | lib/ohai/plugins/gce.rb | 2 | ||||
-rw-r--r-- | lib/ohai/plugins/openstack.rb | 2 | ||||
-rw-r--r-- | lib/ohai/plugins/rackspace.rb | 2 | ||||
-rw-r--r-- | spec/unit/mixin/shell_out_spec.rb | 4 | ||||
-rw-r--r-- | spec/unit/plugins/azure_spec.rb | 5 |
10 files changed, 20 insertions, 11 deletions
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index ab984170..be56701b 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,5 +1,5 @@ # Order is important. The last matching pattern has the most precedence. * @chef/chef-infra-reviewers @chef/chef-infra-approvers @chef/chef-infra-owners -.expeditor/ @chef/jex-team +.expeditor/ @chef/infra-packages *.md @chef/docs-team diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml index 5d4b02eb..9bc13e99 100644 --- a/.github/workflows/unit.yml +++ b/.github/workflows/unit.yml @@ -15,9 +15,11 @@ jobs: fail-fast: false matrix: os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] - ruby: ['2.7', '3.0'] + ruby: ['2.7', '3.0', '3.1'] name: Unit test on ${{ matrix.os }} with Ruby ${{ matrix.ruby }} runs-on: ${{ matrix.os }} + env: + RUBYOPT: '--disable-error_highlight' steps: - uses: actions/checkout@v2 - uses: ruby/setup-ruby@v1 diff --git a/lib/ohai/mixin/os.rb b/lib/ohai/mixin/os.rb index 44d3686f..a6bfdf46 100644 --- a/lib/ohai/mixin/os.rb +++ b/lib/ohai/mixin/os.rb @@ -110,7 +110,7 @@ module Ohai "dragonflybsd" when /solaris2/ "solaris2" - when /mswin|mingw32|windows/ + when /mswin|mingw|windows/ # After long discussion in IRC the "powers that be" have come to a consensus # that no Windows platform exists that was not based on the # Windows_NT kernel, so we herby decree that "windows" will refer to all diff --git a/lib/ohai/plugins/azure.rb b/lib/ohai/plugins/azure.rb index c21b8ac7..008a9a21 100644 --- a/lib/ohai/plugins/azure.rb +++ b/lib/ohai/plugins/azure.rb @@ -73,9 +73,11 @@ Ohai.plugin(:Azure) do end def tcp_ip_dhcp_domain - return unless RUBY_PLATFORM.match?(/mswin|mingw32|windows/) + return unless RUBY_PLATFORM.match?(/mswin|mingw|windows/) - require "win32/registry" unless defined?(Win32::Registry) + if ChefUtils.windows? + require "win32/registry" unless defined?(Win32::Registry) + end begin key = Win32::Registry::HKEY_LOCAL_MACHINE.open("SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters") diff --git a/lib/ohai/plugins/ec2.rb b/lib/ohai/plugins/ec2.rb index 79c124fe..5799d838 100644 --- a/lib/ohai/plugins/ec2.rb +++ b/lib/ohai/plugins/ec2.rb @@ -81,7 +81,7 @@ Ohai.plugin(:EC2) do # linux hosts # @return [Boolean] do we have a Xen Identifying Number or not? def has_ec2_identifying_number? - if RUBY_PLATFORM.match?(/mswin|mingw32|windows/) + if RUBY_PLATFORM.match?(/mswin|mingw|windows/) require "wmi-lite/wmi" unless defined?(WmiLite::Wmi) wmi = WmiLite::Wmi.new if /^ec2/.match?(wmi.first_of("Win32_ComputerSystemProduct")["identifyingnumber"]) diff --git a/lib/ohai/plugins/gce.rb b/lib/ohai/plugins/gce.rb index 90d63e96..fdfce390 100644 --- a/lib/ohai/plugins/gce.rb +++ b/lib/ohai/plugins/gce.rb @@ -49,7 +49,7 @@ Ohai.plugin(:GCE) do # looks at the Manufacturer and Model WMI values to see if they starts with Google. # @return [Boolean] Are the manufacturer and model Google? def has_gce_system_info? - if RUBY_PLATFORM.match?(/mswin|mingw32|windows/) + if RUBY_PLATFORM.match?(/mswin|mingw|windows/) require "wmi-lite/wmi" unless defined?(WmiLite::Wmi) wmi = WmiLite::Wmi.new computer_system = wmi.first_of("Win32_ComputerSystem") diff --git a/lib/ohai/plugins/openstack.rb b/lib/ohai/plugins/openstack.rb index 1c1f7abc..b851ef02 100644 --- a/lib/ohai/plugins/openstack.rb +++ b/lib/ohai/plugins/openstack.rb @@ -49,7 +49,7 @@ Ohai.plugin(:Openstack) do # https://help.dreamhost.com/hc/en-us/articles/228377408-How-to-find-the-default-user-of-an-image def openstack_provider # dream host doesn't support windows so bail early if we're on windows - return "openstack" if RUBY_PLATFORM.match?(/mswin|mingw32|windows/) + return "openstack" if RUBY_PLATFORM.match?(/mswin|mingw|windows/) if Etc::Passwd.entries.map(&:name).include?("dhc-user") "dreamhost" diff --git a/lib/ohai/plugins/rackspace.rb b/lib/ohai/plugins/rackspace.rb index 469290b6..b7a1a795 100644 --- a/lib/ohai/plugins/rackspace.rb +++ b/lib/ohai/plugins/rackspace.rb @@ -48,7 +48,7 @@ Ohai.plugin(:Rackspace) do # true:: If the rackspace cloud can be identified # false:: Otherwise def has_rackspace_manufacturer? - return false unless RUBY_PLATFORM.match?(/mswin|mingw32|windows/) + return false unless RUBY_PLATFORM.match?(/mswin|mingw|windows/) require "wmi-lite/wmi" unless defined?(WmiLite::Wmi) wmi = WmiLite::Wmi.new diff --git a/spec/unit/mixin/shell_out_spec.rb b/spec/unit/mixin/shell_out_spec.rb index 7d08d9ff..d696546e 100644 --- a/spec/unit/mixin/shell_out_spec.rb +++ b/spec/unit/mixin/shell_out_spec.rb @@ -63,14 +63,14 @@ describe Ohai::Mixin::ShellOut, "shell_out" do let(:instance) { DummyPlugin.new } - before do + before(:each) do allow(instance).to receive(:logger).and_return(logger) allow(instance).to receive(:name).and_return(plugin_name) @original_env = ENV.to_hash ENV.clear end - after do + after(:each) do ENV.clear ENV.update(@original_env) end diff --git a/spec/unit/plugins/azure_spec.rb b/spec/unit/plugins/azure_spec.rb index 4d875e80..f1950f46 100644 --- a/spec/unit/plugins/azure_spec.rb +++ b/spec/unit/plugins/azure_spec.rb @@ -17,6 +17,11 @@ # require "spec_helper" +begin + require "win32/registry" unless defined?(Win32::Registry) +rescue LoadError => e + puts "Skipping missing rake dep: #{e}" +end describe Ohai::System, "plugin azure" do let(:plugin) { get_plugin("azure") } |