-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: refactor tauri commands to be more shareable. (#14)
- Loading branch information
1 parent
1bbdaf7
commit 3ea390e
Showing
8 changed files
with
48 additions
and
44 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
use k8s_openapi::api::batch::v1::CronJob; | ||
use kube::core::ObjectList; | ||
|
||
// use crate::internal::get_resource_list; | ||
|
||
use super::internal::get_resource_list; | ||
|
||
#[tauri::command] | ||
pub async fn get_cron_jobs(namespace: Option<String>) -> ObjectList<CronJob> { | ||
return get_resource_list(namespace).await; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use k8s_openapi::NamespaceResourceScope; | ||
use kube::{api::ListParams, core::ObjectList, Api, Client}; | ||
|
||
pub async fn get_resource_list<T>(namespace: Option<String>) -> ObjectList<T> | ||
where | ||
T: serde::de::DeserializeOwned | ||
+ std::fmt::Debug | ||
+ Clone | ||
+ k8s_openapi::Metadata | ||
+ kube::Resource<Scope = NamespaceResourceScope>, | ||
<T as kube::Resource>::DynamicType: std::default::Default, | ||
{ | ||
let client = Client::try_default().await.unwrap(); | ||
let api: Api<T> = match namespace { | ||
Some(ns) => Api::namespaced(client, &ns), | ||
None => Api::all(client), | ||
}; | ||
let lp = ListParams::default(); | ||
return api.list(&lp).await.unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pub mod cron_jobs; | ||
pub mod namespaces; | ||
pub mod pods; | ||
|
||
mod internal; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use k8s_openapi::api::core::v1::Pod; | ||
|
||
use kube::api::ObjectList; | ||
|
||
use super::internal::get_resource_list; | ||
|
||
#[tauri::command] | ||
pub async fn get_pods(namespace: Option<String>) -> ObjectList<Pod> { | ||
return get_resource_list(namespace).await; | ||
} |