@@ -27,6 +27,7 @@ An introduction to using resources with kubectl can be found in [the object mana
27
27
- [ Categories] ( #categories )
28
28
- [ Idempotency] ( #idempotency )
29
29
- [ Optional vs. Required] ( #optional-vs-required )
30
+ - [ Nullable] ( #nullable )
30
31
- [ Defaulting] ( #defaulting )
31
32
- [ Static Defaults] ( #static-defaults )
32
33
- [ Admission Controlled Defaults] ( #admission-controlled-defaults )
@@ -866,6 +867,25 @@ language client, and any other clients that use corresponding types
866
867
Therefore, we ask that pointers always be used with optional fields that do not
867
868
have a built-in `nil` value.
868
869
870
+ # # Nullable
871
+
872
+ The `+nullable` comment tag allows the json `null` value to be a valid value
873
+ for a field. The `null` value is serialized only when a field is a pointer
874
+ in the Go definition, and does not have the `omitempty` json tag, or sometimes where a
875
+ custom marshal function is implemented.
876
+
877
+ For example, a map field marked with `+nullable` would accept either `foo : null` or `foo: {}`.
878
+
879
+ Usage of `+nullable` is discouraged as it introduces several issues :
880
+ - It is not compatible with json merge patching.
881
+ - From the [JSON Merge Patch RFC](https://tools.ietf.org/html/rfc7386#section-1):
882
+ > Null values in the merge patch are given special meaning to indicate the removal of existing values in the target.
883
+ - Explicit `null` values are not persisted in proto serializations.
884
+ - ` null` values are not supported by Server-Side Apply applyconfiguration types.
885
+ - A persisted `null` value would not round-trip through the applyconfiguration type
886
+ encode/decode cycle.
887
+
888
+ Avoid designing APIs that require the distinction between unset and `null`.
869
889
870
890
# # Defaulting
871
891
0 commit comments