summaryrefslogtreecommitdiff
path: root/app/controllers/projects/clusters/applications_controller.rb
blob: 90c7fa62216e5044dcd4d1114ce8ae6d8f65a515 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
    Clusters::Applications::ScheduleInstallationService.new(project, current_user,
                                                            application_class: @application_class,
                                                            cluster: @cluster).execute
    head :no_content
  rescue StandardError
    head :bad_request
  end

  private

  def cluster
    @cluster ||= project.clusters.find(params[:id]) || render_404
  end

  def application_class
    @application_class ||= Clusters::Cluster::APPLICATIONS[params[:application]] || render_404
  end
end