Skip to content

Commit

Permalink
Fixes #35316 - enhance template-seed error-report
Browse files Browse the repository at this point in the history
  • Loading branch information
m-bucher committed Apr 4, 2023
1 parent a1dff93 commit cb8b360
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/seed_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def update_role_permissions(role, options)

def import_raw_template(contents, vendor = 'Foreman')
metadata = Template.parse_metadata(contents)
raise "Metadata could not be parsed, it seems to be empty" if metadata.empty?
raise "Attribute 'name' is required in metadata in order to seed the template" if metadata['name'].nil?
raise "Attribute 'model' is required in metadata in order to seed the template" if metadata['model'].nil?

Expand Down Expand Up @@ -138,6 +139,9 @@ def import_raw_template(contents, vendor = 'Foreman')
def import_templates(template_paths, vendor = 'Foreman')
template_paths.each do |path|
import_raw_template(File.read(path), vendor)
rescue RuntimeError => e
Foreman::Logging.exception("Error in seeding the template #{path.inspect} metadata #{e.message}", e)
raise e
end
end

Expand Down

0 comments on commit cb8b360

Please sign in to comment.