Module: Dapp::Dimg::DockerRegistry

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

Defined Under Namespace

Classes: Base, Default

Class Method Summary collapse

Class Method Details

.hostname_exist?(url) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
34
# File 'lib/dapp/dimg/docker_registry.rb', line 31

def self.hostname_exist?(url)
  return false unless url
  Base.url_available?(url)
end

.new(repo) ⇒ Object



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

def self.new(repo)
  /^#{repo_name_format}$/ =~ repo
  expected_hostname = Regexp.last_match(:hostname)
  expected_repo_suffix = Regexp.last_match(:repo_suffix)
  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_name?(name) ⇒ Boolean

Returns:

  • (Boolean)


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

def self.repo_name?(name)
  !(/^#{repo_name_format}$/ =~ name).nil?
end

.repo_name_formatObject



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

def self.repo_name_format
  separator = '[_.]|__|[-]*'
  alpha_numeric = '[[:alnum:]]*'
  component = "#{alpha_numeric}[#{separator}#{alpha_numeric}]*"
  port_number = '[[:digit:]]+'
  hostcomponent = '[[:alnum:]_-]*[[:alnum:]]'
  hostname = "#{hostcomponent}[\\.#{hostcomponent}]*(?<port>:#{port_number})?"
  "(?<hostname>#{hostname}/)?(?<repo_suffix>#{component}[/#{component}]*)"
end