Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-20 18:08:44 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-20 18:08:44 +0300
commitb9bac6dbf78a5a7976fba14aaeef96bdeb0da612 (patch)
treeffe277b562256f718b0818e8fd3c8fd8766d0269 /lib/gitlab/serverless
parent8c4198cbe631278e87fee04157d23494fbb80cdb (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/serverless')
-rw-r--r--lib/gitlab/serverless/domain.rb13
-rw-r--r--lib/gitlab/serverless/function_uri.rb46
-rw-r--r--lib/gitlab/serverless/service.rb6
3 files changed, 5 insertions, 60 deletions
diff --git a/lib/gitlab/serverless/domain.rb b/lib/gitlab/serverless/domain.rb
deleted file mode 100644
index ec7c68764d1..00000000000
--- a/lib/gitlab/serverless/domain.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-# frozen_string_literal: true
-
-module Gitlab
- module Serverless
- class Domain
- UUID_LENGTH = 14
-
- def self.generate_uuid
- SecureRandom.hex(UUID_LENGTH / 2)
- end
- end
- end
-end
diff --git a/lib/gitlab/serverless/function_uri.rb b/lib/gitlab/serverless/function_uri.rb
deleted file mode 100644
index c0e0cf00f35..00000000000
--- a/lib/gitlab/serverless/function_uri.rb
+++ /dev/null
@@ -1,46 +0,0 @@
-# frozen_string_literal: true
-
-module Gitlab
- module Serverless
- class FunctionURI < URI::HTTPS
- 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
-
- attr_reader :function, :cluster, :environment
-
- def initialize(function: nil, cluster: nil, environment: nil)
- initialize_required_argument(:function, function)
- initialize_required_argument(:cluster, cluster)
- initialize_required_argument(:environment, environment)
-
- @host = "#{function}-#{cluster.uuid[0..1]}a1#{cluster.uuid[2..-3]}f2#{cluster.uuid[-2..-1]}#{"%x" % environment.id}-#{environment.slug}.#{cluster.domain}"
-
- super('https', nil, host, nil, nil, nil, nil, nil, nil)
- end
-
- def self.parse(uri)
- match = SERVERLESS_DOMAIN_REGEXP.match(uri)
- return unless match
-
- cluster = ::Serverless::DomainCluster.find(match[:cluster_left] + match[:cluster_middle] + match[:cluster_right])
- return unless cluster
-
- environment = ::Environment.find(match[:environment_id].to_i(16))
- return unless environment&.slug == match[:environment_slug]
-
- new(
- function: match[:function],
- cluster: cluster,
- environment: environment
- )
- end
-
- private
-
- def initialize_required_argument(name, value)
- raise ArgumentError.new("missing argument: #{name}") unless value
-
- instance_variable_set("@#{name}".to_sym, value)
- end
- end
- end
-end
diff --git a/lib/gitlab/serverless/service.rb b/lib/gitlab/serverless/service.rb
index 643e076c587..c3ab2e9ddeb 100644
--- a/lib/gitlab/serverless/service.rb
+++ b/lib/gitlab/serverless/service.rb
@@ -60,7 +60,11 @@ class Gitlab::Serverless::Service
def proxy_url
if cluster&.serverless_domain
- Gitlab::Serverless::FunctionURI.new(function: name, cluster: cluster.serverless_domain, environment: environment)
+ ::Serverless::Domain.new(
+ function_name: name,
+ serverless_domain_cluster: cluster.serverless_domain,
+ environment: environment
+ ).uri.to_s
end
end