dotnet-kube-client icon indicating copy to clipboard operation
dotnet-kube-client copied to clipboard

Annotate non-updatable properties

Open felixfbecker opened this issue 7 years ago • 4 comments

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

felixfbecker avatar Aug 26 '18 19:08 felixfbecker

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

tintoy avatar Aug 26 '18 19:08 tintoy

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

tintoy avatar Aug 26 '18 19:08 tintoy

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 avatar Aug 26 '18 19:08 felixfbecker

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)

felixfbecker avatar Aug 26 '18 20:08 felixfbecker