lib/percheron/container/actions/recreate.rb in percheron-0.4.0 vs lib/percheron/container/actions/recreate.rb in percheron-0.5.0

- old
+ new

@@ -1,10 +1,12 @@ module Percheron module Container module Actions class Recreate + include Base + def initialize(container) @container = container end def execute! @@ -22,11 +24,11 @@ attr_reader :container def create_opts { 'name' => temporary_name, - 'Image' => container.image, + 'Image' => container.image_name, 'Hostname' => container.name, 'Env' => container.env, 'ExposedPorts' => container.exposed_ports, 'VolumesFrom' => container.volumes } @@ -34,20 +36,20 @@ def temporary_name '%s_wip' % container.name end - # FIXME + # FIXME: brittle def temporary_container_exists? temporary_container.info.empty? rescue Docker::Error::NotFoundError false end def create_image! - unless image_exists? - $logger.debug "Creating '#{container.image}' image" + unless container.image + $logger.debug "Creating '#{container.image_name}' image" Container::Actions::Build.new(container).execute! end end def create_container! @@ -87,20 +89,16 @@ $logger.debug "Renaming '#{container.name}' container to '#{rename_current_new_name}'" container.docker_container.rename(rename_current_new_name) end def rename_wip_to_current! - # FIXME + # FIXME: brittle $logger.debug "Renaming '#{temporary_name}' container to '#{container.name}'" Docker::Container.get(temporary_name).rename(container.name) end def start_new! container.start! - end - - def image_exists? - Docker::Image.exist?(container.image) end def container_was_running? @container_was_running end