class Construi::Target
Attributes
config[R]
name[R]
Public Class Methods
new(name, config)
click to toggle source
# File lib/construi/target.rb, line 7 def initialize(name, config) @name = name @config = config end
Public Instance Methods
commands()
click to toggle source
# File lib/construi/target.rb, line 12 def commands @config.commands end
create_initial_image()
click to toggle source
# File lib/construi/target.rb, line 42 def create_initial_image return Image.from(@config) end
link_option(links)
click to toggle source
# File lib/construi/target.rb, line 57 def link_option(links) links.each_with_object([]) do |l, o| o << "#{l.id}:#{l.name}" end end
run()
click to toggle source
# File lib/construi/target.rb, line 16 def run Console.progress "Running #{name}..." links = start_linked_images begin final_image = IntermediateImage.seed(create_initial_image).reduce(commands) do |image, command| Console.progress " > #{command}" options = config.options.merge( links: link_option(links), volumes_from: volumes_from_option(config, links), name: name ) image.run command, options end final_image.delete ensure links.map(&:delete) end Console.progress "Build Successful." end
start_linked_images()
click to toggle source
# File lib/construi/target.rb, line 46 def start_linked_images @config.links.map do |(name, config)| options = config.options.merge( name: name, log_lifecycle: true ) Image.from(config).start options end end
volumes_from_option(config, links)
click to toggle source
# File lib/construi/target.rb, line 63 def volumes_from_option(config, links) config.volumes_from.each_with_object([]) do |v, o| volume_from = links.detect { |l| l.name == v } o << (volume_from.nil? ? v : volume_from.id) end end