Skip to content

Commit 34588a2

Browse files
authored
chore: Use Rust 2024 edition (#994)
* chore: Use Rust 2024 edition * chore: Apply Rust 2024 formatting * ci: Use Rust 1.85.0 in workflows * ci: Use nightly Rust toolchain for formatting job * ci: Remove duplicate checks * chore: Add rustfmt style edition * chore: Add link to rustfmt config file
1 parent 6c4b022 commit 34588a2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+616
-772
lines changed

.github/workflows/build.yml

+1-56
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ env:
1717
CARGO_TERM_COLOR: always
1818
CARGO_INCREMENTAL: '0'
1919
CARGO_PROFILE_DEV_DEBUG: '0'
20-
RUST_TOOLCHAIN_VERSION: "1.84.1"
20+
RUST_TOOLCHAIN_VERSION: "1.85.0"
2121
RUSTFLAGS: "-D warnings"
2222
RUSTDOCFLAGS: "-D warnings"
2323
RUST_LOG: "info"
@@ -64,59 +64,6 @@ jobs:
6464
with:
6565
command: check ${{ matrix.checks }}
6666

67-
run_rustfmt:
68-
name: Run Rustfmt
69-
runs-on: ubuntu-latest
70-
steps:
71-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
72-
with:
73-
persist-credentials: false
74-
- uses: dtolnay/rust-toolchain@master
75-
with:
76-
toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }}
77-
components: rustfmt
78-
- uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
79-
with:
80-
key: fmt
81-
- run: cargo fmt --all -- --check
82-
83-
run_clippy:
84-
name: Run Clippy
85-
runs-on: ubuntu-latest
86-
steps:
87-
- name: Install host dependencies
88-
run: |
89-
sudo apt-get update
90-
sudo apt-get install protobuf-compiler krb5-user libkrb5-dev libclang-dev liblzma-dev libssl-dev pkg-config
91-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
92-
with:
93-
persist-credentials: false
94-
submodules: recursive
95-
- uses: dtolnay/rust-toolchain@master
96-
with:
97-
toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }}
98-
components: clippy
99-
- uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3 # v2.7.7
100-
with:
101-
key: clippy
102-
- name: Run clippy action to produce annotations
103-
# NOTE (@Techassi): This action might get a new release sonn, because it
104-
# currently uses Node 16, which is deprecated in the next few months by
105-
# GitHub. See https://github.com/giraffate/clippy-action/pull/87
106-
uses: giraffate/clippy-action@13b9d32482f25d29ead141b79e7e04e7900281e0 # v1.0.1
107-
env:
108-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
109-
if: env.GITHUB_TOKEN != null && github.event.pull_request.draft == false
110-
with:
111-
clippy_flags: --all-targets -- -D warnings
112-
reporter: 'github-pr-review'
113-
github_token: ${{ secrets.GITHUB_TOKEN }}
114-
- name: Run clippy manually without annotations
115-
env:
116-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
117-
if: env.GITHUB_TOKEN == null
118-
run: cargo clippy --color never -q --all-targets -- -D warnings
119-
12067
run_rustdoc:
12168
name: Run RustDoc
12269
runs-on: ubuntu-latest
@@ -136,8 +83,6 @@ jobs:
13683
run_tests:
13784
name: Run Cargo Tests
13885
needs:
139-
- run_clippy
140-
- run_rustfmt
14186
- run_rustdoc
14287
runs-on: ubuntu-latest
14388
steps:

.github/workflows/publish-docs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313
- crates/**
1414

1515
env:
16-
RUST_TOOLCHAIN_VERSION: "1.84.1"
16+
RUST_TOOLCHAIN_VERSION: "1.85.0"
1717

1818
permissions: {}
1919

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[workspace]
22
members = ["crates/*"]
3-
resolver = "2"
3+
resolver = "3"
44

55
[workspace.package]
66
authors = ["Stackable GmbH <[email protected]>"]
77
license = "Apache-2.0"
8-
edition = "2021"
8+
edition = "2024"
99
repository = "https://github.com/stackabletech/operator-rs"
1010

1111
[workspace.dependencies]

crates/k8s-version/src/group.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::{fmt, ops::Deref, str::FromStr, sync::LazyLock};
22

33
use regex::Regex;
4-
use snafu::{ensure, Snafu};
4+
use snafu::{Snafu, ensure};
55

66
const MAX_GROUP_LENGTH: usize = 253;
77

crates/k8s-version/src/version.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ static VERSION_REGEX: LazyLock<Regex> = LazyLock::new(|| {
1616
/// unparsed input.
1717
#[derive(Debug, PartialEq, Snafu)]
1818
pub enum ParseVersionError {
19-
#[snafu(display("invalid version format. Input is empty, contains non-ASCII characters or contains more than 63 characters"))]
19+
#[snafu(display(
20+
"invalid version format. Input is empty, contains non-ASCII characters or contains more than 63 characters"
21+
))]
2022
InvalidFormat,
2123

2224
#[snafu(display("failed to parse major version"))]

crates/stackable-certs/src/ca/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use stackable_operator::{client::Client, commons::secret::SecretReference, time:
1010
use tracing::{debug, instrument};
1111
use x509_cert::{
1212
builder::{Builder, CertificateBuilder, Profile},
13-
der::{pem::LineEnding, referenced::OwnedToRef, DecodePem},
13+
der::{DecodePem, pem::LineEnding, referenced::OwnedToRef},
1414
ext::pkix::{AuthorityKeyIdentifier, ExtendedKeyUsage},
1515
name::Name,
1616
serial_number::SerialNumber,
@@ -19,8 +19,8 @@ use x509_cert::{
1919
};
2020

2121
use crate::{
22-
keys::{ecdsa, rsa, CertificateKeypair},
2322
CertificatePair,
23+
keys::{CertificateKeypair, ecdsa, rsa},
2424
};
2525

2626
mod consts;

crates/stackable-certs/src/keys/ecdsa.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Abstraction layer around the [`ecdsa`] crate. This module provides types
22
//! which abstract away the generation of ECDSA keys used for signing of CAs
33
//! and other certificates.
4-
use p256::{pkcs8::DecodePrivateKey, NistP256};
4+
use p256::{NistP256, pkcs8::DecodePrivateKey};
55
use rand_core::{CryptoRngCore, OsRng};
66
use snafu::{ResultExt, Snafu};
77
use tracing::instrument;

crates/stackable-certs/src/keys/rsa.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//! which abstract away the generation of RSA keys used for signing of CAs
33
//! and other certificates.
44
use rand_core::{CryptoRngCore, OsRng};
5-
use rsa::{pkcs8::DecodePrivateKey, RsaPrivateKey};
5+
use rsa::{RsaPrivateKey, pkcs8::DecodePrivateKey};
66
use signature::Keypair;
77
use snafu::{ResultExt, Snafu};
88
use tracing::instrument;

crates/stackable-certs/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
use std::ops::Deref;
2323

2424
use snafu::Snafu;
25-
use x509_cert::{spki::EncodePublicKey, Certificate};
25+
use x509_cert::{Certificate, spki::EncodePublicKey};
2626
#[cfg(feature = "rustls")]
2727
use {
2828
p256::pkcs8::EncodePrivateKey,

crates/stackable-operator-derive/src/fragment.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use darling::{ast::Data, FromDeriveInput, FromField, FromMeta, FromVariant};
1+
use darling::{FromDeriveInput, FromField, FromMeta, FromVariant, ast::Data};
22
use proc_macro2::{Ident, TokenStream, TokenTree};
3-
use quote::{format_ident, quote, ToTokens};
3+
use quote::{ToTokens, format_ident, quote};
44
use syn::{
5-
parse_quote, Attribute, DeriveInput, Generics, Meta, MetaList, Path, Type, Visibility,
6-
WherePredicate,
5+
Attribute, DeriveInput, Generics, Meta, MetaList, Path, Type, Visibility, WherePredicate,
6+
parse_quote,
77
};
88

99
#[derive(FromMeta)]
@@ -125,7 +125,7 @@ pub fn derive(input: DeriveInput) -> TokenStream {
125125
Data::Enum(_) => {
126126
return quote! {
127127
compile_error!("`#[derive(Fragment)]` does not currently support enums");
128-
}
128+
};
129129
}
130130
Data::Struct(fields) => fields.fields,
131131
};

crates/stackable-operator-derive/src/merge.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use darling::{
2-
ast::{Data, Fields},
32
FromDeriveInput, FromField, FromMeta, FromVariant,
3+
ast::{Data, Fields},
44
};
55
use proc_macro2::{Ident, Span, TokenStream};
66
use quote::{format_ident, quote};
7-
use syn::{parse_quote, DeriveInput, Generics, Index, Path, WherePredicate};
7+
use syn::{DeriveInput, Generics, Index, Path, WherePredicate, parse_quote};
88

99
#[derive(FromMeta)]
1010
struct PathOverrides {
@@ -67,13 +67,10 @@ pub fn derive(input: DeriveInput) -> TokenStream {
6767

6868
let (ty, variants) = match data {
6969
// Structs are almost single-variant enums, so we can reuse most of the same matching code for both cases
70-
Data::Struct(fields) => (
71-
InputType::Struct,
72-
vec![MergeVariant {
73-
ident: Ident::new("__placeholder", Span::call_site()),
74-
fields,
75-
}],
76-
),
70+
Data::Struct(fields) => (InputType::Struct, vec![MergeVariant {
71+
ident: Ident::new("__placeholder", Span::call_site()),
72+
fields,
73+
}]),
7774
Data::Enum(variants) => (InputType::Enum, variants),
7875
};
7976
let merge_variants = variants

crates/stackable-operator/src/builder/pdb.rs

+52-59
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ mod tests {
205205
api::policy::v1::{PodDisruptionBudget, PodDisruptionBudgetSpec},
206206
apimachinery::pkg::{apis::meta::v1::LabelSelector, util::intstr::IntOrString},
207207
};
208-
use kube::{core::ObjectMeta, CustomResource};
208+
use kube::{CustomResource, core::ObjectMeta};
209209
use schemars::JsonSchema;
210210
use serde::{Deserialize, Serialize};
211211

@@ -229,28 +229,22 @@ mod tests {
229229
.with_min_available(42)
230230
.build();
231231

232-
assert_eq!(
233-
pdb,
234-
PodDisruptionBudget {
235-
metadata: ObjectMeta {
236-
name: Some("trino".to_string()),
237-
namespace: Some("default".to_string()),
238-
..Default::default()
239-
},
240-
spec: Some(PodDisruptionBudgetSpec {
241-
min_available: Some(IntOrString::Int(42)),
242-
selector: Some(LabelSelector {
243-
match_expressions: None,
244-
match_labels: Some(BTreeMap::from([(
245-
"foo".to_string(),
246-
"bar".to_string()
247-
)])),
248-
}),
249-
..Default::default()
232+
assert_eq!(pdb, PodDisruptionBudget {
233+
metadata: ObjectMeta {
234+
name: Some("trino".to_string()),
235+
namespace: Some("default".to_string()),
236+
..Default::default()
237+
},
238+
spec: Some(PodDisruptionBudgetSpec {
239+
min_available: Some(IntOrString::Int(42)),
240+
selector: Some(LabelSelector {
241+
match_expressions: None,
242+
match_labels: Some(BTreeMap::from([("foo".to_string(), "bar".to_string())])),
250243
}),
251244
..Default::default()
252-
}
253-
)
245+
}),
246+
..Default::default()
247+
})
254248
}
255249

256250
#[test]
@@ -289,55 +283,54 @@ mod tests {
289283
.with_max_unavailable(2)
290284
.build();
291285

292-
assert_eq!(
293-
pdb,
294-
PodDisruptionBudget {
295-
metadata: ObjectMeta {
296-
name: Some("simple-trino-worker".to_string()),
297-
namespace: Some("default".to_string()),
298-
labels: Some(BTreeMap::from([
286+
assert_eq!(pdb, PodDisruptionBudget {
287+
metadata: ObjectMeta {
288+
name: Some("simple-trino-worker".to_string()),
289+
namespace: Some("default".to_string()),
290+
labels: Some(BTreeMap::from([
291+
("app.kubernetes.io/name".to_string(), "trino".to_string()),
292+
(
293+
"app.kubernetes.io/instance".to_string(),
294+
"simple-trino".to_string()
295+
),
296+
(
297+
"app.kubernetes.io/managed-by".to_string(),
298+
"trino.stackable.tech_trino-operator-trino-controller".to_string()
299+
),
300+
(
301+
"app.kubernetes.io/component".to_string(),
302+
"worker".to_string()
303+
)
304+
])),
305+
owner_references: Some(vec![
306+
OwnerReferenceBuilder::new()
307+
.initialize_from_resource(&trino)
308+
.block_owner_deletion_opt(None)
309+
.controller_opt(Some(true))
310+
.build()
311+
.unwrap()
312+
]),
313+
..Default::default()
314+
},
315+
spec: Some(PodDisruptionBudgetSpec {
316+
max_unavailable: Some(IntOrString::Int(2)),
317+
selector: Some(LabelSelector {
318+
match_expressions: None,
319+
match_labels: Some(BTreeMap::from([
299320
("app.kubernetes.io/name".to_string(), "trino".to_string()),
300321
(
301322
"app.kubernetes.io/instance".to_string(),
302323
"simple-trino".to_string()
303324
),
304-
(
305-
"app.kubernetes.io/managed-by".to_string(),
306-
"trino.stackable.tech_trino-operator-trino-controller".to_string()
307-
),
308325
(
309326
"app.kubernetes.io/component".to_string(),
310327
"worker".to_string()
311328
)
312329
])),
313-
owner_references: Some(vec![OwnerReferenceBuilder::new()
314-
.initialize_from_resource(&trino)
315-
.block_owner_deletion_opt(None)
316-
.controller_opt(Some(true))
317-
.build()
318-
.unwrap()]),
319-
..Default::default()
320-
},
321-
spec: Some(PodDisruptionBudgetSpec {
322-
max_unavailable: Some(IntOrString::Int(2)),
323-
selector: Some(LabelSelector {
324-
match_expressions: None,
325-
match_labels: Some(BTreeMap::from([
326-
("app.kubernetes.io/name".to_string(), "trino".to_string()),
327-
(
328-
"app.kubernetes.io/instance".to_string(),
329-
"simple-trino".to_string()
330-
),
331-
(
332-
"app.kubernetes.io/component".to_string(),
333-
"worker".to_string()
334-
)
335-
])),
336-
}),
337-
..Default::default()
338330
}),
339331
..Default::default()
340-
}
341-
)
332+
}),
333+
..Default::default()
334+
})
342335
}
343336
}

0 commit comments

Comments
 (0)