Skip to content

Commit

Permalink
added title to deprecation notice.
Browse files Browse the repository at this point in the history
  • Loading branch information
kbukum1 committed Aug 20, 2024
1 parent 8c91d0d commit 1e43f0e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 10 deletions.
16 changes: 12 additions & 4 deletions common/lib/dependabot/notices.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,30 @@ class Notice
extend T::Sig

sig { returns(String) }
attr_reader :mode, :type, :package_manager_name, :message, :markdown
attr_reader :mode, :type, :package_manager_name, :title, :message, :markdown

# Initializes a new Notice object.
# @param mode [String] The mode of the notice (e.g., "WARN", "ERROR").
# @param type [String] The type of the notice (e.g., "bundler_deprecated_warn").
# @param package_manager_name [String] The name of the package manager (e.g., "bundler").
# @param title [String] The title of the notice.
# @param message [String] The main message of the notice.
# @param markdown [String] The markdown formatted message.
sig do
params(
mode: String,
type: String,
package_manager_name: String,
title: String,
message: String,
markdown: String
).void
end
def initialize(mode:, type:, package_manager_name:, message: "", markdown: "")
def initialize(mode:, type:, package_manager_name:, title: "", message: "", markdown: "")
@mode = mode
@type = type
@package_manager_name = package_manager_name
@title = title
@message = message
@markdown = markdown
end
Expand All @@ -42,6 +45,7 @@ def to_hash
mode: @mode,
type: @type,
package_manager_name: @package_manager_name,
title: @title,
message: @message,
markdown: @markdown
}
Expand Down Expand Up @@ -105,7 +109,8 @@ def self.generate_pm_deprecation_notice(package_manager)
package_manager.supported_versions,
package_manager.support_later_versions?
)
notice_type = "#{package_manager.name}_deprecated_#{mode.downcase}"
notice_type = "#{package_manager.name}_deprecated_warn"
title = "Package manager deprecation notice"
message = "Dependabot will stop supporting `#{package_manager.name} v#{package_manager.version}`!"
## Create a warning markdown message
markdown = "> [!WARNING]\n"
Expand All @@ -122,6 +127,7 @@ def self.generate_pm_deprecation_notice(package_manager)
mode: mode,
type: notice_type,
package_manager_name: package_manager.name,
title: title,
message: message,
markdown: markdown
)
Expand All @@ -143,7 +149,8 @@ def self.generate_pm_unsupported_notice(package_manager)
package_manager.supported_versions,
package_manager.support_later_versions?
)
notice_type = "#{package_manager.name}_unsupported_#{mode.downcase}"
notice_type = "#{package_manager.name}_unsupported_error"
title = "Package manager unsupported notice"
message = "Dependabot no longer supports `#{package_manager.name} v#{package_manager.version}`!"
## Create an error markdown message
markdown = "> [!IMPORTANT]\n"
Expand All @@ -160,6 +167,7 @@ def self.generate_pm_unsupported_notice(package_manager)
mode: mode,
type: notice_type,
package_manager_name: package_manager.name,
title: title,
message: message,
markdown: markdown
)
Expand Down
7 changes: 5 additions & 2 deletions updater/lib/dependabot/api_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,23 @@ def record_update_job_error(error_type:, error_details:)
sig do
params(
warn_type: T.any(String, Symbol),
warn_message: T.any(String, Symbol)
warn_title: String,
warn_message: String
).void
end
def record_update_job_warn(warn_type:, warn_message:)
def record_update_job_warn(warn_type:, warn_title:, warn_message:)
::Dependabot::OpenTelemetry.tracer.in_span("record_update_job_message", kind: :internal) do |_span|
::Dependabot::OpenTelemetry.record_update_job_warn(
job_id: job_id,
warn_type: warn_type,
warn_title: warn_title,
warn_message: warn_message
)
api_url = "#{base_url}/update_jobs/#{job_id}/record_update_job_warn"
body = {
data: {
"warn-type": warn_type,
"warn-title": warn_title,
"warn-message": warn_message
}
}
Expand Down
6 changes: 4 additions & 2 deletions updater/lib/dependabot/opentelemetry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,17 @@ def self.record_update_job_error(job_id:, error_type:, error_details:)
params(
job_id: T.any(String, Integer),
warn_type: T.any(String, Symbol),
warn_message: T.any(String, Symbol)
warn_title: String,
warn_message: String
).void
end
def self.record_update_job_warn(job_id:, warn_type:, warn_message:)
def self.record_update_job_warn(job_id:, warn_type:, warn_title:, warn_message:)
current_span = ::OpenTelemetry::Trace.current_span

attributes = {
Attributes::JOB_ID => job_id,
Attributes::WARN_TYPE => warn_type,
Attributes::WARN_TITLE => warn_title,
Attributes::WARN_MESSAGE => warn_message
}
current_span.add_event(warn_type, attributes: attributes)
Expand Down
6 changes: 4 additions & 2 deletions updater/lib/dependabot/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,15 @@ def record_update_job_error(error_type:, error_details:, dependency: nil)
sig do
params(
warn_type: T.any(String, Symbol),
warn_message: T.any(String, Symbol)
warn_title: String,
warn_message: String
).void
end
def record_update_job_warn(warn_type:, warn_message:)
def record_update_job_warn(warn_type:, warn_title:, warn_message:)
warns << [warn_type.to_s, warn_message]
client.record_update_job_warn(
warn_type: warn_type,
warn_title: warn_title,
warn_message: warn_message
)
end
Expand Down
1 change: 1 addition & 0 deletions updater/lib/dependabot/updater/security_update_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ def send_deprecation_notice(package_manager)
Dependabot::Logger.warn(deprecation_notice.message)
service.record_update_job_warn(
warn_type: deprecation_notice.type,
warn_title: deprecation_notice.title,
warn_message: deprecation_notice.message
)
end
Expand Down

0 comments on commit 1e43f0e

Please sign in to comment.