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-2747-scope6) Allow scope6 to be blocked on all platforms #2037

Merged
merged 1 commit into from
Aug 24, 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
4 changes: 3 additions & 1 deletion lib/facter/facts/aix/networking/scope6.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ module Aix
module Networking
class Scope6
FACT_NAME = 'networking.scope6'
ALIASES = 'scope6'

def call_the_resolver
fact_value = Facter::Resolvers::Aix::Networking.resolve(:scope6)

Facter::ResolvedFact.new(FACT_NAME, fact_value)
[Facter::ResolvedFact.new(FACT_NAME, fact_value),
Facter::ResolvedFact.new('scope6', fact_value, :legacy)]
end
end
end
Expand Down
2 changes: 0 additions & 2 deletions lib/facter/facts/aix/scope6_interfaces.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@ class Scope6Interfaces
def call_the_resolver
resolved_facts = []
interfaces = Facter::Resolvers::Aix::Networking.resolve(:interfaces)
scope6 = Facter::Resolvers::Aix::Networking.resolve(:scope6)

interfaces&.each do |interface_name, info|
if info[:scope6]
resolved_facts << Facter::ResolvedFact.new("scope6_#{interface_name}", info[:scope6], :legacy)
end
end

resolved_facts << Facter::ResolvedFact.new('scope6', scope6, :legacy) if scope6
resolved_facts
end
end
Expand Down
4 changes: 3 additions & 1 deletion lib/facter/facts/linux/networking/scope6.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ module Linux
module Networking
class Scope6
FACT_NAME = 'networking.scope6'
ALIASES = 'scope6'

def call_the_resolver
fact_value = Facter::Resolvers::NetworkingLinux.resolve(:scope6)

Facter::ResolvedFact.new(FACT_NAME, fact_value)
[Facter::ResolvedFact.new(FACT_NAME, fact_value),
Facter::ResolvedFact.new('scope6', fact_value, :legacy)]
end
end
end
Expand Down
3 changes: 1 addition & 2 deletions lib/facter/facts/linux/scope6_interfaces.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ class Scope6Interfaces
def call_the_resolver
resolved_facts = []
interfaces = Facter::Resolvers::NetworkingLinux.resolve(:interfaces)
primary_scope6 = Facter::Resolvers::NetworkingLinux.resolve(:scope6)

interfaces&.each do |interface_name, info|
if info[:scope6]
resolved_facts << Facter::ResolvedFact.new("scope6_#{interface_name}", info[:scope6], :legacy)
end
end
resolved_facts << Facter::ResolvedFact.new('scope6', primary_scope6, :legacy) if primary_scope6

resolved_facts
end
end
Expand Down
4 changes: 3 additions & 1 deletion lib/facter/facts/macosx/networking/scope6.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ module Macosx
module Networking
class Scope6
FACT_NAME = 'networking.scope6'
ALIASES = 'scope6'

def call_the_resolver
fact_value = Facter::Resolvers::Networking.resolve(:scope6)

Facter::ResolvedFact.new(FACT_NAME, fact_value)
[Facter::ResolvedFact.new(FACT_NAME, fact_value),
Facter::ResolvedFact.new('scope6', fact_value, :legacy)]
end
end
end
Expand Down
2 changes: 0 additions & 2 deletions lib/facter/facts/macosx/scope6_interfaces.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ class Scope6Interfaces
def call_the_resolver
resolved_facts = []
interfaces = Facter::Resolvers::Networking.resolve(:interfaces)
primary_scope6 = Facter::Resolvers::Networking.resolve(:scope6)

interfaces&.each do |interface_name, info|
if info[:scope6]
resolved_facts << Facter::ResolvedFact.new("scope6_#{interface_name}", info[:scope6], :legacy)
end
end
resolved_facts << Facter::ResolvedFact.new('scope6', primary_scope6, :legacy) if primary_scope6
resolved_facts
end
end
Expand Down
4 changes: 3 additions & 1 deletion lib/facter/facts/windows/networking/scope6.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ module Windows
module Networking
class Scope6
FACT_NAME = 'networking.scope6'
ALIASES = 'scope6'

def call_the_resolver
fact_value = Facter::Resolvers::Windows::Networking.resolve(:scope6)

Facter::ResolvedFact.new(FACT_NAME, fact_value)
[Facter::ResolvedFact.new(FACT_NAME, fact_value),
Facter::ResolvedFact.new('scope6', fact_value, :legacy)]
end
end
end
Expand Down
10 changes: 6 additions & 4 deletions spec/facter/facts/aix/networking/scope6_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@

it 'returns scope6 fact' do
expect(fact.call_the_resolver)
.to be_an_instance_of(Facter::ResolvedFact)
.and have_attributes(name: 'networking.scope6', value: value)
.to be_an_instance_of(Array)
.and contain_exactly(an_object_having_attributes(name: 'networking.scope6', value: value),
an_object_having_attributes(name: 'scope6', value: value))
end
end

Expand All @@ -27,8 +28,9 @@

it 'returns nil' do
expect(fact.call_the_resolver)
.to be_an_instance_of(Facter::ResolvedFact)
.and have_attributes(name: 'networking.scope6', value: nil)
.to be_an_instance_of(Array)
.and contain_exactly(an_object_having_attributes(name: 'networking.scope6', value: value),
an_object_having_attributes(name: 'scope6', value: value))
end
end
end
11 changes: 1 addition & 10 deletions spec/facter/facts/aix/scope6_interfaces_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,22 @@

before do
allow(Facter::Resolvers::Aix::Networking).to receive(:resolve).with(:interfaces).and_return(interfaces)
allow(Facter::Resolvers::Aix::Networking).to receive(:resolve).with(:scope6).and_return(primary)
end

describe '#call_the_resolver' do
let(:interfaces) { { 'eth0' => { scope6: 'link' }, 'en1' => { scope6: 'global' } } }
let(:primary) { 'link' }

it 'calls Facter::Resolvers::Aix::Networking with interfaces' do
fact.call_the_resolver
expect(Facter::Resolvers::Aix::Networking).to have_received(:resolve).with(:interfaces)
end

it 'calls Facter::Resolvers::Aix::Networking with primary' do
fact.call_the_resolver
expect(Facter::Resolvers::Aix::Networking).to have_received(:resolve).with(:scope6)
end

it 'returns legacy facts with scope6_<interface_name>' do
expect(fact.call_the_resolver).to be_an_instance_of(Array).and \
contain_exactly(an_object_having_attributes(name: 'scope6_eth0',
value: interfaces['eth0'][:scope6], type: :legacy),
an_object_having_attributes(name: 'scope6_en1',
value: interfaces['en1'][:scope6], type: :legacy),
an_object_having_attributes(name: 'scope6',
value: primary, type: :legacy))
value: interfaces['en1'][:scope6], type: :legacy))
end
end

Expand Down
9 changes: 6 additions & 3 deletions spec/facter/facts/linux/networking/scope6_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,19 @@

it 'return scope6 fact' do
expect(fact.call_the_resolver)
.to be_an_instance_of(Facter::ResolvedFact)
.and have_attributes(name: 'networking.scope6', value: value)
.to be_an_instance_of(Array)
.and contain_exactly(an_object_having_attributes(name: 'networking.scope6', value: value),
an_object_having_attributes(name: 'scope6', value: value))
end

context 'when scope6 can not be retrieved' do
let(:value) { nil }

it 'returns nil' do
expect(fact.call_the_resolver)
.to be_an_instance_of(Facter::ResolvedFact).and have_attributes(name: 'networking.scope6', value: value)
.to be_an_instance_of(Array)
.and contain_exactly(an_object_having_attributes(name: 'networking.scope6', value: value),
an_object_having_attributes(name: 'scope6', value: value))
end
end
end
Expand Down
11 changes: 1 addition & 10 deletions spec/facter/facts/linux/scope6_interfaces_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,22 @@

before do
allow(Facter::Resolvers::NetworkingLinux).to receive(:resolve).with(:interfaces).and_return(interfaces)
allow(Facter::Resolvers::NetworkingLinux).to receive(:resolve).with(:scope6).and_return(scope6)
end

describe '#call_the_resolver' do
let(:interfaces) { { 'eth0' => { scope6: 'link' }, 'en1' => { scope6: 'global' } } }
let(:scope6) { 'link' }

it 'calls Facter::Resolvers::NetworkingLinux with interfaces' do
fact.call_the_resolver
expect(Facter::Resolvers::NetworkingLinux).to have_received(:resolve).with(:interfaces)
end

it 'calls Facter::Resolvers::NetworkingLinux with scope6' do
fact.call_the_resolver
expect(Facter::Resolvers::NetworkingLinux).to have_received(:resolve).with(:scope6)
end

it 'returns legacy facts with scope6_<interface_name>' do
expect(fact.call_the_resolver).to be_an_instance_of(Array).and \
contain_exactly(an_object_having_attributes(name: 'scope6_eth0',
value: interfaces['eth0'][:scope6], type: :legacy),
an_object_having_attributes(name: 'scope6_en1',
value: interfaces['en1'][:scope6], type: :legacy),
an_object_having_attributes(name: 'scope6',
value: scope6, type: :legacy))
value: interfaces['en1'][:scope6], type: :legacy))
end
end

Expand Down
10 changes: 6 additions & 4 deletions spec/facter/facts/macosx/networking/scope6_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,19 @@

it 'returns scope6 fact' do
expect(fact.call_the_resolver)
.to be_an_instance_of(Facter::ResolvedFact)
.and have_attributes(name: 'networking.scope6', value: value)
.to be_an_instance_of(Array)
.and contain_exactly(an_object_having_attributes(name: 'networking.scope6', value: value),
an_object_having_attributes(name: 'scope6', value: value))
end

context 'when scope6 can not be resolved' do
let(:value) { nil }

it 'returns nil' do
expect(fact.call_the_resolver)
.to be_an_instance_of(Facter::ResolvedFact)
.and have_attributes(name: 'networking.scope6', value: value)
.to be_an_instance_of(Array)
.and contain_exactly(an_object_having_attributes(name: 'networking.scope6', value: value),
an_object_having_attributes(name: 'scope6', value: value))
end
end
end
Expand Down
11 changes: 1 addition & 10 deletions spec/facter/facts/macosx/scope6_interfaces_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,22 @@

before do
allow(Facter::Resolvers::Networking).to receive(:resolve).with(:interfaces).and_return(interfaces)
allow(Facter::Resolvers::Networking).to receive(:resolve).with(:scope6).and_return(scope6)
end

describe '#call_the_resolver' do
let(:interfaces) { { 'eth0' => { scope6: 'link' }, 'en1' => { scope6: 'global' } } }
let(:scope6) { 'link' }

it 'calls Facter::Resolvers::NetworkingLinux with interfaces' do
fact.call_the_resolver
expect(Facter::Resolvers::Networking).to have_received(:resolve).with(:interfaces)
end

it 'calls Facter::Resolvers::NetworkingLinux with scope6' do
fact.call_the_resolver
expect(Facter::Resolvers::Networking).to have_received(:resolve).with(:scope6)
end

it 'returns legacy facts with scope6_<interface_name>' do
expect(fact.call_the_resolver).to be_an_instance_of(Array).and \
contain_exactly(an_object_having_attributes(name: 'scope6_eth0',
value: interfaces['eth0'][:scope6], type: :legacy),
an_object_having_attributes(name: 'scope6_en1',
value: interfaces['en1'][:scope6], type: :legacy),
an_object_having_attributes(name: 'scope6',
value: scope6, type: :legacy))
value: interfaces['en1'][:scope6], type: :legacy))
end
end

Expand Down
6 changes: 4 additions & 2 deletions spec/facter/facts/windows/networking/scope6_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
end

it 'returns scope for ipv6 address' do
expect(fact.call_the_resolver).to be_an_instance_of(Facter::ResolvedFact).and \
have_attributes(name: 'networking.scope6', value: value)
expect(fact.call_the_resolver)
.to be_an_instance_of(Array)
.and contain_exactly(an_object_having_attributes(name: 'networking.scope6', value: value),
an_object_having_attributes(name: 'scope6', value: value))
end
end
end