Skip to content

Commit

Permalink
Fix Data Service email (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fosol authored Mar 28, 2024
1 parent 70e69d2 commit f935bb3
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 3 deletions.
1 change: 1 addition & 0 deletions devops/kustomize/base/data-service/config-map.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ metadata:
created-by: jeremy.foster
data:
API_URL: http://api:8080
ENVIRONMENT: "DEV"
---
kind: ConfigMap
apiVersion: v1
Expand Down
6 changes: 6 additions & 0 deletions devops/kustomize/base/data-service/cron-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ spec:
name: data-service
key: API_URL

- name: Service__Environment
valueFrom:
configMapKeyRef:
name: data-service
key: ENVIRONMENT

- name: ServiceNow__ApiUrl
valueFrom:
secretKeyRef:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ patches:
value: https://ches-dev.api.gov.bc.ca/api/v1
- op: replace
path: /data/FROM
value: (DEV) Hosting Service Dashboard <[email protected]>
value: Hosting Service Dashboard <[email protected]>
- op: replace
path: /data/TO
value: [email protected]
- op: replace
path: /data/ENVIRONMENT
value: DEV
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ patches:
- op: replace
path: /data/TO
value: [email protected],[email protected]
- op: replace
path: /data/ENVIRONMENT
value: PROD
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ patches:
value: https://ches-test.api.gov.bc.ca/api/v1
- op: replace
path: /data/FROM
value: (TEST) Hosting Service Dashboard <[email protected]>
value: Hosting Service Dashboard <[email protected]>
- op: replace
path: /data/TO
value: [email protected],[email protected]
- op: replace
path: /data/ENVIRONMENT
value: TEST
5 changes: 5 additions & 0 deletions src/data-service/Config/ServiceOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ public class ServiceOptions
/// </summary>
public bool SendFailureEmail { get; set; } = true;

/// <summary>
/// get/set - Identify the environment this service is running in.
/// </summary>
public string Environment { get; set; } = "";

/// <summary>
/// get/set - Number of sequential failures that are allowed to occur before service stops (default = 3).
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/data-service/DataService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public async Task RunAsync()
/// <returns></returns>
private async Task SendEmail(string subject, string body)
{
var email = new EmailModel(this.ChesOptions.From, this.ChesOptions.OverrideTo.Split(","), subject, body);
var email = new EmailModel(this.ChesOptions.From, this.ChesOptions.OverrideTo.Split(","), $"{(!String.IsNullOrWhiteSpace(this.Options.Environment) ? $"({this.Options.Environment}) - " : "")}{subject}", body);
await this.ChesService.SendEmailAsync(email);
}

Expand Down

0 comments on commit f935bb3

Please sign in to comment.