gitlab-org--gitlab-foss/app/controllers/projects/clusters/applications_controller.rb

32 lines
861 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2017-11-02 10:10:46 -04:00
class Projects::Clusters::ApplicationsController < Projects::ApplicationController
before_action :cluster
before_action :authorize_read_cluster!
before_action :authorize_create_cluster!, only: [:create]
def create
application = Clusters::Applications::CreateService
.new(@cluster, current_user, create_cluster_application_params)
.execute(request)
Clusters::Applications::ScheduleInstallationService.new(project, current_user).execute(application)
head :no_content
rescue Clusters::Applications::CreateService::InvalidApplicationError
render_404
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 create_cluster_application_params
params.permit(:application, :hostname)
end
2017-11-02 10:10:46 -04:00
end