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:
authorKamil Trzcinski <ayufan@ayufan.eu>2017-10-05 18:04:35 +0300
committerKamil Trzcinski <ayufan@ayufan.eu>2017-10-05 18:04:35 +0300
commit0ca9ea6e7f09ccaed1d6d55f83a1b81adbc4328a (patch)
tree423ca425ab45e5596caf1d02c27721e49d9f82ac /app/controllers/projects/clusters_controller.rb
parentaba71835f310d5aad9c2af9e22c81bd44e6f0686 (diff)
Split create_params and update_params and fix small redirect bug in controller
Diffstat (limited to 'app/controllers/projects/clusters_controller.rb')
-rw-r--r--app/controllers/projects/clusters_controller.rb33
1 files changed, 20 insertions, 13 deletions
diff --git a/app/controllers/projects/clusters_controller.rb b/app/controllers/projects/clusters_controller.rb
index 5ee30deee9d..8c0fbf72aca 100644
--- a/app/controllers/projects/clusters_controller.rb
+++ b/app/controllers/projects/clusters_controller.rb
@@ -6,6 +6,14 @@ class Projects::ClustersController < Projects::ApplicationController
before_action :authorize_update_cluster!, only: [:update]
before_action :authorize_admin_cluster!, only: [:destroy]
+ def index
+ if project.cluster
+ redirect_to project_cluster_path(project, project.cluster)
+ else
+ redirect_to new_project_cluster_path(project)
+ end
+ end
+
def login
begin
@authorize_url = GoogleApi::CloudPlatform::Client.new(
@@ -16,25 +24,17 @@ class Projects::ClustersController < Projects::ApplicationController
end
end
- def index
- if project.cluster
- redirect_to project_cluster_path(project, project.cluster)
- else
- redirect_to new_project_cluster_path(project)
- end
- end
-
def new
@cluster = project.build_cluster
end
def create
@cluster = Ci::CreateClusterService
- .new(project, current_user, cluster_params)
+ .new(project, current_user, create_params)
.execute(token_in_session)
if @cluster.persisted?
- redirect_to project_clusters_path(project)
+ redirect_to project_cluster_path(project, @cluster)
else
render :new
end
@@ -57,7 +57,7 @@ class Projects::ClustersController < Projects::ApplicationController
def update
Ci::UpdateClusterService
- .new(project, current_user, cluster_params)
+ .new(project, current_user, update_params)
.execute(cluster)
if cluster.valid?
@@ -84,8 +84,9 @@ class Projects::ClustersController < Projects::ApplicationController
@cluster ||= project.cluster
end
- def cluster_params
- params.require(:cluster).permit(:gcp_project_id,
+ def create_params
+ params.require(:cluster).permit(
+ :gcp_project_id,
:gcp_cluster_zone,
:gcp_cluster_name,
:gcp_cluster_size,
@@ -94,6 +95,12 @@ class Projects::ClustersController < Projects::ApplicationController
:enabled)
end
+ def update_params
+ params.require(:cluster).permit(
+ :project_namespace,
+ :enabled)
+ end
+
def authorize_google_api
unless GoogleApi::CloudPlatform::Client.new(token_in_session, nil)
.validate_token(expires_at_in_session)