Skip to content

Commit 2bac6b3

Browse files
authored
Revert "refactor: Replace lazy_static with std::sync::LazyLock (#827)" (#835)
* Revert "refactor: Replace lazy_static with std::sync::LazyLock (#827)" This reverts commit f15a9a3. We still need Rust 1.79.0 compatibility until 1.80 percolates into Nixpkgs. * Changelog
1 parent 12395a0 commit 2bac6b3

File tree

22 files changed

+91
-101
lines changed

22 files changed

+91
-101
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
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.80.0"
20+
RUST_TOOLCHAIN_VERSION: "1.79.0"
2121
RUSTFLAGS: "-D warnings"
2222
RUSTDOCFLAGS: "-D warnings"
2323
RUST_LOG: "info"
@@ -37,7 +37,7 @@ jobs:
3737
- uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
3838
with:
3939
key: udeps
40-
- run: cargo install --locked cargo-udeps@0.1.50
40+
- run: cargo install --locked cargo-udeps@0.1.47
4141
- run: cargo udeps --all-targets
4242

4343
run_cargodeny:

.github/workflows/pr_pre-commit.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66

77
env:
88
CARGO_TERM_COLOR: always
9-
RUST_TOOLCHAIN_VERSION: "1.80.0"
9+
RUST_TOOLCHAIN_VERSION: "1.79.0"
1010

1111
jobs:
1212
pre-commit:

Cargo.lock

Lines changed: 2 additions & 0 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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ json-patch = "2.0.0"
3232
k8s-openapi = { version = "0.22.0", default-features = false, features = ["schemars", "v1_30"] }
3333
# We use rustls instead of openssl for easier portablitly, e.g. so that we can build stackablectl without the need to vendor (build from source) openssl
3434
kube = { version = "0.93.1", default-features = false, features = ["client", "jsonpatch", "runtime", "derive", "rustls-tls"] }
35+
lazy_static = "1.5.0"
3536
opentelemetry = "0.23.0"
3637
opentelemetry_sdk = { version = "0.23.0", features = ["rt-tokio"] }
3738
opentelemetry-appender-tracing = "0.4.0"

crates/k8s-version/CHANGELOG.md

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

55
## [Unreleased]
66

7-
### Changed
8-
9-
- Replace `lazy_static` with `std::cell::LazyCell` ([#827]).
10-
11-
[#827]: https://github.com/stackabletech/operator-rs/pull/827
12-
137
## [0.1.1] - 2024-07-10
148

159
### Changed

crates/k8s-version/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ darling = ["dep:darling"]
1111

1212
[dependencies]
1313
darling = { workspace = true, optional = true }
14+
lazy_static.workspace = true
1415
regex.workspace = true
1516
snafu.workspace = true
1617

crates/k8s-version/src/group.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
use std::{fmt, ops::Deref, str::FromStr, sync::LazyLock};
1+
use std::{fmt, ops::Deref, str::FromStr};
22

3+
use lazy_static::lazy_static;
34
use regex::Regex;
45
use snafu::{ensure, Snafu};
56

67
const MAX_GROUP_LENGTH: usize = 253;
78

8-
static API_GROUP_REGEX: LazyLock<Regex> = LazyLock::new(|| {
9-
Regex::new(r"^(?:(?:[a-z0-9][a-z0-9-]{0,61}[a-z0-9])\.?)+$")
10-
.expect("failed to compile API group regex")
11-
});
9+
lazy_static! {
10+
static ref API_GROUP_REGEX: Regex =
11+
Regex::new(r"^(?:(?:[a-z0-9][a-z0-9-]{0,61}[a-z0-9])\.?)+$")
12+
.expect("failed to compile API group regex");
13+
}
1214

1315
/// Error variants which can be encountered when creating a new [`Group`] from
1416
/// unparsed input.

crates/k8s-version/src/level.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@ use std::{
44
num::ParseIntError,
55
ops::{Add, AddAssign, Sub, SubAssign},
66
str::FromStr,
7-
sync::LazyLock,
87
};
98

9+
use lazy_static::lazy_static;
1010
use regex::Regex;
1111
use snafu::{OptionExt, ResultExt, Snafu};
1212

1313
#[cfg(feature = "darling")]
1414
use darling::FromMeta;
1515

16-
static LEVEL_REGEX: LazyLock<Regex> = LazyLock::new(|| {
17-
Regex::new(r"^(?P<identifier>[a-z]+)(?P<version>\d+)$").expect("failed to compile level regex")
18-
});
16+
lazy_static! {
17+
static ref LEVEL_REGEX: Regex = Regex::new(r"^(?P<identifier>[a-z]+)(?P<version>\d+)$")
18+
.expect("failed to compile level regex");
19+
}
1920

2021
/// Error variants which can be encountered when creating a new [`Level`] from
2122
/// unparsed input.

crates/k8s-version/src/version.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
use std::{cmp::Ordering, fmt::Display, num::ParseIntError, str::FromStr, sync::LazyLock};
1+
use std::{cmp::Ordering, fmt::Display, num::ParseIntError, str::FromStr};
22

3+
use lazy_static::lazy_static;
34
use regex::Regex;
45
use snafu::{OptionExt, ResultExt, Snafu};
56

@@ -8,10 +9,11 @@ use darling::FromMeta;
89

910
use crate::{Level, ParseLevelError};
1011

11-
static VERSION_REGEX: LazyLock<Regex> = LazyLock::new(|| {
12-
Regex::new(r"^v(?P<major>\d+)(?P<level>[a-z0-9][a-z0-9-]{0,60}[a-z0-9])?$")
13-
.expect("failed to compile version regex")
14-
});
12+
lazy_static! {
13+
static ref VERSION_REGEX: Regex =
14+
Regex::new(r"^v(?P<major>\d+)(?P<level>[a-z0-9][a-z0-9-]{0,60}[a-z0-9])?$")
15+
.expect("failed to compile version regex");
16+
}
1517

1618
/// Error variants which can be encountered when creating a new [`Version`] from
1719
/// unparsed input.

crates/stackable-operator/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@ All notable changes to this project will be documented in this file.
88

99
- Rollout tracker for `StatefulSet` ([#833]).
1010

11+
### Changed
12+
13+
- Reverted [#827], in order to restore Rust 1.79 compatibility for now ([#835]).
14+
1115
### Fixed
1216

1317
- Invalid CRD schema for `StackableAffinity` contents. This was caused by the fields being optional and defaulting to `null`, while the custom schema marked the field as required ([#836]).
1418

1519
[#833]: https://github.com/stackabletech/operator-rs/pull/833
20+
[#835]: https://github.com/stackabletech/operator-rs/pull/835
1621
[#836]: https://github.com/stackabletech/operator-rs/pull/836
1722

1823
## [0.72.0] - 2024-08-05

0 commit comments

Comments
 (0)