Skip to content
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: 2 additions & 2 deletions lib/puppet-lint/plugins/legacy_facts/legacy_facts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ def check
fact_name = ''

# This matches legacy facts defined in the fact hash.
if (match = (token.value.match(%r{(::)?facts\['(.*)'\]}) || token.value.match(%r{(::)?facts\[(.*)\]})))
fact_name = match[2]
if (match = token.value.match(%r{^(?:::)?facts\[(?<quote>'?)(?<value>.+)\k<quote>\]$}))
fact_name = match[:value]

# This matches using legacy facts in a the new structured fact. For
# example this would match 'uuid' in $facts['uuid'] so it can be converted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,5 +467,13 @@
expect(manifest).to eq("\"${facts['os']['distro']['release']['specification']}\"")
end
end

context 'variable ending in the word fact' do
let(:code) { "$interface_facts['netmask']" }

it 'does not detect any problems' do
expect(problems).to have(0).problem
end
end
end
end