tintoy / dotnet-kube-client

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

Annotate non-updatable properties #29

Open felixfbecker opened 5 years ago

felixfbecker commented 5 years ago

I am finding myself to write quite a few hardcoded special cases to prevent non-updatable properties from being updated. Would it be possible somehow to mark these as readonly in the field so I can introspect that instead? Do Yaml.NET and Json.NET support populating readonly fields?

This is related to #28 because there are some fields that don't have a "default value" but are populated by the system and cannot be updated, and we don't want those properties to show up in the patch either (to not be reset to their zero value). Examples: ObjectMetaV1.Uid, ContainerV1.TerminationMessagePolicy

tintoy commented 5 years ago

Not directly but we can add a custom attribute (and tell JSON.NET to deserialise but not serialise the property value).

tintoy commented 5 years ago

Does the Swagger say which fields are read-only or do we need another special-case dict in the generator script?

felixfbecker commented 5 years ago

JSON.NET seems to support this: https://stackoverflow.com/a/39380844/4208018 But I don't know about YAML.NET.

This is not exposed through OpenAPI, only mentioned in the descriptions.

felixfbecker commented 5 years ago

Hmm, some properties downright confuse me. ContainerV1.ImagePullPolicy says "Cannot be updated", but the linked documentation literally explains that it can be: https://kubernetes.io/docs/concepts/containers/images/#updating-images (and I would personally expect it to be updatable)