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
Defined Under Namespace
Modules: Mod
Classes: Base, Default
Class Method Summary
collapse
Class Method Details
.hostname_exist?(url) ⇒ Boolean
31
32
33
34
|
# File 'lib/dapp/docker_registry.rb', line 31
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_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
27
28
29
|
# File 'lib/dapp/docker_registry.rb', line 27
def self.repo_name?(name)
!(/^#{repo_name_format}$/ =~ name).nil?
end
|
17
18
19
20
21
22
23
24
25
|
# File 'lib/dapp/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
|