Skip to content

Commit 5a9c415

Browse files
committed
tweaks
Signed-off-by: clux <[email protected]>
1 parent 4065cb9 commit 5a9c415

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

examples/pod_resize.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use k8s_openapi::api::core::v1::Pod;
1+
use k8s_openapi::{api::core::v1::Pod, apimachinery::pkg::api::resource::Quantity};
22
use kube::{
33
api::{Api, DeleteParams, Patch, PatchParams, PostParams, ResourceExt},
44
runtime::wait::{await_condition, conditions::is_pod_running},
@@ -87,25 +87,20 @@ async fn main() -> anyhow::Result<()> {
8787
info!("Updated resources via patch: {:?}", container.resources);
8888
}
8989
}
90-
Err(e) => {
91-
error!("Failed to patch resize pod: {}", e);
92-
}
90+
Err(e) => error!("Failed to patch resize pod: {}", e),
9391
}
9492

9593
// Example 3: Using replace_resize
9694
info!("Example 3: Using replace_resize method");
9795
let mut current_pod = pods.get_resize("resize-demo").await?;
9896

97+
// Update memory request
9998
if let Some(spec) = &mut current_pod.spec
10099
&& let Some(container) = spec.containers.get_mut(0)
101100
&& let Some(resources) = &mut container.resources
102101
&& let Some(requests) = &mut resources.requests
103102
{
104-
// Update memory request
105-
requests.insert(
106-
"memory".to_string(),
107-
k8s_openapi::apimachinery::pkg::api::resource::Quantity("384Mi".to_string()),
108-
);
103+
requests.insert("memory".into(), Quantity("384Mi".into()));
109104
}
110105

111106
match pods.replace_resize("resize-demo", &pp, &current_pod).await {

justfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ clippy:
1212

1313
fmt:
1414
#rustup component add rustfmt --toolchain nightly
15-
rustfmt +nightly --edition 2021 $(find . -type f -iname *.rs)
15+
rustfmt +nightly --edition 2024 $(find . -type f -iname *.rs)
1616

1717
doc:
1818
RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc --all-features --no-deps --open

0 commit comments

Comments
 (0)