summaryrefslogtreecommitdiff
path: root/app/services/serverless
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-27 15:09:24 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-27 15:09:24 +0000
commitf8d15ca65390475e356b06dedc51e10ccd179f86 (patch)
treeef916d4e8e11c9e00d809e5cdcf63814e86d6e89 /app/services/serverless
parent3ab4feda4dce9c9f0672375ae27c2f7c2ba6f4ad (diff)
downloadgitlab-ce-f8d15ca65390475e356b06dedc51e10ccd179f86.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/serverless')
-rw-r--r--app/services/serverless/associate_domain_service.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/app/services/serverless/associate_domain_service.rb b/app/services/serverless/associate_domain_service.rb
new file mode 100644
index 00000000000..673f1f83260
--- /dev/null
+++ b/app/services/serverless/associate_domain_service.rb
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+module Serverless
+ class AssociateDomainService
+ PLACEHOLDER_HOSTNAME = 'example.com'.freeze
+
+ def initialize(knative, pages_domain_id:, creator:)
+ @knative = knative
+ @pages_domain_id = pages_domain_id
+ @creator = creator
+ end
+
+ def execute
+ return if unchanged?
+
+ knative.hostname ||= PLACEHOLDER_HOSTNAME
+
+ knative.pages_domain = knative.find_available_domain(pages_domain_id)
+ knative.serverless_domain_cluster.update(creator: creator) if knative.pages_domain
+ end
+
+ private
+
+ attr_reader :knative, :pages_domain_id, :creator
+
+ def unchanged?
+ knative.pages_domain&.id == pages_domain_id
+ end
+ end
+end