Skip to content

Commit

Permalink
Merge pull request #23290 from nasark/normalize_ol_oracle
Browse files Browse the repository at this point in the history
Normalize ol_x64 as oracle OS
  • Loading branch information
Fryguy authored Dec 4, 2024
2 parents 48a37a3 + 488a238 commit a2a7b2d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/models/operating_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class OperatingSystem < ApplicationRecord
["linux_debian", %w[debian]],
["linux_esx", %w[vmnixx86 vmwareesxserver esxserver vmwareesxi]],
["linux_solaris", %w[solaris]],
["linux_oracle", %w[oracle]],
["linux_oracle", ["oracle", /^ol/]],
["linux_photon", %w[photon]],
["linux_generic", %w[linux]],
["unix_aix", %w[aix vios]],
Expand Down Expand Up @@ -79,7 +79,10 @@ def self.normalize_os_name(os_name)
clean_os_name = os_name.downcase.gsub(/[^a-z0-9]/, "")
OS_MAP.each do |normalized_name, candidate_names|
candidate_names.each do |candidate|
return normalized_name if clean_os_name.include?(candidate)
if (candidate.kind_of?(String) && clean_os_name.include?(candidate)) ||
(candidate.kind_of?(Regexp) && clean_os_name.match?(candidate))
return normalized_name
end
end
end
"unknown"
Expand Down
2 changes: 2 additions & 0 deletions spec/models/operating_system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"linux debian" => "linux_debian",
"redhat coreos" => "linux_coreos",
"rhcos-4.11.2" => "linux_coreos",
"ol_8x64" => "linux_oracle",
"oracle" => "linux_oracle"
}.each do |image, expected|
it "normalizes #{image}" do
expect(described_class.normalize_os_name(image)).to eq(expected)
Expand Down

0 comments on commit a2a7b2d

Please sign in to comment.