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
docs: add API conventions and deprecation guidance to AGENTS.md (#2763)
Add a section documenting OpenShift and Kubernetes API conventions
that must be followed for API changes, including the deprecation
pattern for CRD fields.
Signed-off-by: Predrag Knezevic <pknezevi@redhat.com>
Co-authored-by: Claude <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: AGENTS.md
+34Lines changed: 34 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -207,6 +207,40 @@ Two manifest variants exist:
207
207
-**Standard:** Production-ready features
208
208
-**Experimental:** Features under development/testing (includes `ClusterObjectSet` API)
209
209
210
+
### API Conventions
211
+
212
+
API changes in `api/v1/*_types.go` must follow the [OpenShift API conventions](https://github.com/openshift/enhancements/blob/master/dev-guide/api-conventions.md) in addition to upstream [Kubernetes API conventions](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md).
213
+
214
+
After modifying API types, run `make generate manifests crd-ref-docs` to regenerate DeepCopy/ApplyConfiguration code, CRDs, reference docs, and manifests. Run `make lint-api-diff` to validate changes against kube-api-linter.
215
+
216
+
**Deprecating fields:** Follow Go and OpenShift conventions (see [openshift/api](https://github.com/openshift/api) for examples):
217
+
218
+
```go
219
+
typeExampleConfigstruct {
220
+
// value holds some value.
221
+
Valuestring`json:"value"`
222
+
}
223
+
224
+
// Deprecated: structField is no longer used and will be removed in a future release.
// Deprecated: scalarField is no longer used and will be removed in a future release.
231
+
// Explanation of why and what replaces it.
232
+
//
233
+
// +optional
234
+
ScalarField string`json:"scalarField,omitempty"`
235
+
```
236
+
237
+
- Use `Deprecated:` with capital D and colon (Go convention, recognized by godoc and staticcheck)
238
+
- Use the lowercase JSON field name (camelCase) in doc comments, not the Go PascalCase identifier — doc comments are surfaced to end users via `oc explain` and generated API docs
239
+
- Deprecated fields must be `+optional`, never `+required`
240
+
- Do not use pointers for optional struct fields (OpenShift convention); use value types with `omitzero`
241
+
- Use `omitzero` in the JSON tag for struct types, `omitempty` for scalar types (string, int, bool)
242
+
- For intentional reads of deprecated fields (e.g. deprecation warnings), add `//nolint:staticcheck` with a reason
0 commit comments