Skip to content
This repository has been archived by the owner on Jun 19, 2020. It is now read-only.

(FACT-2636) Set external as fact_type for environment variable facts. #537

Merged
merged 1 commit into from
May 29, 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
2 changes: 1 addition & 1 deletion lib/custom_facts/util/loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def load_env(fact = nil)
# match it.
next if fact && (env_name != fact)

LegacyFacter.add(Regexp.last_match(1)) do
LegacyFacter.add(Regexp.last_match(1), fact_type: :external) do
has_weight 1_000_000
setcode { value }
end
Expand Down
5 changes: 3 additions & 2 deletions spec/custom_facts/util/loader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,11 @@ def loader_from(places)
describe 'when loading facts' do
it 'loads values from the matching environment variable if one is present' do
loader = loader_from(env: { 'facter_testing' => 'yayness' })

expect(LegacyFacter).to receive(:add).with('testing')
allow(LegacyFacter).to receive(:add)

loader.load(:testing)

expect(LegacyFacter).to have_received(:add).with('testing', { fact_type: :external })
end

it 'loads any files in the search path with names matching the fact name' do
Expand Down