Skip to content

Commit

Permalink
Merge branch 'main' into mvp-client-ext
Browse files Browse the repository at this point in the history
  • Loading branch information
clux authored Mar 13, 2024
2 parents 9b46d49 + df37c99 commit 3c1863f
Show file tree
Hide file tree
Showing 25 changed files with 248 additions and 120 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM docker.io/rust:1.70.0-bullseye
FROM docker.io/rust:1.72.0-bullseye

ENV DEBIAN_FRONTEND=noninteractive
RUN apt update && apt upgrade -y
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ jobs:
fail-fast: false
matrix:
# Run these tests against older clusters as well
k8s: [v1.23, latest]
k8s: [v1.24, latest]
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
Expand Down Expand Up @@ -216,7 +216,7 @@ jobs:

- uses: nolar/setup-k3d-k3s@v1
with:
version: v1.23
version: v1.24
# k3d-kube
k3d-name: kube
# Used to avoid rate limits when fetching the releases from k3s repo.
Expand Down Expand Up @@ -247,7 +247,7 @@ jobs:
tls: [openssl, rustls]
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v2
- uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
cluster-name: "test-cluster-1"
args: >-
--agents 1
--image docker.io/rancher/k3s:v1.23.4-k3s1
--image docker.io/rancher/k3s:v1.24.4-k3s1
--k3s-arg "--no-deploy=traefik,servicelb,metrics-server@server:*"
- name: Run cargo-tarpaulin
uses: actions-rs/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rustfmt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- run: rustfmt +nightly --edition 2018 $(find . -type f -iname *.rs)

- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
uses: peter-evans/create-pull-request@v6
with:
commit-message: rustfmt
signoff: true
Expand Down
26 changes: 25 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,31 @@
<!-- next-header -->
UNRELEASED
===================
* see https://github.com/kube-rs/kube/compare/0.87.2...main
* see https://github.com/kube-rs/kube/compare/0.88.1...main

[0.88.1](https://github.com/kube-rs/kube/releases/tag/0.88.1) / 2024-01-26
===================
<!-- Release notes generated using configuration in .github/release.yml at 0.88.1 -->

## What's Changed
This is a bug fix release for a deserialization issue introduced in 0.88.0.

### Fixed
* Minor fixes to `ObjectList` by @flavio in https://github.com/kube-rs/kube/pull/1398

[0.88.0](https://github.com/kube-rs/kube/releases/tag/0.88.0) / 2024-01-21
===================
<!-- Release notes generated using configuration in .github/release.yml at 0.88.0 -->

## Kubernetes `v1_29` support via `k8s-openapi` [0.21](https://github.com/Arnavion/k8s-openapi/releases/tag/v0.21.0)
Please [upgrade k8s-openapi along with kube](https://kube.rs/upgrading/) to avoid conflicts.

## What's Changed
### Added
* Add type meta data for list types by @Danil-Grigorev in https://github.com/kube-rs/kube/pull/1380
### Changed
* Bump MSRV to 1.70 by @clux in https://github.com/kube-rs/kube/pull/1384
* Upgrade `k8s-openapi` for Kubernetes `v1_29` support by @clux in https://github.com/kube-rs/kube/pull/1394

[0.87.2](https://github.com/kube-rs/kube/releases/tag/0.87.2) / 2023-12-22
===================
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# kube-rs

[![Crates.io](https://img.shields.io/crates/v/kube.svg)](https://crates.io/crates/kube)
[![Rust 1.70](https://img.shields.io/badge/MSRV-1.70-dea584.svg)](https://github.com/rust-lang/rust/releases/tag/1.70.0)
[![Tested against Kubernetes v1_23 and above](https://img.shields.io/badge/MK8SV-v1_23-326ce5.svg)](https://kube.rs/kubernetes-version)
[![Rust 1.72](https://img.shields.io/badge/MSRV-1.72-dea584.svg)](https://github.com/rust-lang/rust/releases/tag/1.72.0)
[![Tested against Kubernetes v1_24 and above](https://img.shields.io/badge/MK8SV-v1_24-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)

Expand All @@ -16,8 +16,8 @@ Select a version of `kube` along with the generated [k8s-openapi](https://github

```toml
[dependencies]
kube = { version = "0.87.2", features = ["runtime", "derive"] }
k8s-openapi = { version = "0.20.0", features = ["latest"] }
kube = { version = "0.88.1", features = ["runtime", "derive"] }
k8s-openapi = { version = "0.21.0", features = ["latest"] }
```

[Features are available](https://github.com/kube-rs/kube/blob/main/kube/Cargo.toml#L18).
Expand Down Expand Up @@ -152,8 +152,8 @@ By default [rustls](https://github.com/ctz/rustls) is used for TLS, but `openssl

```toml
[dependencies]
kube = { version = "0.87.2", default-features = false, features = ["client", "openssl-tls"] }
k8s-openapi = { version = "0.20.0", features = ["latest"] }
kube = { version = "0.88.1", default-features = false, features = ["client", "openssl-tls"] }
k8s-openapi = { version = "0.21.0", features = ["latest"] }
```

This will pull in `openssl` and `hyper-openssl`. If `default-features` is left enabled, you will pull in two TLS stacks, and the default will remain as `rustls`.
Expand Down
6 changes: 3 additions & 3 deletions e2e/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ path = "boot.rs"

[features]
latest = ["k8s-openapi/latest"]
mk8sv = ["k8s-openapi/v1_23"]
mk8sv = ["k8s-openapi/v1_24"]
rustls = ["kube/rustls-tls"]
openssl = ["kube/openssl-tls"]

Expand All @@ -28,7 +28,7 @@ anyhow = "1.0.44"
tracing = "0.1.36"
tracing-subscriber = "0.3.3"
futures = "0.3.17"
kube = { path = "../kube", version = "^0.87.2", default-features = false, features = ["client", "runtime", "ws", "admission", "gzip"] }
k8s-openapi = { version = "0.20.0", default-features = false }
kube = { path = "../kube", version = "^0.88.1", default-features = false, features = ["client", "runtime", "ws", "admission", "gzip"] }
k8s-openapi = { version = "0.21.0", default-features = false }
serde_json = "1.0.68"
tokio = { version = "1.14.0", features = ["full"] }
10 changes: 5 additions & 5 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ latest = ["k8s-openapi/latest"]
[dev-dependencies]
tokio-util = "0.7.0"
assert-json-diff = "2.0.1"
garde = { version = "0.16.1", default-features = false, features = ["derive"] }
garde = { version = "0.18.0", default-features = false, features = ["derive"] }
anyhow = "1.0.44"
futures = "0.3.17"
jsonpath-rust = "0.3.4"
kube = { path = "../kube", version = "^0.87.2", default-features = false, features = ["admission"] }
kube-derive = { path = "../kube-derive", version = "^0.87.2", default-features = false } # only needed to opt out of schema
k8s-openapi = { version = "0.20.0", default-features = false }
jsonpath-rust = "0.4.0"
kube = { path = "../kube", version = "^0.88.1", default-features = false, features = ["admission"] }
kube-derive = { path = "../kube-derive", version = "^0.88.1", default-features = false } # only needed to opt out of schema
k8s-openapi = { version = "0.21.0", default-features = false }
serde = { version = "1.0.130", features = ["derive"] }
serde_json = "1.0.68"
serde_yaml = "0.9.19"
Expand Down
12 changes: 6 additions & 6 deletions kube-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "kube-client"
version = "0.87.2"
version = "0.88.1"
description = "Kubernetes client"
authors = [
"clux <[email protected]>",
Expand All @@ -12,7 +12,7 @@ repository = "https://github.com/kube-rs/kube"
readme = "../README.md"
keywords = ["kubernetes", "client",]
categories = ["web-programming::http-client", "configuration", "network-programming", "api-bindings"]
rust-version = "1.70.0"
rust-version = "1.72.0"
edition = "2021"

[features]
Expand Down Expand Up @@ -56,8 +56,8 @@ rustls = { version = "0.21.4", features = ["dangerous_configuration"], optional
rustls-pemfile = { version = "1.0.0", optional = true }
bytes = { version = "1.1.0", optional = true }
tokio = { version = "1.14.0", features = ["time", "signal", "sync"], optional = true }
kube-core = { path = "../kube-core", version = "=0.87.2" }
jsonpath-rust = { version = "0.3.4", optional = true }
kube-core = { path = "../kube-core", version = "=0.88.1" }
jsonpath-rust = { version = "0.4.0", optional = true }
tokio-util = { version = "0.7.0", optional = true, features = ["io", "codec"] }
hyper = { version = "0.14.13", optional = true, features = ["client", "http1", "stream", "tcp"] }
hyper-rustls = { version = "0.24.0", optional = true }
Expand All @@ -75,7 +75,7 @@ hyper-openssl = { version = "0.9.2", optional = true }
form_urlencoded = { version = "1.2.0", optional = true }

[dependencies.k8s-openapi]
version = "0.20.0"
version = "0.21.0"
default-features = false
features = []

Expand All @@ -88,6 +88,6 @@ tokio-test = "0.4.0"
tower-test = "0.4.0"

[dev-dependencies.k8s-openapi]
version = "0.20.0"
version = "0.21.0"
default-features = false
features = ["latest"]
1 change: 1 addition & 0 deletions kube-client/src/api/remote_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type TerminalSizeSender = mpsc::Sender<TerminalSize>;
/// TerminalSize define the size of a terminal
#[derive(Debug, Serialize, Deserialize)]
#[cfg_attr(docsrs, doc(cfg(feature = "ws")))]
#[serde(rename_all = "PascalCase")]
pub struct TerminalSize {
/// width of the terminal
pub width: u16,
Expand Down
9 changes: 2 additions & 7 deletions kube-client/src/api/subresource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,14 +545,9 @@ where
K: Clone + DeserializeOwned + Execute,
{
/// Execute a command in a pod
pub async fn exec<I: Debug, T>(
&self,
name: &str,
command: I,
ap: &AttachParams,
) -> Result<AttachedProcess>
pub async fn exec<I, T>(&self, name: &str, command: I, ap: &AttachParams) -> Result<AttachedProcess>
where
I: IntoIterator<Item = T>,
I: IntoIterator<Item = T> + Debug,
T: Into<String>,
{
let mut req = self
Expand Down
8 changes: 4 additions & 4 deletions kube-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
name = "kube-core"
description = "Kube shared types, traits and client-less behavior"
version = "0.87.2"
version = "0.88.1"
authors = [
"clux <[email protected]>",
"kazk <[email protected]>",
]
edition = "2021"
rust-version = "1.70.0"
rust-version = "1.72.0"
license = "Apache-2.0"
keywords = ["kubernetes", "apimachinery"]
categories = ["api-bindings", "encoding", "parser-implementations"]
Expand Down Expand Up @@ -36,12 +36,12 @@ chrono = { version = "0.4.19", default-features = false, features = ["clock"] }
schemars = { version = "0.8.6", optional = true }

[dependencies.k8s-openapi]
version = "0.20.0"
version = "0.21.0"
default-features = false
features = []

[dev-dependencies.k8s-openapi]
version = "0.20.0"
version = "0.21.0"
default-features = false
features = ["latest"]

Expand Down
4 changes: 2 additions & 2 deletions kube-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ pub use request::Request;

mod resource;
pub use resource::{
ClusterResourceScope, DynamicResourceScope, NamespaceResourceScope, Resource, ResourceExt, ResourceScope,
SubResourceScope,
api_version_from_group_version, ClusterResourceScope, DynamicResourceScope, NamespaceResourceScope,
Resource, ResourceExt, ResourceScope, SubResourceScope,
};

pub mod response;
Expand Down
35 changes: 33 additions & 2 deletions kube-core/src/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ use std::borrow::Cow;
/// and is generally produced from list/watch/delete collection queries on an [`Resource`](super::Resource).
///
/// This is almost equivalent to [`k8s_openapi::List<T>`](k8s_openapi::List), but iterable.
#[derive(Serialize, Deserialize, Debug)]
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ObjectList<T>
where
T: Clone,
{
/// The type fields, always present
#[serde(flatten, default)]
#[serde(flatten, deserialize_with = "deserialize_v1_list_as_default")]
pub types: TypeMeta,

/// ListMeta - only really used for its `resourceVersion`
Expand All @@ -38,6 +38,17 @@ where
pub items: Vec<T>,
}

fn deserialize_v1_list_as_default<'de, D>(deserializer: D) -> Result<TypeMeta, D::Error>
where
D: Deserializer<'de>,
{
let meta = Option::<TypeMeta>::deserialize(deserializer)?;
Ok(meta.unwrap_or(TypeMeta {
api_version: "v1".to_owned(),
kind: "List".to_owned(),
}))
}

fn deserialize_null_as_default<'de, D, T>(deserializer: D) -> Result<T, D::Error>
where
T: Default + Deserialize<'de>,
Expand Down Expand Up @@ -394,4 +405,24 @@ mod test {
assert!(mypod.status.is_none());
assert!(mypod.spec.is_none());
}

#[test]
fn k8s_object_list_default_types() {
use k8s_openapi::api::core::v1::Pod;

let raw_value = serde_json::json!({
"metadata": {
"resourceVersion": ""
},
"items": []
});
let pod_list: ObjectList<Pod> = serde_json::from_value(raw_value).unwrap();
assert_eq!(
TypeMeta {
api_version: "v1".to_owned(),
kind: "List".to_owned(),
},
pod_list.types,
);
}
}
21 changes: 13 additions & 8 deletions kube-core/src/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,7 @@ pub trait Resource {
fn version(dt: &Self::DynamicType) -> Cow<'_, str>;
/// Returns apiVersion of this object
fn api_version(dt: &Self::DynamicType) -> Cow<'_, str> {
let group = Self::group(dt);
if group.is_empty() {
return Self::version(dt);
}
let mut group = group.into_owned();
group.push('/');
group.push_str(&Self::version(dt));
group.into()
api_version_from_group_version(Self::group(dt), Self::version(dt))
}
/// Returns the plural name of the kind
///
Expand Down Expand Up @@ -115,6 +108,18 @@ pub trait Resource {
}
}

/// Helper function that creates the `apiVersion` field from the group and version strings.
pub fn api_version_from_group_version<'a>(group: Cow<'a, str>, version: Cow<'a, str>) -> Cow<'a, str> {
if group.is_empty() {
return version;
}

let mut output = group;
output.to_mut().push('/');
output.to_mut().push_str(&version);
output
}

/// Implement accessor trait for any ObjectMeta-using Kubernetes Resource
impl<K, S> Resource for K
where
Expand Down
6 changes: 3 additions & 3 deletions kube-derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
name = "kube-derive"
description = "Custom derives for the kube kubernetes crates"
version = "0.87.2"
version = "0.88.1"
authors = [
"clux <[email protected]>",
"kazk <[email protected]>",
]
edition = "2021"
rust-version = "1.70.0"
rust-version = "1.72.0"
license = "Apache-2.0"
repository = "https://github.com/kube-rs/kube"
readme = "../README.md"
Expand All @@ -29,7 +29,7 @@ proc-macro = true
serde = { version = "1.0.130", features = ["derive"] }
serde_yaml = "0.9.19"
kube = { path = "../kube", version = "<1.0.0, >=0.61.0", features = ["derive", "client"] }
k8s-openapi = { version = "0.20.0", default-features = false, features = ["latest"] }
k8s-openapi = { version = "0.21.0", default-features = false, features = ["latest"] }
schemars = { version = "0.8.6", features = ["chrono"] }
chrono = { version = "0.4.19", default-features = false }
trybuild = "1.0.48"
Expand Down
2 changes: 1 addition & 1 deletion kube-derive/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Add the `derive` feature to `kube`:

```toml
[dependencies]
kube = { version = "0.87.2", feature = ["derive"] }
kube = { version = "0.88.1", feature = ["derive"] }
```

## Usage
Expand Down
Loading

0 comments on commit 3c1863f

Please sign in to comment.