-
Notifications
You must be signed in to change notification settings - Fork 910
Enable AOT compatibility for Yarp.Kubernetes.Controller #3010
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 4 commits
0bebe98
6245b34
ad10145
dd0c957
b5bf7f6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Collections.Generic; | ||
| using System.Text.Json.Serialization; | ||
| using Yarp.Kubernetes.Protocol; | ||
| using Yarp.ReverseProxy.Configuration; | ||
|
|
||
| namespace Yarp.Kubernetes.Controller.Protocol; | ||
|
|
||
| [JsonSerializable(typeof(Message))] | ||
| [JsonSerializable(typeof(List<RouteConfig>))] | ||
| [JsonSerializable(typeof(List<ClusterConfig>))] | ||
| internal sealed partial class KubernetesJsonSerializerContext : JsonSerializerContext | ||
| { | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| // This app is used to test AOT compatibility of Yarp.Kubernetes.Controller. | ||
| // It exercises the main public API surface to ensure no AOT/trimming warnings | ||
| // are emitted at build or publish time. | ||
|
|
||
| using Microsoft.AspNetCore.Builder; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
| using Yarp.Kubernetes.Protocol; | ||
|
|
||
| // Combined controller scenario (ingress controller + YARP reverse proxy) | ||
| { | ||
| var builder = WebApplication.CreateBuilder(args); | ||
| builder.WebHost.UseKubernetesReverseProxyCertificateSelector(); | ||
| builder.Services.AddKubernetesReverseProxy(builder.Configuration); | ||
| _ = builder.Build(); | ||
| } | ||
|
|
||
| // Monitor-only scenario (ingress monitor + dispatch controller) | ||
| { | ||
| var builder = WebApplication.CreateBuilder(args); | ||
| builder.Services.AddKubernetesIngressMonitor(builder.Configuration); | ||
| builder.Services.AddControllers().AddKubernetesDispatchController(); | ||
| _ = builder.Build(); | ||
| } | ||
|
|
||
| // Receiver scenario (side-car that receives config from ingress monitor) | ||
| { | ||
| var builder = WebApplication.CreateBuilder(args); | ||
| builder.Services.Configure<ReceiverOptions>(builder.Configuration.Bind); | ||
| builder.Services.AddHostedService<Receiver>(); | ||
| builder.Services.AddReverseProxy().LoadFromMessages(); | ||
| _ = builder.Build(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFrameworks>$(ReleaseTFMs)</TargetFrameworks> | ||
| <OutputType>Exe</OutputType> | ||
| <PublishAot>true</PublishAot> | ||
| <Nullable>enable</Nullable> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\..\src\Kubernetes.Controller\Yarp.Kubernetes.Controller.csproj" /> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @copilot - this should reference all the projects that are AOT compatible in teh repo. Also, it needs
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in b5bf7f6. The csproj now references all three AOT-compatible YARP assemblies with |
||
| </ItemGroup> | ||
|
|
||
| </Project> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Just make this the latest TFM - net10.0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in b5bf7f6 — changed to
<TargetFramework>net10.0</TargetFramework>(singular).