kitchen-docker-api 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +6 -1
- data/README.md +29 -4
- data/lib/kitchen/driver/docker.rb +25 -6
- data/lib/kitchen/driver/docker_version.rb +1 -1
- metadata +2 -2
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -8,7 +8,7 @@ driver which uses the docker CLI you should look at the original
|
|
8
8
|
which this fork originated.
|
9
9
|
|
10
10
|
Substantial credit for this driver goes to Sean Porter for the CLI
|
11
|
-
|
11
|
+
implementation & his support in developing the docker-api based version.
|
12
12
|
We ultimately decided it would be best to have two versions so folks
|
13
13
|
could choose to use the CLI or docker-api based client.
|
14
14
|
|
@@ -127,6 +127,31 @@ installed. There are several different behaviors available:
|
|
127
127
|
|
128
128
|
The default value is `true`.
|
129
129
|
|
130
|
+
### container\_name
|
131
|
+
|
132
|
+
Allows for specification of a container name which will be visible in
|
133
|
+
`docker ps`. This makes tracking down containers associated w/ cookbook
|
134
|
+
testing easier.
|
135
|
+
|
136
|
+
This defaults to a calculated value which is a combination of 4 attributes:
|
137
|
+
|
138
|
+
- platform name
|
139
|
+
- CWD basename (where kitchen was run from)
|
140
|
+
- suite name
|
141
|
+
- hostname of initiating system
|
142
|
+
|
143
|
+
For example, a cookbook named `test-gem` has this name when run from my
|
144
|
+
laptop on a remote system:
|
145
|
+
|
146
|
+
`ubuntu-12.04..test-gem..default..anichols-mbr`
|
147
|
+
|
148
|
+
### disable\_upstart
|
149
|
+
|
150
|
+
Disables upstart on Debian/Ubuntu containers, as many images do not
|
151
|
+
support a working upstart.
|
152
|
+
|
153
|
+
The default value is `true`.
|
154
|
+
|
130
155
|
### provision\_command
|
131
156
|
|
132
157
|
Custom command(s) to be run when provisioning the base for the suite containers.
|
@@ -151,10 +176,10 @@ driver_config:
|
|
151
176
|
|
152
177
|
### remove\_images
|
153
178
|
|
154
|
-
This determines if images are
|
155
|
-
|
179
|
+
This determines if intermediate images are removed after container
|
180
|
+
creation. Equivalent to `-rm` docker cli option.
|
156
181
|
|
157
|
-
The default value is `
|
182
|
+
The default value is `true`.
|
158
183
|
|
159
184
|
### run_command
|
160
185
|
|
@@ -17,6 +17,7 @@
|
|
17
17
|
require 'kitchen'
|
18
18
|
require 'json'
|
19
19
|
require 'docker'
|
20
|
+
require 'socket'
|
20
21
|
|
21
22
|
module Kitchen
|
22
23
|
|
@@ -27,7 +28,7 @@ module Kitchen
|
|
27
28
|
|
28
29
|
default_config :socket, 'unix:///var/run/docker.sock'
|
29
30
|
default_config :privileged, false
|
30
|
-
default_config :remove_images,
|
31
|
+
default_config :remove_images, true
|
31
32
|
default_config :run_command, '/usr/sbin/sshd -D -o UseDNS=no -o UsePAM=no'
|
32
33
|
default_config :username, 'kitchen'
|
33
34
|
default_config :password, 'kitchen'
|
@@ -41,6 +42,12 @@ module Kitchen
|
|
41
42
|
driver.default_platform
|
42
43
|
end
|
43
44
|
|
45
|
+
default_config :container_name do |driver|
|
46
|
+
driver.default_container_name
|
47
|
+
end
|
48
|
+
|
49
|
+
default_config :disable_upstart, true
|
50
|
+
|
44
51
|
def initialize(*args)
|
45
52
|
super(*args)
|
46
53
|
@docker_connection = ::Docker::Connection.new(config[:socket], :read_timeout => config[:read_timeout])
|
@@ -49,9 +56,17 @@ module Kitchen
|
|
49
56
|
end
|
50
57
|
end
|
51
58
|
|
59
|
+
def default_container_name
|
60
|
+
platform = instance.platform.name
|
61
|
+
suite = instance.suite.name
|
62
|
+
cookbook = instance.provisioner.instance_variable_get("@config")[:kitchen_root].split('/').last
|
63
|
+
hostname = Socket.gethostname.split('.').first
|
64
|
+
[platform,cookbook,suite,hostname].join('..')
|
65
|
+
end
|
66
|
+
|
52
67
|
def default_image
|
53
68
|
platform, release = instance.platform.name.split('-')
|
54
|
-
release ? [platform, release].join(':') :
|
69
|
+
release ? [platform, release].join(':') : platform
|
55
70
|
end
|
56
71
|
|
57
72
|
def default_platform
|
@@ -88,13 +103,16 @@ module Kitchen
|
|
88
103
|
from = "FROM #{config[:image]}"
|
89
104
|
platform = case config[:platform]
|
90
105
|
when 'debian', 'ubuntu'
|
91
|
-
<<-eos
|
92
|
-
ENV DEBIAN_FRONTEND noninteractive
|
106
|
+
disable_upstart = <<-eos
|
93
107
|
RUN dpkg-divert --local --rename --add /sbin/initctl
|
94
108
|
RUN ln -sf /bin/true /sbin/initctl
|
109
|
+
eos
|
110
|
+
packages = <<-eos
|
111
|
+
ENV DEBIAN_FRONTEND noninteractive
|
95
112
|
RUN apt-get update
|
96
113
|
RUN apt-get install -y sudo openssh-server curl lsb-release
|
97
|
-
|
114
|
+
eos
|
115
|
+
config[:disable_upstart] ? disable_upstart + packages : packages
|
98
116
|
when 'rhel', 'centos'
|
99
117
|
<<-eos
|
100
118
|
RUN yum clean all
|
@@ -130,6 +148,8 @@ module Kitchen
|
|
130
148
|
:Privileged => config[:privileged],
|
131
149
|
:PublishAllPorts => false
|
132
150
|
}
|
151
|
+
# Yes, this key must be a string
|
152
|
+
data['name'] = config[:container_name]
|
133
153
|
data[:CpuShares] = config[:cpu] if config[:cpu]
|
134
154
|
data[:Dns] = config[:dns] if config[:dns]
|
135
155
|
data[:Hostname] = config[:hostname] if config[:hostname]
|
@@ -163,7 +183,6 @@ module Kitchen
|
|
163
183
|
end
|
164
184
|
|
165
185
|
def create_image(state, opts = {})
|
166
|
-
info("Fetching Docker base image '#{config[:image]}' and building...")
|
167
186
|
opts[:rm] = config[:remove_images]
|
168
187
|
image = ::Docker::Image.build(dockerfile, opts, @docker_connection) do |chunk|
|
169
188
|
parse_log_chunk(chunk)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitchen-docker-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-03-
|
13
|
+
date: 2014-03-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: test-kitchen
|