summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn McCrae <john.mccrae@progress.com>2022-04-06 09:36:34 -0700
committerJohn McCrae <john.mccrae@progress.com>2022-04-06 09:36:34 -0700
commit34e02d2527969f3d40cfe338f4c5dbf4fd9aa124 (patch)
treed851b0c62b9afbc6985e82e68db63ef4d09ab302
parentf3df1226e3c5463d5f88600de2eaa164c9db9ef5 (diff)
downloadohai-34e02d2527969f3d40cfe338f4c5dbf4fd9aa124.tar.gz
Updating For Ruby 3.1
Signed-off-by: John McCrae <john.mccrae@progress.com>
-rw-r--r--.github/workflows/unit.yml2
-rw-r--r--Gemfile1
-rw-r--r--lib/ohai/mixin/os.rb2
-rw-r--r--lib/ohai/plugins/azure.rb2
-rw-r--r--lib/ohai/plugins/ec2.rb2
-rw-r--r--lib/ohai/plugins/gce.rb2
-rw-r--r--lib/ohai/plugins/openstack.rb2
-rw-r--r--lib/ohai/plugins/rackspace.rb2
-rw-r--r--ohai.gemspec3
-rw-r--r--spec/unit/mixin/shell_out_spec.rb9
-rw-r--r--spec/unit/plugins/azure_spec.rb1
11 files changed, 19 insertions, 9 deletions
diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml
index 4d5b3007..9bc13e99 100644
--- a/.github/workflows/unit.yml
+++ b/.github/workflows/unit.yml
@@ -18,6 +18,8 @@ jobs:
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/Gemfile b/Gemfile
index 90e95e79..fb2e3a1c 100644
--- a/Gemfile
+++ b/Gemfile
@@ -6,6 +6,7 @@ gemspec
# pull these gems from main of chef/chef so that we're testing against what we will release
gem "chef-config", git: "https://github.com/chef/chef", branch: "main", glob: "chef-config/chef-config.gemspec"
gem "chef-utils", git: "https://github.com/chef/chef", branch: "main", glob: "chef-utils/chef-utils.gemspec"
+# gem "chef-utils", path: "C:\\foo\\chef\\chef-utils"
# NOTE: do not submit PRs to add pry as a dep, add to your Gemfile.local
group :development do
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..ef1d69f5 100644
--- a/lib/ohai/plugins/azure.rb
+++ b/lib/ohai/plugins/azure.rb
@@ -73,7 +73,7 @@ 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)
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/ohai.gemspec b/ohai.gemspec
index e7af4a7c..39a52d51 100644
--- a/ohai.gemspec
+++ b/ohai.gemspec
@@ -15,7 +15,8 @@ Gem::Specification.new do |s|
s.required_ruby_version = ">= 2.7"
s.add_dependency "chef-config", ">= 14.12", "< 19"
- s.add_dependency "chef-utils", ">= 16.0", "< 19"
+ s.add_runtime_dependency "chef-utils"
+ # s.add_dependency "chef-utils", ">= 16.0", "< 19"
s.add_dependency "ffi", "~> 1.9"
s.add_dependency "ffi-yajl", "~> 2.2"
s.add_dependency "ipaddress"
diff --git a/spec/unit/mixin/shell_out_spec.rb b/spec/unit/mixin/shell_out_spec.rb
index 7d08d9ff..0cf5baea 100644
--- a/spec/unit/mixin/shell_out_spec.rb
+++ b/spec/unit/mixin/shell_out_spec.rb
@@ -17,6 +17,7 @@
#
require "spec_helper"
+require "pry"
describe Ohai::Mixin::ShellOut, "shell_out" do
let(:cmd) { "sparkle-dream --version" }
@@ -63,14 +64,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
@@ -88,6 +89,10 @@ describe Ohai::Mixin::ShellOut, "shell_out" do
describe "when the command does not exist" do
it "logs the command and error message" do
+ require "pry"
+ Pry.config.input = STDIN
+ Pry.config.output = STDOUT
+ binding.pry
expect(Mixlib::ShellOut).to receive(:new).with(cmd, options).and_return(shell_out)
expect(shell_out).to receive(:run_command).and_raise(Errno::ENOENT, "sparkle-dream")
expect(logger).to receive(:trace)
diff --git a/spec/unit/plugins/azure_spec.rb b/spec/unit/plugins/azure_spec.rb
index 4d875e80..0d9353d8 100644
--- a/spec/unit/plugins/azure_spec.rb
+++ b/spec/unit/plugins/azure_spec.rb
@@ -17,6 +17,7 @@
#
require "spec_helper"
+require "win32/registry" unless defined?(Win32::Registry)
describe Ohai::System, "plugin azure" do
let(:plugin) { get_plugin("azure") }