-
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 deployment list (#16)
- Loading branch information
1 parent
592a430
commit e20a331
Showing
6 changed files
with
68 additions
and
23 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use k8s_openapi::api::apps::v1::Deployment; | ||
use kube::core::ObjectList; | ||
|
||
use super::internal::get_resource_list; | ||
|
||
#[tauri::command] | ||
pub async fn get_deployments(namespace: Option<String>) -> ObjectList<Deployment> { | ||
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pub mod cron_jobs; | ||
pub mod deployments; | ||
pub mod namespaces; | ||
pub mod pods; | ||
|
||
|
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 { V1Deployment } 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 Deployments() { | ||
const { namespace } = useCurrentNamespace(); | ||
|
||
const result = useQuery(["deployments", namespace], () => { | ||
return invoke<{ items: V1Deployment[] }>(`get_deployments`, { namespace }); | ||
}); | ||
|
||
const data = result.data?.items ?? []; | ||
|
||
return ( | ||
<div> | ||
<Table> | ||
<TableHeader headers={["Name", "Image", "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?.availableReplicas} / {item.status?.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