diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-03 21:07:56 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-03 21:07:56 +0300 |
commit | fc98192f90aaa287731da2d95dd2e3aaae0a54a5 (patch) | |
tree | 9f1d5a229314e4e6882e3bd8a2be147b54c96b1a /app/services/clusters | |
parent | fdd5c2a476dade1dd0874e37ab0c0b9ff88381ab (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/clusters')
-rw-r--r-- | app/services/clusters/applications/base_service.rb | 96 |
1 files changed, 0 insertions, 96 deletions
diff --git a/app/services/clusters/applications/base_service.rb b/app/services/clusters/applications/base_service.rb deleted file mode 100644 index c6f22cfa04c..00000000000 --- a/app/services/clusters/applications/base_service.rb +++ /dev/null @@ -1,96 +0,0 @@ -# frozen_string_literal: true - -module Clusters - module Applications - class BaseService - InvalidApplicationError = Class.new(StandardError) - - attr_reader :cluster, :current_user, :params - - def initialize(cluster, user, params = {}) - @cluster = cluster - @current_user = user - @params = params.dup - end - - def execute(request) - instantiate_application.tap do |application| - if application.has_attribute?(:hostname) - application.hostname = params[:hostname] - end - - if application.has_attribute?(:email) - application.email = params[:email] - end - - if application.has_attribute?(:stack) - application.stack = params[:stack] - end - - if application.respond_to?(:oauth_application) - application.oauth_application = create_oauth_application(application, request) - end - - if application.instance_of?(Knative) - Serverless::AssociateDomainService - .new(application, pages_domain_id: params[:pages_domain_id], creator: current_user) - .execute - end - - worker = worker_class(application) - - application.make_scheduled! - - worker.perform_async(application.name, application.id) - end - end - - protected - - def worker_class(application) - raise NotImplementedError - end - - def builder - raise NotImplementedError - end - - def project_builders - raise NotImplementedError - end - - def instantiate_application - raise_invalid_application_error if unknown_application? - - builder || raise(InvalidApplicationError, "invalid application: #{application_name}") - end - - def raise_invalid_application_error - raise(InvalidApplicationError, "invalid application: #{application_name}") - end - - def unknown_application? - Clusters::Cluster::APPLICATIONS.keys.exclude?(application_name) - end - - def application_name - params[:application] - end - - def application_class - Clusters::Cluster::APPLICATIONS[application_name] - end - - def create_oauth_application(application, request) - oauth_application_params = { - name: params[:application], - redirect_uri: application.callback_url, - scopes: application.oauth_scopes, - owner: current_user - } - - ::Applications::CreateService.new(current_user, oauth_application_params).execute(request) - end - end - end -end |