Module: Dapp::DockerRegistry

Defined in:
lib/dapp/docker_registry.rb,
lib/dapp/docker_registry/base.rb,
lib/dapp/docker_registry/default.rb,
lib/dapp/docker_registry/mod/request.rb,
lib/dapp/docker_registry/mod/authorization.rb

Overview

DockerRegistry

Defined Under Namespace

Modules: Mod Classes: Base, Default

Class Method Summary collapse

Class Method Details

.hostname_exist?(url) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
30
# File 'lib/dapp/docker_registry.rb', line 27

def self.hostname_exist?(url)
  return false unless url
  Mod::Request.url_available?(url)
end

.new(repo) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/dapp/docker_registry.rb', line 4

def self.new(repo)
  repo_regex =~ repo
  expected_hostname = Regexp.last_match(1)
  expected_repo_suffix = Regexp.last_match(2)
  expected_hostname_url = expected_hostname ? "http://#{expected_hostname}" : nil

  if hostname_exist?(expected_hostname_url)
    Base.new(repo, expected_hostname_url, expected_repo_suffix)
  else
    Default.new(repo, File.join(*[expected_hostname, expected_repo_suffix].compact))
  end
end

.repo_regexObject



17
18
19
20
21
22
23
24
25
# File 'lib/dapp/docker_registry.rb', line 17

def self.repo_regex
  separator = /[_.]|__|[-]*/
  alpha_numeric = /[[:alnum:]]*/
  component = /#{alpha_numeric}[#{separator}#{alpha_numeric}]*/
  port_number = /[0-9]+/
  hostcomponent = /[[:alnum:]-]*[[:alnum:]]/
  hostname = /#{hostcomponent}[\.#{hostcomponent}]*[:#{port_number}]?/
  %r{^(#{hostname}/)?(#{component}[/#{component}]*)$}
end