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.
Merge pull request #248 from NuGet/dev
[RI]: dev to master
- Loading branch information
Showing
49 changed files
with
2,893 additions
and
94 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,6 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> | ||
</startup> | ||
<configSections> | ||
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> | ||
</configSections> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> | ||
</startup> | ||
<entityFramework codeConfigurationType="NuGetGallery.EntitiesConfiguration, NuGetGallery.Core"> | ||
</entityFramework> | ||
</configuration> |
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
65 changes: 65 additions & 0 deletions
65
src/NuGet.Services.Validation.Orchestrator/ContainerBuilderExtensions.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,65 @@ | ||
// 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 Autofac; | ||
using Autofac.Builder; | ||
|
||
namespace NuGet.Services.Validation.Orchestrator | ||
{ | ||
public static class ContainerBuilderExtensions | ||
{ | ||
/// <summary> | ||
/// Adds type registration parameter that instructs Autofac to use keyed resolution for a certain constructor parameter type. | ||
/// </summary> | ||
/// <param name="registrationBuilder">Registration builder object returned by <see cref="Autofac.RegistrationExtensions.RegisterType{TImplementer}(ContainerBuilder)"/> call</param> | ||
/// <param name="parameterType">The type of the constructor parameter to use keyed resolution for.</param> | ||
/// <param name="key">The key to use</param> | ||
/// <returns>Registration builder object passed as <paramref name="registrationBuilder"/> to support fluent API</returns> | ||
public static IRegistrationBuilder<TLimit, TReflectionActivatorData, TStyle> | ||
WithKeyedParameter<TLimit, TReflectionActivatorData, TStyle>(this IRegistrationBuilder<TLimit, TReflectionActivatorData, TStyle> registrationBuilder, Type parameterType, string key) | ||
where TReflectionActivatorData : ReflectionActivatorData | ||
{ | ||
return registrationBuilder.WithParameter( | ||
(pi, ctx) => pi.ParameterType == parameterType, | ||
(pi, ctx) => ctx.ResolveKeyed(key, parameterType)); | ||
} | ||
|
||
/// <summary> | ||
/// Registers type with one keyed parameter | ||
/// </summary> | ||
/// <typeparam name="TService">The type to register as</typeparam> | ||
/// <typeparam name="TImplementer">The implementation to register</typeparam> | ||
/// <typeparam name="TKeyedParameter">Keyed parameter type</typeparam> | ||
/// <param name="containerBuilder"><see cref="ContainerBuilder"/> instance</param> | ||
/// <param name="parameterKey">The key to use for keyed parameter</param> | ||
/// <returns>Registration builder object</returns> | ||
public static IRegistrationBuilder<TImplementer, ConcreteReflectionActivatorData, SingleRegistrationStyle> | ||
RegisterTypeWithKeyedParameter<TService, TImplementer, TKeyedParameter>(this ContainerBuilder containerBuilder, string parameterKey) | ||
{ | ||
return containerBuilder | ||
.RegisterType<TImplementer>() | ||
.WithKeyedParameter(typeof(TKeyedParameter), parameterKey) | ||
.As<TService>(); | ||
} | ||
|
||
/// <summary> | ||
/// Registers *keyed* type with one keyed parameter | ||
/// </summary> | ||
/// <typeparam name="TService">The type to register as</typeparam> | ||
/// <typeparam name="TImplementer">The implementation to register</typeparam> | ||
/// <typeparam name="TKeyedParameter">Keyed parameter type</typeparam> | ||
/// <param name="containerBuilder"><see cref="ContainerBuilder"/> instance</param> | ||
/// <param name="typeKey">The key to register type with.</param> | ||
/// <param name="parameterKey">The key to use for keyed parameter</param> | ||
/// <returns>Registration builder object</returns> | ||
public static IRegistrationBuilder<TImplementer, ConcreteReflectionActivatorData, SingleRegistrationStyle> | ||
RegisterKeyedTypeWithKeyedParameter<TService, TImplementer, TKeyedParameter>(this ContainerBuilder containerBuilder, string typeKey, string parameterKey) | ||
{ | ||
return containerBuilder | ||
.RegisterType<TImplementer>() | ||
.WithKeyedParameter(typeof(TKeyedParameter), parameterKey) | ||
.Keyed<TService>(typeKey); | ||
} | ||
} | ||
} |
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
10 changes: 10 additions & 0 deletions
10
src/NuGet.Services.Validation.Orchestrator/GalleryDbConfiguration.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.Services.Validation.Orchestrator | ||
{ | ||
public class GalleryDbConfiguration | ||
{ | ||
public string ConnectionString { get; set; } | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/NuGet.Services.Validation.Orchestrator/IValidationOutcomeProcessor.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,25 @@ | ||
// 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.Threading.Tasks; | ||
using NuGetGallery; | ||
|
||
namespace NuGet.Services.Validation.Orchestrator | ||
{ | ||
/// <summary> | ||
/// Interface for the code that deals with any changes that happened in the validation set | ||
/// </summary> | ||
public interface IValidationOutcomeProcessor | ||
{ | ||
/// <summary> | ||
/// Processes the changes in validation statuses: | ||
/// * If there are failed vailidations, marks package as failed; | ||
/// * If all validations succeeded, copies package to public container and marks package as validated; | ||
/// * Otherwise, queues another check for the package | ||
/// </summary> | ||
/// <param name="validationSet">Current state of validation set</param> | ||
/// <param name="package">Package information from Gallery DB</param> | ||
/// <returns>A task that completes when the outcome has been processed</returns> | ||
Task ProcessValidationOutcomeAsync(PackageValidationSet validationSet, Package package); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/NuGet.Services.Validation.Orchestrator/IValidationSetProcessor.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,23 @@ | ||
// 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.Threading.Tasks; | ||
using NuGetGallery; | ||
|
||
namespace NuGet.Services.Validation.Orchestrator | ||
{ | ||
/// <summary> | ||
/// Interface for the implementation that resolves the validation dependencies and runs them in proper order | ||
/// </summary> | ||
public interface IValidationSetProcessor | ||
{ | ||
/// <summary> | ||
/// Checks the status of all incomplete validations, starts the ones that can be started (due to dependency changes). | ||
/// Persists all validation status changes. | ||
/// </summary> | ||
/// <param name="validationSet">Validation set to work with. Any validation updates would be reflected in that object upon return.</param> | ||
/// <param name="package">Gallery DB package information</param> | ||
/// <returns>Task object representing async operation</returns> | ||
Task ProcessValidationsAsync(PackageValidationSet validationSet, Package package); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/NuGet.Services.Validation.Orchestrator/IValidationSetProvider.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,23 @@ | ||
// 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.Threading.Tasks; | ||
using NuGetGallery; | ||
|
||
namespace NuGet.Services.Validation.Orchestrator | ||
{ | ||
/// <summary> | ||
/// Provides <see cref="PackageValidationSet"/> instances. | ||
/// </summary> | ||
public interface IValidationSetProvider | ||
{ | ||
/// <summary> | ||
/// Reads validation set data from storage, creates one if did not exist in storage | ||
/// </summary> | ||
/// <param name="validationTrackingId">Validation tracking id</param> | ||
/// <param name="package">Package details from Gallery DB</param> | ||
/// <returns><see cref="PackageValidationSet"/> object with information about requested <paramref name="validationTrackingId"/></returns> | ||
Task<PackageValidationSet> GetOrCreateValidationSetAsync(Guid validationTrackingId, Package package); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
src/NuGet.Services.Validation.Orchestrator/IValidationStorageService.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,53 @@ | ||
// 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.Threading.Tasks; | ||
|
||
namespace NuGet.Services.Validation.Orchestrator | ||
{ | ||
/// <summary> | ||
/// Abstracts the validation persistence layer | ||
/// </summary> | ||
public interface IValidationStorageService | ||
{ | ||
/// <summary> | ||
/// Persists the passed validation set in the storage | ||
/// </summary> | ||
/// <param name="packageValidationSet"><see cref="PackageValidationSet"/> instance to persist.</param> | ||
/// <returns>Persisted object with any default values set by storage and tracked if storage provides change tracking.</returns> | ||
Task<PackageValidationSet> CreateValidationSetAsync(PackageValidationSet packageValidationSet); | ||
|
||
/// <summary> | ||
/// Tries to read <see cref="PackageValidationSet"/> from storage by <paramref name="validationTrackingId"/>. | ||
/// </summary> | ||
/// <param name="validationTrackingId">Tracking id of the validation set to read.</param> | ||
/// <returns>Validation set instance if found, null otherwise.</returns> | ||
Task<PackageValidationSet> GetValidationSetAsync(Guid validationTrackingId); | ||
|
||
/// <summary> | ||
/// Updates the passed <see cref="PackageValidation"/> with specified validation status, | ||
/// updates the <see cref="PackageValidation.ValidationStatusTimestamp"/> | ||
/// and <see cref="PackageValidation.Started"/> properties to current timestamp, persists changes in the storage. | ||
/// </summary> | ||
/// <param name="packageValidation">Validation object to update, must be an object from the <see cref="PackageValidationSet.PackageValidations"/> collection | ||
/// from an <see cref="PackageValidationSet"/> previously returned by either <see cref="CreateValidationSetAsync(PackageValidationSet)"/> | ||
/// or <see cref="GetValidationSetAsync(Guid)"/> calls.</param> | ||
/// <param name="startedStatus">Validation status to set. Cannot be <see cref="ValidationStatus.NotStarted"/></param> | ||
/// <returns>Task object tracking the async operation status.</returns> | ||
/// <exception cref="ArgumentOutOfRangeException">If <paramref name="startedStatus"/> is <see cref="ValidationStatus.NotStarted"/></exception> | ||
Task MarkValidationStartedAsync(PackageValidation packageValidation, ValidationStatus startedStatus); | ||
|
||
/// <summary> | ||
/// Updates the passed <see cref="PackageValidation"/> object with specified validation status, | ||
/// updates the <see cref="PackageValidation.ValidationStatusTimestamp"/> | ||
/// property to current timestamp, persists changes in the storage. | ||
/// </summary> | ||
/// <param name="packageValidation">Validation object to update, must be an object from the <see cref="PackageValidationSet.PackageValidations"/> collection | ||
/// from an <see cref="PackageValidationSet"/> previously returned by either <see cref="CreateValidationSetAsync(PackageValidationSet)"/> | ||
/// or <see cref="GetValidationSetAsync(Guid)"/> calls.</param> | ||
/// <param name="validationStatus">Validation status to set.</param> | ||
/// <returns>Task object tracking the async operation status.</returns> | ||
Task UpdateValidationStatusAsync(PackageValidation packageValidation, ValidationStatus validationStatus); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/NuGet.Services.Validation.Orchestrator/IValidatorProvider.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,13 @@ | ||
// 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.Services.Validation.Orchestrator | ||
{ | ||
/// <summary> | ||
/// Interface for the class that provides validator instances by their name | ||
/// </summary> | ||
public interface IValidatorProvider | ||
{ | ||
IValidator GetValidator(string validatorName); | ||
} | ||
} |
Oops, something went wrong.