5b3c096c9e
In preparation so that we can create both cluster attached to project and cluster attached to group. - Move ClustersController to top level - Move Clusters::ApplicationsController to top-level too - Creates a Clusters::BaseController to share common functions - Do not rely on @project ivar. Anything could set the ivar. - Fix Vue page components due to new data-page value Because of the controller change we have gone from `projects:clusters:new` to `clusters:new`, so we need to update the file location of the page components. There is somewhere a function that will convert data-page to a file location. On that note, projects/clusters/gcp/new/, translate to Projects::Clusters::Gcp#new doesn't exist so replace that with clusters/create_gcp/ and clusters/create_user/
28 lines
684 B
Ruby
28 lines
684 B
Ruby
# frozen_string_literal: true
|
|
|
|
class Clusters::ApplicationsController < Clusters::BaseController
|
|
before_action :cluster
|
|
before_action :authorize_create_cluster!, only: [:create]
|
|
|
|
def create
|
|
Clusters::Applications::CreateService
|
|
.new(@cluster, current_user, create_cluster_application_params)
|
|
.execute(request)
|
|
|
|
head :no_content
|
|
rescue Clusters::Applications::CreateService::InvalidApplicationError
|
|
render_404
|
|
rescue StandardError
|
|
head :bad_request
|
|
end
|
|
|
|
private
|
|
|
|
def cluster
|
|
@cluster ||= project.clusters.find(params[:id]) || render_404
|
|
end
|
|
|
|
def create_cluster_application_params
|
|
params.permit(:application, :hostname)
|
|
end
|
|
end
|