OPC # 0009: Fix Worker gitea HttpClient missing token and base URL
controlplane/build ✔ Build succeeded.
controlplane/build ✔ Build succeeded.
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System.Diagnostics;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Net.Http.Json;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
@@ -210,15 +209,11 @@ public sealed class BuildConsumer(
|
||||
{
|
||||
try
|
||||
{
|
||||
var baseUrl = (config["Gitea:BaseUrl"] ?? "https://opc.clarity.test").TrimEnd('/');
|
||||
var owner = config["Gitea:Owner"] ?? "ClarityStack";
|
||||
var token = config["Gitea:Token"] ?? string.Empty;
|
||||
var owner = config["Gitea:Owner"] ?? "ClarityStack";
|
||||
|
||||
using var http = httpFactory.CreateClient("gitea");
|
||||
http.DefaultRequestHeaders.Authorization =
|
||||
new AuthenticationHeaderValue("token", token);
|
||||
|
||||
var url = $"{baseUrl}/api/v1/repos/{owner}/{repoName}/statuses/{sha}";
|
||||
var url = $"api/v1/repos/{owner}/{repoName}/statuses/{sha}";
|
||||
var body = JsonSerializer.Serialize(new
|
||||
{
|
||||
state,
|
||||
|
||||
@@ -27,8 +27,14 @@ builder.Services.AddKeycloakAdminHttpClient(o =>
|
||||
// Custom admin client - handles realm creation, roles, role assignment (not in SDK)
|
||||
builder.Services.AddSingleton<KeycloakAdminClient>();
|
||||
|
||||
// Named HttpClient for Gitea commit status API (self-signed cert)
|
||||
builder.Services.AddHttpClient("gitea").ConfigurePrimaryHttpMessageHandler(() =>
|
||||
// Named HttpClient for Gitea commit status API (self-signed cert + token auth)
|
||||
builder.Services.AddHttpClient("gitea", (sp, client) =>
|
||||
{
|
||||
var cfg = sp.GetRequiredService<IConfiguration>();
|
||||
client.BaseAddress = new Uri(cfg["Gitea:BaseUrl"] ?? "https://opc.clarity.test");
|
||||
client.DefaultRequestHeaders.Authorization =
|
||||
new System.Net.Http.Headers.AuthenticationHeaderValue("token", cfg["Gitea:Token"]);
|
||||
}).ConfigurePrimaryHttpMessageHandler(() =>
|
||||
new HttpClientHandler { ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator });
|
||||
|
||||
// opcdb for build/release history tracking
|
||||
|
||||
Reference in New Issue
Block a user