2017-11-02 10:10:46 -04:00
|
|
|
class Projects::Clusters::ApplicationsController < Projects::ApplicationController
|
|
|
|
before_action :cluster
|
|
|
|
before_action :application_class, only: [:create]
|
|
|
|
before_action :authorize_read_cluster!
|
|
|
|
before_action :authorize_create_cluster!, only: [:create]
|
|
|
|
|
|
|
|
def create
|
2018-05-23 08:49:39 -04:00
|
|
|
application = @application_class.find_or_create_by!(cluster: @cluster)
|
2018-05-16 05:01:13 -04:00
|
|
|
application.update(hostname: params[:hostname]) if application.respond_to?(:hostname)
|
2018-05-23 08:49:39 -04:00
|
|
|
|
|
|
|
Clusters::Applications::ScheduleInstallationService.new(project, current_user).execute(application)
|
|
|
|
|
2017-11-06 12:21:10 -05:00
|
|
|
head :no_content
|
|
|
|
rescue StandardError
|
|
|
|
head :bad_request
|
2017-11-02 10:10:46 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def cluster
|
2017-11-02 10:31:25 -04:00
|
|
|
@cluster ||= project.clusters.find(params[:id]) || render_404
|
2017-11-02 10:10:46 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def application_class
|
2017-11-03 06:10:50 -04:00
|
|
|
@application_class ||= Clusters::Cluster::APPLICATIONS[params[:application]] || render_404
|
2017-11-02 10:10:46 -04:00
|
|
|
end
|
|
|
|
end
|