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
{{ message }}
Repository navigation
Commit eb16c5f
Browse filesBrowse the repository at this point in the historyBrowse files
-**Use**`metav1.Condition` for status (not custom string fields)
99
+
-**Place enum validation on enum types**: Put `// +kubebuilder:validation:Enum=...` on named enum type definitions (for example, `type T string`), not on fields using those types
99
100
-**Use predefined types**: `metav1.Time` instead of `string` for dates
100
101
-**Follow K8s API conventions**: Standard field names (`spec`, `status`, `metadata`)
101
102
@@ -153,6 +154,13 @@ Using `omitempty` or `omitzero` JSON struct tags on gNMI payload structs is dang
153
154
3. Diff compares device state (with defaults) against desired (without) → mismatch
154
155
4. Operator performs a Set on every reconcile — breaking idempotency
155
156
157
+
**`omitempty` guidelines:**
158
+
159
+
1.**Safe:** The field's Go zero value matches the platform default or "absent" state. Omitting it from the payload is semantically equivalent to the device's default.
160
+
2.**Safe:** The field is a pointer or slice representing "not configured" (nil) vs "configured" (non-nil). Mutually exclusive choices (e.g. `accept`/`drop`) fall into this category.
161
+
3.**Dangerous:** The platform default is non-zero (e.g. `admin-state` defaults to `"enable"`, `port` defaults to `49`). Omitting the Go zero value would either misrepresent intent or cause a false diff on subsequent GET responses.
162
+
4.**Unnecessary:** The field is unconditionally set to a non-zero value by the provider code. The tag never triggers, but removing it documents intent — the field is always present.
163
+
156
164
**Rule:** After setting configuration once, the provider must produce no gNMI Set calls on subsequent reconciles when no user-facing configuration has changed. Test this explicitly.
0 commit comments