kitchen-docker_cli 0.12.1 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.kitchen.yml +2 -0
- data/CHANGELOG.md +5 -1
- data/Gemfile +0 -4
- data/README.md +53 -0
- data/circle.yml +15 -0
- data/integration-test/.kitchen.yml +11 -4
- data/integration-test/Gemfile +1 -0
- data/{test → integration-test/test}/integration/ansible/default.yml +0 -0
- data/integration-test/test/integration/{default → chef}/serverspec/default_spec.rb +0 -0
- data/integration-test/test/integration/{default → chef}/serverspec/spec_helper.rb +0 -0
- data/kitchen-docker_cli.gemspec +1 -1
- data/lib/kitchen/driver/docker_cli.rb +1 -0
- data/lib/kitchen/driver/docker_cli_version.rb +1 -1
- data/lib/kitchen/transport/docker_cli.rb +54 -12
- data/spec/kitchen/driver/docker_cli_spec.rb +2 -1
- metadata +15 -9
- data/test/integration/chef/serverspec/dns_spec.rb +0 -7
- data/test/integration/chef/serverspec/spec_helper.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d09c1ca759499f465522eac8a5450d03c9a156f6
|
4
|
+
data.tar.gz: 3c02d60023b1f6cd810209756de6494a51961ea6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a756a6c2d28cc7f572d38fcb9b561487f82be6cff4efbc440ad02a86ac8cf7d984eee63a1cb01b370f3b36e74c17cf2bb02eeecd70a8d2be05d3cdf488f4e775
|
7
|
+
data.tar.gz: 1273593f19790281578cf9522e79a1f4378038b8af3d861dc1d4294147f667ae422a22b285ed2d3ee53ed34db7eeba7a44ed7fccafe95cdab5dd02e099b2c31b
|
data/.kitchen.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## 0.13.0
|
2
|
+
|
3
|
+
* Support Docker LXC driver(for CircleCI)
|
4
|
+
|
1
5
|
## 0.12.1
|
2
6
|
|
3
7
|
* Fix error on `kitchen-ansible` with extra_vars [#18][]
|
@@ -90,4 +94,4 @@
|
|
90
94
|
[#18]: https://github.com/marcy-terui/kitchen-docker_cli/issues/18
|
91
95
|
[@grubernaut]: https://github.com/grubernaut
|
92
96
|
[@hd-deman]: https://github.com/hd-deman
|
93
|
-
[@yewton]: https://github.com/yewton
|
97
|
+
[@yewton]: https://github.com/yewton
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -59,6 +59,8 @@ suites:
|
|
59
59
|
attributes:
|
60
60
|
```
|
61
61
|
|
62
|
+
## Driver Configuration
|
63
|
+
|
62
64
|
### image
|
63
65
|
|
64
66
|
The Docker image's path.
|
@@ -317,6 +319,7 @@ For best results, please:
|
|
317
319
|
```
|
318
320
|
|
319
321
|
### dockerfile_vars
|
322
|
+
|
320
323
|
Template variables for the custom Dockerfile.
|
321
324
|
|
322
325
|
Example:
|
@@ -371,6 +374,56 @@ This option with value 0 indicates that the running container has access to all
|
|
371
374
|
cpu_shares: 512
|
372
375
|
```
|
373
376
|
|
377
|
+
## Transport Configuration
|
378
|
+
|
379
|
+
### lxc_driver
|
380
|
+
|
381
|
+
If you use the LXC Driver of Docker (CircleCI), please set `true`
|
382
|
+
|
383
|
+
The default value is `false`
|
384
|
+
|
385
|
+
```yml
|
386
|
+
lxc_driver: true
|
387
|
+
```
|
388
|
+
|
389
|
+
### docker_base
|
390
|
+
|
391
|
+
Base of `docker` command.
|
392
|
+
|
393
|
+
The default value is `docker`
|
394
|
+
|
395
|
+
Example:
|
396
|
+
|
397
|
+
```yml
|
398
|
+
docker_base: sudo /path/to/docker
|
399
|
+
```
|
400
|
+
|
401
|
+
### lxc_attach_base
|
402
|
+
|
403
|
+
Base of `lxc-attach` command.
|
404
|
+
This option is used on LXC driver only.
|
405
|
+
|
406
|
+
The default value is `sudo lxc-attach`
|
407
|
+
|
408
|
+
Example:
|
409
|
+
|
410
|
+
```yml
|
411
|
+
docker_base: sudo /path/to/lxc-attach
|
412
|
+
```
|
413
|
+
|
414
|
+
### lxc_console_base
|
415
|
+
|
416
|
+
Base of `lxc-console` command.
|
417
|
+
This option is used on LXC driver only.
|
418
|
+
|
419
|
+
The default value is `sudo lxc-console`
|
420
|
+
|
421
|
+
Example:
|
422
|
+
|
423
|
+
```yml
|
424
|
+
docker_base: sudo /path/to/lxc-console
|
425
|
+
```
|
426
|
+
|
374
427
|
## <a name="development"></a> Development
|
375
428
|
|
376
429
|
* Source hosted at [GitHub][repo]
|
data/circle.yml
ADDED
@@ -4,19 +4,26 @@ driver:
|
|
4
4
|
|
5
5
|
transport:
|
6
6
|
name: docker_cli
|
7
|
+
lxc_driver: true
|
7
8
|
|
8
9
|
driver_config:
|
9
10
|
hostname: example.local
|
10
11
|
|
11
|
-
provisioner:
|
12
|
-
name: chef_zero
|
13
|
-
|
14
12
|
platforms:
|
15
13
|
- name: ubuntu-12.04
|
16
14
|
- name: centos-6.4
|
17
15
|
|
18
16
|
suites:
|
19
|
-
- name:
|
17
|
+
- name: chef
|
18
|
+
provisioner:
|
19
|
+
name: chef_zero
|
20
20
|
run_list:
|
21
21
|
- recipe[integration-test::default]
|
22
22
|
attributes:
|
23
|
+
|
24
|
+
- name: ansible
|
25
|
+
provisioner:
|
26
|
+
name: ansible_playbook
|
27
|
+
require_ruby_for_busser: false
|
28
|
+
playbook: test/integration/ansible/default.yml
|
29
|
+
hosts: 127.0.0.1
|
data/integration-test/Gemfile
CHANGED
File without changes
|
File without changes
|
File without changes
|
data/kitchen-docker_cli.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
|
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
17
17
|
spec.executables = []
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features|integration-test)/})
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
21
|
spec.add_dependency 'test-kitchen', '>= 1.3'
|
@@ -29,6 +29,10 @@ module Kitchen
|
|
29
29
|
plugin_version Kitchen::VERSION
|
30
30
|
|
31
31
|
default_config :host, nil
|
32
|
+
default_config :lxc_driver, false
|
33
|
+
default_config :docker_base, "docker"
|
34
|
+
default_config :lxc_attach_base, "sudo lxc-attach"
|
35
|
+
default_config :lxc_console_base, "sudo lxc-console"
|
32
36
|
|
33
37
|
def connection(state, &block)
|
34
38
|
options = config.to_hash.merge(state)
|
@@ -40,24 +44,46 @@ module Kitchen
|
|
40
44
|
include ShellOut
|
41
45
|
|
42
46
|
def login_command
|
47
|
+
if @options[:lxc_driver]
|
48
|
+
lxc_login_command
|
49
|
+
else
|
50
|
+
docker_login_command
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def docker_login_command
|
43
55
|
args = []
|
44
56
|
args << 'exec'
|
45
57
|
args << '-t'
|
46
58
|
args << '-i'
|
47
59
|
args << @options[:container_id]
|
48
60
|
args << '/bin/bash'
|
49
|
-
LoginCommand.new(
|
61
|
+
LoginCommand.new(docker_base, args)
|
50
62
|
end
|
51
63
|
|
52
|
-
def
|
53
|
-
|
54
|
-
|
55
|
-
|
64
|
+
def lxc_login_command
|
65
|
+
args = []
|
66
|
+
args << 'in'
|
67
|
+
args << "\"$(#{docker_base} inspect --format '{{.Id}}' #{@options[:container_id]})\""
|
68
|
+
LoginCommand.new(@options[:lxc_console_base], args)
|
69
|
+
end
|
70
|
+
|
71
|
+
def execute(cmd)
|
72
|
+
if cmd
|
73
|
+
if @options[:lxc_driver]
|
74
|
+
run_lxc(lxc_exec_command(@options[:container_id], cmd))
|
75
|
+
else
|
76
|
+
run_docker(docker_exec_command(@options[:container_id], cmd, :tty => true))
|
77
|
+
end
|
56
78
|
end
|
57
79
|
end
|
58
80
|
|
59
|
-
def
|
60
|
-
run_command("#{
|
81
|
+
def run_lxc(cmd, options={})
|
82
|
+
run_command("#{lxc_attach_base} #{cmd}", options)
|
83
|
+
end
|
84
|
+
|
85
|
+
def run_docker(cmd, options={})
|
86
|
+
run_command("#{docker_base} #{cmd}", options)
|
61
87
|
end
|
62
88
|
|
63
89
|
def upload(locals, remote)
|
@@ -65,7 +91,11 @@ module Kitchen
|
|
65
91
|
execute(cmd)
|
66
92
|
Array(locals).each do |local|
|
67
93
|
remote_cmd = "tar x -C #{remote}"
|
68
|
-
|
94
|
+
if @options[:lxc_driver]
|
95
|
+
remote_cmd = "#{lxc_attach_base} #{lxc_exec_command(@options[:container_id], remote_cmd)}"
|
96
|
+
else
|
97
|
+
remote_cmd = "#{docker_base} #{docker_exec_command(@options[:container_id], remote_cmd, :interactive => true)}"
|
98
|
+
end
|
69
99
|
local_cmd = "cd #{File.dirname(local)} && tar cf - ./#{File.basename(local)}"
|
70
100
|
run_command("#{local_cmd} | #{remote_cmd}")
|
71
101
|
end
|
@@ -75,12 +105,24 @@ module Kitchen
|
|
75
105
|
exec_cmd = "exec"
|
76
106
|
exec_cmd << " -t" if opt[:tty]
|
77
107
|
exec_cmd << " -i" if opt[:interactive]
|
78
|
-
|
79
|
-
|
108
|
+
exec_cmd << " #{container_id} #{wrap_command(cmd)}"
|
109
|
+
end
|
110
|
+
|
111
|
+
def lxc_exec_command(container_id, cmd)
|
112
|
+
exec_cmd = " -n \"$(#{docker_base} inspect --format '{{.Id}}' #{@options[:container_id]})\""
|
113
|
+
exec_cmd << " -- #{wrap_command(cmd)}"
|
114
|
+
end
|
115
|
+
|
116
|
+
def wrap_command(cmd)
|
117
|
+
cmd.match(/\Ash\s\-c/) ? cmd : Util.wrap_command(cmd.gsub('\'', "'\\\\''"))
|
118
|
+
end
|
119
|
+
|
120
|
+
def docker_base
|
121
|
+
@options[:docker_base]
|
80
122
|
end
|
81
123
|
|
82
|
-
def
|
83
|
-
|
124
|
+
def lxc_attach_base
|
125
|
+
@options[:lxc_attach_base]
|
84
126
|
end
|
85
127
|
|
86
128
|
end
|
@@ -198,7 +198,8 @@ describe Kitchen::Driver::DockerCli, "docker_file" do
|
|
198
198
|
example do
|
199
199
|
ret = "FROM centos/centos6\n"
|
200
200
|
ret << "RUN yum clean all\n"
|
201
|
-
ret << "RUN yum -y install sudo curl tar"
|
201
|
+
ret << "RUN yum -y install sudo curl tar\n"
|
202
|
+
ret << 'RUN echo "Defaults:root !requiretty" >> /etc/sudoers'
|
202
203
|
expect(@docker_cli.send(:docker_file)).to eq ret
|
203
204
|
end
|
204
205
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitchen-docker_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masashi Terui
|
@@ -110,6 +110,7 @@ files:
|
|
110
110
|
- LICENSE
|
111
111
|
- README.md
|
112
112
|
- Rakefile
|
113
|
+
- circle.yml
|
113
114
|
- integration-test/.gitignore
|
114
115
|
- integration-test/.kitchen.yml
|
115
116
|
- integration-test/Gemfile
|
@@ -117,8 +118,9 @@ files:
|
|
117
118
|
- integration-test/chefignore
|
118
119
|
- integration-test/metadata.rb
|
119
120
|
- integration-test/recipes/default.rb
|
120
|
-
- integration-test/test/integration/default
|
121
|
-
- integration-test/test/integration/
|
121
|
+
- integration-test/test/integration/ansible/default.yml
|
122
|
+
- integration-test/test/integration/chef/serverspec/default_spec.rb
|
123
|
+
- integration-test/test/integration/chef/serverspec/spec_helper.rb
|
122
124
|
- kitchen-docker_cli.gemspec
|
123
125
|
- lib/kitchen/docker_cli/dockerfile_template.rb
|
124
126
|
- lib/kitchen/driver/docker_cli.rb
|
@@ -128,9 +130,6 @@ files:
|
|
128
130
|
- spec/kitchen/driver/dockerfile.erb
|
129
131
|
- spec/kitchen/driver/dockerfile_nil.erb
|
130
132
|
- spec/spec_helper.rb
|
131
|
-
- test/integration/ansible/default.yml
|
132
|
-
- test/integration/chef/serverspec/dns_spec.rb
|
133
|
-
- test/integration/chef/serverspec/spec_helper.rb
|
134
133
|
homepage: https://github.com/marcy-terui/kitchen-docker_cli
|
135
134
|
licenses:
|
136
135
|
- Apache 2.0
|
@@ -156,10 +155,17 @@ signing_key:
|
|
156
155
|
specification_version: 4
|
157
156
|
summary: A Test Kitchen Driver for Docker native CLI
|
158
157
|
test_files:
|
158
|
+
- integration-test/.gitignore
|
159
|
+
- integration-test/.kitchen.yml
|
160
|
+
- integration-test/Gemfile
|
161
|
+
- integration-test/README.md
|
162
|
+
- integration-test/chefignore
|
163
|
+
- integration-test/metadata.rb
|
164
|
+
- integration-test/recipes/default.rb
|
165
|
+
- integration-test/test/integration/ansible/default.yml
|
166
|
+
- integration-test/test/integration/chef/serverspec/default_spec.rb
|
167
|
+
- integration-test/test/integration/chef/serverspec/spec_helper.rb
|
159
168
|
- spec/kitchen/driver/docker_cli_spec.rb
|
160
169
|
- spec/kitchen/driver/dockerfile.erb
|
161
170
|
- spec/kitchen/driver/dockerfile_nil.erb
|
162
171
|
- spec/spec_helper.rb
|
163
|
-
- test/integration/ansible/default.yml
|
164
|
-
- test/integration/chef/serverspec/dns_spec.rb
|
165
|
-
- test/integration/chef/serverspec/spec_helper.rb
|