You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: contributors/devel/sig-architecture/api-conventions.md
+60-9Lines changed: 60 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -579,11 +579,13 @@ selectors, annotations, data), as opposed to sets of subobjects.
579
579
580
580
#### Primitive types
581
581
582
+
Also read the section on validation, below.
583
+
584
+
When selecting fields, consider the following:
582
585
* Look at similar fields in the API (e.g. ports, durations) and follow the
583
586
conventions of existing fields.
584
-
* Do not use enums. Use aliases for string instead (e.g. `NodeConditionType`).
585
-
* All numeric fields should be bounds-checked, both for too-small or negative
586
-
and for too-large.
587
+
* Do not use numeric enums. Use aliases for string instead (e.g.
588
+
`NodeConditionType`).
587
589
* All public integer fields MUST use the Go `int32` or Go `int64` types, not
588
590
`int`(which is ambiguously sized, depending on target platform). Internal
589
591
types may use `int`.
@@ -1954,12 +1956,61 @@ the future, an HTTP/2 implementation will be exposed that deprecates SPDY.
1954
1956
## Validation
1955
1957
1956
1958
API objects are validated upon receipt by the apiserver.
1957
-
Validation can be implemented in two ways: declaratively, using tags on the Go type definitions, or manually, by writing validation functions.
1958
-
For all new APIs, declarative validation is the preferred approach for the validation rules it supports. For more information see the [declarative validation documentation](api_changes.md#declarative-validation). Validation errors are
1959
-
flagged and returned to the caller in a `Failure` status with `reason` set to
1960
-
`Invalid`. In order to facilitate consistent error messages, we ask that
1961
-
validation logic adheres to the following guidelines whenever possible (though
1962
-
exceptional cases will exist).
1959
+
Validation can be implemented in two ways: declaratively, using tags on the Go
1960
+
type definitions, or manually, by writing validation functions. For all new
1961
+
APIs, declarative validation is the preferred approach for the validation rules
0 commit comments