Skip to content
This repository was archived by the owner on Jul 30, 2024. It is now read-only.

Commit 5aae40c

Browse files
author
Christy Henriksson
authored
Migrate UpdateLicenseReport to JsonConfig (#521)
1 parent 789d577 commit 5aae40c

11 files changed

Lines changed: 267 additions & 147 deletions
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
namespace UpdateLicenseReports
5+
{
6+
public class UpdateLicenseReportsConfiguration
7+
{
8+
public string LicenseReportService { get; set; }
9+
10+
public string LicenseReportUser { get; set; }
11+
12+
public string LicenseReportPassword { get; set; }
13+
14+
public int? RetryCount { get; set; }
15+
16+
public bool Test { get; set; }
17+
}
18+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using System.Collections.Generic;
5+
6+
namespace UpdateLicenseReports
7+
{
8+
internal class PackageLicenseReport
9+
{
10+
public int Sequence { get; set; }
11+
12+
public string PackageId { get; set; }
13+
14+
public string Version { get; set; }
15+
16+
public string ReportUrl { get; set; }
17+
18+
public string Comment { get; set; }
19+
20+
public ICollection<string> Licenses { get; private set; }
21+
22+
public PackageLicenseReport(int sequence)
23+
{
24+
Sequence = sequence;
25+
PackageId = null;
26+
Version = null;
27+
ReportUrl = null;
28+
Comment = null;
29+
Licenses = new LinkedList<string>();
30+
}
31+
32+
public override string ToString()
33+
{
34+
return string.Format("{{ {0}, {1}, [ {2} ] }}", Sequence, string.Join(", ", PackageId, Version, ReportUrl, Comment), string.Join(", ", Licenses));
35+
}
36+
}
37+
}

src/UpdateLicenseReports/Scripts/UpdateLicenseReports.cmd

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
cd bin
44

55
:Top
6-
echo "Starting job - #{Jobs.updatelicensereports.Title}"
6+
echo "Starting job - #{Jobs.updatelicensereports.Title}"
77

8-
title #{Jobs.updatelicensereports.Title}
8+
title #{Jobs.updatelicensereports.Title}
99

10-
start /w updatelicensereports.exe -VaultName "#{Deployment.Azure.KeyVault.VaultName}" -ClientId "#{Deployment.Azure.KeyVault.ClientId}" -CertificateThumbprint "#{Deployment.Azure.KeyVault.CertificateThumbprint}" -LicenseReportService "#{Jobs.updatelicensereports.LicenseReportServiceUri}" -LicenseReportUser "#{Jobs.updatelicensereports.LicenseReportUser}" -LicenseReportPassword "#{Jobs.updatelicensereports.LicenseReportPassword}" -PackageDatabase "#{Jobs.updatelicensereports.PackageDatabase}" -verbose true -Sleep #{Jobs.updatelicensereports.Sleep} -InstrumentationKey "#{Jobs.updatelicensereports.ApplicationInsightsInstrumentationKey}"
10+
start /w updatelicensereports.exe -Configuration #{Jobs.updatelicensereports.Configuration} ^
11+
-verbose true ^
12+
-Sleep #{Jobs.updatelicensereports.Sleep} ^
13+
-InstrumentationKey "#{Jobs.updatelicensereports.ApplicationInsightsInstrumentationKey}"
1114

12-
echo "Finished #{Jobs.updatelicensereports.Title}"
15+
echo "Finished #{Jobs.updatelicensereports.Title}"
1316

14-
goto Top
17+
goto Top
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"Initialization": {
3+
"Test": true
4+
},
5+
6+
"GalleryDb": {
7+
"ConnectionString": "Data Source=tcp:#{Deployment.Azure.Sql.GalleryDatabaseAddress};Initial Catalog=nuget-dev-0-v2gallery;Integrated Security=False;User ID=$$Dev-GalleryDBWriter-UserName$$;Password=$$Dev-GalleryDBWriter-Password$$;Connect Timeout=30;Encrypt=True"
8+
},
9+
10+
"KeyVault_VaultName": "#{Deployment.Azure.KeyVault.VaultName}",
11+
"KeyVault_ClientId": "#{Deployment.Azure.KeyVault.ClientId}",
12+
"KeyVault_CertificateThumbprint": "#{Deployment.Azure.KeyVault.CertificateThumbprint}",
13+
"KeyVault_ValidateCertificate": true,
14+
"KeyVault_StoreName": "My",
15+
"KeyVault_StoreLocation": "LocalMachine"
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"Initialization": {
3+
"Test": true
4+
},
5+
6+
"GalleryDb": {
7+
"ConnectionString": "Data Source=tcp:#{Deployment.Azure.Sql.GalleryDatabaseAddress};Initial Catalog=nuget-int-0-v2gallery;Integrated Security=False;User ID=$$Int-GalleryDBWriter-UserName$$;Password=$$Int-GalleryDBWriter-Password$$;Connect Timeout=30;Encrypt=True"
8+
},
9+
10+
"KeyVault_VaultName": "#{Deployment.Azure.KeyVault.VaultName}",
11+
"KeyVault_ClientId": "#{Deployment.Azure.KeyVault.ClientId}",
12+
"KeyVault_CertificateThumbprint": "#{Deployment.Azure.KeyVault.CertificateThumbprint}",
13+
"KeyVault_ValidateCertificate": true,
14+
"KeyVault_StoreName": "My",
15+
"KeyVault_StoreLocation": "LocalMachine"
16+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"Initialization": {
3+
"LicenseReportService": "https://clm.sonatype.com/nuget/feed/licenses",
4+
"LicenseReportUser": "$$Prod-Sonatype-UserName$$",
5+
"LicenseReportPassword": "$$Prod-Sonatype-Password$$"
6+
},
7+
8+
"GalleryDb": {
9+
"ConnectionString": "Data Source=tcp:#{Deployment.Azure.Sql.GalleryDatabaseAddress};Initial Catalog=NuGetGallery;Integrated Security=False;User ID=$$Prod-GalleryDBWriter-UserName$$;Password=$$Prod-GalleryDBWriter-Password$$;Connect Timeout=30;Encrypt=True"
10+
},
11+
12+
"KeyVault_VaultName": "#{Deployment.Azure.KeyVault.VaultName}",
13+
"KeyVault_ClientId": "#{Deployment.Azure.KeyVault.ClientId}",
14+
"KeyVault_CertificateThumbprint": "#{Deployment.Azure.KeyVault.CertificateThumbprint}",
15+
"KeyVault_ValidateCertificate": true,
16+
"KeyVault_StoreName": "My",
17+
"KeyVault_StoreLocation": "LocalMachine"
18+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"events": [
3+
{
4+
"sequence": 1,
5+
"packageId": "Example",
6+
"version": "1.0",
7+
"licenses": [ "Apache 2.0", "MIT" ],
8+
"reportUrl": "http://sample-license-service/...",
9+
"comment": "Example package published to nuget.org"
10+
}
11+
],
12+
"next": ""
13+
}

src/UpdateLicenseReports/UpdateLicenseReports.Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class Program
66
{
77
static void Main(string[] args)
88
{
9-
var job = new Job();
9+
var job = new UpdateLicenseReportsJob();
1010
JobRunner.Run(job, args).Wait();
1111
}
1212
}

src/UpdateLicenseReports/UpdateLicenseReports.csproj

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,21 @@
4646
<Reference Include="System.Xml" />
4747
</ItemGroup>
4848
<ItemGroup>
49-
<Compile Include="UpdateLicenseReports.Job.cs" />
49+
<Compile Include="Configuration\UpdateLicenseReportsConfiguration.cs" />
50+
<Compile Include="PackageLicenseReport.cs" />
51+
<Compile Include="UpdateLicenseReportsJob.cs" />
5052
<Compile Include="UpdateLicenseReports.Program.cs" />
5153
<Compile Include="Properties\AssemblyInfo.cs" />
5254
</ItemGroup>
5355
<ItemGroup>
5456
<None Include="App.config" />
5557
<None Include="Scripts\*" />
58+
<None Include="Settings\dev.json" />
59+
<None Include="Settings\int.json" />
60+
<None Include="Settings\prod.json" />
61+
<None Include="TestData\LicenseServiceSampleResponse.json">
62+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
63+
</None>
5664
<None Include="UpdateLicenseReports.nuspec" />
5765
</ItemGroup>
5866
<ItemGroup>
@@ -74,9 +82,6 @@
7482
<PackageReference Include="Newtonsoft.Json.Schema">
7583
<Version>2.0.10</Version>
7684
</PackageReference>
77-
<PackageReference Include="NuGet.Services.Sql">
78-
<Version>2.27.0</Version>
79-
</PackageReference>
8085
</ItemGroup>
8186
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
8287
<Import Project="..\..\build\sign.targets" Condition="Exists('..\..\build\sign.targets')" />

src/UpdateLicenseReports/UpdateLicenseReports.nuspec

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,9 @@
1818
<file src="Scripts\PreDeploy.ps1" />
1919
<file src="Scripts\PostDeploy.ps1" />
2020
<file src="Scripts\nssm.exe" />
21+
22+
<file src="TestData\*.json" target="bin" />
23+
24+
<file src="Settings\*.json" target="bin" />
2125
</files>
2226
</package>

0 commit comments

Comments
 (0)