fix ExecCredentialResponse deserializion in aot (#1643)

* Add ExecCredentialResponseContext for JSON serialization support

* Added ExecStatus JsonPropertyNames
This commit is contained in:
Eric Kerst
2025-08-06 07:53:24 +02:00
committed by GitHub
parent 9efecfdcd4
commit 74538d58f2
3 changed files with 15 additions and 1 deletions

View File

@@ -8,9 +8,13 @@ namespace k8s.KubeConfigModels
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

View File

@@ -0,0 +1,7 @@
namespace k8s.KubeConfigModels
{
[JsonSerializable(typeof(ExecCredentialResponse))]
internal partial class ExecCredentialResponseContext : JsonSerializerContext
{
}
}

View File

@@ -523,7 +523,10 @@ namespace k8s
throw new KubeConfigException("external exec failed due to timeout");
}
var responseObject = KubernetesJson.Deserialize<ExecCredentialResponse>(process.StandardOutput.ReadToEnd());
var responseObject = JsonSerializer.Deserialize(
process.StandardOutput.ReadToEnd(),
ExecCredentialResponseContext.Default.ExecCredentialResponse);
if (responseObject == null || responseObject.ApiVersion != config.ApiVersion)
{
throw new KubeConfigException(