Skip to content

Commit 001189d

Browse files
authored
Version 17.0 + Generate 1.33 (#1626)
* generated based on 1.33 * Update version to 17.0 in version.json * Remove extra API endpoint from swagger.json * Remove ModelConverter and related AutoMapper components * Update package versions * Refactor code to use ConfigureAwait(false) for asynchronous calls and update target framework to net9.0 * Remove ConfigureAwait(false) from OidcAuthTests for consistency in async calls * Update SDK version in README to reflect support for net8.0 and net9.0 * Update dotnet SDK version to 9.0.x in build workflow * Revert Fractions package version to 7.3.0 in Directory.Packages.props * Update target framework to netstandard2.1 for improved compatibility * Update package references for Microsoft.CodeAnalysis in Directory.Packages.props and LibKubernetesGenerator.target * Refactor Worker class constructor documentation and standardize Dictionary type declaration in Program.cs
1 parent dfdf0b7 commit 001189d

30 files changed

+19955
-10153
lines changed

.github/workflows/buildtest.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
- name: Setup dotnet SDK
5151
uses: actions/setup-dotnet@v4
5252
with:
53-
dotnet-version: '8.0.x'
53+
dotnet-version: '9.0.x'
5454
- name: Restore nugets (msbuild)
5555
run: msbuild .\src\KubernetesClient\ -t:restore -p:RestorePackagesConfig=true
5656
- name: Build (msbuild)

Directory.Packages.props

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,53 @@
1-
<Project>
2-
<PropertyGroup>
3-
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
4-
</PropertyGroup>
5-
<ItemGroup>
6-
<PackageVersion Include="AutoMapper" Version="13.0.1" />
7-
<PackageVersion Include="BouncyCastle.Cryptography" Version="2.5.0" />
8-
<PackageVersion Include="FluentAssertions" Version="7.0.0" />
9-
<PackageVersion Include="Fractions" Version="7.3.0" />
10-
<PackageVersion Include="JsonPatch.Net" Version="2.1.0" />
11-
<PackageVersion Include="MartinCostello.Logging.XUnit" Version="0.5.1" />
12-
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="9.0.0" />
13-
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
14-
<PackageVersion Include="Microsoft.Extensions.Logging" Version="9.0.0" />
15-
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
16-
<PackageVersion Include="Microsoft.TestPlatform.ObjectModel" Version="17.12.0" />
17-
<PackageVersion Include="Moq" Version="4.20.72" />
18-
<PackageVersion Include="Nito.AsyncEx" Version="5.1.2" />
19-
<PackageVersion Include="Nito.AsyncEx.Coordination" Version="5.1.2" />
20-
<PackageVersion Include="OpenTelemetry.Exporter.Console" Version="1.7.0" />
21-
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="1.8.1" />
22-
<PackageVersion Include="Portable.BouncyCastle" Version="1.9.0" />
23-
<PackageVersion Include="SharpZipLib" Version="1.4.2" />
24-
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.5.0" />
25-
<PackageVersion Include="System.Diagnostics.DiagnosticSource" Version="9.0.0" />
26-
<PackageVersion Include="System.IO.Abstractions.TestingHelpers" Version="21.2.1" />
27-
<PackageVersion Include="System.Reactive" Version="6.0.1" />
28-
<PackageVersion Include="System.Text.Json" Version="9.0.0" />
29-
<PackageVersion Include="Vecc.YamlDotNet.Analyzers.StaticGenerator" Version="16.3.0" />
30-
<PackageVersion Include="Wiremock.Net" Version="1.7.4" />
31-
<PackageVersion Include="xunit" Version="2.9.2" />
32-
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.0" />
33-
<PackageVersion Include="Xunit.StaFact" Version="1.1.11" />
34-
<PackageVersion Include="YamlDotNet" Version="16.3.0" />
35-
</ItemGroup>
36-
<ItemGroup>
37-
<PackageVersion Include="Autofac" Version="8.2.0" />
38-
<PackageVersion Include="CaseExtensions" Version="1.1.0" />
39-
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.4.0" />
40-
<PackageVersion Include="Namotion.Reflection" Version="3.0.1" />
41-
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
42-
<PackageVersion Include="NJsonSchema" Version="10.9.0" />
43-
<PackageVersion Include="NSwag.Core" Version="13.20.0" />
44-
<PackageVersion Include="Scriban" Version="5.9.1" />
45-
</ItemGroup>
46-
<ItemGroup>
47-
<GlobalPackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="9.0.0" />
48-
<GlobalPackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
49-
<GlobalPackageReference Include="Microsoft.VisualStudio.SlnGen" Version="12.0.3" />
50-
<GlobalPackageReference Include="Nerdbank.GitVersioning" Version="3.7.112" />
51-
<GlobalPackageReference Include="StyleCop.Analyzers" Version="1.1.118" />
52-
</ItemGroup>
1+
<Project>
2+
<PropertyGroup>
3+
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
4+
</PropertyGroup>
5+
<ItemGroup>
6+
<PackageVersion Include="BouncyCastle.Cryptography" Version="2.5.1" />
7+
<PackageVersion Include="FluentAssertions" Version="8.2.0" />
8+
<PackageVersion Include="Fractions" Version="7.3.0" />
9+
<PackageVersion Include="JsonPatch.Net" Version="3.3.0" />
10+
<PackageVersion Include="MartinCostello.Logging.XUnit" Version="0.5.1" />
11+
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="9.0.4" />
12+
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="9.0.4" />
13+
<PackageVersion Include="Microsoft.Extensions.Logging" Version="9.0.4" />
14+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
15+
<PackageVersion Include="Microsoft.TestPlatform.ObjectModel" Version="17.13.0" />
16+
<PackageVersion Include="Moq" Version="4.20.72" />
17+
<PackageVersion Include="Nito.AsyncEx" Version="5.1.2" />
18+
<PackageVersion Include="Nito.AsyncEx.Coordination" Version="5.1.2" />
19+
<PackageVersion Include="OpenTelemetry.Exporter.Console" Version="1.11.2" />
20+
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="1.11.1" />
21+
<PackageVersion Include="Portable.BouncyCastle" Version="1.9.0" />
22+
<PackageVersion Include="SharpZipLib" Version="1.4.2" />
23+
<PackageVersion Include="Swashbuckle.AspNetCore" Version="8.1.1" />
24+
<PackageVersion Include="System.Diagnostics.DiagnosticSource" Version="9.0.4" />
25+
<PackageVersion Include="System.IO.Abstractions.TestingHelpers" Version="22.0.14" />
26+
<PackageVersion Include="System.Reactive" Version="6.0.1" />
27+
<PackageVersion Include="System.Text.Json" Version="9.0.4" />
28+
<PackageVersion Include="Vecc.YamlDotNet.Analyzers.StaticGenerator" Version="16.3.0" />
29+
<PackageVersion Include="Wiremock.Net" Version="1.7.4" />
30+
<PackageVersion Include="xunit" Version="2.9.3" />
31+
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.2" />
32+
<PackageVersion Include="Xunit.StaFact" Version="1.2.69" />
33+
<PackageVersion Include="YamlDotNet" Version="16.3.0" />
34+
</ItemGroup>
35+
<ItemGroup>
36+
<PackageVersion Include="Autofac" Version="8.2.1" />
37+
<PackageVersion Include="CaseExtensions" Version="1.1.0" />
38+
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="4.13.0" />
39+
<PackageVersion Include="Namotion.Reflection" Version="3.3.0" />
40+
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
41+
<PackageVersion Include="NJsonSchema" Version="11.2.0" />
42+
<PackageVersion Include="NJsonSchema.Annotations" Version="11.2.0" />
43+
<PackageVersion Include="NSwag.Core" Version="14.3.0" />
44+
<PackageVersion Include="Scriban" Version="6.2.1" />
45+
</ItemGroup>
46+
<ItemGroup>
47+
<GlobalPackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="9.0.0" />
48+
<GlobalPackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
49+
<GlobalPackageReference Include="Microsoft.VisualStudio.SlnGen" Version="12.0.3" />
50+
<GlobalPackageReference Include="Nerdbank.GitVersioning" Version="3.7.112" />
51+
<GlobalPackageReference Include="StyleCop.Analyzers" Version="1.1.118" />
52+
</ItemGroup>
5353
</Project>

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ ${GEN_DIR}/openapi/csharp.sh ${REPO_DIR}/src/KubernetesClient ${REPO_DIR}/csharp
154154

155155
| SDK Version | Kubernetes Version | .NET Targeting |
156156
|-------------|--------------------|-----------------------------------------------------|
157+
| 17.0 | 1.33 | net8.0;net9.0;net48*;netstandard2.0* |
157158
| 16.0 | 1.32 | net8.0;net9.0;net48*;netstandard2.0* |
158159
| 15.0 | 1.31 | net6.0;net8.0;net48*;netstandard2.0* |
159160
| 14.0 | 1.30 | net6.0;net8.0;net48*;netstandard2.0* |

csharp.settings

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export KUBERNETES_BRANCH=v1.32.0
1+
export KUBERNETES_BRANCH=v1.33.0
22
export CLIENT_VERSION=0.0.1
33
export PACKAGE_NAME=k8s

examples/Directory.Build.props

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="..\Directory.Build.props" />
34
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
5+
<TargetFramework>net9.0</TargetFramework>
56
</PropertyGroup>
67
</Project>

examples/Directory.Build.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
<Import Project="..\Directory.Build.targets" />
23
<ItemGroup>
34
<ProjectReference Include="$(MSBuildThisFileDirectory)\..\src\KubernetesClient\KubernetesClient.csproj" Condition="'$(PublishAot)' != 'true'" />
45
</ItemGroup>

examples/cp/Cp.cs

Lines changed: 72 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using ICSharpCode.SharpZipLib.Tar;
1+
using ICSharpCode.SharpZipLib.Tar;
22
using k8s;
33
using System;
44
using System.IO;
@@ -7,110 +7,104 @@
77
using System.Threading;
88
using System.Threading.Tasks;
99

10-
namespace cp
11-
{
12-
internal class Cp
13-
{
14-
private static IKubernetes client;
10+
namespace cp;
1511

16-
private static async Task Main(string[] args)
17-
{
18-
var config = KubernetesClientConfiguration.BuildConfigFromConfigFile();
19-
client = new Kubernetes(config);
12+
internal class Cp
13+
{
14+
private static IKubernetes client;
2015

16+
private static async Task Main(string[] args)
17+
{
18+
var config = KubernetesClientConfiguration.BuildConfigFromConfigFile();
19+
client = new Kubernetes(config);
2120

22-
var pods = client.CoreV1.ListNamespacedPod("default", null, null, null, $"job-name=upload-demo");
23-
var pod = pods.Items.First();
2421

25-
await CopyFileToPodAsync(pod.Metadata.Name, "default", "upload-demo", args[0], $"home/{args[1]}");
22+
var pods = client.CoreV1.ListNamespacedPod("default", null, null, null, $"job-name=upload-demo");
23+
var pod = pods.Items.First();
2624

27-
}
25+
await CopyFileToPodAsync(pod.Metadata.Name, "default", "upload-demo", args[0], $"home/{args[1]}").ConfigureAwait(false);
26+
}
2827

2928

3029

3130

32-
private static void ValidatePathParameters(string sourcePath, string destinationPath)
31+
private static void ValidatePathParameters(string sourcePath, string destinationPath)
32+
{
33+
if (string.IsNullOrWhiteSpace(sourcePath))
3334
{
34-
if (string.IsNullOrWhiteSpace(sourcePath))
35-
{
36-
throw new ArgumentException($"{nameof(sourcePath)} cannot be null or whitespace");
37-
}
38-
39-
if (string.IsNullOrWhiteSpace(destinationPath))
40-
{
41-
throw new ArgumentException($"{nameof(destinationPath)} cannot be null or whitespace");
42-
}
43-
35+
throw new ArgumentException($"{nameof(sourcePath)} cannot be null or whitespace");
4436
}
4537

46-
public static async Task<int> CopyFileToPodAsync(string name, string @namespace, string container, string sourceFilePath, string destinationFilePath, CancellationToken cancellationToken = default(CancellationToken))
38+
if (string.IsNullOrWhiteSpace(destinationPath))
4739
{
48-
// All other parameters are being validated by MuxedStreamNamespacedPodExecAsync called by NamespacedPodExecAsync
49-
ValidatePathParameters(sourceFilePath, destinationFilePath);
40+
throw new ArgumentException($"{nameof(destinationPath)} cannot be null or whitespace");
41+
}
42+
}
43+
44+
public static async Task<int> CopyFileToPodAsync(string name, string @namespace, string container, string sourceFilePath, string destinationFilePath, CancellationToken cancellationToken = default(CancellationToken))
45+
{
46+
// All other parameters are being validated by MuxedStreamNamespacedPodExecAsync called by NamespacedPodExecAsync
47+
ValidatePathParameters(sourceFilePath, destinationFilePath);
5048

51-
// The callback which processes the standard input, standard output and standard error of exec method
52-
var handler = new ExecAsyncCallback(async (stdIn, stdOut, stdError) =>
49+
// The callback which processes the standard input, standard output and standard error of exec method
50+
var handler = new ExecAsyncCallback(async (stdIn, stdOut, stdError) =>
51+
{
52+
var fileInfo = new FileInfo(destinationFilePath);
53+
try
5354
{
54-
var fileInfo = new FileInfo(destinationFilePath);
55-
try
55+
using (var memoryStream = new MemoryStream())
5656
{
57-
using (var memoryStream = new MemoryStream())
57+
using (var inputFileStream = File.OpenRead(sourceFilePath))
58+
using (var tarOutputStream = new TarOutputStream(memoryStream, Encoding.Default))
5859
{
59-
using (var inputFileStream = File.OpenRead(sourceFilePath))
60-
using (var tarOutputStream = new TarOutputStream(memoryStream, Encoding.Default))
61-
{
62-
tarOutputStream.IsStreamOwner = false;
63-
64-
var fileSize = inputFileStream.Length;
65-
var entry = TarEntry.CreateTarEntry(fileInfo.Name);
66-
67-
entry.Size = fileSize;
60+
tarOutputStream.IsStreamOwner = false;
6861

69-
tarOutputStream.PutNextEntry(entry);
70-
await inputFileStream.CopyToAsync(tarOutputStream);
71-
tarOutputStream.CloseEntry();
72-
}
62+
var fileSize = inputFileStream.Length;
63+
var entry = TarEntry.CreateTarEntry(fileInfo.Name);
7364

74-
memoryStream.Position = 0;
65+
entry.Size = fileSize;
7566

76-
await memoryStream.CopyToAsync(stdIn);
77-
await stdIn.FlushAsync();
67+
tarOutputStream.PutNextEntry(entry);
68+
await inputFileStream.CopyToAsync(tarOutputStream).ConfigureAwait(false);
69+
tarOutputStream.CloseEntry();
7870
}
7971

80-
}
81-
catch (Exception ex)
82-
{
83-
throw new IOException($"Copy command failed: {ex.Message}");
84-
}
72+
memoryStream.Position = 0;
8573

86-
using StreamReader streamReader = new StreamReader(stdError);
87-
while (streamReader.EndOfStream == false)
88-
{
89-
string error = await streamReader.ReadToEndAsync();
90-
throw new IOException($"Copy command failed: {error}");
74+
await memoryStream.CopyToAsync(stdIn).ConfigureAwait(false);
75+
await stdIn.FlushAsync().ConfigureAwait(false);
9176
}
92-
});
93-
94-
string destinationFolder = GetFolderName(destinationFilePath);
95-
96-
return await client.NamespacedPodExecAsync(
97-
name,
98-
@namespace,
99-
container,
100-
new string[] { "sh", "-c", $"tar xmf - -C {destinationFolder}" },
101-
false,
102-
handler,
103-
cancellationToken);
104-
}
105-
77+
}
78+
catch (Exception ex)
79+
{
80+
throw new IOException($"Copy command failed: {ex.Message}");
81+
}
10682

107-
private static string GetFolderName(string filePath)
108-
{
109-
var folderName = Path.GetDirectoryName(filePath);
83+
using StreamReader streamReader = new StreamReader(stdError);
84+
while (streamReader.EndOfStream == false)
85+
{
86+
string error = await streamReader.ReadToEndAsync().ConfigureAwait(false);
87+
throw new IOException($"Copy command failed: {error}");
88+
}
89+
});
90+
91+
string destinationFolder = GetFolderName(destinationFilePath);
92+
93+
return await client.NamespacedPodExecAsync(
94+
name,
95+
@namespace,
96+
container,
97+
new string[] { "sh", "-c", $"tar xmf - -C {destinationFolder}" },
98+
false,
99+
handler,
100+
cancellationToken).ConfigureAwait(false);
101+
}
110102

111-
return string.IsNullOrEmpty(folderName) ? "." : folderName;
112-
}
113103

104+
private static string GetFolderName(string filePath)
105+
{
106+
var folderName = Path.GetDirectoryName(filePath);
114107

108+
return string.IsNullOrEmpty(folderName) ? "." : folderName;
115109
}
116110
}

examples/csrApproval/Program.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Json.Patch;
1+
using Json.Patch;
22
using k8s;
33
using k8s.Models;
44
using System.Net;
@@ -44,34 +44,34 @@ string GenerateCertificate(string name)
4444
Kind = "CertificateSigningRequest",
4545
Metadata = new V1ObjectMeta
4646
{
47-
Name = name
47+
Name = name,
4848
},
4949
Spec = new V1CertificateSigningRequestSpec
5050
{
5151
Request = encodedCsr,
5252
SignerName = "kubernetes.io/kube-apiserver-client",
5353
Usages = new List<string> { "client auth" },
54-
ExpirationSeconds = 600 // minimum should be 10 minutes
55-
}
54+
ExpirationSeconds = 600, // minimum should be 10 minutes
55+
},
5656
};
5757

58-
await client.CertificatesV1.CreateCertificateSigningRequestAsync(request);
58+
await client.CertificatesV1.CreateCertificateSigningRequestAsync(request).ConfigureAwait(false);
5959

6060
var serializeOptions = new JsonSerializerOptions
6161
{
6262
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
63-
WriteIndented = true
63+
WriteIndented = true,
6464
};
65-
var readCert = await client.CertificatesV1.ReadCertificateSigningRequestAsync(name);
65+
var readCert = await client.CertificatesV1.ReadCertificateSigningRequestAsync(name).ConfigureAwait(false);
6666
var old = JsonSerializer.SerializeToDocument(readCert, serializeOptions);
6767

6868
var replace = new List<V1CertificateSigningRequestCondition>
6969
{
70-
new("True", "Approved", DateTime.UtcNow, DateTime.UtcNow, "This certificate was approved by k8s client", "Approve")
70+
new("True", "Approved", DateTime.UtcNow, DateTime.UtcNow, "This certificate was approved by k8s client", "Approve"),
7171
};
7272
readCert.Status.Conditions = replace;
7373

7474
var expected = JsonSerializer.SerializeToDocument(readCert, serializeOptions);
7575

7676
var patch = old.CreatePatch(expected);
77-
await client.CertificatesV1.PatchCertificateSigningRequestApprovalAsync(new V1Patch(patch, V1Patch.PatchType.JsonPatch), name);
77+
await client.CertificatesV1.PatchCertificateSigningRequestApprovalAsync(new V1Patch(patch, V1Patch.PatchType.JsonPatch), name).ConfigureAwait(false);

examples/openTelemetryConsole/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
{
3030
Console.WriteLine(item.Metadata.Name);
3131
}
32+
3233
// Or empty if there are no pods
3334
if (list.Items.Count == 0)
3435
{

examples/patch-aot/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@ static void PrintLabels(V1Pod pod)
2828
{
2929
Console.WriteLine($"{k} : {v}");
3030
}
31+
3132
Console.WriteLine("=-=-=-=-=-=-=-=-=-=-=");
3233
}

0 commit comments

Comments
 (0)