mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
wire up Octokit
This commit is contained in:
parent
f1636f4369
commit
814b875aa1
4 changed files with 24 additions and 0 deletions
8
src/FilterLists.Agent/AppSettings/GitHub.cs
Normal file
8
src/FilterLists.Agent/AppSettings/GitHub.cs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
namespace FilterLists.Agent.AppSettings
|
||||
{
|
||||
public class GitHub
|
||||
{
|
||||
public string ProductHeaderValue { get; set; }
|
||||
public string OauthToken { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@
|
|||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Octokit;
|
||||
|
||||
namespace FilterLists.Agent.Extensions
|
||||
{
|
||||
|
|
@ -25,6 +26,15 @@ public static void RegisterAgentServices(this IServiceCollection services)
|
|||
services.AddMediatR(typeof(Program).Assembly);
|
||||
services.AddHttpClient<AgentHttpClient>();
|
||||
services.AddSingleton<IFilterListsApiClient, FilterListsApiClient>();
|
||||
services.AddSingleton<IGitHubClient>(s =>
|
||||
{
|
||||
var gitHubConfig = s.GetService<GitHub>();
|
||||
var client = new GitHubClient(new ProductHeaderValue(gitHubConfig.ProductHeaderValue))
|
||||
{
|
||||
Credentials = new Credentials(gitHubConfig.OauthToken)
|
||||
};
|
||||
return client;
|
||||
});
|
||||
services.AddTransient<IListInfoRepository, ListInfoRepository>();
|
||||
services.AddTransient<IUrlRepository, UrlRepository>();
|
||||
}
|
||||
|
|
@ -37,6 +47,7 @@ private static void AddConfiguration(this IServiceCollection services)
|
|||
.Build();
|
||||
services.Configure<ApplicationInsights>(config.GetSection(nameof(ApplicationInsights)));
|
||||
services.Configure<ConnectionStrings>(config.GetSection(nameof(ConnectionStrings)));
|
||||
services.Configure<GitHub>(config.GetSection(nameof(GitHub)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -42,6 +42,7 @@
|
|||
<PackageReference Include="Microsoft.Extensions.Logging.ApplicationInsights" Version="2.10.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.7.11" />
|
||||
<PackageReference Include="Octokit" Version="0.32.0" />
|
||||
<PackageReference Include="RestSharp" Version="106.6.9" />
|
||||
<PackageReference Include="SharpCompress" Version="0.23.0" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
|
|
@ -4,5 +4,9 @@
|
|||
},
|
||||
"ConnectionStrings": {
|
||||
"FilterListsConnection": ""
|
||||
},
|
||||
"GitHub": {
|
||||
"ProductHeaderValue": "",
|
||||
"OauthToken:": ""
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue