2019-12-04 20:38:33 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Pages
|
|
|
|
class VirtualDomain
|
2019-12-21 20:55:43 +05:30
|
|
|
def initialize(projects, trim_prefix: nil, domain: nil)
|
2019-12-04 20:38:33 +05:30
|
|
|
@projects = projects
|
2019-12-21 20:55:43 +05:30
|
|
|
@trim_prefix = trim_prefix
|
2019-12-04 20:38:33 +05:30
|
|
|
@domain = domain
|
|
|
|
end
|
|
|
|
|
|
|
|
def certificate
|
|
|
|
domain&.certificate
|
|
|
|
end
|
|
|
|
|
|
|
|
def key
|
|
|
|
domain&.key
|
|
|
|
end
|
|
|
|
|
|
|
|
def lookup_paths
|
2021-03-11 19:13:27 +05:30
|
|
|
paths = projects.map do |project|
|
2019-12-21 20:55:43 +05:30
|
|
|
project.pages_lookup_path(trim_prefix: trim_prefix, domain: domain)
|
2021-03-11 19:13:27 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
# TODO: remove in https://gitlab.com/gitlab-org/gitlab/-/issues/297524
|
|
|
|
# source can only be nil if pages_serve_from_legacy_storage FF is disabled
|
|
|
|
# we can remove this filtering once we remove legacy storage
|
|
|
|
paths = paths.select(&:source)
|
|
|
|
|
|
|
|
paths.sort_by(&:prefix).reverse
|
2019-12-04 20:38:33 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
attr_reader :projects, :trim_prefix, :domain
|
2019-12-04 20:38:33 +05:30
|
|
|
end
|
|
|
|
end
|