2018-09-25 23:45:43 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-10-14 23:37:51 -04:00
|
|
|
class Clusters::ApplicationsController < Clusters::BaseController
|
2017-11-02 10:10:46 -04:00
|
|
|
before_action :cluster
|
|
|
|
before_action :authorize_create_cluster!, only: [:create]
|
|
|
|
|
|
|
|
def create
|
2018-10-10 04:45:49 -04:00
|
|
|
Clusters::Applications::CreateService
|
2018-10-09 23:47:27 -04:00
|
|
|
.new(@cluster, current_user, create_cluster_application_params)
|
|
|
|
.execute(request)
|
2018-05-30 05:02:45 -04:00
|
|
|
|
2017-11-06 12:21:10 -05:00
|
|
|
head :no_content
|
2018-10-09 23:47:27 -04:00
|
|
|
rescue Clusters::Applications::CreateService::InvalidApplicationError
|
|
|
|
render_404
|
2017-11-06 12:21:10 -05:00
|
|
|
rescue StandardError
|
|
|
|
head :bad_request
|
2017-11-02 10:10:46 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def cluster
|
2018-10-18 21:42:30 -04:00
|
|
|
@cluster ||= clusterable.clusters.find(params[:id]) || render_404
|
2017-11-02 10:10:46 -04:00
|
|
|
end
|
|
|
|
|
2018-10-09 23:47:27 -04:00
|
|
|
def create_cluster_application_params
|
|
|
|
params.permit(:application, :hostname)
|
2018-05-24 11:11:30 -04:00
|
|
|
end
|
2017-11-02 10:10:46 -04:00
|
|
|
end
|