Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve docs #99

Merged
merged 1 commit into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@ Replace `<version>` with the latest available [release](https://crates.io/crates
Each group of a Kubernetes custom resource has a corresponding Cargo feature in this crate. The group of a custom resource can be seen in the `apiVersion` field of a resource, e.g.:

```yaml
apiVersion: cert-manager.io/v1
kind: Issuer
apiVersion: chaos-mesh.org/v1alpha1
kind: PodNetworkChaos
metadata:
...
```

In the above example, `cert-manager.io` is the group and `v1` is the version. Since Cargo imposes certain rules on how features can be named, `.`, `-`, and `/` are all mapped to `_`. Therefore, the feature that contains the custom resource from the example above is called `cert_manager_io` and can be enabled like this:
In the above example, `chaos-mesh.org` is the group and `v1alpha1` is the version. Since Cargo imposes certain rules on how features can be named, `.`, `-`, and `/` are all mapped to `_`. Therefore, the feature that contains the custom resource from the example above is called `chaos_mesh_org` and can be enabled like this:

```toml
[dependencies]
kube-custom-resources-rs = { version = "<version>", features = ["cert_manager_io"] }
kube-custom-resources-rs = { version = "<version>", features = ["chaos_mesh_org"] }
```

Each version within a group has a corresponding module in that feature, e.g. there is a module called `v1` in the feature `cert_manager_io`.
Each version within a group has a corresponding module in that feature, e.g. there is a module called `v1alpha1` in the feature `chaos_mesh_org`.

Take a look at the [docs](https://docs.rs/kube-custom-resources-rs/latest/kube_custom_resources_rs/) to see all available features and the group/version/kinds they contain.

Expand All @@ -51,8 +51,8 @@ Updates to all CRDs are fetched [automatically](https://github.com/metio/kube-cu
The generated Rust code can be used as a [kube::Resource](https://docs.rs/kube/*/kube/trait.Resource.html) similar to this:

```rust
let issuers: Api<Issuer> = Api::default_namespaced(client);
let issuer = Issuer::new("example", IssuerSpec::default());
let api: Api<PodNetworkChaos> = Api::default_namespaced(client);
let resource = PodNetworkChaos::new("example", PodNetworkChaosSpec::default());
println!("doc: {:?}", issuer);
```

Expand Down
7 changes: 3 additions & 4 deletions code-generator/src/bin/lib_rs_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn main() -> Result<()> {
let mut buffer = BufWriter::new(file);

writeln!(buffer, "/*!")?;
writeln!(buffer, "This crate contains [kube-rs](https://kube.rs/) compatible bindings for Kubernetes [custom resources](https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/). Each binding is generated with [kopium](https://github.com/kube-rs/kopium) and updated weekly.")?;
writeln!(buffer, "This crate contains [kube-rs](https://kube.rs/) compatible bindings for Kubernetes [custom resources](https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/). Each binding is generated with [kopium](https://github.com/kube-rs/kopium), updated weekly, and released monthly.")?;
writeln!(buffer, "")?;
writeln!(buffer, "# Available Features")?;
writeln!(buffer, "")?;
Expand Down Expand Up @@ -73,11 +73,10 @@ fn main() -> Result<()> {

for (version, kinds) in versions.iter().sorted_by_key(|x| x.0) {
writeln!(buffer, "")?;
writeln!(buffer, "- apiVersion: `{}/{}`", group, version)?;
writeln!(buffer, "- kinds:")?;
writeln!(buffer, "apiVersion `{}/{}`:", group, version)?;

for crd in kinds {
writeln!(buffer, " - `{}`", crd.spec.names.kind)?;
writeln!(buffer, "- `{}`", crd.spec.names.kind)?;
}
}
}
Expand Down
Loading