@@ -574,22 +574,28 @@ selectors, annotations, data), as opposed to sets of subobjects.
574
574
575
575
#### Primitive types
576
576
577
+ * Look at similar fields in the API (e.g. ports, durations) and follow the
578
+ conventions of existing fields.
579
+ * Do not use enums. Use aliases for string instead (e.g. ` NodeConditionType`).
580
+ * All numeric fields should be bounds-checked, both for too-small or negative
581
+ and for too-large.
582
+ * All public integer fields MUST use the Go `int32` or Go `int64` types, not
583
+ ` int` (which is ambiguously sized, depending on target platform). Internal
584
+ types may use `int`.
585
+ * For integer fields, prefer `int32` to `int64` unless you need to represent
586
+ values larger than `int32`. See other guidelines about limitations of
587
+ ` int64` and language compatibility.
588
+ * Do not use unsigned integers, due to inconsistent support across languages and
589
+ libraries. Just validate that the integer is non-negative if that's the case.
590
+ * All numbers (e.g. `int32`, `int64`) are converted to `float64` by Javascript
591
+ and some other languages, so any field which is expected to exceed that
592
+ either in magnitude or in precision (e.g. integer values > 53 bits)
593
+ should be serialized and accepted as strings. `int64` fields must be
594
+ bounds-checked to be within the range of `-(2^53) < x < (2^53)`.
577
595
* Avoid floating-point values as much as possible, and never use them in spec.
578
596
Floating-point values cannot be reliably round-tripped (encoded and
579
597
re-decoded) without changing, and have varying precision and representations
580
598
across languages and architectures.
581
- * All numbers (e.g., uint32, int64) are converted to float64 by Javascript and
582
- some other languages, so any field which is expected to exceed that either in
583
- magnitude or in precision (specifically integer values > 53 bits) should be
584
- serialized and accepted as strings.
585
- * Do not use unsigned integers, due to inconsistent support across languages and
586
- libraries. Just validate that the integer is non-negative if that's the case.
587
- * Do not use enums. Use aliases for string instead (e.g., ` NodeConditionType`).
588
- * Look at similar fields in the API (e.g., ports, durations) and follow the
589
- conventions of existing fields.
590
- * All public integer fields MUST use the Go `(u)int32` or Go `(u)int64` types,
591
- not `(u)int` (which is ambiguous depending on target platform). Internal
592
- types may use `(u)int`.
593
599
* Think twice about `bool` fields. Many ideas start as boolean but eventually
594
600
trend towards a small set of mutually exclusive options. Plan for future
595
601
expansions by describing the policy options explicitly as a string type
0 commit comments