Method: PDK::Generate::PuppetObject#run

Defined in:
lib/pdk/generators/puppet_object.rb

#runObject

Check that the target files do not exist, find an appropriate template and create the target files from the template. This is the main entry point for the class.

Raises:



85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/pdk/generators/puppet_object.rb', line 85

def run
  [target_object_path, target_spec_path].each do |target_file|
    if File.exist?(target_file)
      raise PDK::CLI::ExitWithError, _("Unable to generate %{object_type}; '%{file}' already exists.") % { file: target_file, object_type: object_type }
    end
  end

  with_templates do |template_path, config_hash|
    data = template_data.merge(configs: config_hash)

    render_file(target_object_path, template_path[:object], data)
    render_file(target_spec_path, template_path[:spec], data) if template_path[:spec]
  end
end