Skip to content

Commit 260115b

Browse files
authored
docs(stackable-versioned): Improve various sections of docs (#966)
* docs: Explain that struct describes latest version * docs: Explain merged_crd method * docs: Remove outdated warning about preserve_module * chore: Update example in README
1 parent 128b30c commit 260115b

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

crates/stackable-versioned-macros/src/lib.rs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ mod utils;
2929
/// example, `#[automatically_derived]` and `#[allow(deprecated)]` are removed
3030
/// in most examples to reduce visual clutter.
3131
///
32-
/// ## Declaring Versions
32+
/// <div class="warning">
3333
///
3434
/// It is **important** to note that this macro must be placed before any other
3535
/// (derive) macros and attributes. Macros supplied before the versioned macro
@@ -38,16 +38,29 @@ mod utils;
3838
/// attributes are applied to the generated versioned instances of the
3939
/// container.
4040
///
41+
/// </div>
42+
///
43+
/// ## Declaring Versions
44+
///
4145
/// Before any of the fields or variants can be versioned, versions need to be
4246
/// declared at the container level. Each version currently supports two
4347
/// parameters: `name` and the `deprecated` flag. The `name` must be a valid
4448
/// (and supported) format.
4549
///
4650
/// <div class="warning">
51+
///
4752
/// Currently, only Kubernetes API versions are supported. The macro checks each
4853
/// declared version and reports any error encountered during parsing.
54+
///
4955
/// </div>
5056
///
57+
/// It should be noted that the defined struct always represents the **latest**
58+
/// version, eg: when defining three versions `v1alpha1`, `v1beta1`, and `v1`,
59+
/// the struct will describe the structure of the data in `v1`. This behaviour
60+
/// is especially noticeable in the [`changed()`](#changed-action) action which
61+
/// works "backwards" by describing how a field looked before the current
62+
/// (latest) version.
63+
///
5164
/// ```
5265
/// # use stackable_versioned_macros::versioned;
5366
/// #[versioned(version(name = "v1alpha1"))]
@@ -252,12 +265,6 @@ mod utils;
252265
/// }
253266
/// ```
254267
///
255-
/// <div class="warning">
256-
/// It is planned to move the <code>preserve_module</code> flag into the
257-
/// <code>options()</code> argument list, but currently seems tricky to
258-
/// implement.
259-
/// </div>
260-
///
261268
/// ## Item Actions
262269
///
263270
/// This crate currently supports three different item actions. Items can
@@ -601,6 +608,11 @@ println!("{}", serde_yaml::to_string(&merged_crd).unwrap());
601608
# }
602609
```
603610
611+
The generated `merged_crd` method is a wrapper around [kube's `merge_crds`][1]
612+
function. It automatically calls the `crd` methods of the CRD in all of its
613+
versions and additionally provides a strongly typed selector for the stored
614+
API version.
615+
604616
Currently, the following arguments are supported:
605617
606618
- `group`: Set the group of the CR object, usually the domain of the company.

crates/stackable-versioned/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ struct Foo {
3030
/// My docs
3131
#[versioned(
3232
added(since = "v1alpha1"),
33-
renamed(since = "v1beta1", from = "gau"),
33+
changed(since = "v1beta1", from_name = "gau"),
3434
deprecated(since = "v2", note = "not required anymore")
3535
)]
3636
deprecated_bar: usize,

0 commit comments

Comments
 (0)