Skip to content

Commit 74538d5

Browse files
authored
fix ExecCredentialResponse deserializion in aot (#1643)
* Add ExecCredentialResponseContext for JSON serialization support * Added ExecStatus JsonPropertyNames
1 parent 9efecfd commit 74538d5

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

src/KubernetesClient.Aot/KubeConfigModels/ExecCredentialResponse.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ public class ExecCredentialResponse
88
public class ExecStatus
99
{
1010
#nullable enable
11+
[JsonPropertyName("expirationTimestamp")]
1112
public DateTime? ExpirationTimestamp { get; set; }
13+
[JsonPropertyName("token")]
1214
public string? Token { get; set; }
15+
[JsonPropertyName("clientCertificateData")]
1316
public string? ClientCertificateData { get; set; }
17+
[JsonPropertyName("clientKeyData")]
1418
public string? ClientKeyData { get; set; }
1519
#nullable disable
1620

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace k8s.KubeConfigModels
2+
{
3+
[JsonSerializable(typeof(ExecCredentialResponse))]
4+
internal partial class ExecCredentialResponseContext : JsonSerializerContext
5+
{
6+
}
7+
}

src/KubernetesClient.Aot/KubernetesClientConfiguration.ConfigFile.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,10 @@ public static ExecCredentialResponse ExecuteExternalCommand(ExternalExecution co
523523
throw new KubeConfigException("external exec failed due to timeout");
524524
}
525525

526-
var responseObject = KubernetesJson.Deserialize<ExecCredentialResponse>(process.StandardOutput.ReadToEnd());
526+
var responseObject = JsonSerializer.Deserialize(
527+
process.StandardOutput.ReadToEnd(),
528+
ExecCredentialResponseContext.Default.ExecCredentialResponse);
529+
527530
if (responseObject == null || responseObject.ApiVersion != config.ApiVersion)
528531
{
529532
throw new KubeConfigException(

0 commit comments

Comments
 (0)