Skip to content

Commit bf30b9d

Browse files
committed
summarize schema customization in kube-derive docs
1 parent aee3d38 commit bf30b9d

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

kube-derive/src/lib.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ mod custom_resource;
7070
///
7171
/// ### `#[kube(apiextensions = "v1beta1")]`
7272
/// The version for `CustomResourceDefinition` desired in the `apiextensions.k8s.io` group.
73-
/// Default is `v1` (for clusters >= 1.17). If using kubernetes <= 1.16 pluase use `v1beta1`.
73+
/// Default is `v1` (for clusters >= 1.17). If using kubernetes <= 1.16 please use `v1beta1`.
7474
///
7575
/// **NOTE**: Support for `v1` requires deriving the openapi v3 `JsonSchema` via the `schemars` dependency.
7676
///
@@ -150,6 +150,18 @@ mod custom_resource;
150150
/// }
151151
/// ```
152152
///
153+
/// ## Customizing Schemas
154+
/// Should you need to customize the schemas, you can use:
155+
/// - [Serde/Schemars Attributes](https://graham.cool/schemars/examples/3-schemars_attrs/) (no need to duplicate serde renames)
156+
/// - [`#[schemars(schema_with = "func")]`](https://graham.cool/schemars/examples/7-custom_serialization/) (e.g. like in the [`crd_derive` example](https://github.com/clux/kube-rs/blob/master/examples/crd_derive.rs))
157+
///
158+
/// In general, you will need to override parts of the schemas (for fields in question) when you are:
159+
/// - **using enums**: enums do not currently generate [structural schemas](https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#specifying-a-structural-schema), so kubernetes won't support them by default
160+
/// - **customizing [merge-strategies](https://kubernetes.io/docs/reference/using-api/server-side-apply/#merge-strategy)** (e.g. like in the [`crd_derive_schema` example](https://github.com/clux/kube-rs/blob/master/examples/crd_derive_schema.rs))
161+
/// - **customizing [certain kubebuilder like validation rules](https://github.com/clux/kube-rs/issues/129#issuecomment-749463718)** (tail the issue for state of affairs)
162+
///
163+
/// If you have to override a lot, [you can opt-out of schema-generation entirely](https://github.com/clux/kube-rs/issues/355#issuecomment-751253657)
164+
///
153165
/// ## Debugging
154166
/// Try `cargo-expand` to see your own macro expansion.
155167
///

kube/src/api/params.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ impl PostParams {
150150
///
151151
/// See [kubernetes patch docs](https://kubernetes.io/docs/tasks/run-application/update-api-object-kubectl-patch/#use-a-json-merge-patch-to-update-a-deployment) for the older patch types.
152152
///
153-
/// Note that patches have different effects on different fields depending on their [merge-strategies](https://kubernetes.io/docs/reference/using-api/server-side-apply/#merge-strategy).
154-
/// These strategies are configurable when deriving your [`CustomResource`](kube_derive::CustomResource).
153+
/// Note that patches have different effects on different fields depending on their merge strategies.
154+
/// These strategies are configurable when deriving your [`CustomResource`](kube_derive::CustomResource#customizing-schemas).
155155
///
156156
/// # Creating a patch via serde_json
157157
/// ```

0 commit comments

Comments
 (0)