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-2754) Add os.distro release legacy facts #2055

Merged
merged 1 commit into from
Sep 1, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/facter/facts/debian/os/distro/release.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ module Os
module Distro
class Release
FACT_NAME = 'os.distro.release'
ALIASES = %w[lsbdistrelease lsbmajdistrelease lsbminordistrelease].freeze

def call_the_resolver
fact_value = determine_release_for_os
return Facter::ResolvedFact.new(FACT_NAME, nil) unless fact_value

Facter::ResolvedFact.new(FACT_NAME, fact_value)
[Facter::ResolvedFact.new(FACT_NAME, fact_value),
Facter::ResolvedFact.new(ALIASES[0], fact_value['full'], :legacy),
Facter::ResolvedFact.new(ALIASES[1], fact_value['major'], :legacy),
Facter::ResolvedFact.new(ALIASES[2], fact_value['minor'], :legacy)]
end

private
Expand Down
14 changes: 11 additions & 3 deletions spec/facter/facts/debian/os/distro/release_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@

shared_examples 'returns distro release fact' do
it 'returns release fact' do
expect(fact.call_the_resolver).to be_an_instance_of(Facter::ResolvedFact).and \
have_attributes(name: 'os.distro.release', value: fact_value)
expect(fact.call_the_resolver).to be_an_instance_of(Array).and \
contain_exactly(an_object_having_attributes(name: 'os.distro.release', value: fact_value),
an_object_having_attributes(name: 'lsbdistrelease', value: fact_value['full'], type: :legacy),
an_object_having_attributes(name: 'lsbmajdistrelease', value: fact_value['major'],
type: :legacy),
an_object_having_attributes(name: 'lsbminordistrelease', value: fact_value['minor'],
type: :legacy))
end
end

Expand All @@ -31,7 +36,10 @@
let(:os_release_value) { nil }
let(:fact_value) { nil }

it_behaves_like 'returns distro release fact'
it 'returns release fact' do
expect(fact.call_the_resolver).to be_an_instance_of(Facter::ResolvedFact).and \
have_attributes(name: 'os.distro.release', value: fact_value)
end
end

context 'when version has no minor' do
Expand Down