notifications-engine icon indicating copy to clipboard operation
notifications-engine copied to clipboard

fix(newrelic): set default revision template for notifications

Open gerardvanengelen opened this issue 1 year ago • 1 comments

Custom Revision Template for NewRelic Service

Goal

Allow specifying a custom revision template for the NewRelic notification service, which enables support for projects with multiple sources. The default template assumes a specific structure ({{.app.status.operationState.syncResult.revision}}) that doesn't work for all project configurations, especially those with multiple sources.

Changes Made

  • Modified the NewrelicNotification.GetTemplater method to use the Revision field as a template string when provided by the user
  • Maintained backward compatibility by keeping the default template when no custom revision is specified
  • Aligned the implementation with the pattern used by other fields (Changelog and User) that already support custom templates

Tests Added

Updated TestGetTemplater_Newrelic in newrelic_test.go with two test cases:

  1. "default revision template" - Tests the original behavior where the default template {{.app.status.operationState.syncResult.revision}} is used when no custom Revision is provided
  2. "custom revision template" - Tests the new functionality where a custom template specified in the Revision field ({{.app.status.custom.revision}}) is used instead of the default

These tests verify that users can now configure custom paths to retrieve revision information that matches their specific project structure, including support for multiple sources.

gerardvanengelen avatar May 01 '25 04:05 gerardvanengelen

@pasha-codefresh Sorry to ping you directly, can you let me know if there are additional steps I need to take to get this reviewed? This change would really help me, so it would be a shame if it is not reviewed because I miss something.

GVengelen avatar May 16 '25 09:05 GVengelen

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 60.10%. Comparing base (da04400) to head (49e5bca). :warning: Report is 19 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #375      +/-   ##
==========================================
+ Coverage   55.41%   60.10%   +4.68%     
==========================================
  Files          46       47       +1     
  Lines        4125     3617     -508     
==========================================
- Hits         2286     2174     -112     
+ Misses       1511     1097     -414     
- Partials      328      346      +18     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Jan 25 '26 11:01 codecov[bot]