Module: ServiceParams

Extended by:
ActiveSupport::Concern
Included in:
Admin::ServicesController, Projects::ServicesController
Defined in:
app/controllers/concerns/service_params.rb

Constant Summary collapse

ALLOWED_PARAMS_CE =
[
  :active,
  :add_pusher,
  :alert_events,
  :api_key,
  :api_url,
  :api_version,
  :bamboo_url,
  :branches_to_be_notified,
  :build_key,
  :build_type,
  :ca_pem,
  :channel,
  :channels,
  :color,
  :colorize_messages,
  :comment_on_event_enabled,
  :comment_detail,
  :confidential_issues_events,
  :confluence_url,
  :default_irc_uri,
  :device,
  :disable_diffs,
  :drone_url,
  :enable_ssl_verification,
  :external_wiki_url,
  :google_iap_service_account_json,
  :google_iap_audience_client_id,
  :inherit_from_id,
  # 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,
  :manual_configuration,
  :merge_requests_events,
  :mock_service_url,
  :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,
  :token,
  :type,
  :url,
  :user_key,
  :username,
  :webhook
].freeze
FILTER_BLANK_PARAMS =

Parameters to ignore if no value is specified

[:password].freeze

Instance Method Summary collapse

Instance Method Details

#allowed_service_paramsObject


89
90
91
# File 'app/controllers/concerns/service_params.rb', line 89

def allowed_service_params
  ALLOWED_PARAMS_CE
end

#service_paramsObject


76
77
78
79
80
81
82
83
84
85
86
87
# File 'app/controllers/concerns/service_params.rb', line 76

def service_params
  dynamic_params = @service.event_channel_names + @service.event_names # rubocop:disable Gitlab/ModuleWithInstanceVariables
  service_params = params.permit(:id, service: allowed_service_params + dynamic_params)

  if service_params[:service].is_a?(ActionController::Parameters)
    FILTER_BLANK_PARAMS.each do |param|
      service_params[:service].delete(param) if service_params[:service][param].blank?
    end
  end

  service_params
end