tintoy / dotnet-kube-client

A Kubernetes API client for .NET Standard / .NET Core
MIT License
192 stars 33 forks source link

Helper function to map Kubernetes object kind value and apiVersion to Type #26

Closed felixfbecker closed 6 years ago

felixfbecker commented 6 years ago

When parsing YAML files, I don't know beforehand what class I need to serialize it too. I first have to look at the kind and apiVersion properties to find out - but I don't see an easy way to get the Type (e.g. typeof(KubeDeploymentV1Beta)) from a given string kind. I could dynamically assemble the fully qualified name but it seems messy and I'm not sure about the assembly name. I think the best option would be to add a helper function, it could use Type.GetType(string) to load from the current assembly or use a big switch that can be generated (don't know what is better).

tintoy commented 6 years ago

I have some ideas around this - will explain tomorrow :-D

PS. Thanks for taking the time to get involved!

tintoy commented 6 years ago

Going to close this one now that support for model-type lookup has been added but feel free to reopen if the API doesn't do what you need :)