serverspec 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/serverspec/helper/type.rb +1 -0
- data/lib/serverspec/type/docker_base.rb +28 -0
- data/lib/serverspec/type/docker_container.rb +11 -0
- data/lib/serverspec/type/docker_image.rb +4 -0
- data/lib/serverspec/version.rb +1 -1
- data/serverspec.gemspec +1 -0
- data/spec/type/linux/docker_container_spec.rb +104 -0
- data/spec/type/linux/docker_image_spec.rb +94 -0
- metadata +22 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c11ef86a64f8183dfa28220f2a8f0f3decb729d6
|
4
|
+
data.tar.gz: 63ce70dcced311832c744a3ebfe9870fab383362
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c98b2eeec8291a219bbf6e812c7037b555bd8134b278904c3212106ec0549c2a77bf27c3d712b90b3adf94b9ce3cdac75210bc8d0141473881ccb42b1942bf63
|
7
|
+
data.tar.gz: 41073608375f930f27a16457a234fa41b4a3228f7285f6871eb96bd0fd3736b8f3453ebf3eef84200c54a290a479773fd9eed2540c24a1ace222a7ef11300d9e
|
@@ -8,6 +8,7 @@ module Serverspec
|
|
8
8
|
package php_config port ppa process routing_table selinux
|
9
9
|
selinux_module service user yumrepo windows_feature
|
10
10
|
windows_hot_fix windows_registry_key windows_scheduled_task zfs
|
11
|
+
docker_base docker_image docker_container
|
11
12
|
)
|
12
13
|
|
13
14
|
types.each {|type| require "serverspec/type/#{type}" }
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Serverspec::Type
|
4
|
+
class DockerBase < Base
|
5
|
+
def exist?
|
6
|
+
get_inspection.success?
|
7
|
+
end
|
8
|
+
|
9
|
+
def [](key)
|
10
|
+
value = inspection
|
11
|
+
key.split('.').each do |k|
|
12
|
+
value = value[k]
|
13
|
+
end
|
14
|
+
value
|
15
|
+
end
|
16
|
+
|
17
|
+
def inspection
|
18
|
+
return @inspection if @inspection
|
19
|
+
@inspection = JSON.parse(get_inspection.stdout)[0]
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
def get_inspection
|
24
|
+
return @get_inspectiob if @get_inspection
|
25
|
+
@get_inspection = @runner.run_command("docker inspect #{@name}")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/serverspec/version.rb
CHANGED
data/serverspec.gemspec
CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_runtime_dependency "rspec", "~> 3.0"
|
22
22
|
spec.add_runtime_dependency "rspec-its"
|
23
|
+
spec.add_runtime_dependency "json"
|
23
24
|
spec.add_runtime_dependency "specinfra", "~> 2.3"
|
24
25
|
spec.add_development_dependency "bundler", "~> 1.3"
|
25
26
|
spec.add_development_dependency "rake", "~> 10.1.1"
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
property[:os] = nil
|
5
|
+
set :os, {:family => 'linux'}
|
6
|
+
|
7
|
+
describe docker_container('c1') do
|
8
|
+
it { should exist }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe docker_container('c1') do
|
12
|
+
let(:stdout) { inspect_container }
|
13
|
+
it { should be_running }
|
14
|
+
it { should have_volume('/tmp', '/data') }
|
15
|
+
its(:inspection) { should include 'Driver' => 'aufs' }
|
16
|
+
its(['Config.Cmd']) { should include '/bin/sh' }
|
17
|
+
end
|
18
|
+
|
19
|
+
def inspect_container
|
20
|
+
<<'EOS'
|
21
|
+
[{
|
22
|
+
"Args": [],
|
23
|
+
"Config": {
|
24
|
+
"AttachStderr": false,
|
25
|
+
"AttachStdin": false,
|
26
|
+
"AttachStdout": false,
|
27
|
+
"Cmd": [
|
28
|
+
"/bin/sh"
|
29
|
+
],
|
30
|
+
"CpuShares": 0,
|
31
|
+
"Cpuset": "",
|
32
|
+
"Domainname": "",
|
33
|
+
"Entrypoint": null,
|
34
|
+
"Env": [
|
35
|
+
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
36
|
+
],
|
37
|
+
"ExposedPorts": null,
|
38
|
+
"Hostname": "65cd2e2d7963",
|
39
|
+
"Image": "busybox",
|
40
|
+
"Memory": 0,
|
41
|
+
"MemorySwap": 0,
|
42
|
+
"NetworkDisabled": false,
|
43
|
+
"OnBuild": null,
|
44
|
+
"OpenStdin": true,
|
45
|
+
"PortSpecs": null,
|
46
|
+
"StdinOnce": false,
|
47
|
+
"Tty": true,
|
48
|
+
"User": "",
|
49
|
+
"Volumes": null,
|
50
|
+
"WorkingDir": ""
|
51
|
+
},
|
52
|
+
"Created": "2014-09-26T15:08:37.527931773Z",
|
53
|
+
"Driver": "aufs",
|
54
|
+
"ExecDriver": "native-0.2",
|
55
|
+
"HostConfig": {
|
56
|
+
"Binds": [
|
57
|
+
"/data:/tmp"
|
58
|
+
],
|
59
|
+
"ContainerIDFile": "",
|
60
|
+
"Dns": null,
|
61
|
+
"DnsSearch": null,
|
62
|
+
"Links": null,
|
63
|
+
"LxcConf": [],
|
64
|
+
"NetworkMode": "bridge",
|
65
|
+
"PortBindings": {},
|
66
|
+
"Privileged": false,
|
67
|
+
"PublishAllPorts": false,
|
68
|
+
"VolumesFrom": null
|
69
|
+
},
|
70
|
+
"HostnamePath": "/mnt/sda1/var/lib/docker/containers/65cd2e2d7963bacaecda2d7fcd89499010bc0d38d70bce5ad0af7112a94a4545/hostname",
|
71
|
+
"HostsPath": "/mnt/sda1/var/lib/docker/containers/65cd2e2d7963bacaecda2d7fcd89499010bc0d38d70bce5ad0af7112a94a4545/hosts",
|
72
|
+
"Id": "65cd2e2d7963bacaecda2d7fcd89499010bc0d38d70bce5ad0af7112a94a4545",
|
73
|
+
"Image": "e72ac664f4f0c6a061ac4ef332557a70d69b0c624b6add35f1c181ff7fff2287",
|
74
|
+
"MountLabel": "",
|
75
|
+
"Name": "/c1",
|
76
|
+
"NetworkSettings": {
|
77
|
+
"Bridge": "docker0",
|
78
|
+
"Gateway": "172.17.42.1",
|
79
|
+
"IPAddress": "172.17.0.24",
|
80
|
+
"IPPrefixLen": 16,
|
81
|
+
"PortMapping": null,
|
82
|
+
"Ports": {}
|
83
|
+
},
|
84
|
+
"Path": "/bin/sh",
|
85
|
+
"ProcessLabel": "",
|
86
|
+
"ResolvConfPath": "/mnt/sda1/var/lib/docker/containers/65cd2e2d7963bacaecda2d7fcd89499010bc0d38d70bce5ad0af7112a94a4545/resolv.conf",
|
87
|
+
"State": {
|
88
|
+
"ExitCode": 0,
|
89
|
+
"FinishedAt": "0001-01-01T00:00:00Z",
|
90
|
+
"Paused": false,
|
91
|
+
"Pid": 4123,
|
92
|
+
"Running": true,
|
93
|
+
"StartedAt": "2014-09-26T15:08:37.737780273Z"
|
94
|
+
},
|
95
|
+
"Volumes": {
|
96
|
+
"/tmp": "/data"
|
97
|
+
},
|
98
|
+
"VolumesRW": {
|
99
|
+
"/tmp": true
|
100
|
+
}
|
101
|
+
}
|
102
|
+
]
|
103
|
+
EOS
|
104
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
property[:os] = nil
|
5
|
+
set :os, {:family => 'linux'}
|
6
|
+
|
7
|
+
describe docker_image('busybox:latest') do
|
8
|
+
it { should exist }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe docker_image('busybox:latest') do
|
12
|
+
let(:stdout) { inspect_image }
|
13
|
+
its(:inspection) { should include 'Architecture' => 'amd64' }
|
14
|
+
its(['Architecture']) { should eq 'amd64' }
|
15
|
+
its(['Config.Cmd']) { should include '/bin/sh' }
|
16
|
+
end
|
17
|
+
|
18
|
+
def inspect_image
|
19
|
+
<<'EOS'
|
20
|
+
[{
|
21
|
+
"Architecture": "amd64",
|
22
|
+
"Author": "Jérôme Petazzoni \u003cjerome@docker.com\u003e",
|
23
|
+
"Comment": "",
|
24
|
+
"Config": {
|
25
|
+
"AttachStderr": false,
|
26
|
+
"AttachStdin": false,
|
27
|
+
"AttachStdout": false,
|
28
|
+
"Cmd": [
|
29
|
+
"/bin/sh"
|
30
|
+
],
|
31
|
+
"CpuShares": 0,
|
32
|
+
"Cpuset": "",
|
33
|
+
"Domainname": "",
|
34
|
+
"Entrypoint": null,
|
35
|
+
"Env": [
|
36
|
+
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
37
|
+
],
|
38
|
+
"ExposedPorts": null,
|
39
|
+
"Hostname": "88f18f678e5d",
|
40
|
+
"Image": "e433a6c5b276a31aa38bf6eaba9cd1cfd69ea33f706ed72b3f20bafde5cd8644",
|
41
|
+
"Memory": 0,
|
42
|
+
"MemorySwap": 0,
|
43
|
+
"NetworkDisabled": false,
|
44
|
+
"OnBuild": [],
|
45
|
+
"OpenStdin": false,
|
46
|
+
"PortSpecs": null,
|
47
|
+
"StdinOnce": false,
|
48
|
+
"Tty": false,
|
49
|
+
"User": "",
|
50
|
+
"Volumes": null,
|
51
|
+
"WorkingDir": ""
|
52
|
+
},
|
53
|
+
"Container": "8e73b239682fe73338323d9af83d3c5aa5bb7d22a3fe84cbfcf5f47e756d6636",
|
54
|
+
"ContainerConfig": {
|
55
|
+
"AttachStderr": false,
|
56
|
+
"AttachStdin": false,
|
57
|
+
"AttachStdout": false,
|
58
|
+
"Cmd": [
|
59
|
+
"/bin/sh",
|
60
|
+
"-c",
|
61
|
+
"#(nop) CMD [/bin/sh]"
|
62
|
+
],
|
63
|
+
"CpuShares": 0,
|
64
|
+
"Cpuset": "",
|
65
|
+
"Domainname": "",
|
66
|
+
"Entrypoint": null,
|
67
|
+
"Env": [
|
68
|
+
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
69
|
+
],
|
70
|
+
"ExposedPorts": null,
|
71
|
+
"Hostname": "88f18f678e5d",
|
72
|
+
"Image": "e433a6c5b276a31aa38bf6eaba9cd1cfd69ea33f706ed72b3f20bafde5cd8644",
|
73
|
+
"Memory": 0,
|
74
|
+
"MemorySwap": 0,
|
75
|
+
"NetworkDisabled": false,
|
76
|
+
"OnBuild": [],
|
77
|
+
"OpenStdin": false,
|
78
|
+
"PortSpecs": null,
|
79
|
+
"StdinOnce": false,
|
80
|
+
"Tty": false,
|
81
|
+
"User": "",
|
82
|
+
"Volumes": null,
|
83
|
+
"WorkingDir": ""
|
84
|
+
},
|
85
|
+
"Created": "2014-10-01T20:46:08.914288461Z",
|
86
|
+
"DockerVersion": "1.2.0",
|
87
|
+
"Id": "e72ac664f4f0c6a061ac4ef332557a70d69b0c624b6add35f1c181ff7fff2287",
|
88
|
+
"Os": "linux",
|
89
|
+
"Parent": "e433a6c5b276a31aa38bf6eaba9cd1cfd69ea33f706ed72b3f20bafde5cd8644",
|
90
|
+
"Size": 0
|
91
|
+
}
|
92
|
+
]
|
93
|
+
EOS
|
94
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: serverspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gosuke Miyashita
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: json
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: specinfra
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -129,6 +143,9 @@ files:
|
|
129
143
|
- lib/serverspec/type/command.rb
|
130
144
|
- lib/serverspec/type/cron.rb
|
131
145
|
- lib/serverspec/type/default_gateway.rb
|
146
|
+
- lib/serverspec/type/docker_base.rb
|
147
|
+
- lib/serverspec/type/docker_container.rb
|
148
|
+
- lib/serverspec/type/docker_image.rb
|
132
149
|
- lib/serverspec/type/file.rb
|
133
150
|
- lib/serverspec/type/group.rb
|
134
151
|
- lib/serverspec/type/host.rb
|
@@ -203,6 +220,8 @@ files:
|
|
203
220
|
- spec/type/gentoo/package_spec.rb
|
204
221
|
- spec/type/gentoo/service_spec.rb
|
205
222
|
- spec/type/linux/cgroup_spec.rb
|
223
|
+
- spec/type/linux/docker_container_spec.rb
|
224
|
+
- spec/type/linux/docker_image_spec.rb
|
206
225
|
- spec/type/linux/file_spec.rb
|
207
226
|
- spec/type/linux/interface_spec.rb
|
208
227
|
- spec/type/linux/ip6tables_spec.rb
|
@@ -335,6 +354,8 @@ test_files:
|
|
335
354
|
- spec/type/gentoo/package_spec.rb
|
336
355
|
- spec/type/gentoo/service_spec.rb
|
337
356
|
- spec/type/linux/cgroup_spec.rb
|
357
|
+
- spec/type/linux/docker_container_spec.rb
|
358
|
+
- spec/type/linux/docker_image_spec.rb
|
338
359
|
- spec/type/linux/file_spec.rb
|
339
360
|
- spec/type/linux/interface_spec.rb
|
340
361
|
- spec/type/linux/ip6tables_spec.rb
|