Skip to content

Commit

Permalink
Use default-features=false for all deps.
Browse files Browse the repository at this point in the history
This also disables the extra-traits feature of syn, since it was being used for
one `#[derive(Debug)]` that can be done without, and
one `!=` involving `AttrStyle` that can be done with `if let` instead.

base64, chrono and serde_json have "alloc" and "std" features where one of them
is required. In all three cases, it's possible to have both features enabled
and that's essentially treated the same as if only the std feature is enabled.
So this commit enables the "alloc" feature, and if anything else in
the end user's dep tree enables the "std" feature, that's fine.

The one noticeable breaking change is that enabling the schemars feature of
k8s-openapi no longer enables the derive feature of schemars, so users who want
to use `#[derive(schemars::JsonSchema)]` in their own code will need to add
an explicit dependency on schemars to enable that feature.

Ref: kube-rs/kube#650 (comment)
  • Loading branch information
Arnavion committed Oct 26, 2021
1 parent 0e5de07 commit 1a14517
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 36 deletions.
27 changes: 17 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,23 @@ include = [
links = "k8s-openapi-0.13.1"

[dependencies]
base64 = "0.13"
bytes = "1"
chrono = { version = "0.4.1", features = ["serde"] }
http = { version = "0.2", optional = true }
percent-encoding = { version = "2", optional = true }
schemars = { version = "0.8", optional = true }
serde = "1"
serde_json = "1"
serde-value = "0.7"
url = { version = "2", optional = true }
base64 = { version = "0.13", default-features = false, features = [
"alloc", # for base64::decode_config and base64::encode_config
] }
bytes = { version = "1", default-features = false}
chrono = { version = "0.4.1", default-features = false, features = [
"alloc", # for chrono::DateTime::<Utc>::to_rfc3339_opts
"serde", # for chrono::DateTime<Utc>: serde::Deserialize, serde::Serialize
] }
http = { version = "0.2", optional = true, default-features = false }
percent-encoding = { version = "2", optional = true, default-features = false }
schemars = { version = "0.8", optional = true, default-features = false }
serde = { version = "1", default-features = false }
serde_json = { version = "1", default-features = false, features = [
"alloc", # "serde_json requires that either `std` (default) or `alloc` feature is enabled"
] }
serde-value = { version = "0.7", default-features = false }
url = { version = "2", optional = true, default-features = false }

[features]
default = ["api"]
Expand Down
7 changes: 5 additions & 2 deletions k8s-openapi-codegen-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@ include = [
]

[dependencies]
http = "0.2"
serde = { version = "1", features = ["derive", "rc"], optional = true }
http = { version = "0.2", default-features = false }
serde = { version = "1", optional = true, default-features = false, features = [
"derive", # for #[derive(serde::Deserialize, serde::Serialize)]
"rc", # for Arc<Parameter>: serde::Deserialize
] }
26 changes: 17 additions & 9 deletions k8s-openapi-codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,20 @@ publish = false
edition = "2018"

[dependencies]
backtrace = "0.3"
env_logger = "0.9"
http = "0.2"
k8s-openapi-codegen-common = { path = "../k8s-openapi-codegen-common", features = ["serde"] }
log = "0.4"
reqwest = { version = "0.11", default-features = false, features = ["blocking", "default-tls", "json"] }
serde = "1"
serde_derive = "1"
structopt = "0.3"
backtrace = { version = "0.3", default-features = false, features = [
"std", # for backtrace::Backtrace
] }
env_logger = { version = "0.9", default-features = false }
http = { version = "0.2", default-features = false }
k8s-openapi-codegen-common = { path = "../k8s-openapi-codegen-common", features = [
"serde", # to parse OpenAPI specs from JSON files
] }
log = { version = "0.4", default-features = false }
reqwest = { version = "0.11", default-features = false, features = [
"blocking", # for reqwest::blocking
"default-tls", # for TLS support
"json", # for reqwest::blocking::Response::json
] }
serde = { version = "1", default-features = false }
serde_derive = { version = "1", default-features = false }
structopt = { version = "0.3", default-features = false }
12 changes: 8 additions & 4 deletions k8s-openapi-derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ include = [
]

[dependencies]
http = "0.2"
http = { version = "0.2", default-features = false }
k8s-openapi-codegen-common = { version = "=0.13.1", path = "../k8s-openapi-codegen-common" }
proc-macro2 = "1"
quote = "1"
syn = { version = "1", features = ["extra-traits"] }
proc-macro2 = { version = "1", default-features = false, features = ["proc-macro"] }
quote = { version = "1", default-features = false }
syn = { version = "1", default-features = false, features = [
"derive", # minimal feature for writing custom derives
"parsing", # for syn::parse2, syn::Path::is_ident, syn::Attribute::parse_meta
"printing", # for syn types: quote::ToTokens
] }

[lib]
proc-macro = true
10 changes: 7 additions & 3 deletions k8s-openapi-derive/src/custom_resource_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use k8s_openapi_codegen_common::swagger20;

use super::ResultExt;

#[derive(Debug)]
pub(super) struct CustomResourceDefinition {
ident: proc_macro2::Ident,
vis: syn::Visibility,
Expand Down Expand Up @@ -30,8 +29,13 @@ impl super::CustomDerive for CustomResourceDefinition {
let mut namespaced = false;

for attr in &input.attrs {
if attr.style != syn::AttrStyle::Outer {
continue;
#[allow(clippy::needless_continue)]
{
if let syn::AttrStyle::Outer = attr.style {
}
else {
continue;
}
}

if !attr.path.is_ident("custom_resource_definition") {
Expand Down
24 changes: 16 additions & 8 deletions k8s-openapi-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,23 @@ include = [
]

[dependencies]
base64 = "0.13"
dirs = "4"
k8s-openapi = { path = "..", features = ["schemars"] }
base64 = { version = "0.13", default-features = false }
dirs = { version = "4", default-features = false }
k8s-openapi = { path = "..", features = [
"schemars", # for resource types: schemars::JsonSchema
] }
k8s-openapi-derive = { path = "../k8s-openapi-derive" }
openssl = "0.10"
reqwest = { version = "0.11", default-features = false, features = ["blocking", "native-tls"] }
serde = "1"
serde_derive = "1"
serde_yaml = "0.8"
openssl = { version = "0.10", default-features = false }
reqwest = { version = "0.11", default-features = false, features = [
"blocking", # for reqwest::blocking
"native-tls", # for TLS support
] }
schemars = { version = "0.8", default-features = false, features = [
"derive", # for #[derive(schemars::JsonSchema)]
] }
serde = { version = "1", default-features = false }
serde_derive = { version = "1", default-features = false }
serde_yaml = { version = "0.8", default-features = false }

[features]
test_v1_11 = ["k8s-openapi/v1_11"]
Expand Down

0 comments on commit 1a14517

Please sign in to comment.