Refactor cluster app creation code in controller
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
698cd3977b
commit
c075a047cd
1 changed files with 5 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue