all_images 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -0
- data/all_images.gemspec +4 -2
- data/lib/all_images/app.rb +48 -13
- data/lib/all_images/version.rb +1 -1
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de05a97c00f24025bb2e3128230abdbd1c33bbc563cdd3bf7818b24008a784b6
|
4
|
+
data.tar.gz: 609415cdec20cc1b986eebcdb977cdb795c9aa7a5fa82a44107a541ec4dcf5d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69ebf0b5e2b84c6bb3ab86e56f36016cd4152c3def0e63488bfff6ae3b0e234f50b5ddf77ee97549ca2be26dfd870af521d2aa71a968a47b795203250fa80a53
|
7
|
+
data.tar.gz: 3bee4984a3b063ac369da24d24c0d92a13185b5c76df9c0bd0c61aa2a8257e3fbd23c6ee09d5e07a3889d387fa7fcafabb9b237926cf5acf1980558d2064c6f5
|
data/Rakefile
CHANGED
data/all_images.gemspec
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: all_images 0.
|
2
|
+
# stub: all_images 0.2.0 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "all_images".freeze
|
6
|
-
s.version = "0.
|
6
|
+
s.version = "0.2.0"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib".freeze]
|
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
|
|
30
30
|
s.add_development_dependency(%q<rake>.freeze, [">= 0"])
|
31
31
|
s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
|
32
32
|
s.add_development_dependency(%q<rspec>.freeze, [">= 0"])
|
33
|
+
s.add_development_dependency(%q<debug>.freeze, [">= 0"])
|
33
34
|
s.add_runtime_dependency(%q<tins>.freeze, ["~> 1.0"])
|
34
35
|
s.add_runtime_dependency(%q<term-ansicolor>.freeze, [">= 0"])
|
35
36
|
else
|
@@ -37,6 +38,7 @@ Gem::Specification.new do |s|
|
|
37
38
|
s.add_dependency(%q<rake>.freeze, [">= 0"])
|
38
39
|
s.add_dependency(%q<simplecov>.freeze, [">= 0"])
|
39
40
|
s.add_dependency(%q<rspec>.freeze, [">= 0"])
|
41
|
+
s.add_dependency(%q<debug>.freeze, [">= 0"])
|
40
42
|
s.add_dependency(%q<tins>.freeze, ["~> 1.0"])
|
41
43
|
s.add_dependency(%q<term-ansicolor>.freeze, [">= 0"])
|
42
44
|
end
|
data/lib/all_images/app.rb
CHANGED
@@ -10,33 +10,68 @@ class AllImages::App
|
|
10
10
|
|
11
11
|
def initialize(args)
|
12
12
|
@args = args.dup
|
13
|
+
@command = determine_command
|
13
14
|
end
|
14
15
|
|
15
16
|
def run
|
16
17
|
result = 0
|
17
18
|
@config = load_config or return 23
|
18
|
-
dockerfile = @config.fetch('dockerfile').to_s
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
20
|
+
if @command == 'ls'
|
21
|
+
puts Array(@config['images']).map(&:first)
|
22
|
+
else
|
23
|
+
Array(@config['images']).each do |image, script|
|
24
|
+
case @command
|
25
|
+
when 'run_all'
|
26
|
+
run_image(image, script)
|
27
|
+
when 'run_selected'
|
28
|
+
image == @selected and run_image(image, script)
|
29
|
+
when 'debug_selected'
|
30
|
+
image == @selected and run_image(image, script, interactive: true)
|
30
31
|
end
|
31
32
|
end
|
32
|
-
ensure
|
33
|
-
sh 'docker rm -f all_images >/dev/null'
|
34
33
|
end
|
35
34
|
result
|
36
35
|
end
|
37
36
|
|
38
37
|
private
|
39
38
|
|
39
|
+
def run_image(image, script, interactive: false)
|
40
|
+
dockerfile = @config.fetch('dockerfile').to_s
|
41
|
+
tag = provide_image image, dockerfile
|
42
|
+
it = interactive ? ' -it ' : ' '
|
43
|
+
if sh "docker run --name all_images#{it}-v `pwd`:/work '#{tag}' sh -c '#{script}'"
|
44
|
+
puts green('SUCCESS')
|
45
|
+
else
|
46
|
+
puts red('FAILURE')
|
47
|
+
if @config['fail_fast']
|
48
|
+
return 1
|
49
|
+
else
|
50
|
+
result |= 1
|
51
|
+
end
|
52
|
+
end
|
53
|
+
ensure
|
54
|
+
sh 'docker rm -f all_images >/dev/null'
|
55
|
+
end
|
56
|
+
|
57
|
+
def determine_command
|
58
|
+
case command = @args.first
|
59
|
+
when nil
|
60
|
+
'run_all'
|
61
|
+
when 'ls'
|
62
|
+
@args.shift
|
63
|
+
'ls'
|
64
|
+
when 'run'
|
65
|
+
@args.shift
|
66
|
+
@selected = @args.shift or fail "Usage: #{File.basename($0)} #{command} IMAGE"
|
67
|
+
'run_selected'
|
68
|
+
when 'debug'
|
69
|
+
@args.shift
|
70
|
+
@selected = @args.shift or fail "Usage: #{File.basename($0)} #{command} IMAGE"
|
71
|
+
'debug_selected'
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
40
75
|
def load_config
|
41
76
|
config_filename = '.all_images.yml'
|
42
77
|
if @args.empty?
|
data/lib/all_images/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: all_images
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Frank
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: debug
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: tins
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|