diff --git a/.github/renovate.json b/.github/renovate.json index 836511b..69eac68 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -30,6 +30,6 @@ "prCreation": "not-pending" } ], - "timezone": "Europe/Helsinki", + "timezone": "Europe/Amsterdam", "dependencyDashboard": true } \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f8a9f12..1b1fef8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,10 +20,6 @@ jobs: runs-on: ${{ matrix.platform }} steps: - uses: actions/checkout@v3 - - uses: pnpm/action-setup@v2 - with: - version: 2 - run_install: true - name: Use Node.js uses: actions/setup-node@v3 @@ -31,6 +27,9 @@ jobs: node-version: 18 cache: 'pnpm' + - name: Install dependencies + run: npm install + - name: install Rust stable uses: actions-rs/toolchain@v1 with: @@ -43,7 +42,7 @@ jobs: sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf - name: Build Vite + Tauri - run: pnpm build + run: npm run build - name: Create release uses: tauri-apps/tauri-action@v0 diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml index 1808eb7..bbf992c 100644 --- a/.github/workflows/test-build.yml +++ b/.github/workflows/test-build.yml @@ -27,17 +27,14 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Install pnpm + deps - uses: pnpm/action-setup@v2 - with: - version: 8 - run_install: true - - name: Use Node.js uses: actions/setup-node@v3 with: node-version: 18 cache: 'pnpm' + + - name: Install dependencies + run: npm install - name: Install Rust stable uses: actions-rs/toolchain@v1 @@ -51,4 +48,4 @@ jobs: sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf - name: Build Vite + Tauri - run: pnpm build + run: npm run build diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bd72a93..ca05125 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,16 +28,15 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: pnpm/action-setup@v2 - with: - version: 8 - run_install: true - name: Use Node.js uses: actions/setup-node@v3 with: node-version: 18 - cache: 'pnpm' + cache: 'npm' + + - name: Install dependencies + run: npm ci - name: Run unit tests - run: pnpm test + run: npm test diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 29cc08b..1ae6160 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -5,7 +5,7 @@ use tauri::api::shell; use tauri::{CustomMenuItem, Manager, Menu, Submenu}; use k8s_openapi::api::apps::v1::Deployment; -use k8s_openapi::api::core::v1::{Namespace, Pod}; +use k8s_openapi::api::core::v1::{Namespace, Pod, Service}; use kube::api::ListParams; use kube::config::{KubeConfigOptions, Kubeconfig, KubeconfigError}; use kube::{api::Api, Client, Config, Error}; @@ -93,11 +93,6 @@ async fn list_contexts() -> Result, SerializableKubeError> { async fn client_with_context(context: &str) -> Result { if context.to_string() != CURRENT_CONTEXT.lock().unwrap().as_ref().unwrap().clone() { - println!( - "client_with_context - context changed from {} to {}", - CURRENT_CONTEXT.lock().unwrap().as_ref().unwrap().clone(), - context - ); let options = KubeConfigOptions { context: Some(context.to_string()), cluster: None, @@ -176,6 +171,21 @@ async fn list_deployments( .map_err(|err| SerializableKubeError::from(err)); } +#[tauri::command] +async fn list_services( + context: &str, + namespace: &str, +) -> Result, SerializableKubeError> { + let client = client_with_context(context).await?; + let services_api: Api = Api::namespaced(client, namespace); + + return services_api + .list(&ListParams::default()) + .await + .map(|services| services.items) + .map_err(|err| SerializableKubeError::from(err)); +} + struct TerminalSession { writer: Arc>>, } @@ -288,6 +298,7 @@ fn main() { list_pods, get_pod, list_deployments, + list_services, create_tty_session, stop_tty_session, write_to_pty diff --git a/src/command-palette/SwitchContext.ts b/src/command-palette/SwitchContext.ts index f881807..d9d5877 100644 --- a/src/command-palette/SwitchContext.ts +++ b/src/command-palette/SwitchContext.ts @@ -1,37 +1,47 @@ -import { Command } from "@/command-palette"; +import { Kubernetes } from "@/services/Kubernetes"; export function SwitchContext( setContext: (context: string) => void, setNamespace: (namespace: string) => void ) { + const contextCache = { + contexts: [] as string[], + }; + const namespaceCache = {} as { [key: string]: string[] }; + + Kubernetes.getContexts().then((contexts) => { + contextCache["contexts"] = contexts; + + contexts.map((context) => { + Kubernetes.getNamespaces(context).then((namespaces) => { + namespaceCache[context] = namespaces.map( + (namespace) => namespace.metadata?.name || "" + ); + }); + }); + }); + return { id: "switch-context", name: "Switch context", description: "Switch between contexts and namespaces", commands: async () => { - return [ - { - name: "sre-eks-production-1 - all", - execute: () => { - setContext("sre-eks-production-1"); - setNamespace("all"); - }, - }, - { - name: "sre-eks-production-1 - backoffice-platform", - execute: () => { - setContext("sre-eks-production-1"); - setNamespace("backoffice-platform"); - }, - }, - { - name: "sre-eks-staging-1 - tms", - execute: () => { - setContext("sre-eks-staging-1"); - setNamespace("tms"); + return contextCache["contexts"].map((context) => { + return { + name: context, + commands: async () => { + return namespaceCache[context].map((namespace) => { + return { + name: namespace, + execute: () => { + setContext(context); + setNamespace(namespace); + }, + }; + }); }, - }, - ]; + }; + }); }, - } as Command; + }; } diff --git a/src/components/RouterViewport.vue b/src/components/RouterViewport.vue index 88e0e6f..af5119e 100644 --- a/src/components/RouterViewport.vue +++ b/src/components/RouterViewport.vue @@ -3,7 +3,7 @@ import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area";