summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-04 00:09:37 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-04 00:09:37 +0000
commite3bdfa1a13d7e6c92716324c78b5b20c07eeb7c6 (patch)
treee8776263096b027d32d4be5118cccc87b00de2bc /app/controllers
parentc1a50b8195f4e36fda9b233acbde57a449bcf6c3 (diff)
downloadgitlab-ce-e3bdfa1a13d7e6c92716324c78b5b20c07eeb7c6.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/admin/integrations_controller.rb6
-rw-r--r--app/controllers/clusters/applications_controller.rb2
-rw-r--r--app/controllers/concerns/integrations_actions.rb31
-rw-r--r--app/controllers/groups/settings/integrations_controller.rb6
4 files changed, 15 insertions, 30 deletions
diff --git a/app/controllers/admin/integrations_controller.rb b/app/controllers/admin/integrations_controller.rb
index 0d79032233f..4f3be43d14d 100644
--- a/app/controllers/admin/integrations_controller.rb
+++ b/app/controllers/admin/integrations_controller.rb
@@ -5,6 +5,12 @@ class Admin::IntegrationsController < Admin::ApplicationController
private
+ def find_or_initialize_integration(name)
+ if name.in?(Service.available_services_names)
+ "#{name}_service".camelize.constantize.find_or_initialize_by(instance: true) # rubocop:disable CodeReuse/ActiveRecord
+ end
+ end
+
def integrations_enabled?
Feature.enabled?(:instance_level_integrations)
end
diff --git a/app/controllers/clusters/applications_controller.rb b/app/controllers/clusters/applications_controller.rb
index ba62cfeea7e..3ebd248c29e 100644
--- a/app/controllers/clusters/applications_controller.rb
+++ b/app/controllers/clusters/applications_controller.rb
@@ -47,7 +47,7 @@ class Clusters::ApplicationsController < Clusters::BaseController
end
def cluster_application_params
- params.permit(:application, :hostname, :email, :stack, :modsecurity_enabled, :modsecurity_mode)
+ params.permit(:application, :hostname, :pages_domain_id, :email, :stack, :modsecurity_enabled, :modsecurity_mode)
end
def cluster_application_destroy_params
diff --git a/app/controllers/concerns/integrations_actions.rb b/app/controllers/concerns/integrations_actions.rb
index ffb5d7a8086..4c998055a5d 100644
--- a/app/controllers/concerns/integrations_actions.rb
+++ b/app/controllers/concerns/integrations_actions.rb
@@ -37,11 +37,7 @@ module IntegrationsActions
end
def test
- if integration.can_test?
- render json: service_test_response, status: :ok
- else
- render json: {}, status: :not_found
- end
+ render json: {}, status: :ok
end
private
@@ -50,17 +46,11 @@ module IntegrationsActions
false
end
- # TODO: Use actual integrations on the group / instance level
- # To be completed in https://gitlab.com/groups/gitlab-org/-/epics/2430
- def project
- Project.first
- end
-
def integration
# Using instance variable `@service` still required as it's used in ServiceParams
# and app/views/shared/_service_settings.html.haml. Should be removed once
# those 2 are refactored to use `@integration`.
- @integration = @service ||= project.find_or_initialize_service(params[:id]) # rubocop:disable Gitlab/ModuleWithInstanceVariables
+ @integration = @service ||= find_or_initialize_integration(params[:id]) # rubocop:disable Gitlab/ModuleWithInstanceVariables
end
def success_message
@@ -74,21 +64,4 @@ module IntegrationsActions
.as_json(only: integration.json_fields)
.merge(errors: integration.errors.as_json)
end
-
- def service_test_response
- unless integration.update(service_params[:service])
- return { error: true, message: _('Validations failed.'), service_response: integration.errors.full_messages.join(','), test_failed: false }
- end
-
- data = integration.test_data(project, current_user)
- outcome = integration.test(data)
-
- unless outcome[:success]
- return { error: true, message: _('Test failed.'), service_response: outcome[:result].to_s, test_failed: true }
- end
-
- {}
- rescue Gitlab::HTTP::BlockedUrlError => e
- { error: true, message: _('Test failed.'), service_response: e.message, test_failed: true }
- end
end
diff --git a/app/controllers/groups/settings/integrations_controller.rb b/app/controllers/groups/settings/integrations_controller.rb
index 43f8a7118d4..0ba030f26bc 100644
--- a/app/controllers/groups/settings/integrations_controller.rb
+++ b/app/controllers/groups/settings/integrations_controller.rb
@@ -9,6 +9,12 @@ module Groups
private
+ # TODO: Make this compatible with group-level integration
+ # https://gitlab.com/groups/gitlab-org/-/epics/2543
+ def find_or_initialize_integration(name)
+ Project.first.find_or_initialize_service(name)
+ end
+
def integrations_enabled?
Feature.enabled?(:group_level_integrations, group)
end