Class: Kitchen::Driver::DockerAdv

Inherits:
SSHBase
  • Object
show all
Defined in:
lib/kitchen/driver/docker_adv.rb

Overview

DockerAdv driver for Kitchen.

Author:

Instance Method Summary collapse

Instance Method Details

#build_applications_listObject



72
73
74
75
76
77
78
79
80
81
82
# File 'lib/kitchen/driver/docker_adv.rb', line 72

def build_applications_list()
  applications=config[:applications]
  apps = Array.new
  applications.each do | application |
    code   = application[:code]
    branch = application[:branch]
    apps << "#{code}=#{branch}"
  end

  return "#{apps.join(':')}"
end

#create(state) ⇒ Object



96
97
98
99
100
101
102
# File 'lib/kitchen/driver/docker_adv.rb', line 96

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)
  wait_for_sshd(state[:hostname], nil, :port => state[:port])
end

#default_imageObject



84
85
86
87
88
89
90
# File 'lib/kitchen/driver/docker_adv.rb', line 84

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_platformObject



92
93
94
# File 'lib/kitchen/driver/docker_adv.rb', line 92

def default_platform
  instance.platform.name.split('-').first
end

#destroy(state) ⇒ Object



104
105
106
107
108
109
# File 'lib/kitchen/driver/docker_adv.rb', line 104

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

Returns:

  • (Boolean)


111
112
113
# File 'lib/kitchen/driver/docker_adv.rb', line 111

def remote_socket?
  config[:socket] ? socket_uri.scheme == 'tcp' : false
end

#verify_dependenciesObject



65
66
67
68
69
70
# File 'lib/kitchen/driver/docker_adv.rb', line 65

def verify_dependencies
  run_command("#{config[:binary]} > /dev/null", :quiet => true)
  rescue
    raise UserError,
    'You must first install the Docker CLI tool http://www.docker.io/gettingstarted/'
end