csharp icon indicating copy to clipboard operation
csharp copied to clipboard

KubernetesClient.Aot args IList<string> serialization error

Open SGStino opened this issue 1 year ago • 4 comments

Describe the bug If a kubernetes client config contains string lists (for example, at users[*].user.exec.args), the yaml serializer throws that it can't deserialize the node into IList.

No node deserializer was able to deserialize the node into type System.Collections.Generic.IList`1[[System.String, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e

Kubernetes C# SDK Client Version 14.0.2

Server Kubernetes Version N\A

Dotnet Runtime Version net8

To Reproduce Create a config that contains a user that needs to "exec" with arguments, for example kube oidc login (see KubeConfig)

Expected behavior Being able to deserialize the config, including the args list.

KubeConfig

...
users:
- name: oidc-prod
  user:
    exec:
      apiVersion: client.authentication.k8s.io/v1beta1
      args:
      - oidc-login
      - get-token
      - --oidc-issuer-url=https://identity
      - --oidc-client-id=k8s
      - --oidc-client-secret=topsecret
      command: kubectl 
      interactiveMode: IfAvailable
      provideClusterInfo: false
...

Where do you run your app with Kubernetes SDK (please complete the following information): Reproducable in RoslynPad or dotnet console application:

#r "nuget: KubernetesClient.Aot, 14.0.2"
using k8s;
using k8s.Models;
var clientConfig = KubernetesClientConfiguration.BuildConfigFromConfigFile();

Additional context in the JsonSerializationContext for AOT source generation you'd have to include [JsonSerializable(typeof(IList<string>))], my guess would be that there is something similar for YamlDotNet?

SGStino avatar Jul 09 '24 13:07 SGStino