From 2a651b5ed62573b0ee5833aa7e23897ca39bc773 Mon Sep 17 00:00:00 2001 From: Roshan Jobanputra Date: Wed, 9 Aug 2023 10:38:20 -0400 Subject: [PATCH 1/2] Update kube, kube-runtime, and k8s-openapi. Release version 0.2.0 due to compat change --- CHANGELOG.md | 9 +++++++++ Cargo.toml | 8 ++++---- deny.toml | 6 ++++++ src/controller.rs | 27 ++++++++++++++------------- src/lib.rs | 4 ++-- 5 files changed, 35 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b39c37..5312771 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## [0.2.0] - 2023-08-09 + +### Changed + +* Upgrade `kube` and `kube-runtime` to `0.85` + * This includes an interface change that replaces `ListParams` with `watcher::Config`, described here: https://github.com/MaterializeInc/kube-rs/blob/master/CHANGELOG.md#listwatch-changes + * The `namespaced`, `namespaced_all`, and `cluster` methods have been updated correspondingly; this will require an update if you are using them. +* Upgrade `k8s-openapi` to `0.19` with `v1_25` enabled + ## [0.1.1] - 2023-07-14 ### Fixed diff --git a/Cargo.toml b/Cargo.toml index 04c673b..784c9ed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "k8s-controller" -version = "0.1.1" +version = "0.2.0" edition = "2021" description = "lightweight framework for writing kubernetes controllers" @@ -12,9 +12,9 @@ include = ["src/**/*", "LICENSE", "README.md", "CHANGELOG.md"] [dependencies] async-trait = "0.1.71" futures = "0.3.28" -k8s-openapi = { version = "0.16", features = ["v1_24"] } -kube = "0.77" -kube-runtime = "0.77" +k8s-openapi = { version = "0.19", features = ["v1_25"] } +kube = "0.85" +kube-runtime = "0.85" rand = "0.8.5" serde = "1.0.167" tracing = "0.1.37" diff --git a/deny.toml b/deny.toml index 57d36b3..78fa116 100644 --- a/deny.toml +++ b/deny.toml @@ -13,6 +13,12 @@ multiple-versions = "deny" skip = [ { name = "syn", version = "1.0.109" }, { name = "syn", version = "2.0.23" }, + { name = "bitflags", version = "1.3.2" }, + { name = "bitflags", version = "2.3.3" }, + { name = "base64", version = "0.13.1" }, + { name = "base64", version = "0.20.0" }, + { name = "base64", version = "0.21.2" }, + { name = "socket2", version = "0.4.9" }, ] # Use `tracing` instead. diff --git a/src/controller.rs b/src/controller.rs index 149e2cb..8375874 100644 --- a/src/controller.rs +++ b/src/controller.rs @@ -5,11 +5,12 @@ use std::time::Duration; use futures::future::FutureExt; use futures::stream::StreamExt; -use kube::api::{Api, ListParams}; +use kube::api::Api; use kube::core::{ClusterResourceScope, NamespaceResourceScope}; use kube::{Client, Resource, ResourceExt}; use kube_runtime::controller::Action; use kube_runtime::finalizer::{finalizer, Event}; +use kube_runtime::watcher; use rand::{thread_rng, Rng}; use tracing::{event, Level}; @@ -45,10 +46,10 @@ where /// `client`. The `context` given determines the type of resource /// to watch (via the [`Context::Resource`] type provided as part of /// the trait implementation). The resources to be watched will be - /// limited to resources in the given `namespace`. A [`ListParams`] + /// limited to resources in the given `namespace`. A [`watcher::Config`] /// can be given to limit the resources watched (for instance, - /// `ListParams::default().labels("app=myapp")`). - pub fn namespaced(client: Client, context: Ctx, namespace: &str, lp: ListParams) -> Self + /// `watcher::Config::default().labels("app=myapp")`). + pub fn namespaced(client: Client, context: Ctx, namespace: &str, wc: watcher::Config) -> Self where Ctx::Resource: Resource, { @@ -60,7 +61,7 @@ where }; let controller = kube_runtime::controller::Controller::new( Api::::namespaced(client.clone(), namespace), - lp, + wc, ); Self { client, @@ -74,10 +75,10 @@ where /// `client`. The `context` given determines the type of resource to /// watch (via the [`Context::Resource`] type provided as part of the /// trait implementation). The resources to be watched will not be - /// limited by namespace. A [`ListParams`] can be given to limit the + /// limited by namespace. A [`watcher::Config`] can be given to limit the /// resources watched (for instance, - /// `ListParams::default().labels("app=myapp")`). - pub fn namespaced_all(client: Client, context: Ctx, lp: ListParams) -> Self + /// `watcher::Config::default().labels("app=myapp")`). + pub fn namespaced_all(client: Client, context: Ctx, wc: watcher::Config) -> Self where Ctx::Resource: Resource, { @@ -89,7 +90,7 @@ where }; let controller = kube_runtime::controller::Controller::new( Api::::all(client.clone()), - lp, + wc, ); Self { client, @@ -102,10 +103,10 @@ where /// Creates a new controller for a cluster-scoped resource using the /// given `client`. The `context` given determines the type of resource /// to watch (via the [`Context::Resource`] type provided as part of the - /// trait implementation). A [`ListParams`] can be given to limit the + /// trait implementation). A [`watcher::Config`] can be given to limit the /// resources watched (for instance, - /// `ListParams::default().labels("app=myapp")`). - pub fn cluster(client: Client, context: Ctx, lp: ListParams) -> Self + /// `watcher::Config::default().labels("app=myapp")`). + pub fn cluster(client: Client, context: Ctx, wc: watcher::Config) -> Self where Ctx::Resource: Resource, { @@ -115,7 +116,7 @@ where }; let controller = kube_runtime::controller::Controller::new( Api::::all(client.clone()), - lp, + wc, ); Self { client, diff --git a/src/lib.rs b/src/lib.rs index c1edd5b..e922e64 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -123,8 +123,8 @@ //! # use std::time::Duration; //! # use k8s_openapi::api::core::v1::Pod; //! # use kube::{Config, Client}; -//! # use kube::api::ListParams; //! # use kube_runtime::controller::Action; +//! # use kube_runtime::watcher; //! # use tokio::task; //! # #[derive(Default, Clone)] //! # struct PodCounter { @@ -156,7 +156,7 @@ //! let controller = k8s_controller::Controller::namespaced_all( //! kube_client, //! context.clone(), -//! ListParams::default(), +//! watcher::Config::default(), //! ); //! task::spawn(controller.run()); //! From 491b9b838557ae140bf3fbe19becbc98212618d3 Mon Sep 17 00:00:00 2001 From: Roshan Jobanputra Date: Wed, 9 Aug 2023 11:01:41 -0400 Subject: [PATCH 2/2] Fix github lint action --- .github/workflows/pr.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 4ad37b6..3a3032a 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -23,10 +23,9 @@ jobs: with: command: clippy args: -- --deny warnings - - uses: actions-rs/cargo@v1 + - uses: EmbarkStudios/cargo-deny-action@v1 with: - command: deny - args: check + command: check test: runs-on: ubuntu-20.04 steps: