Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(FACT-2134) Distinguish between CentOS and CentOS Stream #2291

Merged
merged 1 commit into from Mar 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/facter/resolvers/os_release.rb
Expand Up @@ -55,7 +55,7 @@ def pad_version_id
def process_name
return unless @fact_list[:name]

@fact_list[:name] = if @fact_list[:name].downcase.start_with?('red', 'oracle')
@fact_list[:name] = if @fact_list[:name].downcase.start_with?('red', 'oracle', 'centos stream')
@fact_list[:name].split(' ')[0..1].join
else
@fact_list[:name].split(' ')[0].strip
Expand Down
20 changes: 20 additions & 0 deletions spec/facter/resolvers/os_release_spec.rb
Expand Up @@ -118,4 +118,24 @@
expect(result).to eq('OracleLinux')
end
end

context 'when on CentOS Stream' do
let(:os_release_content) { load_fixture('os_release_centos_stream').readlines }

it 'returns os NAME' do
result = Facter::Resolvers::OsRelease.resolve(:name)

expect(result).to eq('CentOSStream')
end
end

context 'when on CentOS' do
let(:os_release_content) { load_fixture('os_release_centos').readlines }

it 'returns os NAME' do
result = Facter::Resolvers::OsRelease.resolve(:name)

expect(result).to eq('CentOS')
end
end
end
13 changes: 13 additions & 0 deletions spec/fixtures/os_release_centos
@@ -0,0 +1,13 @@
NAME="CentOS Linux"
VERSION="8"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Linux 8"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-8"
CENTOS_MANTISBT_PROJECT_VERSION="8"
13 changes: 13 additions & 0 deletions spec/fixtures/os_release_centos_stream
@@ -0,0 +1,13 @@
NAME="CentOS Stream"
VERSION="8"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Stream 8"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://centos.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux 8"
REDHAT_SUPPORT_PRODUCT_VERSION="CentOS Stream"