From ea288c88386216fbefe8a108ce6f678821ab008e Mon Sep 17 00:00:00 2001 From: David Hu Date: Thu, 19 Jan 2023 20:30:24 -0800 Subject: [PATCH] replica-sets --- src-tauri/src/main.rs | 3 +- src-tauri/src/resources/mod.rs | 1 + src-tauri/src/resources/replica_sets.rs | 11 ++++++ src/layout.tsx | 6 ++-- src/replica-sets/replica-sets.tsx | 35 ++++++++++++++++++ src/router.tsx | 27 +++++++------- yarn.lock | 48 ++++++++++++------------- 7 files changed, 88 insertions(+), 43 deletions(-) create mode 100644 src-tauri/src/resources/replica_sets.rs create mode 100644 src/replica-sets/replica-sets.tsx diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index b452714..16df526 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -5,7 +5,7 @@ mod resources; -use crate::resources::{cron_jobs, deployments, jobs, namespaces, pods}; +use crate::resources::{cron_jobs, deployments, jobs, namespaces, pods, replica_sets}; fn main() { tauri::Builder::default() @@ -18,6 +18,7 @@ fn main() { pods::get_pod_logs, pods::get_pods, namespaces::get_namespaces, + replica_sets::get_replica_sets ]) .run(tauri::generate_context!()) .expect("error while running tauri application"); diff --git a/src-tauri/src/resources/mod.rs b/src-tauri/src/resources/mod.rs index ae0628d..c17891c 100644 --- a/src-tauri/src/resources/mod.rs +++ b/src-tauri/src/resources/mod.rs @@ -5,3 +5,4 @@ pub mod deployments; pub mod jobs; pub mod namespaces; pub mod pods; +pub mod replica_sets; diff --git a/src-tauri/src/resources/replica_sets.rs b/src-tauri/src/resources/replica_sets.rs new file mode 100644 index 0000000..6f7952f --- /dev/null +++ b/src-tauri/src/resources/replica_sets.rs @@ -0,0 +1,11 @@ +use k8s_openapi::api::apps::v1::ReplicaSet; +use kube::{api::ListParams, core::ObjectList, Api}; + +use super::internal::get_api; + +#[tauri::command] +pub async fn get_replica_sets(namespace: Option) -> ObjectList { + let api: Api = get_api(namespace).await; + let lp = ListParams::default(); + return api.list(&lp).await.unwrap(); +} diff --git a/src/layout.tsx b/src/layout.tsx index 37c0ec1..24c1533 100644 --- a/src/layout.tsx +++ b/src/layout.tsx @@ -3,7 +3,7 @@ import { Link } from "@tanstack/react-router"; import type { PropsWithChildren } from "react"; import { NamespaceSelect } from "./namespaces/namespace-select"; -import { navigationLinks } from "./router"; +import { routes } from "./router"; export function Layout({ children }: PropsWithChildren) { return ( @@ -17,10 +17,10 @@ export function Layout({ children }: PropsWithChildren) {