Commit c075a047 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Refactor cluster app creation code in controller

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 698cd397
......@@ -5,17 +5,18 @@ class Projects::Clusters::ApplicationsController < Projects::ApplicationControll
before_action :authorize_create_cluster!, only: [:create]
def create
application = @application_class.find_or_create_by!(cluster: @cluster)
application = @application_class.find_or_initialize_by(cluster: @cluster)
if application.respond_to?(:hostname)
application.update(hostname: params[:hostname])
if has_attribute?(:hostname)
application.hostname = params[:hostname]
end
if application.respond_to?(:oauth_application)
application.oauth_application = create_oauth_application(application)
application.save
end
application.save!
Clusters::Applications::ScheduleInstallationService.new(project, current_user).execute(application)
head :no_content
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment