cli/lib/rbld_reg_docker.rb in rbld-1.1.0 vs cli/lib/rbld_reg_docker.rb in rbld-1.2.0
- old
+ new
@@ -1,8 +1,9 @@
require 'docker_registry2'
require_relative 'rbld_log'
require_relative 'rbld_utils'
+require_relative 'rbld_dockerops'
module Rebuild
module Registry
module Docker
extend Rebuild::Utils::Errors
@@ -34,11 +35,11 @@
attr_reader :name, :tag, :url, :wildcard
end
class API
- def initialize(remote, api_accessor = DockerRegistry)
+ def initialize(remote, api_accessor = DockerRegistry2)
@remote = remote
rbld_log.info( "Connecting to registry #{@remote}" )
begin
@api = api_accessor.connect("http://#{@remote}")
rescue StandardError
@@ -55,35 +56,15 @@
end.compact
end
def publish(name, tag, img)
url = Entry.new( name, tag, @remote ).url
- api_obj = img.api_obj
-
- api_obj.tag( repo: url.repo, tag: url.tag )
-
- begin
- rbld_log.info( "Pushing #{url.full}" )
- api_obj.push(nil, :repo_tag => url.full) do |log|
- trace_progress( log )
- end
- ensure
- api_obj.remove( :name => url.full )
- end
+ EnvironmentImage.new.publish( img, url )
end
- def deploy(name, tag, api_class = ::Docker::Image)
+ def deploy(name, tag, api_module = ::Docker)
url = Entry.new( name, tag, @remote ).url
-
- begin
- rbld_log.info( "Pulling #{url.full}" )
- img = api_class.create(:fromImage => url.full) do |log|
- trace_progress( log )
- end
- yield img
- ensure
- img.remove( :name => url.full ) if img
- end
+ EnvironmentImage.new(api_module).deploy( url ) { |img| yield img }
end
private
def trace_progress(log_item)