2018-09-14 01:42:05 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-07-12 16:00:49 -04:00
|
|
|
module ServiceParams
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
2017-01-10 09:41:31 -05:00
|
|
|
ALLOWED_PARAMS_CE = [
|
|
|
|
:active,
|
|
|
|
:add_pusher,
|
|
|
|
:api_key,
|
|
|
|
:api_url,
|
|
|
|
:api_version,
|
|
|
|
:bamboo_url,
|
2019-09-13 14:06:03 -04:00
|
|
|
:branches_to_be_notified,
|
2017-01-10 09:41:31 -05:00
|
|
|
:build_key,
|
|
|
|
:build_type,
|
|
|
|
:ca_pem,
|
|
|
|
:channel,
|
|
|
|
:channels,
|
|
|
|
:color,
|
|
|
|
:colorize_messages,
|
2019-11-26 07:06:18 -05:00
|
|
|
:comment_on_event_enabled,
|
2020-04-21 11:21:10 -04:00
|
|
|
:comment_detail,
|
2017-01-10 09:41:31 -05:00
|
|
|
:confidential_issues_events,
|
|
|
|
:default_irc_uri,
|
|
|
|
:description,
|
|
|
|
:device,
|
|
|
|
:disable_diffs,
|
|
|
|
:drone_url,
|
|
|
|
:enable_ssl_verification,
|
|
|
|
:external_wiki_url,
|
|
|
|
# We're using `issues_events` and `merge_requests_events`
|
|
|
|
# in the view so we still need to explicitly state them
|
|
|
|
# here. `Service#event_names` would only give
|
|
|
|
# `issue_events` and `merge_request_events` (singular!)
|
|
|
|
# See app/helpers/services_helper.rb for how we
|
|
|
|
# make those event names plural as special case.
|
|
|
|
:issues_events,
|
|
|
|
:issues_url,
|
|
|
|
:jira_issue_transition_id,
|
2018-01-02 16:40:03 -05:00
|
|
|
:manual_configuration,
|
2017-01-10 09:41:31 -05:00
|
|
|
:merge_requests_events,
|
2017-02-14 20:52:44 -05:00
|
|
|
:mock_service_url,
|
2017-01-10 09:41:31 -05:00
|
|
|
:namespace,
|
|
|
|
:new_issue_url,
|
|
|
|
:notify,
|
|
|
|
:notify_only_broken_pipelines,
|
|
|
|
:password,
|
|
|
|
:priority,
|
|
|
|
:project_key,
|
|
|
|
:project_url,
|
|
|
|
:recipients,
|
|
|
|
:restrict_to_branch,
|
|
|
|
:room,
|
|
|
|
:send_from_committer_email,
|
|
|
|
:server,
|
|
|
|
:server_host,
|
|
|
|
:server_port,
|
|
|
|
:sound,
|
|
|
|
:subdomain,
|
|
|
|
:teamcity_url,
|
|
|
|
:title,
|
|
|
|
:token,
|
|
|
|
:type,
|
|
|
|
:url,
|
|
|
|
:user_key,
|
|
|
|
:username,
|
|
|
|
:webhook
|
2017-02-21 18:32:18 -05:00
|
|
|
].freeze
|
2016-07-12 16:00:49 -04:00
|
|
|
|
|
|
|
# Parameters to ignore if no value is specified
|
2017-02-21 18:32:18 -05:00
|
|
|
FILTER_BLANK_PARAMS = [:password].freeze
|
2016-07-12 16:00:49 -04:00
|
|
|
|
2016-07-13 15:49:47 -04:00
|
|
|
def service_params
|
2017-11-22 02:50:36 -05:00
|
|
|
dynamic_params = @service.event_channel_names + @service.event_names # rubocop:disable Gitlab/ModuleWithInstanceVariables
|
2018-12-17 11:59:06 -05:00
|
|
|
service_params = params.permit(:id, service: allowed_service_params + dynamic_params)
|
2016-07-12 16:00:49 -04:00
|
|
|
|
2019-02-05 07:30:06 -05:00
|
|
|
if service_params[:service].is_a?(ActionController::Parameters)
|
2016-07-12 16:00:49 -04:00
|
|
|
FILTER_BLANK_PARAMS.each do |param|
|
2016-07-13 15:49:47 -04:00
|
|
|
service_params[:service].delete(param) if service_params[:service][param].blank?
|
2016-07-12 16:00:49 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-07-13 15:49:47 -04:00
|
|
|
service_params
|
2016-07-12 16:00:49 -04:00
|
|
|
end
|
2018-12-17 11:59:06 -05:00
|
|
|
|
|
|
|
def allowed_service_params
|
|
|
|
ALLOWED_PARAMS_CE
|
|
|
|
end
|
2016-07-12 16:00:49 -04:00
|
|
|
end
|
2019-09-13 09:26:31 -04:00
|
|
|
|
|
|
|
ServiceParams.prepend_if_ee('EE::ServiceParams')
|