pub fn merge_crds(
crds: Vec<CustomResourceDefinition>,
stored_apiversion: &str,
) -> Result<CustomResourceDefinition, MergeError>
Expand description
Merge a collection of crds into a single multiversion crd
Given multiple CustomResource
derived types granting CRD
s via CustomResourceExt::crd
,
we can merge them into a single CRD
with multiple CRDVersion
objects, marking only
the specified apiversion as storage: true
.
This merge algorithm assumes that every CRD
:
- exposes exactly one
CRDVersion
- uses identical values for
spec.group
,spec.scope
, andspec.names.kind
This is always true for CustomResource
derives.
ยงUsage
use kube::core::crd::merge_crds;
let crds = vec![mycrd_v1, mycrd_v2];
let multi_version_crd = merge_crds(crds, "v1").unwrap();
Note the merge is done by marking the:
- crd containing the
stored_apiversion
as the place the other crds merge theirCRDVersion
items - stored version is marked with
storage: true
, while all others getstorage: false