diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-17 15:13:49 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-17 15:13:49 +0300 |
commit | 458b945df3652f3f42f3665ea2e39e745c8b05c6 (patch) | |
tree | 355810a602413a558e1f8edf19a17f14e604e062 /lib | |
parent | e750680e89a6f98803709c172943962741eeb9e7 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/commits.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/alert_management/payload/base.rb | 12 |
2 files changed, 9 insertions, 5 deletions
diff --git a/lib/api/commits.rb b/lib/api/commits.rb index ef9d989d013..7a6c3e4d53f 100644 --- a/lib/api/commits.rb +++ b/lib/api/commits.rb @@ -88,7 +88,7 @@ module API requires :branch, type: String, desc: 'Name of the branch to commit into. To create a new branch, also provide either `start_branch` or `start_sha`, and optionally `start_project`.', allow_blank: false requires :commit_message, type: String, desc: 'Commit message' requires :actions, type: Array, desc: 'Actions to perform in commit' do - requires :action, type: String, desc: 'The action to perform, `create`, `delete`, `move`, `update`, `chmod`', values: %w[create update move delete chmod].freeze + requires :action, type: String, desc: 'The action to perform, `create`, `delete`, `move`, `update`, `chmod`', values: %w[create update move delete chmod].freeze, allow_blank: false requires :file_path, type: String, desc: 'Full path to the file. Ex. `lib/class.rb`' given action: ->(action) { action == 'move' } do requires :previous_path, type: String, desc: 'Original full path to the file being moved. Ex. `lib/class1.rb`' diff --git a/lib/gitlab/alert_management/payload/base.rb b/lib/gitlab/alert_management/payload/base.rb index 5e535ded439..2d769148c5f 100644 --- a/lib/gitlab/alert_management/payload/base.rb +++ b/lib/gitlab/alert_management/payload/base.rb @@ -102,19 +102,19 @@ module Gitlab # AlertManagement::Alert directly for read operations. def alert_params { - description: description&.truncate(::AlertManagement::Alert::DESCRIPTION_MAX_LENGTH), + description: truncate(description, ::AlertManagement::Alert::DESCRIPTION_MAX_LENGTH), ended_at: ends_at, environment: environment, fingerprint: gitlab_fingerprint, hosts: truncate_hosts(Array(hosts).flatten), - monitoring_tool: monitoring_tool&.truncate(::AlertManagement::Alert::TOOL_MAX_LENGTH), + monitoring_tool: truncate(monitoring_tool, ::AlertManagement::Alert::TOOL_MAX_LENGTH), payload: payload, project_id: project.id, prometheus_alert: gitlab_alert, - service: service&.truncate(::AlertManagement::Alert::SERVICE_MAX_LENGTH), + service: truncate(service, ::AlertManagement::Alert::SERVICE_MAX_LENGTH), severity: severity, started_at: starts_at, - title: title&.truncate(::AlertManagement::Alert::TITLE_MAX_LENGTH) + title: truncate(title, ::AlertManagement::Alert::TITLE_MAX_LENGTH) }.transform_values(&:presence).compact end @@ -161,6 +161,10 @@ module Gitlab SEVERITY_MAPPING end + def truncate(value, length) + value.to_s.truncate(length) + end + def truncate_hosts(hosts) return hosts if hosts.join.length <= ::AlertManagement::Alert::HOSTS_MAX_LENGTH |