Skip to content

Commit 1b7de87

Browse files
refactor!: Replace unmaintained derivative create with educe (#907)
* refactor!: Replace unmaintained derivative create with educe * changelog * changelog * changelog * Fix rust docs * Fix uneeded trait bounds * Update crates/stackable-operator/CHANGELOG.md Co-authored-by: Siegfried Weber <mail@siegfriedweber.net> --------- Co-authored-by: Siegfried Weber <mail@siegfriedweber.net>
1 parent 3e5b3ba commit 1b7de87

File tree

10 files changed

+55
-80
lines changed

10 files changed

+55
-80
lines changed

Cargo.lock

Lines changed: 1 addition & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ const-oid = "0.9.6"
1919
convert_case = "0.6.0"
2020
darling = "0.20.10"
2121
delegate = "0.13.0"
22-
derivative = "2.2.0"
2322
dockerfile-parser = "0.8.0"
2423
ecdsa = { version = "0.16.9", features = ["digest", "pem"] }
24+
educe = { version = "0.6.0", default-features = false, features = ["Clone", "Debug", "Default", "PartialEq"] }
2525
either = "1.13.0"
2626
futures = "0.3.30"
2727
futures-util = "0.3.30"

crates/stackable-operator/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
### Changed
8+
9+
- Replace unmaintained `derivative` crate with `educe` ([#907]).
10+
11+
[#907]: https://github.com/stackabletech/operator-rs/pull/907
12+
713
## [0.82.0] - 2024-11-23
814

915
### Fixed

crates/stackable-operator/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ chrono.workspace = true
1818
clap.workspace = true
1919
const_format.workspace = true
2020
delegate.workspace = true
21-
derivative.workspace = true
2221
dockerfile-parser.workspace = true
2322
either.workspace = true
23+
educe.workspace = true
2424
futures.workspace = true
2525
indexmap.workspace = true
2626
json-patch.workspace = true

crates/stackable-operator/src/commons/resources.rs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ use crate::{
7676
cpu::CpuQuantity,
7777
memory::MemoryQuantity,
7878
};
79-
use derivative::Derivative;
79+
use educe::Educe;
8080
use k8s_openapi::api::core::v1::{
8181
Container, PersistentVolumeClaim, PersistentVolumeClaimSpec, PodSpec, ResourceRequirements,
8282
VolumeResourceRequirements,
@@ -133,13 +133,8 @@ pub enum Error {
133133
path_overrides(fragment = "crate::config::fragment")
134134
)]
135135
#[fragment_attrs(
136-
derive(Merge, Serialize, Deserialize, JsonSchema, Derivative),
137-
derivative(
138-
Default(bound = "T::Fragment: Default, K::Fragment: Default"),
139-
Debug(bound = "T::Fragment: Debug, K::Fragment: Debug"),
140-
Clone(bound = "T::Fragment: Clone, K::Fragment: Clone"),
141-
PartialEq(bound = "T::Fragment: PartialEq, K::Fragment: PartialEq")
142-
),
136+
derive(Merge, Serialize, Deserialize, JsonSchema, Educe),
137+
educe(Clone, Debug, Default, PartialEq),
143138
merge(
144139
bound = "T::Fragment: Merge, K::Fragment: Merge",
145140
path_overrides(merge = "crate::config::merge")
@@ -172,13 +167,8 @@ pub struct Resources<T, K = NoRuntimeLimits> {
172167
path_overrides(fragment = "crate::config::fragment")
173168
)]
174169
#[fragment_attrs(
175-
derive(Merge, Serialize, Deserialize, JsonSchema, Derivative),
176-
derivative(
177-
Default(bound = "T::Fragment: Default"),
178-
Debug(bound = "T::Fragment: Debug"),
179-
Clone(bound = "T::Fragment: Clone"),
180-
PartialEq(bound = "T::Fragment: PartialEq")
181-
),
170+
derive(Merge, Serialize, Deserialize, JsonSchema, Educe),
171+
educe(Clone, Debug, Default, PartialEq),
182172
merge(
183173
bound = "T::Fragment: Merge",
184174
path_overrides(merge = "crate::config::merge")

crates/stackable-operator/src/crd.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,24 @@
11
use std::marker::PhantomData;
22

3-
use derivative::Derivative;
3+
use educe::Educe;
44
use schemars::JsonSchema;
55
use serde::{Deserialize, Serialize};
66

77
/// A reference to a product cluster (for example, a `ZookeeperCluster`)
88
///
99
/// `namespace`'s defaulting only applies when retrieved via [`ClusterRef::namespace_relative_from`]
10-
#[derive(Deserialize, Serialize, JsonSchema, Derivative)]
11-
#[derivative(
12-
Default(bound = ""),
13-
Clone(bound = ""),
14-
Debug(bound = ""),
15-
PartialEq(bound = "")
16-
)]
10+
#[derive(Deserialize, Serialize, JsonSchema, Educe)]
11+
#[educe(Clone(bound()), Debug(bound()), Default(bound()), PartialEq(bound()))]
1712
pub struct ClusterRef<K> {
1813
/// The name of the cluster
1914
pub name: Option<String>,
15+
2016
/// The namespace of the cluster
2117
///
2218
/// This field is optional, and will default to the namespace of the referring object.
2319
#[serde(default)]
2420
pub namespace: Option<String>,
21+
2522
#[serde(skip)]
2623
_kind: PhantomData<K>,
2724
}

crates/stackable-operator/src/product_logging/spec.rs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::config::{
88
merge::Merge,
99
};
1010

11-
use derivative::Derivative;
11+
use educe::Educe;
1212
use schemars::JsonSchema;
1313
use serde::{Deserialize, Serialize};
1414

@@ -46,21 +46,21 @@ use serde::{Deserialize, Serialize};
4646
///
4747
/// let logging = product_logging::spec::default_logging::<Container>();
4848
/// ```
49-
#[derive(Clone, Debug, Derivative, Eq, Fragment, JsonSchema, PartialEq)]
50-
#[derivative(Default(bound = ""))]
49+
#[derive(Clone, Debug, Eq, Fragment, JsonSchema, PartialEq, Educe)]
50+
#[educe(Default)]
5151
#[fragment(path_overrides(fragment = "crate::config::fragment"))]
5252
#[fragment_attrs(
5353
derive(
5454
Clone,
5555
Debug,
56-
Derivative,
5756
Deserialize,
5857
JsonSchema,
5958
Merge,
6059
PartialEq,
61-
Serialize
60+
Serialize,
61+
Educe,
6262
),
63-
derivative(Default(bound = "")),
63+
educe(Default),
6464
merge(path_overrides(merge = "crate::config::merge")),
6565
serde(
6666
bound(serialize = "T: Serialize", deserialize = "T: Deserialize<'de>",),
@@ -75,6 +75,7 @@ where
7575
{
7676
/// Wether or not to deploy a container with the Vector log agent.
7777
pub enable_vector_agent: bool,
78+
7879
/// Log configuration per container.
7980
#[fragment_attrs(serde(default))]
8081
pub containers: BTreeMap<T, ContainerLogConfig>,
@@ -119,25 +120,27 @@ pub struct ContainerLogConfig {
119120
/// Custom or automatic log configuration
120121
///
121122
/// The custom log configuration takes precedence over the automatic one.
122-
#[derive(Clone, Debug, Derivative, Eq, JsonSchema, PartialEq)]
123-
#[derivative(Default)]
123+
#[derive(Clone, Debug, Eq, JsonSchema, PartialEq, Educe)]
124+
#[educe(Default)]
124125
pub enum ContainerLogConfigChoice {
125126
/// Custom log configuration provided in a ConfigMap
126127
Custom(CustomContainerLogConfig),
128+
127129
/// Automatic log configuration according to the given values
128-
#[derivative(Default)]
130+
#[educe(Default)]
129131
Automatic(AutomaticContainerLogConfig),
130132
}
131133

132-
#[derive(Clone, Debug, Derivative, Deserialize, JsonSchema, Merge, PartialEq, Serialize)]
133-
#[derivative(Default)]
134+
#[derive(Clone, Debug, Deserialize, JsonSchema, Merge, PartialEq, Serialize, Educe)]
135+
#[educe(Default)]
134136
#[merge(path_overrides(merge = "crate::config::merge"))]
135137
#[serde(untagged)]
136138
pub enum ContainerLogConfigChoiceFragment {
137139
/// Custom log configuration provided in a ConfigMap
138140
Custom(CustomContainerLogConfigFragment),
139-
#[derivative(Default)]
141+
140142
/// Automatic log configuration according to the given values
143+
#[educe(Default)]
141144
Automatic(AutomaticContainerLogConfigFragment),
142145
}
143146

@@ -306,7 +309,7 @@ pub struct AppenderConfig {
306309
Clone,
307310
Copy,
308311
Debug,
309-
Derivative,
312+
Default,
310313
Deserialize,
311314
Eq,
312315
JsonSchema,
@@ -316,11 +319,10 @@ pub struct AppenderConfig {
316319
Serialize,
317320
strum::Display,
318321
)]
319-
#[derivative(Default)]
320322
pub enum LogLevel {
321323
TRACE,
322324
DEBUG,
323-
#[derivative(Default)]
325+
#[default]
324326
INFO,
325327
WARN,
326328
ERROR,

crates/stackable-operator/src/role_utils.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ use crate::{
9494
product_config_utils::Configuration,
9595
utils::crds::raw_object_schema,
9696
};
97-
use derivative::Derivative;
97+
use educe::Educe;
9898
use k8s_openapi::api::core::v1::PodTemplateSpec;
9999
use kube::{runtime::reflector::ObjectRef, Resource};
100100
use schemars::JsonSchema;
@@ -274,11 +274,8 @@ impl<T> RoleGroup<T> {
274274
}
275275

276276
/// A reference to a named role group of a given cluster object
277-
#[derive(Derivative)]
278-
#[derivative(
279-
Debug(bound = "K::DynamicType: Debug"),
280-
Clone(bound = "K::DynamicType: Clone")
281-
)]
277+
#[derive(Educe)]
278+
#[educe(Clone, Debug)]
282279
pub struct RoleGroupRef<K: Resource> {
283280
pub cluster: ObjectRef<K>,
284281
pub role: String,

crates/stackable-operator/src/time/duration.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
//! This module contains a common [`Duration`] struct which is able to parse
22
//! human-readable duration formats, like `5s`, `24h`, `2y2h20m42s` or`15d2m2s`. It
3-
//! additionally implements many required traits, like [`Derivative`],
4-
//! [`JsonSchema`], [`Deserialize`][serde::Deserialize], and
5-
//! [`Serialize`][serde::Serialize].
3+
//! additionally implements many required traits, like [`JsonSchema`],
4+
//! [`Deserialize`][serde::Deserialize], and [`Serialize`][serde::Serialize].
65
//!
76
//! Furthermore, it implements [`Deref`], which enables us to use all associated
87
//! functions of [`std::time::Duration`] without re-implementing the public
@@ -20,7 +19,6 @@ use std::{
2019
str::FromStr,
2120
};
2221

23-
use derivative::Derivative;
2422
use schemars::JsonSchema;
2523
use snafu::{OptionExt, ResultExt, Snafu};
2624
use strum::IntoEnumIterator;
@@ -63,7 +61,7 @@ pub enum DurationParseError {
6361
/// A common [`Duration`] struct which is able to parse human-readable duration
6462
/// formats, like `5s`, `24h`, `2y2h20m42s` or`15d2m2s`. It additionally
6563
/// implements many required traits (for CRD deserialization and serialization).
66-
#[derive(Clone, Copy, Debug, Derivative, Hash, PartialEq, Eq, PartialOrd, Ord)]
64+
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
6765
pub struct Duration(std::time::Duration);
6866

6967
impl FromStr for Duration {

deny.toml

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[graph]
12
targets = [
23
{ triple = "x86_64-unknown-linux-gnu" },
34
{ triple = "aarch64-unknown-linux-gnu" },
@@ -7,49 +8,44 @@ targets = [
78
]
89

910
[advisories]
10-
vulnerability = "warn"
11-
unmaintained = "allow"
12-
unsound = "warn"
13-
yanked = "warn"
14-
notice = "warn"
11+
yanked = "deny"
1512

1613
[bans]
1714
multiple-versions = "allow"
1815

19-
[[bans.deny]]
20-
name = "time"
21-
version = "0.1"
22-
2316
[licenses]
24-
unlicensed = "deny"
25-
copyleft = "deny"
26-
allow-osi-fsf-free = "neither"
27-
default = "deny"
17+
unused-allowed-license = "allow"
2818
confidence-threshold = 1.0
2919
allow = [
3020
"Apache-2.0",
21+
"BSD-2-Clause",
3122
"BSD-3-Clause",
3223
"CC0-1.0",
3324
"ISC",
3425
"LicenseRef-ring",
3526
"LicenseRef-webpki",
3627
"MIT",
28+
"MPL-2.0",
29+
"Unicode-3.0",
3730
"Unicode-DFS-2016",
3831
"Zlib",
3932
"Unlicense",
40-
"OpenSSL",
41-
"Unicode-3.0",
4233
]
34+
private = { ignore = true }
4335

4436
[[licenses.clarify]]
4537
name = "ring"
4638
expression = "LicenseRef-ring"
47-
license-files = [{ path = "LICENSE", hash = 0xbd0eed23 }]
39+
license-files = [
40+
{ path = "LICENSE", hash = 0xbd0eed23 },
41+
]
4842

4943
[[licenses.clarify]]
5044
name = "webpki"
5145
expression = "LicenseRef-webpki"
52-
license-files = [{ path = "LICENSE", hash = 0x001c7e6c }]
46+
license-files = [
47+
{ path = "LICENSE", hash = 0x001c7e6c },
48+
]
5349

5450
[sources]
5551
unknown-registry = "deny"

0 commit comments

Comments
 (0)