diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2017-10-04 00:21:54 +0300 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2017-10-04 00:21:54 +0300 |
commit | 2507652084b7ca397574878538384edcbad68c73 (patch) | |
tree | f40972615b18d8eafc41bc8367865dd2a05ac005 /app/controllers/projects/clusters_controller.rb | |
parent | 65b4627d3eda27844b093c981d05499a86e7235a (diff) |
Introduce serializer for ClusterEntity
Diffstat (limited to 'app/controllers/projects/clusters_controller.rb')
-rw-r--r-- | app/controllers/projects/clusters_controller.rb | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/app/controllers/projects/clusters_controller.rb b/app/controllers/projects/clusters_controller.rb index 1b6165def51..8d07f695e78 100644 --- a/app/controllers/projects/clusters_controller.rb +++ b/app/controllers/projects/clusters_controller.rb @@ -46,10 +46,9 @@ class Projects::ClustersController < Projects::ApplicationController format.json do Gitlab::PollingInterval.set_header(response, interval: 10_000) - render json: { - status: cluster.status, # The current status of the operation. - status_reason: cluster.status_reason # If an error has occurred, a textual description of the error. - } + render json: ClusterSerializer + .new(project: @project, current_user: @current_user) + .represent_status(@cluster) end end end @@ -62,7 +61,15 @@ class Projects::ClustersController < Projects::ApplicationController .new(project, current_user, cluster_params) .execute(cluster) - render :show + respond_to do |format| + format.html do + render :show + end + + format.json do + head :no_data + end + end end def destroy @@ -80,9 +87,13 @@ class Projects::ClustersController < Projects::ApplicationController end def cluster_params - params.require(:cluster) - .permit(:gcp_project_id, :gcp_cluster_zone, :gcp_cluster_name, :gcp_cluster_size, - :gcp_machine_type, :project_namespace, :enabled) + params.require(:cluster).permit(:gcp_project_id, + :gcp_cluster_zone, + :gcp_cluster_name, + :gcp_cluster_size, + :gcp_machine_type, + :project_namespace, + :enabled) end def authorize_google_api @@ -103,10 +114,10 @@ class Projects::ClustersController < Projects::ApplicationController end def authorize_update_cluster! - return access_denied! unless can?(current_user, :update_cluster, cluster) + access_denied! unless can?(current_user, :update_cluster, cluster) end def authorize_admin_cluster! - return access_denied! unless can?(current_user, :admin_cluster, cluster) + access_denied! unless can?(current_user, :admin_cluster, cluster) end end |