-
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.
feat: add functionality to get replica sets (#37)
- Loading branch information
1 parent
f10877a
commit cfe472d
Showing
7 changed files
with
88 additions
and
43 deletions.
There are no files selected for viewing
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 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 |
---|---|---|
|
@@ -5,3 +5,4 @@ pub mod deployments; | |
pub mod jobs; | ||
pub mod namespaces; | ||
pub mod pods; | ||
pub mod replica_sets; |
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::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<String>) -> ObjectList<ReplicaSet> { | ||
let api: Api<ReplicaSet> = get_api(namespace).await; | ||
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
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,35 @@ | ||
import type { V1ReplicaSet } from "@kubernetes/client-node"; | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { invoke } from "@tauri-apps/api"; | ||
|
||
import { Table, TableHeader, TableBody, TableCell } from "../components/table"; | ||
import { useCurrentNamespace } from "../namespaces/namespaces"; | ||
|
||
export function ReplicaSets() { | ||
const { namespace } = useCurrentNamespace(); | ||
|
||
const result = useQuery(["replica-sets", namespace], () => { | ||
return invoke<{ items: V1ReplicaSet[] }>(`get_replica_sets`, { namespace }); | ||
}); | ||
|
||
const data = result.data?.items ?? []; | ||
|
||
return ( | ||
<div> | ||
<Table> | ||
<TableHeader headers={["Name", "Images", "Pods"]} /> | ||
<TableBody> | ||
{data.map((item) => ( | ||
<tr key={item.metadata?.uid}> | ||
<TableCell>{item.metadata?.name}</TableCell> | ||
<TableCell>{item.spec?.template?.spec?.containers[0].image}</TableCell> | ||
<TableCell> | ||
{item.status?.replicas} / {item.spec?.replicas} | ||
</TableCell> | ||
</tr> | ||
))} | ||
</TableBody> | ||
</Table> | ||
</div> | ||
); | ||
} |
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 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