audit, advisories and doctors/setup work
This commit is contained in:
@@ -20,7 +20,7 @@ public sealed class MyConnector : IFeedConnector
|
||||
/// <summary>
|
||||
/// Gets the unique identifier for this connector.
|
||||
/// </summary>
|
||||
public string Id => "my-connector";
|
||||
public string SourceName => "my-connector";
|
||||
|
||||
/// <summary>
|
||||
/// Gets the display name for this connector.
|
||||
@@ -28,47 +28,34 @@ public sealed class MyConnector : IFeedConnector
|
||||
public string DisplayName => "My Connector";
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<FetchResult> FetchAsync(FetchContext context, CancellationToken cancellationToken = default)
|
||||
public async Task FetchAsync(IServiceProvider services, CancellationToken cancellationToken = default)
|
||||
{
|
||||
_logger.LogInformation("Fetching data from {ConnectorId}...", Id);
|
||||
ArgumentNullException.ThrowIfNull(services);
|
||||
_logger.LogInformation("Fetching data from {SourceName}...", SourceName);
|
||||
|
||||
// TODO: Implement your fetch logic here
|
||||
// Example: Download data from an external source
|
||||
await Task.Delay(100, cancellationToken); // Placeholder
|
||||
|
||||
return new FetchResult(
|
||||
Success: true,
|
||||
Data: Array.Empty<byte>(),
|
||||
ContentType: "application/json",
|
||||
ETag: null);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<ParseResult> ParseAsync(byte[] data, CancellationToken cancellationToken = default)
|
||||
public async Task ParseAsync(IServiceProvider services, CancellationToken cancellationToken = default)
|
||||
{
|
||||
_logger.LogInformation("Parsing data from {ConnectorId}...", Id);
|
||||
ArgumentNullException.ThrowIfNull(services);
|
||||
_logger.LogInformation("Parsing data from {SourceName}...", SourceName);
|
||||
|
||||
// TODO: Implement your parsing logic here
|
||||
await Task.Yield();
|
||||
|
||||
return new ParseResult(
|
||||
Success: true,
|
||||
Items: Array.Empty<object>(),
|
||||
Errors: Array.Empty<string>());
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<MapResult> MapAsync(object item, CancellationToken cancellationToken = default)
|
||||
public async Task MapAsync(IServiceProvider services, CancellationToken cancellationToken = default)
|
||||
{
|
||||
_logger.LogInformation("Mapping item from {ConnectorId}...", Id);
|
||||
ArgumentNullException.ThrowIfNull(services);
|
||||
_logger.LogInformation("Mapping item from {SourceName}...", SourceName);
|
||||
|
||||
// TODO: Implement your mapping logic here
|
||||
await Task.Yield();
|
||||
|
||||
return new MapResult(
|
||||
Success: true,
|
||||
MappedItem: item,
|
||||
Errors: Array.Empty<string>());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,16 +10,21 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="10.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="10.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Reference StellaOps plugin infrastructure -->
|
||||
<!-- Adjust paths based on your repository structure -->
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\__Libraries\StellaOps.Plugin\StellaOps.Plugin.csproj" />
|
||||
<ProjectReference Include="..\..\src\__Libraries\StellaOps.DependencyInjection\StellaOps.DependencyInjection.csproj" />
|
||||
<ProjectReference Include="..\..\..\..\..\src\__Libraries\StellaOps.Plugin\StellaOps.Plugin.csproj" />
|
||||
<ProjectReference Include="..\..\..\..\..\src\__Libraries\StellaOps.DependencyInjection\StellaOps.DependencyInjection.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="__Tests\\**\\*.cs" />
|
||||
<None Remove="__Tests\\**\\*" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using Microsoft.Extensions.Options;
|
||||
using StellaOps.Plugin.MyConnector;
|
||||
using Xunit;
|
||||
|
||||
namespace StellaOps.Plugin.MyConnector.Tests;
|
||||
|
||||
public sealed class MyConnectorTests
|
||||
{
|
||||
[Fact]
|
||||
public void MyConnector_ExposesIdentifiers()
|
||||
{
|
||||
var options = new MyConnectorOptions
|
||||
{
|
||||
BaseUrl = "https://example.com"
|
||||
};
|
||||
|
||||
var connector = new MyConnector(NullLogger<MyConnector>.Instance, options);
|
||||
|
||||
Assert.Equal("my-connector", connector.SourceName);
|
||||
Assert.Equal("My Connector", connector.DisplayName);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Plugin_Create_ReturnsConnector()
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
services.AddSingleton<ILogger<MyConnector>>(NullLogger<MyConnector>.Instance);
|
||||
services.AddSingleton<IOptions<MyConnectorOptions>>(Options.Create(new MyConnectorOptions
|
||||
{
|
||||
BaseUrl = "https://example.com"
|
||||
}));
|
||||
|
||||
using var provider = services.BuildServiceProvider();
|
||||
var plugin = new MyConnectorPlugin();
|
||||
|
||||
var connector = plugin.Create(provider);
|
||||
|
||||
Assert.NotNull(connector);
|
||||
Assert.Equal("my-connector", connector.SourceName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<IsPackable>false</IsPackable>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\StellaOps.Plugin.MyConnector.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="10.0.1" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
|
||||
<PackageReference Include="xunit" Version="2.9.3" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -10,16 +10,21 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="10.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="10.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Reference StellaOps plugin infrastructure -->
|
||||
<!-- Adjust paths based on your repository structure -->
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\__Libraries\StellaOps.Plugin\StellaOps.Plugin.csproj" />
|
||||
<ProjectReference Include="..\..\src\__Libraries\StellaOps.DependencyInjection\StellaOps.DependencyInjection.csproj" />
|
||||
<ProjectReference Include="..\..\..\..\..\src\__Libraries\StellaOps.Plugin\StellaOps.Plugin.csproj" />
|
||||
<ProjectReference Include="..\..\..\..\..\src\__Libraries\StellaOps.DependencyInjection\StellaOps.DependencyInjection.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="__Tests\\**\\*.cs" />
|
||||
<None Remove="__Tests\\**\\*" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using Microsoft.Extensions.Options;
|
||||
using StellaOps.Plugin.MyJob;
|
||||
using Xunit;
|
||||
|
||||
namespace StellaOps.Plugin.MyJob.Tests;
|
||||
|
||||
public sealed class MyJobTests
|
||||
{
|
||||
[Fact]
|
||||
public void MyJob_UsesConfiguredSchedule()
|
||||
{
|
||||
var options = Options.Create(new MyJobOptions
|
||||
{
|
||||
CronSchedule = "0 0 * * *"
|
||||
});
|
||||
|
||||
var job = new MyJob(NullLogger<MyJob>.Instance, options);
|
||||
|
||||
Assert.Equal("my-job", job.JobId);
|
||||
Assert.Equal("My Scheduled Job", job.DisplayName);
|
||||
Assert.Equal("0 0 * * *", job.CronSchedule);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<IsPackable>false</IsPackable>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\\..\\StellaOps.Plugin.MyJob.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="10.0.1" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
|
||||
<PackageReference Include="xunit" Version="2.9.3" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user