Skip to content

Commit

Permalink
Do not crash on a typoed legacy fact hash syntax (i.e., missing closi…
Browse files Browse the repository at this point in the history
…ng quote)
  • Loading branch information
chutzimir committed Apr 25, 2023
1 parent df127fe commit 43fc623
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/puppet-lint/plugins/legacy_facts/legacy_facts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ def check

# This matches legacy facts defined in the fact hash that use the top scope
# fact assignment.
if token.value.start_with?("::facts['")
fact_name = token.value.match(%r{::facts\['(.*)'\]})[1]
if token.value.match(%r{::facts\['(.*)'\]})
fact_name = token.value.match(%r{::facts\['(.*)'\]})[1]

# This matches legacy facts defined in the fact hash.
elsif token.value.start_with?("facts['")
fact_name = token.value.match(%r{facts\['(.*)'\]})[1]
elsif token.value.match(%r{facts\['(.*)'\]})
fact_name = token.value.match(%r{facts\['(.*)'\]})[1]

# 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

0 comments on commit 43fc623

Please sign in to comment.