Class: Katello::RepoDiscovery

Inherits:
Object
  • Object
show all
Includes:
Util::HttpProxy
Defined in:
app/lib/katello/repo_discovery.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util::HttpProxy

#proxy, #proxy_host, #proxy_port, #proxy_scheme, #proxy_uri

Constructor Details

#initialize(url, content_type = 'yum', upstream_username = nil, upstream_password = nil, search = '*', crawled = [], found = [], to_follow = []) ⇒ RepoDiscovery

rubocop:disable Metrics/ParameterLists



8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/lib/katello/repo_discovery.rb', line 8

def initialize(url, content_type = 'yum', upstream_username = nil,
  upstream_password = nil, search = '*', crawled = [],
  found = [], to_follow = [])
  @uri = uri(url)
  @content_type = content_type
  @upstream_username = upstream_username.empty? ? nil : upstream_username
  @upstream_password = upstream_password.empty? ? nil : upstream_password
  @search = search
  @found = found
  @crawled = crawled
  @to_follow = to_follow
end

Instance Attribute Details

#crawledObject (readonly)

Returns the value of attribute crawled.



5
6
7
# File 'app/lib/katello/repo_discovery.rb', line 5

def crawled
  @crawled
end

#foundObject (readonly)

Returns the value of attribute found.



5
6
7
# File 'app/lib/katello/repo_discovery.rb', line 5

def found
  @found
end

#to_followObject (readonly)

Returns the value of attribute to_follow.



5
6
7
# File 'app/lib/katello/repo_discovery.rb', line 5

def to_follow
  @to_follow
end

Instance Method Details

#run(resume_point) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/lib/katello/repo_discovery.rb', line 29

def run(resume_point)
  if @content_type == 'docker'
    docker_search
  else
    if @uri.scheme == 'file'
      file_crawl(uri(resume_point))
    elsif %w(http https).include?(@uri.scheme)
      http_crawl(uri(resume_point))
    else
      fail _("Unsupported URL protocol %s.") % @uri.scheme
    end
  end
end

#uri(url) ⇒ Object

rubocop:enable Metrics/ParameterLists



22
23
24
25
26
27
# File 'app/lib/katello/repo_discovery.rb', line 22

def uri(url)
  #add a / on the end, as directories require it or else
  #  They will get double slahes on them
  url += '/' unless url.ends_with?('/')
  URI(url)
end