rbld 1.2.0 → 1.3.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
  SHA1:
3
- metadata.gz: ab06977050419017e9293fc7add885a3474ded72
4
- data.tar.gz: 777845489d399990b3942c2d70df0fbf42bd32d3
3
+ metadata.gz: 52af85fe8048b73c2ec54a99f10a301b3e53d068
4
+ data.tar.gz: 27c99030446802b42462fed1ccd05d3599257ac3
5
5
  SHA512:
6
- metadata.gz: 36db91de99ee92c41d64b6f1b684edaa539c3e76c1ba0cec9fb91b50af40f074f57f2ff4c148b5ae71f785330412ebbbe1b96f54e1d484ed6508f4ed0950087e
7
- data.tar.gz: 066ccf5ce3425c76784e4c2cca7bd90c5030076f106e56969a1444130955197d4341d5d00436969a6551be2ca6024406188ba1faef4ac12cca979a34cf95efde
6
+ metadata.gz: 59f37575451ae36fb42b35d0d03f2206e68ef43be2cdc59ddadce167811a650ea45506529fdc6d981189c96d433bbc996f32841b4bd271a1eb8f09d81af29fd0
7
+ data.tar.gz: 8ec25e4ee262fef7f77dd4503e31d98fb05ba5d3eec5b1e969dc34d53ead3151553747cda04eaa80660f086158daaade7279dabb295047cf536871ba041fe151
data/cli/bin/rbld CHANGED
@@ -5,12 +5,15 @@ require 'require_all'
5
5
  module Rebuild
6
6
  require_relative '../lib/rbld_commands'
7
7
  require_rel '../lib/commands'
8
+ require_relative '../lib/rbld_plugins'
8
9
  end
9
10
 
10
11
  begin
11
12
 
12
13
  rbld_log.info( "ARGV: #{ARGV.join(' ')}" )
13
14
 
15
+ Rebuild::PlugMgr.instance.notify(:start)
16
+
14
17
  if !ARGV[0] || (ARGV[0] == "help" && !ARGV[1])
15
18
  puts Rebuild::CLI::Main.usage
16
19
  puts
@@ -33,4 +36,8 @@ rescue StandardError => e
33
36
  rbld_print.error(e.message)
34
37
  e.backtrace.each { |l| rbld_log.fatal(l) }
35
38
  exit 1
39
+ rescue SignalException => e
40
+ rbld_print.error("Command execution was terminated.")
41
+ e.backtrace.each { |l| rbld_log.fatal(l) }
42
+ exit 2
36
43
  end
data/cli/lib/data/version CHANGED
@@ -1 +1 @@
1
- 1.2.0
1
+ 1.3.0
@@ -43,7 +43,7 @@ module Rebuild
43
43
  def get_credential(name, is_secret = false)
44
44
  print "#{name}: "
45
45
  predefined = ENV["RBLD_CREDENTIAL_#{name.upcase}"]
46
- if predefined
46
+ unless predefined.to_s.empty?
47
47
  puts "<environment>"
48
48
  predefined
49
49
  else
@@ -119,7 +119,7 @@ module Rebuild
119
119
  case @last_error
120
120
  when nil
121
121
  # No error
122
- when /authentication required/, /unauthorized/
122
+ when /authentication required/, /unauthorized/, /denied/
123
123
  raise RegistryNotAuthenticatedError, @last_error
124
124
  else
125
125
  raise RegistryOperationError, @last_error
@@ -15,23 +15,21 @@ module Rebuild::Engine
15
15
  end
16
16
 
17
17
  def load!
18
- begin
19
- with_gzip_reader { |gz| Docker::Image.load(gz) }
18
+ with_gzip_reader { |gz| Docker::Image.load(gz) }
19
+
20
20
  rescue => msg
21
21
  rbld_print.trace( msg )
22
22
  raise EnvironmentLoadFailure, @filename
23
- end
24
23
  end
25
24
 
26
25
  def save!(name, identity)
27
- begin
28
- with_gzip_writer do |gz|
29
- Docker::Image.save_stream( identity ) { |chunk| gz.write chunk }
30
- end
26
+ with_gzip_writer do |gz|
27
+ Docker::Image.save_stream( identity ) { |chunk| gz.write chunk }
28
+ end
29
+
31
30
  rescue => msg
32
31
  rbld_print.trace( msg )
33
32
  raise EnvironmentSaveFailure, [name, @filename]
34
- end
35
33
  end
36
34
 
37
35
  private
@@ -42,7 +40,7 @@ module Rebuild::Engine
42
40
  f.binmode
43
41
  gz = Zlib::GzipWriter.new(f)
44
42
  begin
45
- yield gz
43
+ yield Rebuild::Utils::WithProgressBar.new( gz, :write )
46
44
  ensure
47
45
  gz.close
48
46
  end
@@ -56,7 +54,7 @@ module Rebuild::Engine
56
54
  def with_gzip_reader
57
55
  Zlib::GzipReader.open( @filename ) do |gz|
58
56
  begin
59
- yield gz
57
+ yield Rebuild::Utils::WithProgressBar.new( gz, :read )
60
58
  ensure
61
59
  gz.close
62
60
  end
@@ -0,0 +1,42 @@
1
+ require 'singleton'
2
+ require 'plugman'
3
+
4
+ class Rebuild::PlugMgr
5
+
6
+ include Singleton
7
+ extend Forwardable
8
+
9
+ def_delegator :@plugman, :notify
10
+
11
+ private
12
+
13
+ def initialize
14
+ @plugman = Plugman.new( loader: loader )
15
+ @plugman.load_plugins
16
+ end
17
+
18
+ def loader
19
+ ->(a) do
20
+ plugins.each { |p| load( p ) }
21
+ end
22
+ end
23
+
24
+ def plugins
25
+ Gem::Specification.\
26
+ map { |g| g.name }.\
27
+ sort.\
28
+ uniq.\
29
+ grep /^rbld-plugin-.*/
30
+ end
31
+
32
+ def load(plugin)
33
+
34
+ require plugin
35
+
36
+ rescue LoadError
37
+ rbld_log.warn( "Failed to load plugin #{plugin}" )
38
+ else
39
+ rbld_log.info( "Loaded plugin #{plugin}" )
40
+ end
41
+
42
+ end
@@ -55,6 +55,10 @@ module Rebuild
55
55
  end
56
56
  end
57
57
 
58
+ def search_repos
59
+ @index.search( @path ).map( &:name ).find_all { |n| n.start_with?("#{@path}/") }
60
+ end
61
+
58
62
  def search(name = nil, tag = nil)
59
63
  rbld_log.info( "Searching for #{name}:#{tag}" )
60
64
 
@@ -16,7 +16,7 @@ module Rebuild
16
16
  def initialize(path)
17
17
  @path = path
18
18
  rbld_log.info( "Connecting to registry #{@path}" )
19
- raise FSLookupError, @remote unless Dir.exists?( @path )
19
+ raise FSLookupError, @path unless Dir.exists?( @path )
20
20
  end
21
21
 
22
22
  def search(name = nil, tag = nil)
@@ -53,7 +53,7 @@ module Rebuild
53
53
  def deploy(name, tag, api_class = ::Docker::Image)
54
54
  reg_file = File.join( @path, name, tag ) + FILE_SFX
55
55
  rbld_log.info( "Pulling from #{@path}" )
56
- ef = Rebuild::Engine::EnvironmentFile.new(reg_file).load!
56
+ Rebuild::Engine::EnvironmentFile.new(reg_file).load!
57
57
  end
58
58
 
59
59
  end
@@ -1,3 +1,6 @@
1
+ require 'delegate'
2
+ require 'ruby-progressbar'
3
+
1
4
  module Rebuild
2
5
  module Utils
3
6
 
@@ -50,5 +53,60 @@ module Rebuild
50
53
 
51
54
  alias rebuild_error rebuild_errors
52
55
  end
56
+
57
+ class StopWatch
58
+ def restart
59
+ @start_time = Time.now
60
+ end
61
+
62
+ alias_method :initialize, :restart
63
+
64
+ def time_ms
65
+ (Time.now - @start_time).to_i * 1000
66
+ end
67
+ end
68
+
69
+ class WithProgressBar < SimpleDelegator
70
+ def initialize(target, methods = [], progressbar_class = ProgressBar, console_obj = STDOUT)
71
+ if console_obj.tty?
72
+ __init_progress__( progressbar_class, console_obj )
73
+ methods = [ methods ] unless methods.respond_to? :each
74
+ methods.each { |m| __create_hook__( m ) }
75
+ end
76
+
77
+ super(target)
78
+ end
79
+
80
+ private
81
+
82
+ def __init_progress__(progressbar_class, console_obj)
83
+ @__progressbar__ = progressbar_class.create(title: 'Working',
84
+ length: 60,
85
+ total: nil,
86
+ output: console_obj)
87
+ @__stopwatch__ = StopWatch.new
88
+ @__first_call__ = true
89
+ end
90
+
91
+ def __create_hook__(name)
92
+ instance_eval(
93
+ %Q{
94
+ def #{name}(*args)
95
+ __do_tick__
96
+ super
97
+ end
98
+ }
99
+ )
100
+ end
101
+
102
+ def __do_tick__(*args)
103
+ if @__first_call__ || @__stopwatch__.time_ms >= 200
104
+ @__progressbar__.increment
105
+ @__stopwatch__.restart
106
+ @__first_call__ = false
107
+ end
108
+ end
109
+ end
110
+
53
111
  end
54
112
  end
@@ -15,6 +15,11 @@ CONF_CONTENTS = <<TEXT
15
15
  #REMOTE_NAME=origin
16
16
  #REMOTE_TYPE_origin="rebuild"
17
17
  #REMOTE_origin="/mnt/rbld_regsitry_root"
18
+
19
+ #For Docker Hub
20
+ REMOTE_NAME=origin
21
+ REMOTE_TYPE_origin="dockerhub"
22
+ REMOTE_origin="rbld/environments"
18
23
  TEXT
19
24
 
20
25
  task default: [RBLD_CONF]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbld
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Fleytman
8
8
  autorequire:
9
9
  bindir: cli/bin
10
10
  cert_chain: []
11
- date: 2017-03-07 00:00:00.000000000 Z
11
+ date: 2017-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -166,6 +166,46 @@ dependencies:
166
166
  - - ">="
167
167
  - !ruby/object:Gem::Version
168
168
  version: 0.1.6
169
+ - !ruby/object:Gem::Dependency
170
+ name: ruby-progressbar
171
+ requirement: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - "~>"
174
+ - !ruby/object:Gem::Version
175
+ version: '1.8'
176
+ - - ">="
177
+ - !ruby/object:Gem::Version
178
+ version: 1.8.1
179
+ type: :runtime
180
+ prerelease: false
181
+ version_requirements: !ruby/object:Gem::Requirement
182
+ requirements:
183
+ - - "~>"
184
+ - !ruby/object:Gem::Version
185
+ version: '1.8'
186
+ - - ">="
187
+ - !ruby/object:Gem::Version
188
+ version: 1.8.1
189
+ - !ruby/object:Gem::Dependency
190
+ name: plugman
191
+ requirement: !ruby/object:Gem::Requirement
192
+ requirements:
193
+ - - "~>"
194
+ - !ruby/object:Gem::Version
195
+ version: '1.0'
196
+ - - ">="
197
+ - !ruby/object:Gem::Version
198
+ version: 1.0.2
199
+ type: :runtime
200
+ prerelease: false
201
+ version_requirements: !ruby/object:Gem::Requirement
202
+ requirements:
203
+ - - "~>"
204
+ - !ruby/object:Gem::Version
205
+ version: '1.0'
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: 1.0.2
169
209
  - !ruby/object:Gem::Dependency
170
210
  name: rake
171
211
  requirement: !ruby/object:Gem::Requirement
@@ -286,6 +326,26 @@ dependencies:
286
326
  - - ">="
287
327
  - !ruby/object:Gem::Version
288
328
  version: 3.5.0
329
+ - !ruby/object:Gem::Dependency
330
+ name: timecop
331
+ requirement: !ruby/object:Gem::Requirement
332
+ requirements:
333
+ - - "~>"
334
+ - !ruby/object:Gem::Version
335
+ version: '0.8'
336
+ - - ">="
337
+ - !ruby/object:Gem::Version
338
+ version: 0.8.1
339
+ type: :development
340
+ prerelease: false
341
+ version_requirements: !ruby/object:Gem::Requirement
342
+ requirements:
343
+ - - "~>"
344
+ - !ruby/object:Gem::Version
345
+ version: '0.8'
346
+ - - ">="
347
+ - !ruby/object:Gem::Version
348
+ version: 0.8.1
289
349
  description: Zero-dependency, reproducible build environments
290
350
  email: rbld-devel@rbld.io
291
351
  executables:
@@ -320,6 +380,7 @@ files:
320
380
  - cli/lib/rbld_engine.rb
321
381
  - cli/lib/rbld_fileops.rb
322
382
  - cli/lib/rbld_log.rb
383
+ - cli/lib/rbld_plugins.rb
323
384
  - cli/lib/rbld_print.rb
324
385
  - cli/lib/rbld_reg_docker.rb
325
386
  - cli/lib/rbld_reg_dockerhub.rb
@@ -350,5 +411,5 @@ rubyforge_project:
350
411
  rubygems_version: 2.4.8
351
412
  signing_key:
352
413
  specification_version: 4
353
- summary: rbld-1.2.0
414
+ summary: rbld-1.3.0
354
415
  test_files: []