Skip to content

Commit

Permalink
Fix puppet classes import filter when using Ruby >=3.1 and Regexp/Sym…
Browse files Browse the repository at this point in the history
…bol in YAML file

Co-authored-by: Ewoud Kohl van Wijngaarden <[email protected]>
  • Loading branch information
Romuald Conty and ekohl committed Dec 17, 2024
1 parent 6f8266d commit 948394f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/services/foreman_puppet/puppet_class_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,17 @@ def ignored_file_path
end

def load_ignored_file
File.exist?(ignored_file_path) ? YAML.load_file(ignored_file_path) : {}
if File.exist?(ignored_file_path)
# Ruby 3+
if YAML.respond_to(:safe_load_file)
YAML.safe_load_file(ignored_file_path, permitted_classes: [Symbol, Regexp])
else
# NOTE: Once we drop Ruby 2.7 support, you can drop the load_file call.
YAML.load_file(ignored_file_path)
end
else
{}
end
end

def ignored_file
Expand Down

0 comments on commit 948394f

Please sign in to comment.