diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2018-12-10 17:14:38 +0300 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2018-12-10 17:14:38 +0300 |
commit | 2d85d362c626f7c4afdc3e8f7123672b3a6363c0 (patch) | |
tree | e3f8737d2805cb1037f6940540d6fdfc39937272 /app | |
parent | 355aa02dc7c930e3c2414c652b3dea8cd9959d54 (diff) | |
parent | ecda32eaa293f094bd33b8c792ea78071b0be8e7 (diff) |
Merge branch '55090-fix-group-clusters-no-project-namespace' into 'master'
Resolve "Project Namespace field should be removed from Group Cluster, Add existing"
Closes #55090
See merge request gitlab-org/gitlab-ce!23679
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/clusters/clusters_controller.rb | 12 | ||||
-rw-r--r-- | app/services/clusters/build_service.rb | 21 |
2 files changed, 27 insertions, 6 deletions
diff --git a/app/controllers/clusters/clusters_controller.rb b/app/controllers/clusters/clusters_controller.rb index 2e9c77ae55c..9aa8b758539 100644 --- a/app/controllers/clusters/clusters_controller.rb +++ b/app/controllers/clusters/clusters_controller.rb @@ -181,15 +181,15 @@ class Clusters::ClustersController < Clusters::BaseController end def gcp_cluster - @gcp_cluster = ::Clusters::Cluster.new.tap do |cluster| - cluster.build_provider_gcp - end.present(current_user: current_user) + cluster = Clusters::BuildService.new(clusterable.subject).execute + cluster.build_provider_gcp + @gcp_cluster = cluster.present(current_user: current_user) end def user_cluster - @user_cluster = ::Clusters::Cluster.new.tap do |cluster| - cluster.build_platform_kubernetes - end.present(current_user: current_user) + cluster = Clusters::BuildService.new(clusterable.subject).execute + cluster.build_platform_kubernetes + @user_cluster = cluster.present(current_user: current_user) end def validate_gcp_token diff --git a/app/services/clusters/build_service.rb b/app/services/clusters/build_service.rb new file mode 100644 index 00000000000..8de73831164 --- /dev/null +++ b/app/services/clusters/build_service.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true +module Clusters + class BuildService + def initialize(subject) + @subject = subject + end + + def execute + ::Clusters::Cluster.new.tap do |cluster| + case @subject + when ::Project + cluster.cluster_type = :project_type + when ::Group + cluster.cluster_type = :group_type + else + raise NotImplementedError + end + end + end + end +end |