This repository has been archived by the owner on Jul 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9207482
commit 241e1c7
Showing
23 changed files
with
213 additions
and
128 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
src/NuGet.Jobs.Common/Configuration/SupportRequestDbConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
namespace NuGet.Jobs.Configuration | ||
{ | ||
public class SupportRequestDbConfiguration : IDbConfiguration | ||
{ | ||
public string ConnectionString { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/NuGet.SupportRequests.Notifications/Configuration/InitializationConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
namespace NuGet.SupportRequests.Notifications | ||
{ | ||
public class InitializationConfiguration | ||
{ | ||
/// <summary> | ||
/// Obsolete: replace with IcM configuration | ||
/// </summary> | ||
public string PagerDutyAccountName { get; set; } | ||
|
||
/// <summary> | ||
/// Obsolete: replace with IcM configuration | ||
/// </summary> | ||
public string PagerDutyApiKey { get; set; } | ||
|
||
/// <summary> | ||
/// SMTP configuration. | ||
/// </summary> | ||
public string SmtpUri { get; set; } | ||
|
||
/// <summary> | ||
/// Email address to which the weekly report is sent. | ||
/// </summary> | ||
public string TargetEmailAddress { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,50 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel.Design; | ||
using System.Threading.Tasks; | ||
using Autofac; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Options; | ||
using NuGet.Jobs; | ||
using NuGet.Jobs.Configuration; | ||
|
||
namespace NuGet.SupportRequests.Notifications | ||
{ | ||
internal class Job | ||
: JobBase | ||
: JsonConfigurationJob | ||
{ | ||
private IServiceContainer _serviceContainer; | ||
private IDictionary<string, string> _jobArgsDictionary; | ||
private InitializationConfiguration _configuration; | ||
private string _taskName; | ||
|
||
public override void Init(IServiceContainer serviceContainer, IDictionary<string, string> jobArgsDictionary) | ||
{ | ||
if (!jobArgsDictionary.ContainsKey(JobArgumentNames.ScheduledTask)) | ||
{ | ||
throw new NotSupportedException("The required argument -Task is missing."); | ||
} | ||
base.Init(serviceContainer, jobArgsDictionary); | ||
|
||
_serviceContainer = serviceContainer ?? throw new ArgumentNullException(nameof(serviceContainer)); | ||
_jobArgsDictionary = jobArgsDictionary; | ||
_taskName = jobArgsDictionary[JobArgumentNames.ScheduledTask]; | ||
_configuration = _serviceProvider.GetRequiredService<IOptionsSnapshot<InitializationConfiguration>>().Value; | ||
} | ||
|
||
public override async Task Run() | ||
{ | ||
var scheduledTask = ScheduledTaskFactory.Create(_serviceContainer, _jobArgsDictionary, LoggerFactory); | ||
var scheduledTask = ScheduledTaskFactory.Create( | ||
_taskName, | ||
_configuration, | ||
OpenSqlConnectionAsync<SupportRequestDbConfiguration>, | ||
LoggerFactory); | ||
|
||
await scheduledTask.RunAsync(); | ||
} | ||
|
||
protected override void ConfigureAutofacServices(ContainerBuilder containerBuilder) | ||
{ | ||
} | ||
|
||
protected override void ConfigureJobServices(IServiceCollection services, IConfigurationRoot configurationRoot) | ||
{ | ||
ConfigureInitializationSection<InitializationConfiguration>(services, configurationRoot); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"Initialization": { | ||
"PagerDutyAccountName": "nuget", | ||
"PagerDutyApiKey": "$$Dev-PagerDuty-ApiKey$$", | ||
"SmtpUri": "#{Jobs.supportrequests.notifications.SmtpUri}", | ||
"TargetEmailAddress": "#{Jobs.supportrequests.notifications.weeklysummarynotification.TargetEmailAddress}" | ||
}, | ||
|
||
"SupportRequestDb": { | ||
"ConnectionString": "Data Source=tcp:#{Deployment.Azure.Sql.SupportRequestDatabaseAddress};Initial Catalog=nuget-dev-supportrequest;User ID=$$Dev-SupportRequestDBWriter-UserName$$;Password=$$Dev-SupportRequestDBWriter-Password$$;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;" | ||
}, | ||
|
||
"KeyVault_VaultName": "#{Deployment.Azure.KeyVault.VaultName}", | ||
"KeyVault_ClientId": "#{Deployment.Azure.KeyVault.ClientId}", | ||
"KeyVault_CertificateThumbprint": "#{Deployment.Azure.KeyVault.CertificateThumbprint}", | ||
"KeyVault_ValidateCertificate": true, | ||
"KeyVault_StoreName": "My", | ||
"KeyVault_StoreLocation": "LocalMachine" | ||
} |
Oops, something went wrong.