Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2018-05-30 12:02:45 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2018-05-30 12:02:45 +0300
commitc075a047cd89ad53839b877a6dc8f4dbf970c5fb (patch)
tree331146ca6ef969b5a9736d4dff4af03d42024336 /app/controllers/projects/clusters
parent698cd3977b7d6089a8a98024f9e68beddbc07b86 (diff)
Refactor cluster app creation code in controller
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/controllers/projects/clusters')
-rw-r--r--app/controllers/projects/clusters/applications_controller.rb9
1 files changed, 5 insertions, 4 deletions
diff --git a/app/controllers/projects/clusters/applications_controller.rb b/app/controllers/projects/clusters/applications_controller.rb
index 6de7a332164..ce04c186dc0 100644
--- a/app/controllers/projects/clusters/applications_controller.rb
+++ b/app/controllers/projects/clusters/applications_controller.rb
@@ -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