2018-09-26 03:45:43 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-11-02 14:10:46 +00:00
|
|
|
class Projects::Clusters::ApplicationsController < Projects::ApplicationController
|
|
|
|
before_action :cluster
|
|
|
|
before_action :authorize_read_cluster!
|
|
|
|
before_action :authorize_create_cluster!, only: [:create]
|
|
|
|
|
|
|
|
def create
|
2018-10-10 08:45:49 +00:00
|
|
|
Clusters::Applications::CreateService
|
2018-10-10 03:47:27 +00:00
|
|
|
.new(@cluster, current_user, create_cluster_application_params)
|
|
|
|
.execute(request)
|
2018-05-30 09:02:45 +00:00
|
|
|
|
2017-11-06 17:21:10 +00:00
|
|
|
head :no_content
|
2018-10-10 03:47:27 +00:00
|
|
|
rescue Clusters::Applications::CreateService::InvalidApplicationError
|
|
|
|
render_404
|
2017-11-06 17:21:10 +00:00
|
|
|
rescue StandardError
|
|
|
|
head :bad_request
|
2017-11-02 14:10:46 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def cluster
|
2017-11-02 14:31:25 +00:00
|
|
|
@cluster ||= project.clusters.find(params[:id]) || render_404
|
2017-11-02 14:10:46 +00:00
|
|
|
end
|
|
|
|
|
2018-10-10 03:47:27 +00:00
|
|
|
def create_cluster_application_params
|
|
|
|
params.permit(:application, :hostname)
|
2018-05-24 15:11:30 +00:00
|
|
|
end
|
2017-11-02 14:10:46 +00:00
|
|
|
end
|