Skip to content

Commit 27bc6a6

Browse files
authored
Merge pull request #10279 from NuGet/dev
[ReleasePrep][2024.11.22]RI of dev into main
2 parents 0ec9961 + b9466ae commit 27bc6a6

89 files changed

Lines changed: 1730 additions & 319 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/AccountDeleter/Configuration/AccountDeleteConfiguration.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System.Collections.Generic;
@@ -27,6 +27,7 @@ public class AccountDeleteConfiguration
2727
/// </summary>
2828
public Dictionary<string, string> TemplateReplacements { get; set; }
2929

30+
3031
/// <summary>
3132
/// Storage container connection string where gallery content can be found
3233
/// </summary>
@@ -50,4 +51,4 @@ public SourceConfiguration GetSourceConfiguration(string source)
5051
throw new UnknownSourceException();
5152
}
5253
}
53-
}
54+
}

src/AccountDeleter/EmptyFeatureFlagService.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using NuGet.Services.Entities;
@@ -323,5 +323,10 @@ public bool IsAdvancedFrameworkFilteringEnabled(User user)
323323
{
324324
throw new NotImplementedException();
325325
}
326+
327+
public bool CanUseFederatedCredentials(User user)
328+
{
329+
throw new NotImplementedException();
330+
}
326331
}
327332
}

src/AccountDeleter/Job.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
@@ -27,6 +27,7 @@
2727
using NuGetGallery.Features;
2828
using NuGetGallery.Infrastructure.Authentication;
2929
using NuGetGallery.Security;
30+
using ConfigConstants = NuGet.Services.Configuration.Constants;
3031

3132
namespace NuGetGallery.AccountDeleter
3233
{
@@ -104,6 +105,13 @@ protected override void ConfigureJobServices(IServiceCollection services, IConfi
104105
services.AddScoped<ITelemetryClient, TelemetryClientWrapper>(
105106
sp => TelemetryClientWrapper.UseTelemetryConfiguration(ApplicationInsightsConfiguration.TelemetryConfiguration));
106107

108+
services.AddScoped<ICloudBlobClient>(serviceProvider =>
109+
{
110+
var options = serviceProvider.GetRequiredService<IOptionsSnapshot<AccountDeleteConfiguration>>();
111+
return CloudBlobClientWrapper.UsingMsi(options.Value.GalleryStorageConnectionString,
112+
configurationRoot[ConfigConstants.StorageManagedIdentityClientIdPropertyName]);
113+
});
114+
107115
ConfigureGalleryServices(services);
108116
}
109117

@@ -160,14 +168,6 @@ protected void ConfigureGalleryServices(IServiceCollection services)
160168
return new SupportRequestDbContext(connection);
161169
});
162170

163-
services.AddScoped<ICloudBlobClient>(sp =>
164-
{
165-
var options = sp.GetRequiredService<IOptionsSnapshot<AccountDeleteConfiguration>>();
166-
var optionsSnapshot = options.Value;
167-
168-
return new CloudBlobClientWrapper(optionsSnapshot.GalleryStorageConnectionString, readAccessGeoRedundant: true);
169-
});
170-
171171
services.AddScoped<ITelemetryService, TelemetryService>();
172172
services.AddScoped<ISecurityPolicyService, SecurityPolicyService>();
173173
services.AddScoped<IAppConfiguration, GalleryConfiguration>();

src/Catalog/Dnx/DnxCatalogCollector.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
@@ -193,7 +193,7 @@ await catalogEntries.ForEachAsync(_maxConcurrentCommitItemsWithinBatch, async ca
193193
return processedCatalogEntries;
194194
}
195195

196-
private async Task<bool> AreRequiredPropertiesPresentAsync(Storage destinationStorage, Uri destinationUri)
196+
private async Task<bool> AreRequiredPropertiesPresentAsync(Persistence.Storage destinationStorage, Uri destinationUri)
197197
{
198198
var azureStorage = destinationStorage as IAzureStorage;
199199

@@ -561,4 +561,4 @@ internal static CatalogEntry Create(CatalogCommitItem item)
561561
}
562562
}
563563
}
564-
}
564+
}

src/Catalog/Dnx/DnxMaker.cs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
@@ -16,6 +16,7 @@
1616
using NuGet.Versioning;
1717

1818
using ILogger = Microsoft.Extensions.Logging.ILogger;
19+
using CatalogStorage = NuGet.Services.Metadata.Catalog.Persistence.Storage;
1920

2021
namespace NuGet.Services.Metadata.Catalog.Dnx
2122
{
@@ -154,7 +155,7 @@ public async Task DeletePackageAsync(string id, string version, CancellationToke
154155
await DeleteNupkgAsync(storage, id, normalizedVersion, cancellationToken);
155156
}
156157

157-
public async Task<bool> HasPackageInIndexAsync(Storage storage, string id, string version, CancellationToken cancellationToken)
158+
public async Task<bool> HasPackageInIndexAsync(CatalogStorage storage, string id, string version, CancellationToken cancellationToken)
158159
{
159160
if (storage == null)
160161
{
@@ -179,7 +180,7 @@ public async Task<bool> HasPackageInIndexAsync(Storage storage, string id, strin
179180
return versionsContext.Versions.Contains(parsedVersion);
180181
}
181182

182-
private async Task<Uri> SaveNuspecAsync(Storage storage, string id, string version, string nuspec, CancellationToken cancellationToken)
183+
private async Task<Uri> SaveNuspecAsync(CatalogStorage storage, string id, string version, string nuspec, CancellationToken cancellationToken)
183184
{
184185
var relativeAddress = GetRelativeAddressNuspec(id, version);
185186
var nuspecUri = new Uri(storage.BaseAddress, relativeAddress);
@@ -230,7 +231,7 @@ public async Task UpdatePackageVersionIndexAsync(string id, Action<HashSet<NuGet
230231
}
231232
}
232233

233-
private async Task<VersionsResult> GetVersionsAsync(Storage storage, CancellationToken cancellationToken)
234+
private async Task<VersionsResult> GetVersionsAsync(CatalogStorage storage, CancellationToken cancellationToken)
234235
{
235236
var relativeAddress = "index.json";
236237
var resourceUri = new Uri(storage.BaseAddress, relativeAddress);
@@ -265,7 +266,7 @@ private StorageContent CreateContent(IEnumerable<string> versions)
265266
return new StringStorageContent(obj.ToString(), "application/json", Constants.NoStoreCacheControl);
266267
}
267268

268-
private async Task<Uri> SaveNupkgAsync(Stream nupkgStream, Storage storage, string id, string version, CancellationToken cancellationToken)
269+
private async Task<Uri> SaveNupkgAsync(Stream nupkgStream, CatalogStorage storage, string id, string version, CancellationToken cancellationToken)
269270
{
270271
Uri nupkgUri = new Uri(storage.BaseAddress, GetRelativeAddressNupkg(id, version));
271272
var content = new StreamStorageContent(
@@ -280,7 +281,7 @@ private async Task<Uri> SaveNupkgAsync(Stream nupkgStream, Storage storage, stri
280281

281282
private async Task<Uri> CopyNupkgAsync(
282283
IStorage sourceStorage,
283-
Storage destinationStorage,
284+
CatalogStorage destinationStorage,
284285
string id, string version, CancellationToken cancellationToken)
285286
{
286287
var packageFileName = PackageUtility.GetPackageFileName(id, version);
@@ -300,7 +301,7 @@ await sourceStorage.CopyAsync(
300301

301302
private async Task CopyIconFromAzureStorageIfExistAsync(
302303
IAzureStorage sourceStorage,
303-
Storage destinationStorage,
304+
CatalogStorage destinationStorage,
304305
string packageId,
305306
string normalizedPackageVersion,
306307
string iconFilename,
@@ -321,7 +322,7 @@ await CopyIconAsync(
321322
private async Task CopyIconFromNupkgStreamAsync(
322323
Stream nupkgStream,
323324
string iconFilename,
324-
Storage destinationStorage,
325+
CatalogStorage destinationStorage,
325326
string packageId,
326327
string normalizedPackageVersion,
327328
CancellationToken cancellationToken)
@@ -338,7 +339,7 @@ await CopyIconAsync(
338339
private async Task CopyIconAsync(
339340
Stream packageStream,
340341
string iconFilename,
341-
Storage destinationStorage,
342+
CatalogStorage destinationStorage,
342343
string packageId,
343344
string normalizedPackageVersion,
344345
CancellationToken cancellationToken)
@@ -366,7 +367,7 @@ await ExtractAndStoreIconAsync(
366367
private async Task ExtractAndStoreIconAsync(
367368
Stream packageStream,
368369
string iconPath,
369-
Storage destinationStorage,
370+
CatalogStorage destinationStorage,
370371
Uri destinationUri,
371372
CancellationToken cancellationToken,
372373
string packageId,
@@ -406,7 +407,7 @@ private async Task<Stream> GetPackageStreamAsync(
406407
return await packageSourceBlob.GetStreamAsync(cancellationToken);
407408
}
408409

409-
private async Task DeleteNuspecAsync(Storage storage, string id, string version, CancellationToken cancellationToken)
410+
private async Task DeleteNuspecAsync(CatalogStorage storage, string id, string version, CancellationToken cancellationToken)
410411
{
411412
string relativeAddress = GetRelativeAddressNuspec(id, version);
412413
Uri nuspecUri = new Uri(storage.BaseAddress, relativeAddress);
@@ -416,7 +417,7 @@ private async Task DeleteNuspecAsync(Storage storage, string id, string version,
416417
}
417418
}
418419

419-
private async Task DeleteNupkgAsync(Storage storage, string id, string version, CancellationToken cancellationToken)
420+
private async Task DeleteNupkgAsync(CatalogStorage storage, string id, string version, CancellationToken cancellationToken)
420421
{
421422
string relativeAddress = GetRelativeAddressNupkg(id, version);
422423
Uri nupkgUri = new Uri(storage.BaseAddress, relativeAddress);
@@ -426,7 +427,7 @@ private async Task DeleteNupkgAsync(Storage storage, string id, string version,
426427
}
427428
}
428429

429-
private async Task DeleteIconAsync(Storage storage, string id, string version, CancellationToken cancellationToken)
430+
private async Task DeleteIconAsync(CatalogStorage storage, string id, string version, CancellationToken cancellationToken)
430431
{
431432
string relativeAddress = GetRelativeAddressIcon(id, version);
432433
Uri iconUri = new Uri(storage.BaseAddress, relativeAddress);
@@ -479,4 +480,4 @@ public VersionsResult(string relativeAddress, Uri resourceUri, HashSet<NuGetVers
479480
public HashSet<NuGetVersion> Versions { get; }
480481
}
481482
}
482-
}
483+
}

src/Catalog/DurableCursor.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
@@ -12,10 +12,10 @@ namespace NuGet.Services.Metadata.Catalog
1212
public class DurableCursor : ReadWriteCursor
1313
{
1414
Uri _address;
15-
Storage _storage;
15+
Persistence.Storage _storage;
1616
DateTime _defaultValue;
1717

18-
public DurableCursor(Uri address, Storage storage, DateTime defaultValue)
18+
public DurableCursor(Uri address, Persistence.Storage storage, DateTime defaultValue)
1919
{
2020
_address = address;
2121
_storage = storage;
@@ -43,4 +43,4 @@ public override async Task LoadAsync(CancellationToken cancellationToken)
4343
Value = obj["value"].ToObject<DateTime>();
4444
}
4545
}
46-
}
46+
}

src/Catalog/Helpers/DeletionAuditEntry.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
@@ -163,7 +163,7 @@ public static Task<IEnumerable<DeletionAuditEntry>> GetAsync(
163163
DateTime? maxTime = null,
164164
ILogger logger = null)
165165
{
166-
Storage storage = auditingStorageFactory.Create(package != null ? GetAuditRecordPrefixFromPackage(package) : null);
166+
Persistence.Storage storage = auditingStorageFactory.Create(package != null ? GetAuditRecordPrefixFromPackage(package) : null);
167167
return GetAsync(storage, cancellationToken, minTime, maxTime, logger);
168168
}
169169

@@ -258,4 +258,4 @@ private static bool IsPackageDelete(StorageListItem auditRecord)
258258
return FileNameSuffixes.Any(suffix => fileName.EndsWith(suffix));
259259
}
260260
}
261-
}
261+
}

src/Catalog/Icons/CatalogLeafDataProcessor.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
@@ -12,6 +12,8 @@
1212
using NuGet.Services.Metadata.Catalog.Helpers;
1313
using NuGet.Services.Metadata.Catalog.Persistence;
1414

15+
using CatalogStorage = NuGet.Services.Metadata.Catalog.Persistence.Storage;
16+
1517
namespace NuGet.Services.Metadata.Catalog.Icons
1618
{
1719
public class CatalogLeafDataProcessor : ICatalogLeafDataProcessor
@@ -42,7 +44,7 @@ public CatalogLeafDataProcessor(
4244
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
4345
}
4446

45-
public async Task ProcessPackageDeleteLeafAsync(Storage storage, CatalogCommitItem item, CancellationToken cancellationToken)
47+
public async Task ProcessPackageDeleteLeafAsync(CatalogStorage storage, CatalogCommitItem item, CancellationToken cancellationToken)
4648
{
4749
var targetStoragePath = GetTargetStorageIconPath(item);
4850
await _iconProcessor.DeleteIconAsync(storage, targetStoragePath, cancellationToken, item.PackageIdentity.Id, item.PackageIdentity.Version.ToNormalizedString());
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System.Threading;
@@ -9,7 +9,7 @@ namespace NuGet.Services.Metadata.Catalog.Icons
99
{
1010
public interface ICatalogLeafDataProcessor
1111
{
12-
Task ProcessPackageDeleteLeafAsync(Storage storage, CatalogCommitItem item, CancellationToken cancellationToken);
12+
Task ProcessPackageDeleteLeafAsync(Persistence.Storage storage, CatalogCommitItem item, CancellationToken cancellationToken);
1313
Task ProcessPackageDetailsLeafAsync(IStorage destinationStorage, IStorage iconCacheStorage, CatalogCommitItem item, string iconUrlString, string iconFile, CancellationToken cancellationToken);
1414
}
15-
}
15+
}

src/Catalog/NuGet.Services.Metadata.Catalog.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
<ProjectReference Include="..\NuGet.Services.Configuration\NuGet.Services.Configuration.csproj" />
7777
<ProjectReference Include="..\NuGet.Services.Logging\NuGet.Services.Logging.csproj" />
7878
<ProjectReference Include="..\NuGet.Services.Sql\NuGet.Services.Sql.csproj" />
79+
<ProjectReference Include="..\NuGet.Services.Storage\NuGet.Services.Storage.csproj" />
7980
<ProjectReference Include="..\NuGetGallery.Core\NuGetGallery.Core.csproj" />
8081
</ItemGroup>
8182

0 commit comments

Comments
 (0)