diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-20 18:08:44 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-20 18:08:44 +0300 |
commit | b9bac6dbf78a5a7976fba14aaeef96bdeb0da612 (patch) | |
tree | ffe277b562256f718b0818e8fd3c8fd8766d0269 /app/finders | |
parent | 8c4198cbe631278e87fee04157d23494fbb80cdb (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/finders')
-rw-r--r-- | app/finders/serverless_domain_finder.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/app/finders/serverless_domain_finder.rb b/app/finders/serverless_domain_finder.rb new file mode 100644 index 00000000000..3a8a55022bb --- /dev/null +++ b/app/finders/serverless_domain_finder.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +class ServerlessDomainFinder + attr_reader :match, :serverless_domain_cluster, :environment + + def initialize(uri) + @match = ::Serverless::Domain::REGEXP.match(uri) + end + + def execute + return unless serverless? + + @serverless_domain_cluster = ::Serverless::DomainCluster.for_uuid(serverless_domain_cluster_uuid) + return unless serverless_domain_cluster + + @environment = ::Environment.for_id_and_slug(match[:environment_id].to_i(16), match[:environment_slug]) + return unless environment + + ::Serverless::Domain.new( + function_name: match[:function_name], + serverless_domain_cluster: serverless_domain_cluster, + environment: environment + ) + end + + def serverless_domain_cluster_uuid + return unless serverless? + + match[:cluster_left] + match[:cluster_middle] + match[:cluster_right] + end + + def serverless? + !!match + end +end |