BigW Consortium Gitlab

Refactor cluster app creation code in controller

parent 698cd397
...@@ -5,17 +5,18 @@ class Projects::Clusters::ApplicationsController < Projects::ApplicationControll ...@@ -5,17 +5,18 @@ class Projects::Clusters::ApplicationsController < Projects::ApplicationControll
before_action :authorize_create_cluster!, only: [:create] before_action :authorize_create_cluster!, only: [:create]
def 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) if has_attribute?(:hostname)
application.update(hostname: params[:hostname]) application.hostname = params[:hostname]
end end
if application.respond_to?(:oauth_application) if application.respond_to?(:oauth_application)
application.oauth_application = create_oauth_application(application) application.oauth_application = create_oauth_application(application)
application.save
end end
application.save!
Clusters::Applications::ScheduleInstallationService.new(project, current_user).execute(application) Clusters::Applications::ScheduleInstallationService.new(project, current_user).execute(application)
head :no_content 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