Extend Pages API for serverless domains

We need to extend the Pages API to support serverless domains:

  • Add Gitlab::Serverless::FunctionURI module in lib/
    • Should have a frozen Regexp assigned to a constant:
      • SERVERLESS_DOMAIN_REGEXP = %r{^(?<scheme>https?://)?(?<function>[^.]+)-(?<cluster_left>\h{2})a1(?<cluster_middle>\h{10})f2(?<cluster_right>\h{2})(?<environment_id>\h+)-(?<environment_slug>[^.]+)\.(?<domain>.+)}.freeze
    • Where cluster uuid is a 14 hex character string
    • Should implement parse(uri) using regexp
    • Should implement new(function: function, cluster: serverless_domain_cluster, environment: environment)
  • Add app/models/pages/serverless_domain.rb to present a Serverless::DomainCluster and a PagesDomain as a proxy type
  • Add app/models/pages/serverless_proxy.rb to return a type: proxy
  • Branch logic in pages API at a regexp match of a cluster-uuid
  • Lookup PagesDomain along with Serverless::DomainCluster
    • Return:
      • Full hostname to function (eg. function-name.project-11111-environment.serverless.gitlab.io)
      • knative.hostname (aka TLS ServerName)
      • PagesDomain.certificate
      • PagesDomain.key
      • Serverless::DomainCluster.istio_cert
      • Serverless::DomainCluster.istio_key
Edited by Matt Kasa