Class: Machinery::ContainerizeTask

Inherits:
Object
  • Object
show all
Defined in:
lib/containerize_task.rb

Overview

Copyright © 2013-2016 SUSE LLC

This program is free software; you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, contact SUSE LLC.

To contact SUSE about this file by physical or electronic mail, you may find current contact information at www.suse.com

Instance Method Summary collapse

Instance Method Details

#containerize(description, dir) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/containerize_task.rb', line 19

def containerize(description, dir)
  output_path = File.join(dir, description.name)

  mapper = Machinery::WorkloadMapper.new
  workloads = mapper.identify_workloads(description)

  if workloads.empty?
    Machinery::Ui.puts "No workloads detected."
  else
    FileUtils.mkdir_p(output_path)
    services = mapper.save(workloads, output_path)
    mapper.extract(description, workloads, output_path)
    write_readme_file(output_path)
    copy_workload_setup_files(description, workloads, services, output_path)

    workloads.each do |workload|
      Machinery::Ui.puts "Detected workload '#{workload[0]}'."
    end
    Machinery::Ui.puts "\nWrote to #{output_path}."
  end
end

#write_readme_file(dir) ⇒ Object



41
42
43
44
45
46
# File 'lib/containerize_task.rb', line 41

def write_readme_file(dir)
  FileUtils.cp(
    File.join(Machinery::ROOT, "export_helpers", "containerize_readme.md"),
    File.join(dir, "README.md")
  )
end