diff options
author | Thong Kuah <tkuah@gitlab.com> | 2018-12-10 13:42:47 +1300 |
---|---|---|
committer | Thong Kuah <tkuah@gitlab.com> | 2018-12-10 13:57:19 +1300 |
commit | 01dc3c966f35f851b2cd028605d3cb50e8f6b64c (patch) | |
tree | 82abc8081eb0556937c2a1f95c119683034e93f2 /app/controllers/clusters/clusters_controller.rb | |
parent | 22289352be9cfb2e031634394ab19cf778f68b6c (diff) | |
download | gitlab-ce-01dc3c966f35f851b2cd028605d3cb50e8f6b64c.tar.gz |
Refactor to re-use similar block
Diffstat (limited to 'app/controllers/clusters/clusters_controller.rb')
-rw-r--r-- | app/controllers/clusters/clusters_controller.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/app/controllers/clusters/clusters_controller.rb b/app/controllers/clusters/clusters_controller.rb index 86721fd7a7e..cb6f49e608c 100644 --- a/app/controllers/clusters/clusters_controller.rb +++ b/app/controllers/clusters/clusters_controller.rb @@ -181,14 +181,20 @@ class Clusters::ClustersController < Clusters::BaseController end def gcp_cluster - @gcp_cluster = ::Clusters::Cluster.new.tap do |cluster| + @gcp_cluster = new_cluster do |cluster| cluster.build_provider_gcp - end.present(current_user: current_user) + end end def user_cluster - @user_cluster = ::Clusters::Cluster.new.tap do |cluster| + @user_cluster = new_cluster do |cluster| cluster.build_platform_kubernetes + end + end + + def new_cluster + ::Clusters::Cluster.new.tap do |cluster| + yield cluster case clusterable.subject when ::Project |