88800abcd8
To the extent possible swap out `project` with `clusterable` - Abstract paths for showing cluster or clusters. This will allow us to swap in alternative paths for group level cluster - Push :project_id and :namespace_id params from the URL to the POST body. - Create a nice helper for to generate links for the destroy action For some reason, spec :project_id and :namespace_id param are not going through `to_param` for a JSON format. Manually call `to_param` to fix specs. - Move :layout to BaseController
28 lines
688 B
Ruby
28 lines
688 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 ||= clusterable.clusters.find(params[:id]) || render_404
|
|
end
|
|
|
|
def create_cluster_application_params
|
|
params.permit(:application, :hostname)
|
|
end
|
|
end
|