add KubernetesClient.Aot to support Aot (#1498)

* init aot

* fix ca2007

* xUnit1031

* fix ca2007

* fix ca2007

* remove deprecated ctor

* fix xUnit1031

* fix missing doc

* fix missing dispose

* wait for warnings fix

* fix space

* move aot code to dedicated proj

* Remove commented out code

* eliminate know warnings

* add e2e test for aot

* rever on field convert annotation

* add e2e aot gh

* Add KubernetesClient.Aot project reference

* move CA1812 rule violation to file
This commit is contained in:
Boshi Lian
2024-01-29 13:58:22 -08:00
committed by GitHub
parent c7060d4301
commit 00c4c6f4ab
27 changed files with 2030 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ProjectReference Include="$(MSBuildThisFileDirectory)\..\src\KubernetesClient\KubernetesClient.csproj" />
<ProjectReference Include="$(MSBuildThisFileDirectory)\..\src\KubernetesClient\KubernetesClient.csproj" Condition="'$(PublishAot)' != 'true'" />
</ItemGroup>
</Project>

16
examples/aot/Program.cs Normal file
View File

@@ -0,0 +1,16 @@
using k8s;
var config = KubernetesClientConfiguration.BuildDefaultConfig();
IKubernetes client = new Kubernetes(config);
Console.WriteLine("Starting Request!");
var list = client.CoreV1.ListNamespacedPod("default");
foreach (var item in list.Items)
{
Console.WriteLine(item.Metadata.Name);
}
if (list.Items.Count == 0)
{
Console.WriteLine("Empty!");
}

11
examples/aot/aot.csproj Normal file
View File

@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PublishAot>true</PublishAot>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\KubernetesClient.Aot\KubernetesClient.Aot.csproj"/>
</ItemGroup>
</Project>