|
3 | 3 |
|
4 | 4 | using System.Globalization; |
5 | 5 | using System.Net; |
6 | | -using System.Reflection; |
7 | 6 | using System.Text; |
8 | 7 | using Azure.Identity; |
9 | 8 | using EntityFrameworkCore.Triggers; |
|
21 | 20 | using Microsoft.DotNet.GitHub.Authentication; |
22 | 21 | using Microsoft.DotNet.Internal.Logging; |
23 | 22 | using Microsoft.DotNet.Services.Utility; |
24 | | -using Microsoft.EntityFrameworkCore; |
25 | | -using Microsoft.EntityFrameworkCore.Infrastructure; |
26 | 23 | using Microsoft.Extensions.Options; |
27 | 24 | using Newtonsoft.Json; |
28 | 25 | using Newtonsoft.Json.Converters; |
|
33 | 30 | using ProductConstructionService.Api.Telemetry; |
34 | 31 | using ProductConstructionService.Api.VirtualMonoRepo; |
35 | 32 | using ProductConstructionService.Common; |
36 | | -using ProductConstructionService.DependencyFlow.WorkItems; |
37 | 33 | using ProductConstructionService.WorkItems; |
38 | 34 | using ProductConstructionService.DependencyFlow; |
39 | 35 | using ProductConstructionService.ServiceDefaults; |
@@ -76,57 +72,7 @@ private static class ConfigurationKeys |
76 | 72 |
|
77 | 73 | static PcsStartup() |
78 | 74 | { |
79 | | - var metadata = typeof(Program).Assembly |
80 | | - .GetCustomAttributes() |
81 | | - .OfType<AssemblyMetadataAttribute>() |
82 | | - .ToDictionary(m => m.Key, m => m.Value); |
83 | | - |
84 | | - Triggers<BuildChannel>.Inserted += entry => |
85 | | - { |
86 | | - var context = (BuildAssetRegistryContext)entry.Context; |
87 | | - ILogger<BuildAssetRegistryContext> logger = context.GetService<ILogger<BuildAssetRegistryContext>>(); |
88 | | - var workItemProducerFactory = context.GetService<IWorkItemProducerFactory>(); |
89 | | - BuildChannel entity = entry.Entity; |
90 | | - |
91 | | - Build? build = context.Builds |
92 | | - .Include(b => b.Assets) |
93 | | - .ThenInclude(a => a.Locations) |
94 | | - .FirstOrDefault(b => b.Id == entity.BuildId); |
95 | | - |
96 | | - if (build == null) |
97 | | - { |
98 | | - logger.LogError("Could not find build with id {buildId} in BAR. Skipping dependency update.", entity.BuildId); |
99 | | - } |
100 | | - else |
101 | | - { |
102 | | - bool hasAssetsWithPublishedLocations = build.Assets |
103 | | - .Any(a => a.Locations.Any(al => al.Type != LocationType.None && !al.Location.EndsWith("/artifacts"))); |
104 | | - |
105 | | - if (!hasAssetsWithPublishedLocations) |
106 | | - { |
107 | | - logger.LogInformation("Skipping Dependency update for Build {buildId} because it contains no assets in valid locations", entity.BuildId); |
108 | | - return; |
109 | | - } |
110 | | - |
111 | | - List<Subscription> subscriptionsToUpdate = context.Subscriptions |
112 | | - .Where(sub => |
113 | | - sub.Enabled && |
114 | | - sub.ChannelId == entity.ChannelId && |
115 | | - (sub.SourceRepository == entity.Build.GitHubRepository || sub.SourceDirectory == entity.Build.AzureDevOpsRepository) && |
116 | | - JsonExtensions.JsonValue(sub.PolicyString, "lax $.UpdateFrequency") == ((int)UpdateFrequency.EveryBuild).ToString()) |
117 | | - .ToList(); |
118 | | - |
119 | | - foreach (Subscription subscription in subscriptionsToUpdate) |
120 | | - { |
121 | | - var workItemProducer = workItemProducerFactory.CreateProducer<SubscriptionTriggerWorkItem>(subscription.SourceEnabled); |
122 | | - workItemProducer.ProduceWorkItemAsync(new() |
123 | | - { |
124 | | - BuildId = entity.BuildId, |
125 | | - SubscriptionId = subscription.Id |
126 | | - }).GetAwaiter().GetResult(); |
127 | | - } |
128 | | - } |
129 | | - }; |
| 75 | + Triggers<BuildChannel>.Inserted += SubscriptionTriggerConfiguration.TriggerSubscriptionOnNewBuild; |
130 | 76 | } |
131 | 77 |
|
132 | 78 | /// <summary> |
|
0 commit comments