flock-sandbox 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/flock/sandbox.rb +18 -13
- data/lib/flock/sandbox/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8084b68a2683319e8d2c158aee9e4085445fd0e4
|
4
|
+
data.tar.gz: 083606bfaa2944b79d9b49e49c57830106acd681
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64a741c23bd4d0c76247ec1ac5317b38f6c8517e43eef88ad7f280b13713c625d8420fcfad2c48549010e1256e316127700c3e31453c1b352ae4b5f8c38c7ace
|
7
|
+
data.tar.gz: 342fbc2dcfd3c3e9bb30f15f199c965cca21fa14d8f3d016fc35f4cc3e05b575d2ee50c239a3dc4642bdea5fb91f9fd98f0995e904bf5ecd0c8d602f32dbac35
|
data/lib/flock/sandbox.rb
CHANGED
@@ -38,12 +38,14 @@ module Flock
|
|
38
38
|
end
|
39
39
|
class Definition
|
40
40
|
attr_accessor :config, :containers, :scripts
|
41
|
+
def initialize
|
42
|
+
@scripts = []
|
43
|
+
@containers = []
|
44
|
+
end
|
41
45
|
def container(name, params = {})
|
42
|
-
@containers ||= []
|
43
46
|
@containers << params.merge(name: name)
|
44
47
|
end
|
45
48
|
def script(name, params = {})
|
46
|
-
@scripts ||= []
|
47
49
|
@scripts << params.merge(name: name)
|
48
50
|
end
|
49
51
|
end
|
@@ -69,8 +71,7 @@ module Flock
|
|
69
71
|
class Docker
|
70
72
|
def initialize(definition)
|
71
73
|
@definition = definition
|
72
|
-
::Docker.options = {
|
73
|
-
}
|
74
|
+
::Docker.options = {}
|
74
75
|
end
|
75
76
|
|
76
77
|
def run
|
@@ -80,26 +81,30 @@ module Flock
|
|
80
81
|
@definition.containers.each do |c|
|
81
82
|
puts "Start container #{c[:name]} (#{c[:image]})"
|
82
83
|
::Docker::Image.create('fromImage' => c[:image])
|
83
|
-
container = ::Docker::Container.create(
|
84
|
-
|
85
|
-
|
86
|
-
|
84
|
+
container = ::Docker::Container.create(
|
85
|
+
'Image' => c[:image],
|
86
|
+
'name' => c[:name],
|
87
|
+
'Env' => c[:envs],
|
88
|
+
'HostConfig' => { 'Links' => c[:links] })
|
87
89
|
containers << container
|
88
90
|
container.start
|
89
91
|
end
|
90
92
|
end
|
91
93
|
if ENV['MANUAL_SCRIPTS']
|
92
94
|
@definition.scripts.each do |c|
|
93
|
-
puts "docker run #{(c[:links] || [])
|
95
|
+
puts "docker run #{(c[:links] || [])
|
96
|
+
.map { |v| "--link #{v}" } * ' ' } #{(c[:envs] || [])
|
97
|
+
.map { |e| "-e #{e}" } * ' ' } #{c[:image]} #{c[:cmd] * ' '}"
|
94
98
|
end
|
95
99
|
else
|
96
100
|
@definition.scripts.each do |c|
|
97
101
|
puts "Run script #{c[:name]} (#{c[:image]} #{c[:cmd].inspect})"
|
98
102
|
::Docker::Image.create('fromImage' => c[:image])
|
99
|
-
container = ::Docker::Container.create(
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
+
container = ::Docker::Container.create(
|
104
|
+
'Cmd' => c[:cmd],
|
105
|
+
'Image' => c[:image],
|
106
|
+
'Env' => c[:envs],
|
107
|
+
'HostConfig' => { 'Links' => c[:links] })
|
103
108
|
containers << container
|
104
109
|
container.start
|
105
110
|
res = container.wait(1200)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flock-sandbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Rudenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docker-api
|
@@ -92,8 +92,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
92
|
version: '0'
|
93
93
|
requirements: []
|
94
94
|
rubyforge_project:
|
95
|
-
rubygems_version: 2.
|
95
|
+
rubygems_version: 2.4.3
|
96
96
|
signing_key:
|
97
97
|
specification_version: 4
|
98
98
|
summary: Write a short summary. Required.
|
99
99
|
test_files: []
|
100
|
+
has_rdoc:
|