Skip to content

Commit e64879f

Browse files
committed
Update to kube-rs 0.82.2 and dependencies (#589)
## Description fixes #588 updated dependencies: - kube-rs 0.82.2 - k8s-openapi 0.18.0 - json_patch 1.0.0 - rstest 0.17.0 other: - derive defaults for some enums instead of impl (clippy) Co-authored-by: Malte Sander <malte.sander.it@gmail.com>
1 parent f40c028 commit e64879f

File tree

5 files changed

+33
-31
lines changed

5 files changed

+33
-31
lines changed

CHANGELOG.md

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

55
## [Unreleased]
66

7+
### Changed
8+
9+
- kube: 0.78.0 -> 0.82.2 ([#589]).
10+
- k8s-openapi: 0.17.0 -> 0.18.0 ([#589]).
11+
12+
[#589]: https://github.com/stackabletech/operator-rs/pull/589
13+
714
## [0.40.2] - 2023-04-12
815

916
### Fixed

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ clap = { version = "4.1.4", features = ["derive", "cargo", "env"] }
1313
const_format = "0.2.30"
1414
either = "1.8.1"
1515
futures = "0.3.26"
16-
json-patch = "0.3.0"
17-
k8s-openapi = { version = "0.17.0", default-features = false, features = ["schemars", "v1_26"] }
18-
kube = { version = "0.78.0", features = ["jsonpatch", "runtime", "derive"] }
16+
json-patch = "1.0.0"
17+
k8s-openapi = { version = "0.18.0", default-features = false, features = ["schemars", "v1_26"] }
18+
kube = { version = "0.82.2", features = ["jsonpatch", "runtime", "derive"] }
1919
lazy_static = "1.4.0"
2020
product-config = { git = "https://github.com/stackabletech/product-config.git", tag = "0.4.0" }
2121
rand = "0.8.5"
@@ -37,7 +37,7 @@ stackable-operator-derive = { path = "stackable-operator-derive" }
3737
snafu = "0.7.4"
3838

3939
[dev-dependencies]
40-
rstest = "0.16.0"
40+
rstest = "0.17.0"
4141
tempfile = "3.3.0"
4242

4343
[workspace]

src/client.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use kube::api::{DeleteParams, ListParams, Patch, PatchParams, PostParams, Resour
99
use kube::client::Client as KubeClient;
1010
use kube::core::Status;
1111
use kube::runtime::wait::delete::delete_and_finalize;
12-
use kube::runtime::WatchStreamExt;
12+
use kube::runtime::{watcher, WatchStreamExt};
1313
use kube::{Api, Config};
1414
use serde::de::DeserializeOwned;
1515
use serde::Serialize;
@@ -426,34 +426,35 @@ impl Client {
426426
/// # Example
427427
///
428428
/// ```no_run
429-
/// use kube::api::ListParams;
430429
/// use std::time::Duration;
431430
/// use tokio::time::error::Elapsed;
431+
/// use kube::runtime::watcher;
432432
/// use k8s_openapi::api::core::v1::Pod;
433433
/// use stackable_operator::client::{Client, create_client};
434434
///
435435
/// #[tokio::main]
436436
/// async fn main(){
437+
///
437438
/// let client: Client = create_client(None).await.expect("Unable to construct client.");
438-
/// let lp: ListParams =
439-
/// ListParams::default().fields(&format!("metadata.name=nonexistent-pod"));
439+
/// let watcher_config: watcher::Config =
440+
/// watcher::Config::default().fields(&format!("metadata.name=nonexistent-pod"));
440441
///
441442
/// // Will time out in 1 second unless the nonexistent-pod actually exists
442443
/// let wait_created_result: Result<(), Elapsed> = tokio::time::timeout(
443444
/// Duration::from_secs(1),
444-
/// client.wait_created::<Pod>(&client.default_namespace, lp.clone()),
445+
/// client.wait_created::<Pod>(&client.default_namespace, watcher_config),
445446
/// )
446447
/// .await;
447448
/// }
448449
/// ```
449450
///
450-
pub async fn wait_created<T>(&self, namespace: &T::Namespace, lp: ListParams)
451+
pub async fn wait_created<T>(&self, namespace: &T::Namespace, watcher_config: watcher::Config)
451452
where
452453
T: Resource + GetApi + Clone + Debug + DeserializeOwned + Send + 'static,
453454
<T as Resource>::DynamicType: Default,
454455
{
455456
let api: Api<T> = self.get_api(namespace);
456-
let watcher = kube::runtime::watcher(api, lp).boxed();
457+
let watcher = kube::runtime::watcher(api, watcher_config).boxed();
457458
watcher
458459
.applied_objects()
459460
.skip_while(|res| std::future::ready(res.is_err()))
@@ -558,7 +559,8 @@ mod tests {
558559
use futures::StreamExt;
559560
use k8s_openapi::api::core::v1::{Container, Pod, PodSpec};
560561
use k8s_openapi::apimachinery::pkg::apis::meta::v1::LabelSelector;
561-
use kube::api::{ListParams, ObjectMeta, PostParams, ResourceExt};
562+
use kube::api::{ObjectMeta, PostParams, ResourceExt};
563+
use kube::runtime::watcher;
562564
use kube::runtime::watcher::Event;
563565
use std::collections::BTreeMap;
564566
use std::time::Duration;
@@ -595,7 +597,7 @@ mod tests {
595597
.create(&PostParams::default(), &pod_to_wait_for)
596598
.await
597599
.expect("Test pod not created.");
598-
let lp: ListParams = ListParams::default().fields(&format!(
600+
let watcher_config: watcher::Config = watcher::Config::default().fields(&format!(
599601
"metadata.name={}",
600602
created_pod
601603
.metadata
@@ -607,14 +609,14 @@ mod tests {
607609
// Timeout is not acceptable
608610
tokio::time::timeout(
609611
Duration::from_secs(30), // Busybox is ~5MB and sub 1 sec to start.
610-
client.wait_created::<Pod>(&client.default_namespace, lp.clone()),
612+
client.wait_created::<Pod>(&client.default_namespace, watcher_config.clone()),
611613
)
612614
.await
613615
.expect("The tested wait_created function timed out.");
614616

615617
// A second, manually constructed watcher is used to verify the ListParams filter out the correct resource
616618
// and the `wait_created` function returned when the correct resources had been detected.
617-
let mut ready_watcher = kube::runtime::watcher::<Pod>(api, lp).boxed();
619+
let mut ready_watcher = kube::runtime::watcher::<Pod>(api, watcher_config).boxed();
618620
while let Some(result) = ready_watcher.next().await {
619621
match result {
620622
Ok(event) => match event {
@@ -649,12 +651,13 @@ mod tests {
649651
.await
650652
.expect("KUBECONFIG variable must be configured.");
651653

652-
let lp: ListParams = ListParams::default().fields("metadata.name=nonexistent-pod");
654+
let watcher_config: watcher::Config =
655+
watcher::Config::default().fields("metadata.name=nonexistent-pod");
653656

654657
// There is no such pod, therefore the `wait_created` function call times out.
655658
let wait_created_result: Result<(), Elapsed> = tokio::time::timeout(
656659
Duration::from_secs(1),
657-
client.wait_created::<Pod>(&client.default_namespace, lp.clone()),
660+
client.wait_created::<Pod>(&client.default_namespace, watcher_config),
658661
)
659662
.await;
660663

src/commons/product_image_selection.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,16 @@ pub struct ResolvedProductImage {
6767
pub pull_secrets: Option<Vec<LocalObjectReference>>,
6868
}
6969

70-
#[derive(Clone, Debug, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
70+
#[derive(Clone, Debug, Default, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
7171
#[serde(rename = "PascalCase")]
7272
#[derive(AsRefStr)]
7373
pub enum PullPolicy {
74+
#[default]
7475
IfNotPresent,
7576
Always,
7677
Never,
7778
}
7879

79-
impl Default for PullPolicy {
80-
fn default() -> PullPolicy {
81-
PullPolicy::IfNotPresent
82-
}
83-
}
84-
8580
impl ProductImage {
8681
pub fn resolve(&self, image_base_name: &str) -> ResolvedProductImage {
8782
let image_pull_policy = self.pull_policy.as_ref().to_string();

src/commons/s3.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -205,21 +205,18 @@ impl S3ConnectionSpec {
205205
}
206206
}
207207

208-
#[derive(strum::Display, Clone, Debug, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
208+
#[derive(
209+
strum::Display, Clone, Debug, Default, Deserialize, Eq, JsonSchema, PartialEq, Serialize,
210+
)]
209211
#[strum(serialize_all = "PascalCase")]
210212
pub enum S3AccessStyle {
211213
/// Use path-style access as described in <https://docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html#path-style-access>
212214
Path,
213215
/// Use as virtual hosted-style access as described in <https://docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html#virtual-hosted-style-access>
216+
#[default]
214217
VirtualHosted,
215218
}
216219

217-
impl Default for S3AccessStyle {
218-
fn default() -> Self {
219-
S3AccessStyle::VirtualHosted
220-
}
221-
}
222-
223220
#[cfg(test)]
224221
mod test {
225222
use std::str;

0 commit comments

Comments
 (0)