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

Upgrade darling and syn and rename #[kube(struct)] #1307

Merged
merged 4 commits into from
Oct 12, 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
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