Module: Dapp::Dimg::DockerRegistry

Defined in:
lib/dapp/dimg/docker_registry.rb,
lib/dapp/dimg/docker_registry/base.rb,
lib/dapp/dimg/docker_registry/dimg.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, Dimg

Class Method Summary collapse

Class Method Details

.hostname_exist?(url) ⇒ Boolean

Returns:

  • (Boolean)


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

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
16
# 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)

  if expected_hostname
    %w(https http).each do |protocol|
      expected_hostname_url = [protocol, expected_hostname].join('://')
      return Dimg.new(repo, expected_hostname_url, expected_repo_suffix) if hostname_exist?(expected_hostname_url)
    end
  end
  Default.new(repo, File.join(*[expected_hostname, expected_repo_suffix].compact))
end

.repo_name?(name) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/dapp/dimg/docker_registry.rb', line 24

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

.repo_name_formatObject



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

def self.repo_name_format
  rpart = '[a-z0-9]+(([_.]|__|-+)[a-z0-9]+)*'
  hpart = '(?!-)[a-z0-9-]+(?<!-)'
  "(?<hostname>#{hpart}(\\.#{hpart})*(?<port>:[0-9]+)?\/)?(?<repo_suffix>#{rpart}(\/#{rpart})*)"
end