lib/kitchen/docker/container.rb in kitchen-docker-2.10.0 vs lib/kitchen/docker/container.rb in kitchen-docker-2.11.0
- old
+ new
@@ -35,17 +35,31 @@
raise ActionFailed, "Container ID #{state[:container_id]} was found in the kitchen state data, "\
'but the container does not exist.'
end
state[:username] = @config[:username]
- state[:hostname] = 'localhost'
+ end
+ def destroy(state)
+ info("[Docker] Destroying Docker container #{state[:container_id]}") if state[:container_id]
+ remove_container(state) if container_exists?(state)
+
+ if @config[:remove_images] && state[:image_id]
+ remove_image(state) if image_exists?(state)
+ end
+ end
+
+ def hostname(state)
+ hostname = 'localhost'
+
if remote_socket?
- state[:hostname] = socket_uri.host
- elsif config[:use_internal_docker_network]
- state[:hostname] = container_ip_address(state)
+ hostname = socket_uri.host
+ elsif @config[:use_internal_docker_network]
+ hostname = container_ip_address(state)
end
+
+ hostname
end
def upload(locals, remote)
files = locals
files = Array(locals) unless locals.is_a?(Array)
@@ -53,18 +67,9 @@
files.each do |file|
copy_file_to_container(@config, file, remote)
end
files
- end
-
- def destroy(state)
- info("[Docker] Destroying Docker container #{state[:container_id]}") if state[:container_id]
- remove_container(state) if container_exists?(state)
-
- if @config[:remove_images] && state[:image_id]
- remove_image(state) if image_exists?(state)
- end
end
end
end
end