From 2e4512ea9851a6c496b379dd12193922e0199184 Mon Sep 17 00:00:00 2001 From: Eirik A Date: Mon, 16 Sep 2024 12:48:31 +0100 Subject: [PATCH] Bump `k8s-openapi` to 0.23 for Kubernetes 1.31 support (#1581) * bump k8s-openapi pin and associated MK8SV Signed-off-by: clux * option wrap change in upstream type Signed-off-by: clux * client ext small fixes to one doc tests - reorder imports - client ext trait needs an explicit import despite being in prelude? - unpacking of type as now required Signed-off-by: clux * bump msrv according to cargo msrv check Signed-off-by: clux --------- Signed-off-by: clux --- .devcontainer/Dockerfile | 2 +- .github/workflows/ci.yml | 4 ++-- .github/workflows/coverage.yml | 2 +- Cargo.toml | 4 ++-- README.md | 4 ++-- e2e/Cargo.toml | 2 +- kube-client/src/api/mod.rs | 7 +------ kube-client/src/client/client_ext.rs | 16 +++++++--------- 8 files changed, 17 insertions(+), 24 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 54c983a1b..0b8f7fea6 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -FROM docker.io/rust:1.75.0-bullseye +FROM docker.io/rust:1.77.2-bullseye ENV DEBIAN_FRONTEND=noninteractive RUN apt update && apt upgrade -y diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d9c6b70ee..66e280efa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -140,7 +140,7 @@ jobs: fail-fast: false matrix: # Run these tests against older clusters as well - k8s: [v1.25, v1.29] + k8s: [v1.26, v1.30] steps: - uses: actions/checkout@v4 - uses: actions-rs/toolchain@v1 @@ -214,7 +214,7 @@ jobs: - uses: nolar/setup-k3d-k3s@v1 with: - version: v1.25 + version: v1.26 # k3d-kube k3d-name: kube # Used to avoid rate limits when fetching the releases from k3s repo. diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 0b1d89f31..88076c809 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -25,7 +25,7 @@ jobs: tool: cargo-tarpaulin@0.28.0 - uses: nolar/setup-k3d-k3s@v1 with: - version: v1.25 + version: v1.26 # k3d-kube k3d-name: kube # Used to avoid rate limits when fetching the releases from k3s repo. diff --git a/Cargo.toml b/Cargo.toml index ad2ce3ffe..1b48f1c73 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ repository = "https://github.com/kube-rs/kube" readme = "README.md" license = "Apache-2.0" edition = "2021" -rust-version = "1.75.0" +rust-version = "1.77.2" [workspace.lints.rust] unsafe_code = "forbid" @@ -60,7 +60,7 @@ hyper-timeout = "0.5.1" json-patch = "2.0.0" jsonptr = "0.4.7" jsonpath-rust = "0.5.0" -k8s-openapi = { version = "0.22.0", default-features = false } +k8s-openapi = { version = "0.23.0", default-features = false } openssl = "0.10.36" parking_lot = "0.12.0" pem = "3.0.1" diff --git a/README.md b/README.md index dd49a5e7b..e90188e73 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # kube-rs [![Crates.io](https://img.shields.io/crates/v/kube.svg)](https://crates.io/crates/kube) -[![Rust 1.75](https://img.shields.io/badge/MSRV-1.75-dea584.svg)](https://github.com/rust-lang/rust/releases/tag/1.75.0) -[![Tested against Kubernetes v1_25 and above](https://img.shields.io/badge/MK8SV-v1_25-326ce5.svg)](https://kube.rs/kubernetes-version) +[![Rust 1.77](https://img.shields.io/badge/MSRV-1.77-dea584.svg)](https://github.com/rust-lang/rust/releases/tag/1.77.2) +[![Tested against Kubernetes v1_26 and above](https://img.shields.io/badge/MK8SV-v1_26-326ce5.svg)](https://kube.rs/kubernetes-version) [![Best Practices](https://bestpractices.coreinfrastructure.org/projects/5413/badge)](https://bestpractices.coreinfrastructure.org/projects/5413) [![Discord chat](https://img.shields.io/discord/500028886025895936.svg?logo=discord&style=plastic)](https://discord.gg/tokio) diff --git a/e2e/Cargo.toml b/e2e/Cargo.toml index ecc4d5b39..28e5c9930 100644 --- a/e2e/Cargo.toml +++ b/e2e/Cargo.toml @@ -19,7 +19,7 @@ path = "boot.rs" [features] latest = ["k8s-openapi/latest"] -mk8sv = ["k8s-openapi/v1_25"] +mk8sv = ["k8s-openapi/v1_26"] rustls = ["kube/rustls-tls"] openssl = ["kube/openssl-tls"] diff --git a/kube-client/src/api/mod.rs b/kube-client/src/api/mod.rs index 24088e71a..020d95337 100644 --- a/kube-client/src/api/mod.rs +++ b/kube-client/src/api/mod.rs @@ -11,14 +11,9 @@ use std::fmt::Debug; mod subresource; #[cfg(feature = "ws")] #[cfg_attr(docsrs, doc(cfg(feature = "ws")))] -pub use subresource::{Attach, AttachParams, Execute, Portforward}; +pub use subresource::{Attach, AttachParams, Ephemeral, Execute, Portforward}; pub use subresource::{Evict, EvictParams, Log, LogParams, ScaleSpec, ScaleStatus}; -// Ephemeral containers were stabilized in Kubernetes 1.25. -k8s_openapi::k8s_if_ge_1_25! { - pub use subresource::Ephemeral; -} - mod util; pub mod entry; diff --git a/kube-client/src/client/client_ext.rs b/kube-client/src/client/client_ext.rs index f0de2f5b2..ced2df626 100644 --- a/kube-client/src/client/client_ext.rs +++ b/kube-client/src/client/client_ext.rs @@ -140,7 +140,7 @@ where ObjectReference { api_version: K::api_version(&dt).to_string().into(), namespace: namespace.into(), - name: self.name.clone(), + name: Some(self.name.clone()), kind: K::kind(&dt).to_string().into(), ..Default::default() } @@ -243,8 +243,7 @@ pub enum NamespaceError { /// ## Example /// /// ```no_run -/// # use k8s_openapi::api::core::v1::Pod; -/// # use k8s_openapi::api::core::v1::Service; +/// # use k8s_openapi::api::core::v1::{Pod, Service}; /// # use kube::client::scope::{Namespace, Cluster}; /// # use kube::prelude::*; /// # use kube::api::ListParams; @@ -295,11 +294,10 @@ impl Client { /// /// ```no_run /// # use k8s_openapi::api::rbac::v1::ClusterRole; - /// # use k8s_openapi::api::core::v1::Service; - /// # use k8s_openapi::api::core::v1::Secret; - /// # use k8s_openapi::api::core::v1::ObjectReference; - /// # use k8s_openapi::api::core::v1::LocalObjectReference; - /// # use k8s_openapi::api::core::v1::{Node, Pod}; + /// # use k8s_openapi::apimachinery::pkg::apis::meta::v1::OwnerReference; + /// # use k8s_openapi::api::core::v1::{ObjectReference, LocalObjectReference}; + /// # use k8s_openapi::api::core::v1::{Node, Pod, Service, Secret}; + /// # use kube::client::scope::NamespacedRef; /// # use kube::api::GetParams; /// # use kube::prelude::*; /// # use kube::api::DynamicObject; @@ -333,7 +331,7 @@ impl Client { /// .image_pull_secrets /// .unwrap_or_default() /// .get(0) - /// .unwrap_or(&LocalObjectReference{name: Some("pull_secret".into())}); + /// .unwrap_or(&LocalObjectReference{name: "pull_secret".into()}); /// let secret: Secret = client.fetch(&secret_ref.within(pod.namespace())).await?; /// # Ok(()) /// # }