-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jeroen Nijhuis
committed
Dec 21, 2023
1 parent
d339cda
commit f7b58c0
Showing
16 changed files
with
230 additions
and
72 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
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
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 |
---|---|---|
@@ -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; | ||
}; | ||
} |
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,40 @@ | ||
import { V1Deployment, V1Service } from "@kubernetes/client-node"; | ||
import { ColumnDef } from "@tanstack/vue-table"; | ||
|
||
export const columns: ColumnDef<V1Service>[] = [ | ||
{ | ||
accessorKey: "metadata.name", | ||
header: "Name", | ||
}, | ||
{ | ||
header: "Type", | ||
accessorKey: "spec.type", | ||
}, | ||
{ | ||
header: "Cluster IP", | ||
accessorKey: "spec.clusterIP", | ||
}, | ||
{ | ||
header: "External IP", | ||
accessorFn: (row) => { | ||
return row.spec?.externalIPs?.join(", ") || ""; | ||
}, | ||
}, | ||
{ | ||
header: "Ports", | ||
accessorFn: (row) => { | ||
return ( | ||
row.spec?.ports?.map((p) => `${p.name}:${p.port}`).join(", ") || "" | ||
); | ||
}, | ||
}, | ||
{ | ||
header: "Age", | ||
accessorFn: (row) => { | ||
const date = new Date(row.metadata?.creationTimestamp || ""); | ||
return `${Math.floor( | ||
(Date.now() - date.getTime()) / 1000 / 60 / 60 / 24 | ||
)}d`; | ||
}, | ||
}, | ||
]; |
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,23 +1,30 @@ | ||
<script setup lang="ts"> | ||
import { ScrollAreaScrollbar, type ScrollAreaScrollbarProps, ScrollAreaThumb } from 'radix-vue' | ||
import { cn } from '@/lib/utils' | ||
import { | ||
ScrollAreaScrollbar, | ||
type ScrollAreaScrollbarProps, | ||
ScrollAreaThumb, | ||
} from "radix-vue"; | ||
import { cn } from "@/lib/utils"; | ||
const props = withDefaults(defineProps<ScrollAreaScrollbarProps>(), { | ||
orientation: 'vertical', | ||
}) | ||
orientation: "vertical", | ||
}); | ||
</script> | ||
|
||
<template> | ||
<ScrollAreaScrollbar | ||
v-bind="props" | ||
:class=" | ||
cn('flex touch-none select-none transition-colors', | ||
orientation === 'vertical' | ||
&& 'h-full w-2.5 border-l border-l-transparent p-[1px]', | ||
orientation === 'horizontal' | ||
&& 'h-2.5 border-t border-t-transparent p-[1px]', | ||
$attrs.class ?? '')" | ||
cn( | ||
'flex touch-none select-none transition-colors', | ||
orientation === 'vertical' && | ||
'h-full w-2.5 border-l border-l-transparent p-[1px]', | ||
orientation === 'horizontal' && | ||
'h-2.5 border-t border-t-transparent p-[1px]', | ||
$attrs.class ?? '' | ||
) | ||
" | ||
> | ||
<ScrollAreaThumb class="relative flex-1 rounded-full bg-border" /> | ||
<ScrollAreaThumb class="relative flex-1 rounded-full bg-white opacity-25" /> | ||
</ScrollAreaScrollbar> | ||
</template> |
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
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
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
Oops, something went wrong.