Class: Kitchen::Driver::DockerSsh
- Inherits:
-
SSHBase
- Object
- SSHBase
- Kitchen::Driver::DockerSsh
- Defined in:
- lib/kitchen/driver/docker_ssh.rb
Overview
DockerSsh driver for Kitchen.
Instance Method Summary collapse
- #create(state) ⇒ Object
- #default_image ⇒ Object
- #default_platform ⇒ Object
- #default_platform_version ⇒ Object
- #destroy(state) ⇒ Object
- #remote_socket? ⇒ Boolean
- #verify_dependencies ⇒ Object
- #wait_for_container(state) ⇒ Object
Instance Method Details
#create(state) ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/kitchen/driver/docker_ssh.rb', line 108 def create(state) state[:image_id] = build_image(state) unless state[:image_id] state[:container_id] = run_container(state) unless state[:container_id] state[:hostname] = remote_socket? ? socket_uri.host : 'localhost' state[:port] = container_ssh_port(state) if config[:no_ssh_tcp_check] wait_for_container(state) else sleep 1 wait_for_sshd(state[:hostname], nil, :port => state[:port]) end logger.info("Created Container: #{state[:container_id]}") end |
#default_image ⇒ Object
92 93 94 95 96 97 98 |
# File 'lib/kitchen/driver/docker_ssh.rb', line 92 def default_image platform, release = instance.platform.name.split('-') if platform == 'centos' && release release = 'centos' + release.split('.').first end release ? [platform, release].join(':') : platform end |
#default_platform ⇒ Object
100 101 102 |
# File 'lib/kitchen/driver/docker_ssh.rb', line 100 def default_platform instance.platform.name.split('-').first end |
#default_platform_version ⇒ Object
104 105 106 |
# File 'lib/kitchen/driver/docker_ssh.rb', line 104 def default_platform_version instance.platform.name.split('-').last end |
#destroy(state) ⇒ Object
132 133 134 135 136 137 |
# File 'lib/kitchen/driver/docker_ssh.rb', line 132 def destroy(state) rm_container(state) if container_exists?(state) if config[:remove_images] && state[:image_id] rm_image(state) end end |
#remote_socket? ⇒ Boolean
139 140 141 |
# File 'lib/kitchen/driver/docker_ssh.rb', line 139 def remote_socket? config[:socket] ? socket_uri.scheme == 'tcp' : false end |
#verify_dependencies ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/kitchen/driver/docker_ssh.rb', line 74 def verify_dependencies begin run_command("#{config[:binary]} info #{Helper.env_error_redirect}", \ :quiet => true,\ :use_sudo => false) rescue unless ENV['CI'] raise UserError, \ 'You must first install the Docker CLI tool http://www.docker.io/gettingstarted/' end end if config[:cpuset] && !version_above?('1.1.0') raise UserError, \ 'The cpuset option is only supported on docker '\ 'version >= 1.1.0, either remove this option or upgarde docker' end end |
#wait_for_container(state) ⇒ Object
123 124 125 126 127 128 129 130 |
# File 'lib/kitchen/driver/docker_ssh.rb', line 123 def wait_for_container(state) logger.info("Waiting for #{state[:hostname]}:#{state[:port]}...") until begin container_exists?(state) rescue false end end |