gitlab-org--gitlab-foss/app/controllers/projects/clusters/applications_controller.rb
Thong Kuah 504cbb27c1 Remove un-used inheritance from service
Remove the inheritance from ::BaseService which is causing us to inherit
the initializer that has project as the first arg, as we will not have
access to project with forthcoming group clusters.

Also call install service from create service - 1 less thing to re-use

Extract TestRequest code into a spec helper. Given that we need
different behaviour for Rails 5.0 (and again in Rails 5.1!), it's handy
to have that branching behaviour in one place
2018-10-15 11:09:10 +13:00

29 lines
742 B
Ruby

# frozen_string_literal: true
class Projects::Clusters::ApplicationsController < Projects::ApplicationController
before_action :cluster
before_action :authorize_read_cluster!
before_action :authorize_create_cluster!, only: [:create]
def create
Clusters::Applications::CreateService
.new(@cluster, current_user, create_cluster_application_params)
.execute(request)
head :no_content
rescue Clusters::Applications::CreateService::InvalidApplicationError
render_404
rescue StandardError
head :bad_request
end
private
def cluster
@cluster ||= project.clusters.find(params[:id]) || render_404
end
def create_cluster_application_params
params.permit(:application, :hostname)
end
end