Skip to content

Commit

Permalink
feat: add navigatorPath to all kind handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
devcatalin committed Aug 16, 2021
1 parent 1da060b commit 10f086c
Show file tree
Hide file tree
Showing 24 changed files with 52 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/constants/navigator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const NAV_K8S_RESOURCES = 'K8s Resources';
export const SECTION_WORKLOADS = 'Workloads';
export const SECTION_CONFIGURATION = 'Configuration';
export const SECTION_NETWORK = 'Network';
export const SECTION_STORAGE = 'Storage';
export const SECTION_ACCESS_CONTROL = 'Access Control';
export const SECTION_CUSTOM_RESOURCES = 'Custom Resources';
2 changes: 2 additions & 0 deletions src/kindhandlers/ClusterRole.handler.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_ACCESS_CONTROL} from '@constants/navigator';

const ClusterRoleHandler: ResourceKindHandler = {
kind: 'ClusterRole',
apiVersionMatcher: '*',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_ACCESS_CONTROL, 'ClusterRoles'],
clusterApiVersion: 'rbac.authorization.k8s.io/v1',
description: '',
getResourceFromCluster(kubeconfig: k8s.KubeConfig, name: string): Promise<any> {
Expand Down
2 changes: 2 additions & 0 deletions src/kindhandlers/ClusterRoleBinding.handler.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_ACCESS_CONTROL} from '@constants/navigator';

const ClusterRoleBindingHandler: ResourceKindHandler = {
kind: 'ClusterRoleBinding',
apiVersionMatcher: '*',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_ACCESS_CONTROL, 'ClusterRoleBindings'],
clusterApiVersion: 'rbac.authorization.k8s.io/v1',
description: '',
getResourceFromCluster(kubeconfig: k8s.KubeConfig, name: string): Promise<any> {
Expand Down
2 changes: 2 additions & 0 deletions src/kindhandlers/ConfigMap.handler.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_CONFIGURATION} from '@constants/navigator';

const ConfigMapHandler: ResourceKindHandler = {
kind: 'ConfigMap',
apiVersionMatcher: '*',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_CONFIGURATION, 'ConfigMaps'],
clusterApiVersion: 'v1',
description: '',
getResourceFromCluster(kubeconfig: k8s.KubeConfig, name: string, namespace: string): Promise<any> {
Expand Down
2 changes: 2 additions & 0 deletions src/kindhandlers/CronJob.handler.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_WORKLOADS} from '@constants/navigator';
import {PodOutgoingRefMappers} from './common/outgoingRefMappers';

const CronJobHandler: ResourceKindHandler = {
kind: 'CronJob',
apiVersionMatcher: '*',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_WORKLOADS, 'CronJobs'],
clusterApiVersion: 'batch/v1',
description: '',
getResourceFromCluster(kubeconfig: k8s.KubeConfig, name: string, namespace: string): Promise<any> {
Expand Down
2 changes: 2 additions & 0 deletions src/kindhandlers/CustomResourceDefinition.handler.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_CUSTOM_RESOURCES} from '@constants/navigator';

const CustomResourceDefinitionHandler: ResourceKindHandler = {
kind: 'CustomResourceDefinition',
apiVersionMatcher: '*',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_CUSTOM_RESOURCES, 'Custom Resources'],
clusterApiVersion: 'apiextensions.k8s.io/v1',
description: '',
getResourceFromCluster(kubeconfig: k8s.KubeConfig, name: string): Promise<any> {
Expand Down
2 changes: 2 additions & 0 deletions src/kindhandlers/DaemonSet.handler.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_WORKLOADS} from '@constants/navigator';
import {PodOutgoingRefMappers} from './common/outgoingRefMappers';

const DaemonSetHandler: ResourceKindHandler = {
kind: 'DaemonSet',
apiVersionMatcher: '*',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_WORKLOADS, 'DaemonSets'],
clusterApiVersion: 'apps/v1',
description: '',
getResourceFromCluster(kubeconfig: k8s.KubeConfig, name: string, namespace: string): Promise<any> {
Expand Down
2 changes: 2 additions & 0 deletions src/kindhandlers/Deployment.handler.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_WORKLOADS} from '@constants/navigator';
import {PodOutgoingRefMappers} from './common/outgoingRefMappers';

const DeploymentHandler: ResourceKindHandler = {
kind: 'Deployment',
apiVersionMatcher: '*',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_WORKLOADS, 'Deployments'],
clusterApiVersion: 'apps/v1',
description: '',
getResourceFromCluster(kubeconfig: k8s.KubeConfig, name: string, namespace: string): Promise<any> {
Expand Down
2 changes: 2 additions & 0 deletions src/kindhandlers/Endpoint.handler.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_NETWORK} from '@constants/navigator';

const EndpointHandler: ResourceKindHandler = {
kind: 'Endpoint',
apiVersionMatcher: '*',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_NETWORK, 'Endpoints'],
clusterApiVersion: 'v1',
description: '',
getResourceFromCluster(kubeconfig: k8s.KubeConfig, name: string, namespace: string): Promise<any> {
Expand Down
2 changes: 2 additions & 0 deletions src/kindhandlers/Ingress.handler.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_NETWORK} from '@constants/navigator';

const IngressHandler: ResourceKindHandler = {
kind: 'Ingress',
apiVersionMatcher: '*',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_NETWORK, 'Ingresses'],
clusterApiVersion: 'networking.k8s.io/v1',
description: '',
getResourceFromCluster(kubeconfig: k8s.KubeConfig, name: string, namespace: string): Promise<any> {
Expand Down
2 changes: 2 additions & 0 deletions src/kindhandlers/Job.handler.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_WORKLOADS} from '@constants/navigator';
import {PodOutgoingRefMappers} from './common/outgoingRefMappers';

const JobHandler: ResourceKindHandler = {
kind: 'Job',
apiVersionMatcher: '*',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_WORKLOADS, 'Jobs'],
clusterApiVersion: 'batch/v1',
description: '',
getResourceFromCluster(kubeconfig: k8s.KubeConfig, name: string, namespace: string): Promise<any> {
Expand Down
2 changes: 2 additions & 0 deletions src/kindhandlers/NetworkPolicy.handler.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_NETWORK} from '@constants/navigator';

const NetworkPolicyHandler: ResourceKindHandler = {
kind: 'NetworkPolicy',
apiVersionMatcher: '*',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_NETWORK, 'NetworkPolicies'],
clusterApiVersion: 'networking.k8s.io/v1',
description: '',
getResourceFromCluster(kubeconfig: k8s.KubeConfig, name: string, namespace: string): Promise<any> {
Expand Down
2 changes: 2 additions & 0 deletions src/kindhandlers/PersistentVolume.handler.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_STORAGE} from '@constants/navigator';

const PersistentVolumeHandler: ResourceKindHandler = {
kind: 'PersistentVolume',
apiVersionMatcher: '*',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_STORAGE, 'PersistentVolumes'],
clusterApiVersion: 'v1',
description: '',
getResourceFromCluster(kubeconfig: k8s.KubeConfig, name: string): Promise<any> {
Expand Down
2 changes: 2 additions & 0 deletions src/kindhandlers/PersistentVolumeClaim.handler.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_STORAGE} from '@constants/navigator';

const PersistentVolumeClaimHandler: ResourceKindHandler = {
kind: 'PersistentVolumeClaim',
apiVersionMatcher: '*',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_STORAGE, 'PersistentVolumeClaims'],
clusterApiVersion: 'v1',
description: '',
getResourceFromCluster(kubeconfig: k8s.KubeConfig, name: string, namespace: string): Promise<any> {
Expand Down
2 changes: 2 additions & 0 deletions src/kindhandlers/Pod.handler.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_WORKLOADS} from '@constants/navigator';
import {PodOutgoingRefMappers} from './common/outgoingRefMappers';

const PodHandler: ResourceKindHandler = {
kind: 'Pod',
apiVersionMatcher: '*',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_WORKLOADS, 'Pods'],
clusterApiVersion: 'v1',
description: '',
getResourceFromCluster(kubeconfig: k8s.KubeConfig, name: string, namespace: string): Promise<any> {
Expand Down
2 changes: 2 additions & 0 deletions src/kindhandlers/ReplicaSet.handler.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_WORKLOADS} from '@constants/navigator';
import {PodOutgoingRefMappers} from './common/outgoingRefMappers';

const ReplicaSetHandler: ResourceKindHandler = {
kind: 'ReplicaSet',
apiVersionMatcher: '*',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_WORKLOADS, 'ReplicaSets'],
clusterApiVersion: 'apps/v1',
description: '',
getResourceFromCluster(kubeconfig: k8s.KubeConfig, name: string, namespace: string): Promise<any> {
Expand Down
2 changes: 2 additions & 0 deletions src/kindhandlers/ReplicationController.handler.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_WORKLOADS} from '@constants/navigator';
import {PodOutgoingRefMappers} from './common/outgoingRefMappers';

const ReplicationControllerHandler: ResourceKindHandler = {
kind: 'ReplicationController',
apiVersionMatcher: '*',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_WORKLOADS, 'ReplicationControllers'],
clusterApiVersion: 'v1',
description: '',
getResourceFromCluster(kubeconfig: k8s.KubeConfig, name: string, namespace: string): Promise<any> {
Expand Down
2 changes: 2 additions & 0 deletions src/kindhandlers/Role.handler.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_ACCESS_CONTROL} from '@constants/navigator';

const RoleHandler: ResourceKindHandler = {
kind: 'Role',
apiVersionMatcher: '*',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_ACCESS_CONTROL, 'Roles'],
clusterApiVersion: 'rbac.authorization.k8s.io/v1',
description: '',
getResourceFromCluster(kubeconfig: k8s.KubeConfig, name: string, namespace: string): Promise<any> {
Expand Down
2 changes: 2 additions & 0 deletions src/kindhandlers/RoleBinding.handler.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_ACCESS_CONTROL} from '@constants/navigator';

const RoleBindingHandler: ResourceKindHandler = {
kind: 'RoleBinding',
apiVersionMatcher: '*',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_ACCESS_CONTROL, 'RoleBindings'],
clusterApiVersion: 'rbac.authorization.k8s.io/v1',
description: '',
getResourceFromCluster(kubeconfig: k8s.KubeConfig, name: string, namespace: string): Promise<any> {
Expand Down
2 changes: 2 additions & 0 deletions src/kindhandlers/Secret.handler.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_CONFIGURATION} from '@constants/navigator';

const SecretHandler: ResourceKindHandler = {
kind: 'Secret',
apiVersionMatcher: '*',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_CONFIGURATION, 'Secrets'],
clusterApiVersion: 'v1',
description: '',
getResourceFromCluster(kubeconfig: k8s.KubeConfig, name: string, namespace: string): Promise<any> {
Expand Down
2 changes: 2 additions & 0 deletions src/kindhandlers/Service.handler.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_NETWORK} from '@constants/navigator';

const ServiceHandler: ResourceKindHandler = {
kind: 'Service',
apiVersionMatcher: '*',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_NETWORK, 'Services'],
clusterApiVersion: 'v1',
description: '',
getResourceFromCluster(kubeconfig: k8s.KubeConfig, name: string, namespace: string): Promise<any> {
Expand Down
2 changes: 2 additions & 0 deletions src/kindhandlers/ServiceAccount.handler.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_ACCESS_CONTROL} from '@constants/navigator';

const ServiceAccountHandler: ResourceKindHandler = {
kind: 'ServiceAccount',
apiVersionMatcher: '*',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_ACCESS_CONTROL, 'Service Accounts'],
clusterApiVersion: 'v1',
description: '',
getResourceFromCluster(kubeconfig: k8s.KubeConfig, name: string, namespace: string): Promise<any> {
Expand Down
2 changes: 2 additions & 0 deletions src/kindhandlers/StatefulSet.handler.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_WORKLOADS} from '@constants/navigator';
import {PodOutgoingRefMappers} from './common/outgoingRefMappers';

const StatefulSetHandler: ResourceKindHandler = {
kind: 'StatefulSet',
apiVersionMatcher: '*',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_WORKLOADS, 'StatefulSets'],
clusterApiVersion: 'apps/v1',
description: '',
getResourceFromCluster(kubeconfig: k8s.KubeConfig, name: string, namespace: string): Promise<any> {
Expand Down
2 changes: 1 addition & 1 deletion src/models/resourcekindhandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ interface ResourceKindHandler {
* which has the kindSelector equal to the resource kind
*/

navigatorPath?: [navigatorName: string, sectionName: string, subsectionName: string];
navigatorPath: [navigatorName: string, sectionName: string, subsectionName: string];

/**
* optional JSON Schema and symbol-matchers to pass to the source editor
Expand Down

0 comments on commit 10f086c

Please sign in to comment.