diff --git a/src/components/Navigation.vue b/src/components/Navigation.vue index 2247ada..b8f719a 100644 --- a/src/components/Navigation.vue +++ b/src/components/Navigation.vue @@ -13,45 +13,45 @@ const { context } = injectStrict(KubeContextStateKey); interface NavigationGroup { title: string; - coreResources: string[]; + coreResourceKinds: string[]; apiGroupResources: string[]; } const navigationGroups: NavigationGroup[] = [ { title: "Workloads", - coreResources: ["pods"], + coreResourceKinds: ["Pod"], apiGroupResources: ["apps", "batch"], }, { title: "Config", - coreResources: ["configmaps", "resourcequotas", "secrets"], - apiGroupResources: [""], + coreResourceKinds: ["ConfigMap", "ResourceQuota", "Secret"], + apiGroupResources: [], }, { title: "Network", - coreResources: ["endpoints", "services", "endpointslices"], - apiGroupResources: ["networking.k8s.io"], + coreResourceKinds: ["Endpoints", "Service"], + apiGroupResources: ["networking.*"], }, { title: "Storage", - coreResources: ["persistentvolumeclaims"], - apiGroupResources: ["storage.k8s.io"], + coreResourceKinds: ["PersistentVolumeClaim"], + apiGroupResources: ["storage.*"], }, { title: "Scaling", - coreResources: [], - apiGroupResources: ["autoscaling"], + coreResourceKinds: [], + apiGroupResources: ["autoscaling.*"], }, { title: "Policies", - coreResources: ["poddisruptionbudgets", "limitranges"], - apiGroupResources: [], + coreResourceKinds: ["LimitRange"], + apiGroupResources: ["policy.*", "policies.*"], }, { title: "Access Control", - coreResources: ["serviceaccounts"], - apiGroupResources: ["rbac.authorization.k8s.io"], + coreResourceKinds: ["ServiceAccount", "Role", "RoleBinding"], + apiGroupResources: [".*authorization.*"], }, ]; @@ -60,22 +60,48 @@ const clusterResources = ref>(new Map()); const getCoreResourcesForGroup = (group: NavigationGroup) => { return Array.from(clusterResources.value.values()) .flat() - .filter((resource) => group.coreResources.includes(resource.name)); + .filter((resource) => group.coreResourceKinds.includes(resource.kind)) + .filter((resource) => !resource.name.includes("/")); }; const getApiResourcesForGroup = (group: NavigationGroup) => { return Array.from(clusterResources.value.keys()) - .filter((key) => group.apiGroupResources.includes(key)) + .filter((key) => { + return group.apiGroupResources.some((group) => { + return key.match(group); + }); + }) + .map((key) => clusterResources.value.get(key)!) + .flat() + .filter((resource) => !resource.name.includes("/")); +}; + +const getOtherResources = () => { + return Array.from(clusterResources.value.keys()) + .filter((key) => { + return !navigationGroups.some((group) => { + return group.apiGroupResources.some((group) => { + return key.match(group); + }); + }); + }) .map((key) => clusterResources.value.get(key)!) .flat() - .filter((resource) => resource.singularName !== ""); + .filter((resource) => !resource.name.includes("/")) + .filter( + (resource) => + !navigationGroups.some((group) => { + return group.coreResourceKinds.includes(resource.kind); + }) + ); }; const formatResourceKind = (kind: string) => { return pluralize(kind); }; -onMounted(() => { +const fetchResources = () => { + clusterResources.value.clear(); Kubernetes.getCoreApiVersions(context.value).then((results) => { results.forEach((version) => { Kubernetes.getCoreApiResources(context.value, version).then( @@ -110,6 +136,14 @@ onMounted(() => { .catch((error) => { console.error(error); }); +}; + +onMounted(() => { + fetchResources(); +}); + +watch(context, () => { + fetchResources(); }); @@ -120,57 +154,6 @@ onMounted(() => {
- { }" /> + + +
diff --git a/src/components/NavigationGroup.vue b/src/components/NavigationGroup.vue index c22b5eb..76caba4 100644 --- a/src/components/NavigationGroup.vue +++ b/src/components/NavigationGroup.vue @@ -1,9 +1,29 @@ diff --git a/src/views/Shell.vue b/src/views/Shell.vue index bea8553..bc7b30f 100644 --- a/src/views/Shell.vue +++ b/src/views/Shell.vue @@ -30,7 +30,7 @@ const openTerminal = () => { invoke("create_tty_session", { initCommand: [ "kubectl", - "edit", + "exec", "--tty", "--stdin", props.pod.metadata?.name as string,