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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: feb4ff216824577dd4a43b43b3c1141798d7d6e9e17fcb9335bb40ca71ca0e43
4
- data.tar.gz: fbcea97721bdc2b7059f5d5756e97d1595ff37f6207b494359cf91d353fe8d31
3
+ metadata.gz: de05a97c00f24025bb2e3128230abdbd1c33bbc563cdd3bf7818b24008a784b6
4
+ data.tar.gz: 609415cdec20cc1b986eebcdb977cdb795c9aa7a5fa82a44107a541ec4dcf5d6
5
5
  SHA512:
6
- metadata.gz: 41873271043dd20170d03faf0596cc1fdfafd974ead42be1a8dc48fae2b758ebebb8e4cc1dcd980076daac663f4950f43516214966de4f02845eb326a7d2c6af
7
- data.tar.gz: 78148fcfd5ad39dd9637d109e523c48a6706f0b55e4e6e16def8fdd0deacffad35c9cdcbeeafa8f1cb9af8081939972baa2b516cf4269097a156006b4b21a544
6
+ metadata.gz: 69ebf0b5e2b84c6bb3ab86e56f36016cd4152c3def0e63488bfff6ae3b0e234f50b5ddf77ee97549ca2be26dfd870af521d2aa71a968a47b795203250fa80a53
7
+ data.tar.gz: 3bee4984a3b063ac369da24d24c0d92a13185b5c76df9c0bd0c61aa2a8257e3fbd23c6ee09d5e07a3889d387fa7fcafabb9b237926cf5acf1980558d2064c6f5
data/Rakefile CHANGED
@@ -21,6 +21,7 @@ GemHadar do
21
21
  development_dependency 'rake'
22
22
  development_dependency 'simplecov'
23
23
  development_dependency 'rspec'
24
+ development_dependency 'debug'
24
25
  licenses << 'MIT'
25
26
  executables << 'all_images'
26
27
  end
data/all_images.gemspec CHANGED
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: all_images 0.1.0 ruby lib
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.1.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
@@ -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
- Array(@config['images']).each do |image, script|
21
- tag = provide_image image, dockerfile
22
- if sh "docker run --name all_images -v `pwd`:/work '#{tag}' sh -c '#{script}'"
23
- puts green('SUCCESS')
24
- else
25
- puts red('FAILURE')
26
- if @config['fail_fast']
27
- return 1
28
- else
29
- result |= 1
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?
@@ -1,6 +1,6 @@
1
1
  module AllImages
2
2
  # AllImages version
3
- VERSION = '0.1.0'
3
+ VERSION = '0.2.0'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
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.1.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