Skip to content

Commit 044b659

Browse files
committed
Merge branch 'main' into feat/crd-versioning-from-impls
2 parents 1d821e7 + 3548b01 commit 044b659

File tree

11 files changed

+202
-117
lines changed

11 files changed

+202
-117
lines changed

Cargo.lock

+99-99
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+8-8
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ chrono = { version = "0.4.38", default-features = false }
1616
clap = { version = "4.5.4", features = ["derive", "cargo", "env"] }
1717
const_format = "0.2.32"
1818
const-oid = "0.9.6"
19-
darling = "0.20.8"
19+
darling = "0.20.9"
2020
delegate = "0.12.0"
2121
derivative = "2.2.0"
2222
dockerfile-parser = "0.8.0"
2323
ecdsa = { version = "0.16.9", features = ["digest", "pem"] }
24-
either = "1.11.0"
24+
either = "1.12.0"
2525
futures = "0.3.30"
2626
futures-util = "0.3.30"
2727
hyper = { version = "1.3.1", features = ["full"] }
@@ -40,25 +40,25 @@ opentelemetry-otlp = "0.15.0"
4040
opentelemetry-semantic-conventions = "0.14.0"
4141
p256 = { version = "0.13.2", features = ["ecdsa"] }
4242
pin-project = "1.1.5"
43-
proc-macro2 = "1.0.81"
43+
proc-macro2 = "1.0.83"
4444
quote = "1.0.36"
4545
rand = "0.8.5"
4646
rand_core = "0.6.4"
4747
regex = "1.10.4"
4848
rsa = { version = "0.9.6", features = ["sha2"] }
4949
rstest = "0.19.0"
5050
rstest_reuse = "0.6.0"
51-
schemars = { version = "0.8.16", features = ["url"] }
52-
semver = "1.0.22"
53-
serde = { version = "1.0.198", features = ["derive"] }
54-
serde_json = "1.0.116"
51+
schemars = { version = "0.8.20", features = ["url"] }
52+
semver = "1.0.23"
53+
serde = { version = "1.0.202", features = ["derive"] }
54+
serde_json = "1.0.117"
5555
serde_yaml = "0.9.34" # This is the last available version, see https://github.com/dtolnay/serde-yaml/releases/tag/0.9.34 for details
5656
sha2 = { version = "0.10.8", features = ["oid"] }
5757
signature = "2.2.0"
5858
snafu = "0.8.2"
5959
stackable-operator-derive = { path = "stackable-operator-derive" }
6060
strum = { version = "0.26.2", features = ["derive"] }
61-
syn = "2.0.60"
61+
syn = "2.0.65"
6262
tempfile = "3.10.1"
6363
time = { version = "0.3.36" }
6464
tokio = { version = "1.37.0", features = ["macros", "rt-multi-thread", "fs"] }

crates/stackable-operator/CHANGELOG.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7-
- Support specifying externalTrafficPolicy in Services created by listener-operator ([#773], [#789]).
8-
- BREAKING: Rename `commons::listener::ServiceType` to `commons::listener::KubernetesServiceType` ([#773]).
7+
## [0.68.0] - 2024-05-22
8+
9+
- Support specifying externalTrafficPolicy in Services created by listener-operator ([#773], [#789], [#791]).
910

1011
[#773]: https://github.com/stackabletech/operator-rs/pull/773
1112
[#789]: https://github.com/stackabletech/operator-rs/pull/789
13+
[#791]: https://github.com/stackabletech/operator-rs/pull/791
1214

1315
## [0.67.1] - 2024-05-08
1416

crates/stackable-operator/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "stackable-operator"
33
description = "Stackable Operator Framework"
4-
version = "0.67.1"
4+
version = "0.68.0"
55
authors.workspace = true
66
license.workspace = true
77
edition.workspace = true

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

+6-5
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ use crate::builder::pod::volume::ListenerOperatorVolumeSourceBuilder;
5050
)]
5151
#[serde(rename_all = "camelCase")]
5252
pub struct ListenerClassSpec {
53-
pub service_type: KubernetesServiceType,
53+
pub service_type: ServiceType,
5454

5555
/// Annotations that should be added to the Service object.
5656
#[serde(default)]
@@ -73,10 +73,11 @@ impl ListenerClassSpec {
7373

7474
/// The method used to access the services.
7575
//
76-
// Please note that this represents a Kubernetes type, so the name of the enum variant needs to exactly match the
77-
// Kubernetes service type.
78-
#[derive(Serialize, Deserialize, Clone, Copy, Debug, JsonSchema, PartialEq, Eq, strum::Display)]
79-
pub enum KubernetesServiceType {
76+
// Please note that this does not necessarely need to be restricted to the same Service types Kubernetes supports.
77+
// Listeners currently happens to support the same set of service types as upstream Kubernetes, but we still want to
78+
// have the freedom to add custom ones in the future (for example: Istio ingress?).
79+
#[derive(Serialize, Deserialize, Clone, Copy, Debug, JsonSchema, PartialEq, Eq)]
80+
pub enum ServiceType {
8081
/// Reserve a port on each node.
8182
NodePort,
8283

crates/stackable-versioned/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ All notable changes to this project will be documented in this file.
1111
[#784](ttps://github.com/stackabletech/operator-rs/pull/784)
1212
[#CHANGEME](ttps://github.com/stackabletech/operator-rs/pull/CHANGEME)
1313

14+
- Improve action chain generation ([#784]).
15+
16+
[#784](ttps://github.com/stackabletech/operator-rs/pull/784)
17+
1418
## [0.1.0] - 2024-05-08
1519

1620
### Changed

crates/stackable-versioned/src/attrs/field.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,10 @@ impl FieldAttributes {
197197
}
198198

199199
fn validate_deprecated_options(&self) -> Result<(), Error> {
200-
// TODO (@Techassi): Make note optional
200+
// TODO (@Techassi): Make the field 'note' optional, because in the
201+
// future, the macro will generate parts of the deprecation note
202+
// automatically. The user-provided note will then be appended to the
203+
// auto-generated one.
201204

202205
if let Some(deprecated) = &self.deprecated {
203206
if deprecated.note.is_empty() {

crates/stackable-versioned/src/gen/field.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use syn::{Field, Ident};
99
use crate::{
1010
attrs::field::FieldAttributes,
1111
consts::DEPRECATED_PREFIX,
12-
gen::{version::ContainerVersion, Neighbors, ToTokensExt},
12+
gen::{neighbors::Neighbors, version::ContainerVersion, ToTokensExt},
1313
};
1414

1515
/// A versioned field, which contains contains common [`Field`] data and a chain

crates/stackable-versioned/src/gen/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use crate::{
1111
};
1212

1313
pub(crate) mod field;
14+
pub(crate) mod neighbors;
1415
pub(crate) mod venum;
1516
pub(crate) mod version;
1617
pub(crate) mod vstruct;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
use std::{collections::BTreeMap, ops::Bound};
2+
3+
pub(crate) trait Neighbors<K, V>
4+
where
5+
K: Ord + Eq,
6+
{
7+
fn get_neighbors(&self, key: &K) -> (Option<&V>, Option<&V>);
8+
9+
fn lo_bound(&self, bound: Bound<&K>) -> Option<(&K, &V)>;
10+
fn up_bound(&self, bound: Bound<&K>) -> Option<(&K, &V)>;
11+
}
12+
13+
impl<K, V> Neighbors<K, V> for BTreeMap<K, V>
14+
where
15+
K: Ord + Eq,
16+
{
17+
fn get_neighbors(&self, key: &K) -> (Option<&V>, Option<&V>) {
18+
// NOTE (@Techassi): These functions might get added to the standard
19+
// library at some point. If that's the case, we can use the ones
20+
// provided by the standard lib.
21+
// See: https://github.com/rust-lang/rust/issues/107540
22+
match (
23+
self.lo_bound(Bound::Excluded(key)),
24+
self.up_bound(Bound::Excluded(key)),
25+
) {
26+
(Some((k, v)), None) => {
27+
if key > k {
28+
(Some(v), None)
29+
} else {
30+
(self.lo_bound(Bound::Excluded(k)).map(|(_, v)| v), None)
31+
}
32+
}
33+
(None, Some((k, v))) => {
34+
if key < k {
35+
(None, Some(v))
36+
} else {
37+
(None, self.up_bound(Bound::Excluded(k)).map(|(_, v)| v))
38+
}
39+
}
40+
(Some((_, lo)), Some((_, up))) => (Some(lo), Some(up)),
41+
(None, None) => unreachable!(),
42+
}
43+
}
44+
45+
fn lo_bound(&self, bound: Bound<&K>) -> Option<(&K, &V)> {
46+
self.range((Bound::Unbounded, bound)).next_back()
47+
}
48+
49+
fn up_bound(&self, bound: Bound<&K>) -> Option<(&K, &V)> {
50+
self.range((bound, Bound::Unbounded)).next()
51+
}
52+
}
53+
54+
#[cfg(test)]
55+
mod test {
56+
use super::*;
57+
use rstest::rstest;
58+
59+
#[rstest]
60+
#[case(0, (None, Some(&"test1")))]
61+
#[case(1, (None, Some(&"test3")))]
62+
#[case(2, (Some(&"test1"), Some(&"test3")))]
63+
#[case(3, (Some(&"test1"), None))]
64+
#[case(4, (Some(&"test3"), None))]
65+
fn test(#[case] key: i32, #[case] expected: (Option<&&str>, Option<&&str>)) {
66+
let map = BTreeMap::from([(1, "test1"), (3, "test3")]);
67+
let neigbors = map.get_neighbors(&key);
68+
69+
assert_eq!(neigbors, expected);
70+
}
71+
}

crates/stackable-versioned/tests/basic.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use stackable_versioned::Versioned;
22

3+
// To expand the generated code (for debugging and testing), it is recommended
4+
// to first change directory via `cd crates/stackable-versioned` and to then
5+
// run `cargo expand --test basic --all-features`.
36
#[derive(Versioned)]
47
#[allow(dead_code)]
58
#[versioned(

0 commit comments

Comments
 (0)