From f62c446962a49280333961d650d4c9a0b6dcb506 Mon Sep 17 00:00:00 2001 From: Eric Kerst Date: Fri, 1 Aug 2025 21:45:43 +0200 Subject: [PATCH 1/2] Add ExecCredentialResponseContext for JSON serialization support --- .../KubeConfigModels/ExecCredentialResponseContext.cs | 7 +++++++ .../KubernetesClientConfiguration.ConfigFile.cs | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 src/KubernetesClient.Aot/KubeConfigModels/ExecCredentialResponseContext.cs diff --git a/src/KubernetesClient.Aot/KubeConfigModels/ExecCredentialResponseContext.cs b/src/KubernetesClient.Aot/KubeConfigModels/ExecCredentialResponseContext.cs new file mode 100644 index 000000000..c7ffd8294 --- /dev/null +++ b/src/KubernetesClient.Aot/KubeConfigModels/ExecCredentialResponseContext.cs @@ -0,0 +1,7 @@ +namespace k8s.KubeConfigModels +{ + [JsonSerializable(typeof(ExecCredentialResponse))] + internal partial class ExecCredentialResponseContext : JsonSerializerContext + { + } +} diff --git a/src/KubernetesClient.Aot/KubernetesClientConfiguration.ConfigFile.cs b/src/KubernetesClient.Aot/KubernetesClientConfiguration.ConfigFile.cs index c1865687c..a2301b464 100644 --- a/src/KubernetesClient.Aot/KubernetesClientConfiguration.ConfigFile.cs +++ b/src/KubernetesClient.Aot/KubernetesClientConfiguration.ConfigFile.cs @@ -523,7 +523,10 @@ public static ExecCredentialResponse ExecuteExternalCommand(ExternalExecution co throw new KubeConfigException("external exec failed due to timeout"); } - var responseObject = KubernetesJson.Deserialize(process.StandardOutput.ReadToEnd()); + var responseObject = JsonSerializer.Deserialize( + process.StandardOutput.ReadToEnd(), + ExecCredentialResponseContext.Default.ExecCredentialResponse); + if (responseObject == null || responseObject.ApiVersion != config.ApiVersion) { throw new KubeConfigException( From fba618cb731c204aa9aa5d195abbbf0a3eee3206 Mon Sep 17 00:00:00 2001 From: Eric Kerst Date: Sat, 2 Aug 2025 11:14:34 +0200 Subject: [PATCH 2/2] Added ExecStatus JsonPropertyNames --- .../KubeConfigModels/ExecCredentialResponse.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/KubernetesClient.Aot/KubeConfigModels/ExecCredentialResponse.cs b/src/KubernetesClient.Aot/KubeConfigModels/ExecCredentialResponse.cs index 5bac4af5e..d593ff4f6 100644 --- a/src/KubernetesClient.Aot/KubeConfigModels/ExecCredentialResponse.cs +++ b/src/KubernetesClient.Aot/KubeConfigModels/ExecCredentialResponse.cs @@ -8,9 +8,13 @@ public class ExecCredentialResponse public class ExecStatus { #nullable enable + [JsonPropertyName("expirationTimestamp")] public DateTime? ExpirationTimestamp { get; set; } + [JsonPropertyName("token")] public string? Token { get; set; } + [JsonPropertyName("clientCertificateData")] public string? ClientCertificateData { get; set; } + [JsonPropertyName("clientKeyData")] public string? ClientKeyData { get; set; } #nullable disable