Method: PDK::Module::Convert#stage_changes!

Defined in:
lib/pdk/module/convert.rb

#stage_changes!Object



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/pdk/module/convert.rb', line 68

def stage_changes!
   = 'metadata.json'

  PDK::Module::TemplateDir.new(template_url, nil, false) do |templates|
     = (, templates.)
    templates. = .data unless .nil?

    if options[:noop] && .nil?
      update_manager.add_file(, '')
    elsif File.file?()
      update_manager.modify_file(, .to_json)
    else
      update_manager.add_file(, .to_json)
    end

    templates.render do |file_path, file_content, file_status|
      if file_status == :unmanage
        PDK.logger.debug(_("skipping '%{path}'") % { path: file_path })
      elsif file_status == :delete
        update_manager.remove_file(file_path)
      elsif file_status == :manage
        if File.exist? file_path
          update_manager.modify_file(file_path, file_content)
        else
          update_manager.add_file(file_path, file_content)
        end
      end
    end
  end
rescue ArgumentError => e
  raise PDK::CLI::ExitWithError, e
end