Skip to content

Commit

Permalink
Upgrade darling and syn and rename #[kube(struct)] (#1307)
Browse files Browse the repository at this point in the history
* Bump darling and syn

Signed-off-by: clux <[email protected]>

* breaking rename of `#[kube(struct)]`

Signed-off-by: clux <[email protected]>

* r/generate/root and make docs consistently refer to root struct

Signed-off-by: clux <[email protected]>

---------

Signed-off-by: clux <[email protected]>
  • Loading branch information
clux authored Oct 12, 2023
1 parent fba2b9d commit c3fbe25
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion examples/crd_derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use serde::{Deserialize, Serialize};
version = "v1",
kind = "Foo",
plural = "fooz",
struct = "FooCrd",
root = "FooCrd",
namespaced,
status = "FooStatus",
derive = "PartialEq",
Expand Down
4 changes: 2 additions & 2 deletions kube-derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ categories = ["api-bindings", "encoding"]
[dependencies]
proc-macro2 = "1.0.29"
quote = "1.0.10"
syn = { version = "1.0.80", features = ["extra-traits"] }
syn = { version = "2.0.38", features = ["extra-traits"] }
serde_json = "1.0.68"
darling = "0.14.0"
darling = "0.20.3"

[lib]
proc-macro = true
Expand Down
2 changes: 1 addition & 1 deletion kube-derive/src/custom_resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ struct KubeAttrs {
group: String,
version: String,
kind: String,
#[darling(rename = "struct")]
#[darling(rename = "root")]
kind_struct: Option<String>,
/// lowercase plural of kind (inferred if omitted)
plural: Option<String>,
Expand Down
16 changes: 8 additions & 8 deletions kube-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ mod custom_resource;
/// let f = Foo::new("foo-1", FooSpec {
/// info: "informative info".into(),
/// });
/// println!("foo: {:?}", f); // debug print on generated type
/// println!("foo: {:?}", f); // debug print on root type
/// println!("crd: {}", serde_yaml::to_string(&Foo::crd()).unwrap()); // crd yaml
/// ```
///
/// This example creates a `struct Foo` containing metadata, the spec,
/// and optionally status. The **generated** type `Foo` can be used with the [`kube`] crate
/// This example generates a `struct Foo` containing metadata, the spec,
/// and optionally status. The **root** struct `Foo` can be used with the [`kube`] crate
/// as an `Api<Foo>` object (`FooSpec` can not be used with [`Api`][`kube::Api`]).
///
/// ```no_run
Expand Down Expand Up @@ -73,21 +73,21 @@ mod custom_resource;
/// Your cr api version. The part after the slash in the top level `apiVersion` key.
///
/// ## `#[kube(kind = "Kind")]`
/// Name of your kind and your generated root type.
/// Name of your kind, and implied default for your generated root type.
///
/// # Optional `#[kube]` attributes
///
/// ## `#[kube(singular = "nonstandard-singular")]`
/// To specify the singular name. Defaults to lowercased `kind`.
/// To specify the singular name. Defaults to lowercased `.kind` value.
///
/// ## `#[kube(plural = "nonstandard-plural")]`
/// To specify the plural name. Defaults to inferring from singular.
///
/// ## `#[kube(namespaced)]`
/// To specify that this is a namespaced resource rather than cluster level.
///
/// ## `#[kube(struct = "StructName")]`
/// Customize the name of the generated root struct (defaults to `kind`).
/// ## `#[kube(root = "StructName")]`
/// Customize the name of the generated root struct (defaults to `.kind` value).
///
/// ## `#[kube(crates(kube_core = "::kube::core"))]`
/// Customize the crate name the generated code will reach into (defaults to `::kube::core`).
Expand Down Expand Up @@ -153,7 +153,7 @@ mod custom_resource;
/// group = "clux.dev",
/// version = "v1",
/// kind = "Foo",
/// struct = "FooCrd",
/// root = "FooCrd",
/// namespaced,
/// status = "FooStatus",
/// derive = "PartialEq",
Expand Down

0 comments on commit c3fbe25

Please sign in to comment.