tintoy / dotnet-kube-client

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

Expose Kubernetes OpenAPI extensions as attributes on members #23

Closed felixfbecker closed 6 years ago

felixfbecker commented 6 years ago

To properly patch resources (like a kubectl apply), it is necessary to know how the fields (especially lists) in the resources are intended to be merged. This is exposed as OpenAPI extensions in x-kubernetes-patch-strategy and x-kubernetes-patch-merge-key.

tintoy commented 6 years ago

Ok yeah this looks interesting! :)

I'm happy to have a go at this unless you'd like to open a PR yourself (either is fine by me).

tintoy commented 6 years ago

@felixfbecker can you have a look at https://github.com/tintoy/dotnet-kube-client/commit/5092fd14faf0de6575ace26da279221c68fe533a and see if that's the information you want?

felixfbecker commented 6 years ago

Looks right! But would need to be actually applied from the OpenAPI schema

tintoy commented 6 years ago

Are you expecting to find the attribute on all properties, or will it suffice on fields that should be merged (with the default being replace for all others)?

If so, I'd change the attribute to something like StrategicPatchMergeAttribute, remove the enum, and only decorate properties with [StrategicPatchMerge(Key="name")] (or similar) if the field is mergeable.

The reasoning behind this is that the only time x-kubernetes-patch-strategy appears in the Swagger for the Kubernetes API, it has the value merge (i.e. never replace).

tintoy commented 6 years ago

But would need to be actually applied from the OpenAPI schema

Yep - the Python script that generates the models would emit it :)

felixfbecker commented 6 years ago

Not sure, I think I would just apply it wherever the OpenAPI schema applies it

tintoy commented 6 years ago

Ok, I can work with that - should have it done sometime today I hope :)

tintoy commented 6 years ago

I think we've dealt with this one but I can't be sure - when you have a moment can you check if the API does what you want now?

felixfbecker commented 6 years ago

Yeah this gives all I need!