class Dockly::Docker::Registry
Constants
- DEFAULT_SERVER_ADDRESS
Public Instance Methods
authenticate!()
click to toggle source
# File lib/dockly/docker/registry.rb, line 17 def authenticate! return unless authentication_required? @password ||= ENV['DOCKER_REGISTRY_PASSWORD'] ensure_present! :email, :password, :server_address, :username debug "Attempting to authenticate at #{server_address}" ::Docker.authenticate!(self.to_h) info "Successfully authenticated at #{server_address} with username #{username}" rescue ::Docker::Error::AuthenticationError raise "Could not authenticate at #{server_address} with username #{username}" end
config_file()
click to toggle source
# File lib/dockly/docker/registry.rb, line 34 def config_file @config_file ||= File.join('build', 'docker', 'registry', '.dockercfg') end
default_server_address?()
click to toggle source
# File lib/dockly/docker/registry.rb, line 30 def default_server_address? server_address == DEFAULT_SERVER_ADDRESS end
generate_config_file!()
click to toggle source
# File lib/dockly/docker/registry.rb, line 38 def generate_config_file! return unless authentication_required? @password ||= ENV['DOCKER_REGISTRY_PASSWORD'] ensure_present! :username, :password, :email, :server_address auth = { server_address => { :auth => Base64.encode64("#{username}:#{password}"), :email => email.to_s } }.to_json FileUtils.mkdir_p(File.dirname(config_file)) File.open(config_file, 'w') { |file| file.write(auth) } end
to_h()
click to toggle source
# File lib/dockly/docker/registry.rb, line 54 def to_h { 'serveraddress' => server_address, 'email' => email, 'username' => username, 'password' => password } end