rbld 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/cli/lib/commands/rbld_deploy.rb +0 -1
 - data/cli/lib/commands/rbld_modify.rb +6 -1
 - data/cli/lib/commands/rbld_run.rb +6 -1
 - data/cli/lib/commands/rbld_version.rb +12 -0
 - data/cli/lib/data/version +1 -0
 - data/cli/lib/rbld_commands.rb +22 -0
 - data/cli/lib/rbld_config.rb +28 -8
 - data/cli/lib/rbld_engine.rb +36 -81
 - data/cli/lib/rbld_fileops.rb +67 -0
 - data/cli/lib/{rbld_registry.rb → rbld_reg_docker.rb} +5 -2
 - data/cli/lib/rbld_reg_fs.rb +62 -0
 - data/cli/lib/rbld_verinfo.rb +19 -0
 - data/tools/rebuild-conf/Rakefile +11 -0
 - metadata +9 -4
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: d227fefcee50eefa5f3d6bfa353ada39b2ca01af
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 8ac255f0c137b88e4ba6d38d43f3c6dd4d26ff7d
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: c6d267b8044f72f2fa02ab7768eca155bb9555945707858da17e884a76f46c0d32c1243f0774aac6448bcf8824a3b375390241dbfd88f1fdb73234a6a720ebeb
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: e124388ec7544bb4c7fe5b5457db4faffa90f6fa4b914c49759b4e60452a59476d6821e1aef2dec22dde51e0e64df088f132c19b1cef996e69103bce7c1c9c15
         
     | 
| 
         @@ -1,5 +1,8 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module Rebuild::CLI
         
     | 
| 
       2 
2 
     | 
    
         
             
              class RbldModifyCommand < Command
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
                include RunOptions
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
       3 
6 
     | 
    
         
             
                def initialize
         
     | 
| 
       4 
7 
     | 
    
         
             
                  @usage = [
         
     | 
| 
       5 
8 
     | 
    
         
             
                            { :syntax => "modify [OPTIONS] [ENVIRONMENT[:TAG]]",
         
     | 
| 
         @@ -10,13 +13,15 @@ module Rebuild::CLI 
     | 
|
| 
       10 
13 
     | 
    
         
             
                                              "specified environment" }
         
     | 
| 
       11 
14 
     | 
    
         
             
                           ]
         
     | 
| 
       12 
15 
     | 
    
         
             
                  @description = "Modify a local environment"
         
     | 
| 
      
 16 
     | 
    
         
            +
                  @options = opts_text
         
     | 
| 
       13 
17 
     | 
    
         
             
                end
         
     | 
| 
       14 
18 
     | 
    
         | 
| 
       15 
19 
     | 
    
         
             
                def run(parameters)
         
     | 
| 
      
 20 
     | 
    
         
            +
                  runopts, parameters = parse_opts( parameters )
         
     | 
| 
       16 
21 
     | 
    
         
             
                  env = Environment.new( parameters.shift )
         
     | 
| 
       17 
22 
     | 
    
         
             
                  cmd = get_cmdline_tail( parameters )
         
     | 
| 
       18 
23 
     | 
    
         
             
                  rbld_log.info("Going to modify \"#{env}\" with \"#{cmd}\"")
         
     | 
| 
       19 
     | 
    
         
            -
                  @errno = engine_api.modify!( env, cmd )
         
     | 
| 
      
 24 
     | 
    
         
            +
                  @errno = engine_api.modify!( env, cmd, runopts )
         
     | 
| 
       20 
25 
     | 
    
         
             
                end
         
     | 
| 
       21 
26 
     | 
    
         
             
              end
         
     | 
| 
       22 
27 
     | 
    
         
             
            end
         
     | 
| 
         @@ -1,5 +1,8 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module Rebuild::CLI
         
     | 
| 
       2 
2 
     | 
    
         
             
              class RbldRunCommand < Command
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
                include RunOptions
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
       3 
6 
     | 
    
         
             
                def initialize
         
     | 
| 
       4 
7 
     | 
    
         
             
                  @usage = [
         
     | 
| 
       5 
8 
     | 
    
         
             
                            { :syntax => "run [OPTIONS] [ENVIRONMENT[:TAG]]",
         
     | 
| 
         @@ -10,15 +13,17 @@ module Rebuild::CLI 
     | 
|
| 
       10 
13 
     | 
    
         
             
                                              "specified environment" }
         
     | 
| 
       11 
14 
     | 
    
         
             
                           ]
         
     | 
| 
       12 
15 
     | 
    
         
             
                  @description = "Run command in a local environment"
         
     | 
| 
      
 16 
     | 
    
         
            +
                  @options = opts_text
         
     | 
| 
       13 
17 
     | 
    
         
             
                end
         
     | 
| 
       14 
18 
     | 
    
         | 
| 
       15 
19 
     | 
    
         
             
                def run(parameters)
         
     | 
| 
      
 20 
     | 
    
         
            +
                  runopts, parameters = parse_opts( parameters )
         
     | 
| 
       16 
21 
     | 
    
         
             
                  env = Environment.new( parameters.shift )
         
     | 
| 
       17 
22 
     | 
    
         
             
                  cmd = get_cmdline_tail( parameters )
         
     | 
| 
       18 
23 
     | 
    
         
             
                  rbld_log.info("Going to run \"#{cmd}\" in \"#{env}\"")
         
     | 
| 
       19 
24 
     | 
    
         | 
| 
       20 
25 
     | 
    
         
             
                  warn_if_modified( env, 'running' )
         
     | 
| 
       21 
     | 
    
         
            -
                  @errno = engine_api.run( env, cmd )
         
     | 
| 
      
 26 
     | 
    
         
            +
                  @errno = engine_api.run( env, cmd, runopts )
         
     | 
| 
       22 
27 
     | 
    
         
             
                end
         
     | 
| 
       23 
28 
     | 
    
         
             
              end
         
     | 
| 
       24 
29 
     | 
    
         
             
            end
         
     | 
| 
         @@ -0,0 +1,12 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Rebuild::CLI
         
     | 
| 
      
 2 
     | 
    
         
            +
              class RbldVersionCommand < Command
         
     | 
| 
      
 3 
     | 
    
         
            +
                def initialize
         
     | 
| 
      
 4 
     | 
    
         
            +
                  @usage = "version [OPTIONS]"
         
     | 
| 
      
 5 
     | 
    
         
            +
                  @description = "Show the Rebuild version information"
         
     | 
| 
      
 6 
     | 
    
         
            +
                end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                def run(parameters)
         
     | 
| 
      
 9 
     | 
    
         
            +
                  puts "Rebuild CLI version #{Rebuild::Version.info}"
         
     | 
| 
      
 10 
     | 
    
         
            +
                end
         
     | 
| 
      
 11 
     | 
    
         
            +
              end
         
     | 
| 
      
 12 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            1.1.0
         
     | 
    
        data/cli/lib/rbld_commands.rb
    CHANGED
    
    | 
         @@ -1,5 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require_relative 'rbld_log'
         
     | 
| 
       2 
2 
     | 
    
         
             
            require_relative 'rbld_utils'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require_relative 'rbld_verinfo'
         
     | 
| 
       3 
4 
     | 
    
         
             
            require_relative 'rbld_engine'
         
     | 
| 
       4 
5 
     | 
    
         | 
| 
       5 
6 
     | 
    
         
             
            module Rebuild::CLI
         
     | 
| 
         @@ -184,6 +185,27 @@ END_USAGE 
     | 
|
| 
       184 
185 
     | 
    
         
             
                end
         
     | 
| 
       185 
186 
     | 
    
         
             
              end
         
     | 
| 
       186 
187 
     | 
    
         | 
| 
      
 188 
     | 
    
         
            +
              module RunOptions
         
     | 
| 
      
 189 
     | 
    
         
            +
                def opts_text
         
     | 
| 
      
 190 
     | 
    
         
            +
                  [["-p, --privileged", "Run environment with superuser privileges"]]
         
     | 
| 
      
 191 
     | 
    
         
            +
                end
         
     | 
| 
      
 192 
     | 
    
         
            +
             
     | 
| 
      
 193 
     | 
    
         
            +
                def parse_opts(parameters)
         
     | 
| 
      
 194 
     | 
    
         
            +
                  replace_argv( parameters ) do
         
     | 
| 
      
 195 
     | 
    
         
            +
                    opts = GetoptLong.new([ '--privileged', '-p', GetoptLong::NO_ARGUMENT ])
         
     | 
| 
      
 196 
     | 
    
         
            +
                    runopts = {}
         
     | 
| 
      
 197 
     | 
    
         
            +
                    opts.each do |opt, arg|
         
     | 
| 
      
 198 
     | 
    
         
            +
                      case opt
         
     | 
| 
      
 199 
     | 
    
         
            +
                      when '--privileged'
         
     | 
| 
      
 200 
     | 
    
         
            +
                          runopts[:privileged] = true
         
     | 
| 
      
 201 
     | 
    
         
            +
                      end
         
     | 
| 
      
 202 
     | 
    
         
            +
                    end
         
     | 
| 
      
 203 
     | 
    
         
            +
             
     | 
| 
      
 204 
     | 
    
         
            +
                    return runopts, ARGV
         
     | 
| 
      
 205 
     | 
    
         
            +
                  end
         
     | 
| 
      
 206 
     | 
    
         
            +
                end
         
     | 
| 
      
 207 
     | 
    
         
            +
              end
         
     | 
| 
      
 208 
     | 
    
         
            +
             
     | 
| 
       187 
209 
     | 
    
         
             
              class Main
         
     | 
| 
       188 
210 
     | 
    
         | 
| 
       189 
211 
     | 
    
         
             
                def self.usage
         
     | 
    
        data/cli/lib/rbld_config.rb
    CHANGED
    
    | 
         @@ -1,20 +1,40 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'parseconfig'
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            module Rebuild
         
     | 
| 
      
 4 
     | 
    
         
            +
              class Remote
         
     | 
| 
      
 5 
     | 
    
         
            +
                def initialize(cfg)
         
     | 
| 
      
 6 
     | 
    
         
            +
                  return unless cfg
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                  if @name = cfg['REMOTE_NAME']
         
     | 
| 
      
 9 
     | 
    
         
            +
                    @type = cfg["REMOTE_TYPE_#{@name}"]
         
     | 
| 
      
 10 
     | 
    
         
            +
                    @path = cfg["REMOTE_#{@name}"]
         
     | 
| 
      
 11 
     | 
    
         
            +
                  end
         
     | 
| 
      
 12 
     | 
    
         
            +
                end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                def validate!
         
     | 
| 
      
 15 
     | 
    
         
            +
                  unless @valid
         
     | 
| 
      
 16 
     | 
    
         
            +
                    raise 'Remote not defined' unless @name
         
     | 
| 
      
 17 
     | 
    
         
            +
                    raise 'Remote type not defined' unless @type
         
     | 
| 
      
 18 
     | 
    
         
            +
                    raise 'Remote location not defined' unless @path
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                    @valid = true
         
     | 
| 
      
 21 
     | 
    
         
            +
                  end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                  self
         
     | 
| 
      
 24 
     | 
    
         
            +
                end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                attr_reader :name, :type, :path
         
     | 
| 
      
 27 
     | 
    
         
            +
              end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
       4 
29 
     | 
    
         
             
              class Config
         
     | 
| 
       5 
30 
     | 
    
         
             
                def initialize()
         
     | 
| 
       6 
31 
     | 
    
         
             
                  cfg_file = File.join( Dir.home, '.rbld', 'rebuild.conf' )
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
                   
     | 
| 
       9 
     | 
    
         
            -
                    cfg = ParseConfig.new( cfg_file )
         
     | 
| 
       10 
     | 
    
         
            -
                    rname = cfg['REMOTE_NAME']
         
     | 
| 
       11 
     | 
    
         
            -
                    @remote = rname ? cfg["REMOTE_#{rname}"] : nil
         
     | 
| 
       12 
     | 
    
         
            -
                  end
         
     | 
| 
      
 32 
     | 
    
         
            +
                  cfg = File.exist?( cfg_file ) ? ParseConfig.new( cfg_file ) : nil
         
     | 
| 
      
 33 
     | 
    
         
            +
                  @remote = Remote.new( cfg )
         
     | 
| 
       13 
34 
     | 
    
         
             
                end
         
     | 
| 
       14 
35 
     | 
    
         | 
| 
       15 
36 
     | 
    
         
             
                def remote!
         
     | 
| 
       16 
     | 
    
         
            -
                   
     | 
| 
       17 
     | 
    
         
            -
                  @remote
         
     | 
| 
      
 37 
     | 
    
         
            +
                  @remote.validate!
         
     | 
| 
       18 
38 
     | 
    
         
             
                end
         
     | 
| 
       19 
39 
     | 
    
         
             
              end
         
     | 
| 
       20 
40 
     | 
    
         
             
            end
         
     | 
    
        data/cli/lib/rbld_engine.rb
    CHANGED
    
    | 
         @@ -7,7 +7,9 @@ require_relative 'rbld_log' 
     | 
|
| 
       7 
7 
     | 
    
         
             
            require_relative 'rbld_config'
         
     | 
| 
       8 
8 
     | 
    
         
             
            require_relative 'rbld_utils'
         
     | 
| 
       9 
9 
     | 
    
         
             
            require_relative 'rbld_print'
         
     | 
| 
       10 
     | 
    
         
            -
            require_relative ' 
     | 
| 
      
 10 
     | 
    
         
            +
            require_relative 'rbld_reg_docker'
         
     | 
| 
      
 11 
     | 
    
         
            +
            require_relative 'rbld_reg_fs'
         
     | 
| 
      
 12 
     | 
    
         
            +
            require_relative 'rbld_fileops'
         
     | 
| 
       11 
13 
     | 
    
         | 
| 
       12 
14 
     | 
    
         
             
            module Rebuild::Engine
         
     | 
| 
       13 
15 
     | 
    
         
             
              extend Rebuild::Utils::Errors
         
     | 
| 
         @@ -271,8 +273,6 @@ module Rebuild::Engine 
     | 
|
| 
       271 
273 
     | 
    
         
             
               EnvironmentIsModified: 'Environment is modified, commit or checkout first',
         
     | 
| 
       272 
274 
     | 
    
         
             
               EnvironmentNotKnown: 'Unknown environment %s',
         
     | 
| 
       273 
275 
     | 
    
         
             
               NoChangesToCommit: 'No changes to commit for %s',
         
     | 
| 
       274 
     | 
    
         
            -
               EnvironmentLoadFailure: 'Failed to load environment from %s',
         
     | 
| 
       275 
     | 
    
         
            -
               EnvironmentSaveFailure: 'Failed to save environment %s to %s',
         
     | 
| 
       276 
276 
     | 
    
         
             
               EnvironmentDeploymentFailure: 'Failed to deploy from %s',
         
     | 
| 
       277 
277 
     | 
    
         
             
               EnvironmentAlreadyExists: 'Environment %s already exists',
         
     | 
| 
       278 
278 
     | 
    
         
             
               EnvironmentNotFoundInTheRegistry: 'Environment %s does not exist in the registry',
         
     | 
| 
         @@ -281,61 +281,6 @@ module Rebuild::Engine 
     | 
|
| 
       281 
281 
     | 
    
         
             
               EnvironmentPublishFailure: 'Failed to publish on %s',
         
     | 
| 
       282 
282 
     | 
    
         
             
               EnvironmentCreateFailure: 'Failed to create %s'
         
     | 
| 
       283 
283 
     | 
    
         | 
| 
       284 
     | 
    
         
            -
              class EnvironmentFile
         
     | 
| 
       285 
     | 
    
         
            -
                def initialize(filename, docker_api = Docker)
         
     | 
| 
       286 
     | 
    
         
            -
                  @filename, @docker_api = filename, docker_api
         
     | 
| 
       287 
     | 
    
         
            -
                end
         
     | 
| 
       288 
     | 
    
         
            -
             
     | 
| 
       289 
     | 
    
         
            -
                def load!
         
     | 
| 
       290 
     | 
    
         
            -
                  begin
         
     | 
| 
       291 
     | 
    
         
            -
                    with_gzip_reader { |gz| Docker::Image.load(gz) }
         
     | 
| 
       292 
     | 
    
         
            -
                  rescue => msg
         
     | 
| 
       293 
     | 
    
         
            -
                    rbld_print.trace( msg )
         
     | 
| 
       294 
     | 
    
         
            -
                    raise EnvironmentLoadFailure, @filename
         
     | 
| 
       295 
     | 
    
         
            -
                  end
         
     | 
| 
       296 
     | 
    
         
            -
                end
         
     | 
| 
       297 
     | 
    
         
            -
             
     | 
| 
       298 
     | 
    
         
            -
                def save!(name, identity)
         
     | 
| 
       299 
     | 
    
         
            -
                  begin
         
     | 
| 
       300 
     | 
    
         
            -
                    with_gzip_writer do |gz|
         
     | 
| 
       301 
     | 
    
         
            -
                      Docker::Image.save_stream( identity ) { |chunk| gz.write chunk }
         
     | 
| 
       302 
     | 
    
         
            -
                    end
         
     | 
| 
       303 
     | 
    
         
            -
                  rescue => msg
         
     | 
| 
       304 
     | 
    
         
            -
                    rbld_print.trace( msg )
         
     | 
| 
       305 
     | 
    
         
            -
                    raise EnvironmentSaveFailure, [name, @filename]
         
     | 
| 
       306 
     | 
    
         
            -
                  end
         
     | 
| 
       307 
     | 
    
         
            -
                end
         
     | 
| 
       308 
     | 
    
         
            -
             
     | 
| 
       309 
     | 
    
         
            -
                private
         
     | 
| 
       310 
     | 
    
         
            -
             
     | 
| 
       311 
     | 
    
         
            -
                def with_gzip_writer
         
     | 
| 
       312 
     | 
    
         
            -
                  begin
         
     | 
| 
       313 
     | 
    
         
            -
                    File.open(@filename, 'w') do |f|
         
     | 
| 
       314 
     | 
    
         
            -
                      f.binmode
         
     | 
| 
       315 
     | 
    
         
            -
                      gz = Zlib::GzipWriter.new(f)
         
     | 
| 
       316 
     | 
    
         
            -
                      begin
         
     | 
| 
       317 
     | 
    
         
            -
                        yield gz
         
     | 
| 
       318 
     | 
    
         
            -
                      ensure
         
     | 
| 
       319 
     | 
    
         
            -
                        gz.close
         
     | 
| 
       320 
     | 
    
         
            -
                      end
         
     | 
| 
       321 
     | 
    
         
            -
                    end
         
     | 
| 
       322 
     | 
    
         
            -
                  rescue
         
     | 
| 
       323 
     | 
    
         
            -
                    FileUtils::safe_unlink( @filename )
         
     | 
| 
       324 
     | 
    
         
            -
                    raise
         
     | 
| 
       325 
     | 
    
         
            -
                  end
         
     | 
| 
       326 
     | 
    
         
            -
                end
         
     | 
| 
       327 
     | 
    
         
            -
             
     | 
| 
       328 
     | 
    
         
            -
                def with_gzip_reader
         
     | 
| 
       329 
     | 
    
         
            -
                  Zlib::GzipReader.open( @filename ) do |gz|
         
     | 
| 
       330 
     | 
    
         
            -
                    begin
         
     | 
| 
       331 
     | 
    
         
            -
                      yield gz
         
     | 
| 
       332 
     | 
    
         
            -
                    ensure
         
     | 
| 
       333 
     | 
    
         
            -
                      gz.close
         
     | 
| 
       334 
     | 
    
         
            -
                    end
         
     | 
| 
       335 
     | 
    
         
            -
                  end
         
     | 
| 
       336 
     | 
    
         
            -
                end
         
     | 
| 
       337 
     | 
    
         
            -
              end
         
     | 
| 
       338 
     | 
    
         
            -
             
     | 
| 
       339 
284 
     | 
    
         
             
              class DockerContext
         
     | 
| 
       340 
285 
     | 
    
         
             
                def self.from_file(file)
         
     | 
| 
       341 
286 
     | 
    
         
             
                  base = %Q{
         
     | 
| 
         @@ -501,13 +446,13 @@ module Rebuild::Engine 
     | 
|
| 
       501 
446 
     | 
    
         
             
                end
         
     | 
| 
       502 
447 
     | 
    
         | 
| 
       503 
448 
     | 
    
         
             
                def search(env_name)
         
     | 
| 
       504 
     | 
    
         
            -
                  rbld_print.progress "Searching in #{@cfg.remote 
     | 
| 
      
 449 
     | 
    
         
            +
                  rbld_print.progress "Searching in #{@cfg.remote!.path}..."
         
     | 
| 
       505 
450 
     | 
    
         | 
| 
       506 
451 
     | 
    
         
             
                  begin
         
     | 
| 
       507 
452 
     | 
    
         
             
                    registry.search( env_name.name, env_name.tag )
         
     | 
| 
       508 
453 
     | 
    
         
             
                  rescue => msg
         
     | 
| 
       509 
454 
     | 
    
         
             
                    rbld_print.trace( msg )
         
     | 
| 
       510 
     | 
    
         
            -
                    raise RegistrySearchFailed, @cfg.remote 
     | 
| 
      
 455 
     | 
    
         
            +
                    raise RegistrySearchFailed, @cfg.remote!.path
         
     | 
| 
       511 
456 
     | 
    
         
             
                  end
         
     | 
| 
       512 
457 
     | 
    
         
             
                end
         
     | 
| 
       513 
458 
     | 
    
         | 
| 
         @@ -517,7 +462,7 @@ module Rebuild::Engine 
     | 
|
| 
       517 
462 
     | 
    
         
             
                  raise EnvironmentNotFoundInTheRegistry, env_name.full \
         
     | 
| 
       518 
463 
     | 
    
         
             
                    if registry.search( env_name.name, env_name.tag ).empty?
         
     | 
| 
       519 
464 
     | 
    
         | 
| 
       520 
     | 
    
         
            -
                  rbld_print.progress "Deploying from #{@cfg.remote 
     | 
| 
      
 465 
     | 
    
         
            +
                  rbld_print.progress "Deploying from #{@cfg.remote!.path}..."
         
     | 
| 
       521 
466 
     | 
    
         | 
| 
       522 
467 
     | 
    
         
             
                  begin
         
     | 
| 
       523 
468 
     | 
    
         
             
                   registry.deploy( env_name.name, env_name.tag ) do |img|
         
     | 
| 
         @@ -526,7 +471,7 @@ module Rebuild::Engine 
     | 
|
| 
       526 
471 
     | 
    
         
             
                   end
         
     | 
| 
       527 
472 
     | 
    
         
             
                  rescue => msg
         
     | 
| 
       528 
473 
     | 
    
         
             
                   rbld_print.trace( msg )
         
     | 
| 
       529 
     | 
    
         
            -
                   raise EnvironmentDeploymentFailure, @cfg.remote 
     | 
| 
      
 474 
     | 
    
         
            +
                   raise EnvironmentDeploymentFailure, @cfg.remote!.path
         
     | 
| 
       530 
475 
     | 
    
         
             
                  end
         
     | 
| 
       531 
476 
     | 
    
         | 
| 
       532 
477 
     | 
    
         
             
                  @cache.refresh!
         
     | 
| 
         @@ -541,33 +486,33 @@ module Rebuild::Engine 
     | 
|
| 
       541 
486 
     | 
    
         
             
                     unless registry.search( env_name.name, env_name.tag ).empty?
         
     | 
| 
       542 
487 
     | 
    
         | 
| 
       543 
488 
     | 
    
         
             
                  begin
         
     | 
| 
       544 
     | 
    
         
            -
                    rbld_print.progress "Publishing on #{@cfg.remote 
     | 
| 
       545 
     | 
    
         
            -
                    registry.publish( env.name, env.tag, env.img 
     | 
| 
      
 489 
     | 
    
         
            +
                    rbld_print.progress "Publishing on #{@cfg.remote!.path}..."
         
     | 
| 
      
 490 
     | 
    
         
            +
                    registry.publish( env.name, env.tag, env.img )
         
     | 
| 
       546 
491 
     | 
    
         
             
                  rescue => msg
         
     | 
| 
       547 
492 
     | 
    
         
             
                    rbld_print.trace( msg )
         
     | 
| 
       548 
     | 
    
         
            -
                    raise EnvironmentPublishFailure, @cfg.remote 
     | 
| 
      
 493 
     | 
    
         
            +
                    raise EnvironmentPublishFailure, @cfg.remote!.path
         
     | 
| 
       549 
494 
     | 
    
         
             
                  end
         
     | 
| 
       550 
495 
     | 
    
         
             
                end
         
     | 
| 
       551 
496 
     | 
    
         | 
| 
       552 
     | 
    
         
            -
                def run(env_name, cmd)
         
     | 
| 
      
 497 
     | 
    
         
            +
                def run(env_name, cmd, runopts = {})
         
     | 
| 
       553 
498 
     | 
    
         
             
                  env = existing_env( env_name )
         
     | 
| 
       554 
     | 
    
         
            -
                  run_env_disposable( env, cmd )
         
     | 
| 
      
 499 
     | 
    
         
            +
                  run_env_disposable( env, cmd, runopts )
         
     | 
| 
       555 
500 
     | 
    
         
             
                  @cache.refresh!
         
     | 
| 
       556 
501 
     | 
    
         
             
                  @errno
         
     | 
| 
       557 
502 
     | 
    
         
             
                end
         
     | 
| 
       558 
503 
     | 
    
         | 
| 
       559 
     | 
    
         
            -
                def modify!(env_name, cmd)
         
     | 
| 
      
 504 
     | 
    
         
            +
                def modify!(env_name, cmd, runopts = {})
         
     | 
| 
       560 
505 
     | 
    
         
             
                  env = existing_env( env_name )
         
     | 
| 
       561 
506 
     | 
    
         | 
| 
       562 
507 
     | 
    
         
             
                  rbld_print.progress_start 'Initializing environment'
         
     | 
| 
       563 
508 
     | 
    
         | 
| 
       564 
509 
     | 
    
         
             
                  if env.modified?
         
     | 
| 
       565 
510 
     | 
    
         
             
                    rbld_log.info("Running container #{env.modification_container}")
         
     | 
| 
       566 
     | 
    
         
            -
                    rerun_modification_cont(env, cmd)
         
     | 
| 
      
 511 
     | 
    
         
            +
                    rerun_modification_cont(env, cmd, runopts)
         
     | 
| 
       567 
512 
     | 
    
         
             
                  else
         
     | 
| 
       568 
513 
     | 
    
         
             
                    rbld_log.info("Running environment #{env.img}")
         
     | 
| 
       569 
514 
     | 
    
         
             
                    rbld_print.progress_end
         
     | 
| 
       570 
     | 
    
         
            -
                    run_env(env, cmd)
         
     | 
| 
      
 515 
     | 
    
         
            +
                    run_env(env, cmd, runopts)
         
     | 
| 
       571 
516 
     | 
    
         
             
                  end
         
     | 
| 
       572 
517 
     | 
    
         
             
                  @cache.refresh!
         
     | 
| 
       573 
518 
     | 
    
         
             
                  @errno
         
     | 
| 
         @@ -667,8 +612,18 @@ module Rebuild::Engine 
     | 
|
| 
       667 
612 
     | 
    
         
             
                end
         
     | 
| 
       668 
613 
     | 
    
         | 
| 
       669 
614 
     | 
    
         
             
                def registry
         
     | 
| 
       670 
     | 
    
         
            -
                  @registry  
     | 
| 
       671 
     | 
    
         
            -
             
     | 
| 
      
 615 
     | 
    
         
            +
                  return @registry if @registry
         
     | 
| 
      
 616 
     | 
    
         
            +
             
     | 
| 
      
 617 
     | 
    
         
            +
                  case @cfg.remote!.type
         
     | 
| 
      
 618 
     | 
    
         
            +
                  when 'docker'
         
     | 
| 
      
 619 
     | 
    
         
            +
                    reg_module = Rebuild::Registry::Docker
         
     | 
| 
      
 620 
     | 
    
         
            +
                  when 'rebuild'
         
     | 
| 
      
 621 
     | 
    
         
            +
                    reg_module = Rebuild::Registry::FS
         
     | 
| 
      
 622 
     | 
    
         
            +
                  else
         
     | 
| 
      
 623 
     | 
    
         
            +
                    raise "Remote type #{@cfg.remote!.type} is unknown"
         
     | 
| 
      
 624 
     | 
    
         
            +
                  end
         
     | 
| 
      
 625 
     | 
    
         
            +
             
     | 
| 
      
 626 
     | 
    
         
            +
                  @registry = reg_module::API.new( @cfg.remote!.path )
         
     | 
| 
       672 
627 
     | 
    
         
             
                end
         
     | 
| 
       673 
628 
     | 
    
         | 
| 
       674 
629 
     | 
    
         
             
                def run_external(cmdline)
         
     | 
| 
         @@ -706,23 +661,23 @@ module Rebuild::Engine 
     | 
|
| 
       706 
661 
     | 
    
         
             
                      -e REBUILD_PWD=#{rs.pwd}                          \
         
     | 
| 
       707 
662 
     | 
    
         
             
                      --security-opt label:disable                      \
         
     | 
| 
       708 
663 
     | 
    
         
             
                      #{trace_run_settings}                             \
         
     | 
| 
      
 664 
     | 
    
         
            +
                      #{opts[:privileged] ? "--privileged" : ""}        \
         
     | 
| 
       709 
665 
     | 
    
         
             
                      #{opts[:rerun] ? env.rerun_img.id : env.img.id}   \
         
     | 
| 
       710 
666 
     | 
    
         
             
                      "#{cmd.join(' ')}"                                \
         
     | 
| 
       711 
667 
     | 
    
         
             
                  }
         
     | 
| 
       712 
668 
     | 
    
         
             
                end
         
     | 
| 
       713 
669 
     | 
    
         | 
| 
       714 
     | 
    
         
            -
                def run_env_disposable(env, cmd)
         
     | 
| 
      
 670 
     | 
    
         
            +
                def run_env_disposable(env, cmd, runopts)
         
     | 
| 
       715 
671 
     | 
    
         
             
                  env.execution_container.remove! if env.execution_container
         
     | 
| 
       716 
672 
     | 
    
         
             
                  names = NameFactory.new(env)
         
     | 
| 
       717 
673 
     | 
    
         | 
| 
       718 
674 
     | 
    
         
             
                  cmdline = %Q{
         
     | 
| 
       719 
     | 
    
         
            -
                    docker run 
     | 
| 
       720 
     | 
    
         
            -
                         --rm 
     | 
| 
       721 
     | 
    
         
            -
                         --name #{names.running} 
     | 
| 
       722 
     | 
    
         
            -
                         --hostname #{names.hostname} 
     | 
| 
       723 
     | 
    
         
            -
                         #{run_settings( env, cmd )}     \
         
     | 
| 
      
 675 
     | 
    
         
            +
                    docker run                                    \
         
     | 
| 
      
 676 
     | 
    
         
            +
                         --rm                                     \
         
     | 
| 
      
 677 
     | 
    
         
            +
                         --name #{names.running}                  \
         
     | 
| 
      
 678 
     | 
    
         
            +
                         --hostname #{names.hostname}             \
         
     | 
| 
      
 679 
     | 
    
         
            +
                         #{run_settings( env, cmd, runopts )}     \
         
     | 
| 
       724 
680 
     | 
    
         
             
                  }
         
     | 
| 
       725 
     | 
    
         
            -
             
     | 
| 
       726 
681 
     | 
    
         
             
                  run_external( cmdline )
         
     | 
| 
       727 
682 
     | 
    
         
             
                end
         
     | 
| 
       728 
683 
     | 
    
         | 
| 
         @@ -739,7 +694,7 @@ module Rebuild::Engine 
     | 
|
| 
       739 
694 
     | 
    
         
             
                  run_external( cmdline )
         
     | 
| 
       740 
695 
     | 
    
         
             
                end
         
     | 
| 
       741 
696 
     | 
    
         | 
| 
       742 
     | 
    
         
            -
                def rerun_modification_cont(env, cmd)
         
     | 
| 
      
 697 
     | 
    
         
            +
                def rerun_modification_cont(env, cmd, opts = {})
         
     | 
| 
       743 
698 
     | 
    
         
             
                  rbld_print.progress_tick
         
     | 
| 
       744 
699 
     | 
    
         | 
| 
       745 
700 
     | 
    
         
             
                  names = NameFactory.new( env )
         
     | 
| 
         @@ -754,7 +709,7 @@ module Rebuild::Engine 
     | 
|
| 
       754 
709 
     | 
    
         | 
| 
       755 
710 
     | 
    
         
             
                  @cache.refresh!
         
     | 
| 
       756 
711 
     | 
    
         | 
| 
       757 
     | 
    
         
            -
                  run_env( @cache.get(env), cmd, rerun: true )
         
     | 
| 
      
 712 
     | 
    
         
            +
                  run_env( @cache.get(env), cmd, opts.merge(rerun: true) )
         
     | 
| 
       758 
713 
     | 
    
         
             
                end
         
     | 
| 
       759 
714 
     | 
    
         | 
| 
       760 
715 
     | 
    
         
             
                def existing_env(name)
         
     | 
| 
         @@ -0,0 +1,67 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'docker'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require_relative 'rbld_utils'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require_relative 'rbld_print'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            module Rebuild::Engine
         
     | 
| 
      
 6 
     | 
    
         
            +
              extend Rebuild::Utils::Errors
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              rebuild_errors \
         
     | 
| 
      
 9 
     | 
    
         
            +
               EnvironmentLoadFailure: 'Failed to load environment from %s',
         
     | 
| 
      
 10 
     | 
    
         
            +
               EnvironmentSaveFailure: 'Failed to save environment %s to %s'
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              class EnvironmentFile
         
     | 
| 
      
 13 
     | 
    
         
            +
                def initialize(filename, docker_api = Docker)
         
     | 
| 
      
 14 
     | 
    
         
            +
                  @filename, @docker_api = filename, docker_api
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                def load!
         
     | 
| 
      
 18 
     | 
    
         
            +
                  begin
         
     | 
| 
      
 19 
     | 
    
         
            +
                    with_gzip_reader { |gz| Docker::Image.load(gz) }
         
     | 
| 
      
 20 
     | 
    
         
            +
                  rescue => msg
         
     | 
| 
      
 21 
     | 
    
         
            +
                    rbld_print.trace( msg )
         
     | 
| 
      
 22 
     | 
    
         
            +
                    raise EnvironmentLoadFailure, @filename
         
     | 
| 
      
 23 
     | 
    
         
            +
                  end
         
     | 
| 
      
 24 
     | 
    
         
            +
                end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                def save!(name, identity)
         
     | 
| 
      
 27 
     | 
    
         
            +
                  begin
         
     | 
| 
      
 28 
     | 
    
         
            +
                    with_gzip_writer do |gz|
         
     | 
| 
      
 29 
     | 
    
         
            +
                      Docker::Image.save_stream( identity ) { |chunk| gz.write chunk }
         
     | 
| 
      
 30 
     | 
    
         
            +
                    end
         
     | 
| 
      
 31 
     | 
    
         
            +
                  rescue => msg
         
     | 
| 
      
 32 
     | 
    
         
            +
                    rbld_print.trace( msg )
         
     | 
| 
      
 33 
     | 
    
         
            +
                    raise EnvironmentSaveFailure, [name, @filename]
         
     | 
| 
      
 34 
     | 
    
         
            +
                  end
         
     | 
| 
      
 35 
     | 
    
         
            +
                end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                private
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                def with_gzip_writer
         
     | 
| 
      
 40 
     | 
    
         
            +
                  begin
         
     | 
| 
      
 41 
     | 
    
         
            +
                    File.open(@filename, 'w') do |f|
         
     | 
| 
      
 42 
     | 
    
         
            +
                      f.binmode
         
     | 
| 
      
 43 
     | 
    
         
            +
                      gz = Zlib::GzipWriter.new(f)
         
     | 
| 
      
 44 
     | 
    
         
            +
                      begin
         
     | 
| 
      
 45 
     | 
    
         
            +
                        yield gz
         
     | 
| 
      
 46 
     | 
    
         
            +
                      ensure
         
     | 
| 
      
 47 
     | 
    
         
            +
                        gz.close
         
     | 
| 
      
 48 
     | 
    
         
            +
                      end
         
     | 
| 
      
 49 
     | 
    
         
            +
                    end
         
     | 
| 
      
 50 
     | 
    
         
            +
                  rescue
         
     | 
| 
      
 51 
     | 
    
         
            +
                    FileUtils::safe_unlink( @filename )
         
     | 
| 
      
 52 
     | 
    
         
            +
                    raise
         
     | 
| 
      
 53 
     | 
    
         
            +
                  end
         
     | 
| 
      
 54 
     | 
    
         
            +
                end
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
                def with_gzip_reader
         
     | 
| 
      
 57 
     | 
    
         
            +
                  Zlib::GzipReader.open( @filename ) do |gz|
         
     | 
| 
      
 58 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 59 
     | 
    
         
            +
                      yield gz
         
     | 
| 
      
 60 
     | 
    
         
            +
                    ensure
         
     | 
| 
      
 61 
     | 
    
         
            +
                      gz.close
         
     | 
| 
      
 62 
     | 
    
         
            +
                    end
         
     | 
| 
      
 63 
     | 
    
         
            +
                  end
         
     | 
| 
      
 64 
     | 
    
         
            +
                end
         
     | 
| 
      
 65 
     | 
    
         
            +
              end
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -4,6 +4,7 @@ require_relative 'rbld_utils' 
     | 
|
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            module Rebuild
         
     | 
| 
       6 
6 
     | 
    
         
             
              module Registry
         
     | 
| 
      
 7 
     | 
    
         
            +
              module Docker
         
     | 
| 
       7 
8 
     | 
    
         
             
                extend Rebuild::Utils::Errors
         
     | 
| 
       8 
9 
     | 
    
         | 
| 
       9 
10 
     | 
    
         
             
                rebuild_errors \
         
     | 
| 
         @@ -54,8 +55,9 @@ module Rebuild 
     | 
|
| 
       54 
55 
     | 
    
         
             
                    end.compact
         
     | 
| 
       55 
56 
     | 
    
         
             
                  end
         
     | 
| 
       56 
57 
     | 
    
         | 
| 
       57 
     | 
    
         
            -
                  def publish(name, tag,  
     | 
| 
      
 58 
     | 
    
         
            +
                  def publish(name, tag, img)
         
     | 
| 
       58 
59 
     | 
    
         
             
                    url = Entry.new( name, tag, @remote ).url
         
     | 
| 
      
 60 
     | 
    
         
            +
                    api_obj = img.api_obj
         
     | 
| 
       59 
61 
     | 
    
         | 
| 
       60 
62 
     | 
    
         
             
                    api_obj.tag( repo: url.repo, tag: url.tag )
         
     | 
| 
       61 
63 
     | 
    
         | 
| 
         @@ -69,7 +71,7 @@ module Rebuild 
     | 
|
| 
       69 
71 
     | 
    
         
             
                    end
         
     | 
| 
       70 
72 
     | 
    
         
             
                  end
         
     | 
| 
       71 
73 
     | 
    
         | 
| 
       72 
     | 
    
         
            -
                  def deploy(name, tag, api_class = Docker::Image)
         
     | 
| 
      
 74 
     | 
    
         
            +
                  def deploy(name, tag, api_class = ::Docker::Image)
         
     | 
| 
       73 
75 
     | 
    
         
             
                    url = Entry.new( name, tag, @remote ).url
         
     | 
| 
       74 
76 
     | 
    
         | 
| 
       75 
77 
     | 
    
         
             
                    begin
         
     | 
| 
         @@ -103,4 +105,5 @@ module Rebuild 
     | 
|
| 
       103 
105 
     | 
    
         
             
                  end
         
     | 
| 
       104 
106 
     | 
    
         
             
                end
         
     | 
| 
       105 
107 
     | 
    
         
             
              end
         
     | 
| 
      
 108 
     | 
    
         
            +
              end
         
     | 
| 
       106 
109 
     | 
    
         
             
            end
         
     | 
| 
         @@ -0,0 +1,62 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require_relative 'rbld_log'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require_relative 'rbld_utils'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require_relative 'rbld_fileops'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            module Rebuild
         
     | 
| 
      
 6 
     | 
    
         
            +
              module Registry
         
     | 
| 
      
 7 
     | 
    
         
            +
              module FS
         
     | 
| 
      
 8 
     | 
    
         
            +
                extend Rebuild::Utils::Errors
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                rebuild_error FSLookupError: 'Failed to access registry at %s'
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                class API
         
     | 
| 
      
 13 
     | 
    
         
            +
                  FILE_SFX = '.rbe'
         
     | 
| 
      
 14 
     | 
    
         
            +
                  private_constant :FILE_SFX
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                  def initialize(path)
         
     | 
| 
      
 17 
     | 
    
         
            +
                    @path = path
         
     | 
| 
      
 18 
     | 
    
         
            +
                    rbld_log.info( "Connecting to registry #{@path}" )
         
     | 
| 
      
 19 
     | 
    
         
            +
                    raise FSLookupError, @remote unless Dir.exists?( @path )
         
     | 
| 
      
 20 
     | 
    
         
            +
                  end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                  def search(name = nil, tag = nil)
         
     | 
| 
      
 23 
     | 
    
         
            +
                    wildcard = File.join( tag.to_s.empty? ? ["#{name}*", '*' ] : [name, tag] ) + FILE_SFX
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                    rbld_log.info( "Searching for #{wildcard}" )
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                    Dir.glob( File.join( @path, wildcard ) ).map do |n|
         
     | 
| 
      
 28 
     | 
    
         
            +
                      pfx = File.join( @path,'' )
         
     | 
| 
      
 29 
     | 
    
         
            +
                      sfx = FILE_SFX
         
     | 
| 
      
 30 
     | 
    
         
            +
                      s = File::SEPARATOR
         
     | 
| 
      
 31 
     | 
    
         
            +
                      nametag = n.match( /^#{pfx}([^#{s}]+)#{s}([^#{s}]+)#{sfx}$/ ).captures
         
     | 
| 
      
 32 
     | 
    
         
            +
                      Rebuild::Utils::FullImageName.new( *nametag )
         
     | 
| 
      
 33 
     | 
    
         
            +
                    end
         
     | 
| 
      
 34 
     | 
    
         
            +
                  end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                  def publish(name, tag, img)
         
     | 
| 
      
 37 
     | 
    
         
            +
                    reg_dir = File.join( @path, name )
         
     | 
| 
      
 38 
     | 
    
         
            +
                    reg_file = File.join( reg_dir, tag ) + FILE_SFX
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                    rbld_log.info( "Pushing to #{@path}" )
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                    FileUtils.mkdir_p( File.join( reg_dir ) )
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 45 
     | 
    
         
            +
                      ef = Rebuild::Engine::EnvironmentFile.new(reg_file)
         
     | 
| 
      
 46 
     | 
    
         
            +
                      ef.save!( Rebuild::Utils::FullImageName.new( name, tag ), img.identity )
         
     | 
| 
      
 47 
     | 
    
         
            +
                    rescue
         
     | 
| 
      
 48 
     | 
    
         
            +
                      FileUtils.rm_rf( reg_file )
         
     | 
| 
      
 49 
     | 
    
         
            +
                      raise
         
     | 
| 
      
 50 
     | 
    
         
            +
                    end
         
     | 
| 
      
 51 
     | 
    
         
            +
                  end
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
                  def deploy(name, tag, api_class = ::Docker::Image)
         
     | 
| 
      
 54 
     | 
    
         
            +
                    reg_file = File.join( @path, name, tag ) + FILE_SFX
         
     | 
| 
      
 55 
     | 
    
         
            +
                    rbld_log.info( "Pulling from #{@path}" )
         
     | 
| 
      
 56 
     | 
    
         
            +
                    ef = Rebuild::Engine::EnvironmentFile.new(reg_file).load!
         
     | 
| 
      
 57 
     | 
    
         
            +
                  end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                end
         
     | 
| 
      
 60 
     | 
    
         
            +
              end
         
     | 
| 
      
 61 
     | 
    
         
            +
              end
         
     | 
| 
      
 62 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,19 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Rebuild
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Version
         
     | 
| 
      
 3 
     | 
    
         
            +
                def self.retrieve_info
         
     | 
| 
      
 4 
     | 
    
         
            +
                  git_ver_script = File.expand_path("../../../tools/version.rb", __FILE__)
         
     | 
| 
      
 5 
     | 
    
         
            +
                  if File.exists?( git_ver_script )
         
     | 
| 
      
 6 
     | 
    
         
            +
                    require git_ver_script
         
     | 
| 
      
 7 
     | 
    
         
            +
                    rbld_version
         
     | 
| 
      
 8 
     | 
    
         
            +
                  else
         
     | 
| 
      
 9 
     | 
    
         
            +
                    File.read(File.expand_path("../data/version", __FILE__))
         
     | 
| 
      
 10 
     | 
    
         
            +
                  end
         
     | 
| 
      
 11 
     | 
    
         
            +
                end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                private_class_method :retrieve_info
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                def self.info
         
     | 
| 
      
 16 
     | 
    
         
            +
                  @ver ||= retrieve_info
         
     | 
| 
      
 17 
     | 
    
         
            +
                end
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
            end
         
     | 
    
        data/tools/rebuild-conf/Rakefile
    CHANGED
    
    | 
         @@ -2,8 +2,19 @@ CONF_DIR = File.join( Dir.home, '.rbld' ) 
     | 
|
| 
       2 
2 
     | 
    
         
             
            RBLD_CONF = File.expand_path( 'rebuild.conf', CONF_DIR )
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
            CONF_CONTENTS = <<TEXT
         
     | 
| 
      
 5 
     | 
    
         
            +
            #This is a sample config file for Rebuild
         
     | 
| 
      
 6 
     | 
    
         
            +
            #Uncomment and adjust following lines
         
     | 
| 
      
 7 
     | 
    
         
            +
            #according to your registry configuration
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            #For Docker registries
         
     | 
| 
       5 
10 
     | 
    
         
             
            #REMOTE_NAME=origin
         
     | 
| 
      
 11 
     | 
    
         
            +
            #REMOTE_TYPE_origin="docker"
         
     | 
| 
       6 
12 
     | 
    
         
             
            #REMOTE_origin="10.0.110.110:5000"
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            #For native Rebuild registry
         
     | 
| 
      
 15 
     | 
    
         
            +
            #REMOTE_NAME=origin
         
     | 
| 
      
 16 
     | 
    
         
            +
            #REMOTE_TYPE_origin="rebuild"
         
     | 
| 
      
 17 
     | 
    
         
            +
            #REMOTE_origin="/mnt/rbld_regsitry_root"
         
     | 
| 
       7 
18 
     | 
    
         
             
            TEXT
         
     | 
| 
       8 
19 
     | 
    
         | 
| 
       9 
20 
     | 
    
         
             
            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.0 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.1.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- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2017-02-02 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: colorize
         
     | 
| 
         @@ -278,13 +278,18 @@ files: 
     | 
|
| 
       278 
278 
     | 
    
         
             
            - cli/lib/commands/rbld_save.rb
         
     | 
| 
       279 
279 
     | 
    
         
             
            - cli/lib/commands/rbld_search.rb
         
     | 
| 
       280 
280 
     | 
    
         
             
            - cli/lib/commands/rbld_status.rb
         
     | 
| 
      
 281 
     | 
    
         
            +
            - cli/lib/commands/rbld_version.rb
         
     | 
| 
      
 282 
     | 
    
         
            +
            - cli/lib/data/version
         
     | 
| 
       281 
283 
     | 
    
         
             
            - cli/lib/rbld_commands.rb
         
     | 
| 
       282 
284 
     | 
    
         
             
            - cli/lib/rbld_config.rb
         
     | 
| 
       283 
285 
     | 
    
         
             
            - cli/lib/rbld_engine.rb
         
     | 
| 
      
 286 
     | 
    
         
            +
            - cli/lib/rbld_fileops.rb
         
     | 
| 
       284 
287 
     | 
    
         
             
            - cli/lib/rbld_log.rb
         
     | 
| 
       285 
288 
     | 
    
         
             
            - cli/lib/rbld_print.rb
         
     | 
| 
       286 
     | 
    
         
            -
            - cli/lib/ 
     | 
| 
      
 289 
     | 
    
         
            +
            - cli/lib/rbld_reg_docker.rb
         
     | 
| 
      
 290 
     | 
    
         
            +
            - cli/lib/rbld_reg_fs.rb
         
     | 
| 
       287 
291 
     | 
    
         
             
            - cli/lib/rbld_utils.rb
         
     | 
| 
      
 292 
     | 
    
         
            +
            - cli/lib/rbld_verinfo.rb
         
     | 
| 
       288 
293 
     | 
    
         
             
            - tools/rebuild-conf/Rakefile
         
     | 
| 
       289 
294 
     | 
    
         
             
            homepage: http://rbld.io/
         
     | 
| 
       290 
295 
     | 
    
         
             
            licenses:
         
     | 
| 
         @@ -309,5 +314,5 @@ rubyforge_project: 
     | 
|
| 
       309 
314 
     | 
    
         
             
            rubygems_version: 2.4.8
         
     | 
| 
       310 
315 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       311 
316 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       312 
     | 
    
         
            -
            summary: rbld-1.0 
     | 
| 
      
 317 
     | 
    
         
            +
            summary: rbld-1.1.0
         
     | 
| 
       313 
318 
     | 
    
         
             
            test_files: []
         
     |