Skip to content

Commit

Permalink
refactor: nav constants and kind handlers navigator paths
Browse files Browse the repository at this point in the history
  • Loading branch information
devcatalin committed Sep 13, 2021
1 parent b3235e1 commit 87ac228
Show file tree
Hide file tree
Showing 25 changed files with 70 additions and 61 deletions.
23 changes: 23 additions & 0 deletions src/constants/navSectionNames.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const K8S_RESOURCES = 'K8s Resources';
const WORKLOADS = 'Workloads';
const CONFIGURATION = 'Configuration';
const NETWORK = 'Network';
const STORAGE = 'Storage';
const ACCESS_CONTROL = 'Access Control';
const CUSTOM_RESOURCES = 'Custom Resources';

/** stores the order of subsections for each section */
const representation: Record<string, string[]> = {
[K8S_RESOURCES]: [WORKLOADS, CONFIGURATION, NETWORK, STORAGE, ACCESS_CONTROL, CUSTOM_RESOURCES],
};

export default {
representation,
K8S_RESOURCES,
WORKLOADS,
CONFIGURATION,
NETWORK,
STORAGE,
ACCESS_CONTROL,
CUSTOM_RESOURCES,
};
16 changes: 0 additions & 16 deletions src/constants/navigator.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/kindhandlers/ClusterRole.handler.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_ACCESS_CONTROL} from '@constants/navigator';
import navSectionNames from '@constants/navSectionNames';

const ClusterRoleHandler: ResourceKindHandler = {
kind: 'ClusterRole',
apiVersionMatcher: '**',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_ACCESS_CONTROL, 'ClusterRoles'],
navigatorPath: [navSectionNames.K8S_RESOURCES, navSectionNames.ACCESS_CONTROL, 'ClusterRoles'],
clusterApiVersion: 'rbac.authorization.k8s.io/v1',
validationSchemaPrefix: 'io.k8s.api.rbac.v1',
description: '',
Expand Down
4 changes: 2 additions & 2 deletions src/kindhandlers/ClusterRoleBinding.handler.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_ACCESS_CONTROL} from '@constants/navigator';
import navSectionNames from '@constants/navSectionNames';

const ClusterRoleBindingHandler: ResourceKindHandler = {
kind: 'ClusterRoleBinding',
apiVersionMatcher: '**',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_ACCESS_CONTROL, 'ClusterRoleBindings'],
navigatorPath: [navSectionNames.K8S_RESOURCES, navSectionNames.ACCESS_CONTROL, 'ClusterRoleBindings'],
clusterApiVersion: 'rbac.authorization.k8s.io/v1',
validationSchemaPrefix: 'io.k8s.api.rbac.v1',
description: '',
Expand Down
4 changes: 2 additions & 2 deletions src/kindhandlers/ConfigMap.handler.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_CONFIGURATION} from '@constants/navigator';
import navSectionNames from '@constants/navSectionNames';

const ConfigMapHandler: ResourceKindHandler = {
kind: 'ConfigMap',
apiVersionMatcher: '**',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_CONFIGURATION, 'ConfigMaps'],
navigatorPath: [navSectionNames.K8S_RESOURCES, navSectionNames.CONFIGURATION, 'ConfigMaps'],
clusterApiVersion: 'v1',
validationSchemaPrefix: 'io.k8s.api.core.v1',
description: '',
Expand Down
4 changes: 2 additions & 2 deletions src/kindhandlers/CronJob.handler.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_WORKLOADS} from '@constants/navigator';
import navSectionNames from '@constants/navSectionNames';
import {PodOutgoingRefMappers} from './common/outgoingRefMappers';

const CronJobHandler: ResourceKindHandler = {
kind: 'CronJob',
apiVersionMatcher: '**',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_WORKLOADS, 'CronJobs'],
navigatorPath: [navSectionNames.K8S_RESOURCES, navSectionNames.WORKLOADS, 'CronJobs'],
clusterApiVersion: 'batch/v1',
validationSchemaPrefix: 'io.k8s.api.batch.v1',
description: '',
Expand Down
4 changes: 2 additions & 2 deletions src/kindhandlers/CustomResourceDefinition.handler.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_CUSTOM_RESOURCES} from '@constants/navigator';
import navSectionNames from '@constants/navSectionNames';

const CustomResourceDefinitionHandler: ResourceKindHandler = {
kind: 'CustomResourceDefinition',
apiVersionMatcher: '**',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_CUSTOM_RESOURCES, 'Custom Resources'],
navigatorPath: [navSectionNames.K8S_RESOURCES, navSectionNames.CUSTOM_RESOURCES, 'Custom Resources'],
clusterApiVersion: 'apiextensions.k8s.io/v1',
validationSchemaPrefix: 'io.k8s.apiextensions-apiserver.pkg.apis.apiextensions.v1',
description: '',
Expand Down
4 changes: 2 additions & 2 deletions src/kindhandlers/DaemonSet.handler.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_WORKLOADS} from '@constants/navigator';
import navSectionNames from '@constants/navSectionNames';
import {PodOutgoingRefMappers} from './common/outgoingRefMappers';

const DaemonSetHandler: ResourceKindHandler = {
kind: 'DaemonSet',
apiVersionMatcher: '**',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_WORKLOADS, 'DaemonSets'],
navigatorPath: [navSectionNames.K8S_RESOURCES, navSectionNames.WORKLOADS, 'DaemonSets'],
clusterApiVersion: 'apps/v1',
validationSchemaPrefix: 'io.k8s.api.apps.v1',
description: '',
Expand Down
4 changes: 2 additions & 2 deletions src/kindhandlers/Deployment.handler.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_WORKLOADS} from '@constants/navigator';
import navSectionNames from '@constants/navSectionNames';
import {PodOutgoingRefMappers} from './common/outgoingRefMappers';

const DeploymentHandler: ResourceKindHandler = {
kind: 'Deployment',
apiVersionMatcher: '**',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_WORKLOADS, 'Deployments'],
navigatorPath: [navSectionNames.K8S_RESOURCES, navSectionNames.WORKLOADS, 'Deployments'],
clusterApiVersion: 'apps/v1',
validationSchemaPrefix: 'io.k8s.api.apps.v1',
description: '',
Expand Down
4 changes: 2 additions & 2 deletions src/kindhandlers/Endpoints.handler.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_NETWORK} from '@constants/navigator';
import navSectionNames from '@constants/navSectionNames';

const EndpointsHandler: ResourceKindHandler = {
kind: 'Endpoints',
apiVersionMatcher: '**',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_NETWORK, 'Endpoints'],
navigatorPath: [navSectionNames.K8S_RESOURCES, navSectionNames.NETWORK, 'Endpoints'],
clusterApiVersion: 'v1',
validationSchemaPrefix: 'io.k8s.api.core.v1',
description: '',
Expand Down
4 changes: 2 additions & 2 deletions src/kindhandlers/Ingress.handler.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_NETWORK} from '@constants/navigator';
import navSectionNames from '@constants/navSectionNames';

const IngressHandler: ResourceKindHandler = {
kind: 'Ingress',
apiVersionMatcher: '**',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_NETWORK, 'Ingresses'],
navigatorPath: [navSectionNames.K8S_RESOURCES, navSectionNames.NETWORK, 'Ingresses'],
clusterApiVersion: 'networking.k8s.io/v1',
validationSchemaPrefix: 'io.k8s.api.networking.v1',
description: '',
Expand Down
4 changes: 2 additions & 2 deletions src/kindhandlers/Job.handler.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_WORKLOADS} from '@constants/navigator';
import navSectionNames from '@constants/navSectionNames';
import {PodOutgoingRefMappers} from './common/outgoingRefMappers';

const JobHandler: ResourceKindHandler = {
kind: 'Job',
apiVersionMatcher: '**',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_WORKLOADS, 'Jobs'],
navigatorPath: [navSectionNames.K8S_RESOURCES, navSectionNames.WORKLOADS, 'Jobs'],
clusterApiVersion: 'batch/v1',
validationSchemaPrefix: 'io.k8s.api.batch.v1',
description: '',
Expand Down
4 changes: 2 additions & 2 deletions src/kindhandlers/NetworkPolicy.handler.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_NETWORK} from '@constants/navigator';
import navSectionNames from '@constants/navSectionNames';

const NetworkPolicyHandler: ResourceKindHandler = {
kind: 'NetworkPolicy',
apiVersionMatcher: '**',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_NETWORK, 'NetworkPolicies'],
navigatorPath: [navSectionNames.K8S_RESOURCES, navSectionNames.NETWORK, 'NetworkPolicies'],
clusterApiVersion: 'networking.k8s.io/v1',
validationSchemaPrefix: 'io.k8s.api.networking.v1',
description: '',
Expand Down
4 changes: 2 additions & 2 deletions src/kindhandlers/PersistentVolume.handler.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_STORAGE} from '@constants/navigator';
import navSectionNames from '@constants/navSectionNames';

const PersistentVolumeHandler: ResourceKindHandler = {
kind: 'PersistentVolume',
apiVersionMatcher: '**',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_STORAGE, 'PersistentVolumes'],
navigatorPath: [navSectionNames.K8S_RESOURCES, navSectionNames.STORAGE, 'PersistentVolumes'],
clusterApiVersion: 'v1',
validationSchemaPrefix: 'io.k8s.api.core.v1',
description: '',
Expand Down
4 changes: 2 additions & 2 deletions src/kindhandlers/PersistentVolumeClaim.handler.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_STORAGE} from '@constants/navigator';
import navSectionNames from '@constants/navSectionNames';

const PersistentVolumeClaimHandler: ResourceKindHandler = {
kind: 'PersistentVolumeClaim',
apiVersionMatcher: '**',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_STORAGE, 'PersistentVolumeClaims'],
navigatorPath: [navSectionNames.K8S_RESOURCES, navSectionNames.STORAGE, 'PersistentVolumeClaims'],
clusterApiVersion: 'v1',
validationSchemaPrefix: 'io.k8s.api.core.v1',
description: '',
Expand Down
4 changes: 2 additions & 2 deletions src/kindhandlers/Pod.handler.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_WORKLOADS} from '@constants/navigator';
import navSectionNames from '@constants/navSectionNames';
import {PodOutgoingRefMappers} from './common/outgoingRefMappers';

const PodHandler: ResourceKindHandler = {
kind: 'Pod',
apiVersionMatcher: '**',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_WORKLOADS, 'Pods'],
navigatorPath: [navSectionNames.K8S_RESOURCES, navSectionNames.WORKLOADS, 'Pods'],
clusterApiVersion: 'v1',
validationSchemaPrefix: 'io.k8s.api.core.v1',
description: '',
Expand Down
4 changes: 2 additions & 2 deletions src/kindhandlers/ReplicaSet.handler.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_WORKLOADS} from '@constants/navigator';
import navSectionNames from '@constants/navSectionNames';
import {PodOutgoingRefMappers} from './common/outgoingRefMappers';

const ReplicaSetHandler: ResourceKindHandler = {
kind: 'ReplicaSet',
apiVersionMatcher: '**',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_WORKLOADS, 'ReplicaSets'],
navigatorPath: [navSectionNames.K8S_RESOURCES, navSectionNames.WORKLOADS, 'ReplicaSets'],
clusterApiVersion: 'apps/v1',
validationSchemaPrefix: 'io.k8s.api.apps.v1',
description: '',
Expand Down
4 changes: 2 additions & 2 deletions src/kindhandlers/ReplicationController.handler.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_WORKLOADS} from '@constants/navigator';
import navSectionNames from '@constants/navSectionNames';
import {PodOutgoingRefMappers} from './common/outgoingRefMappers';

const ReplicationControllerHandler: ResourceKindHandler = {
kind: 'ReplicationController',
apiVersionMatcher: '**',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_WORKLOADS, 'ReplicationControllers'],
navigatorPath: [navSectionNames.K8S_RESOURCES, navSectionNames.WORKLOADS, 'ReplicationControllers'],
clusterApiVersion: 'v1',
validationSchemaPrefix: 'io.k8s.api.core.v1',
description: '',
Expand Down
4 changes: 2 additions & 2 deletions src/kindhandlers/Role.handler.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_ACCESS_CONTROL} from '@constants/navigator';
import navSectionNames from '@constants/navSectionNames';

const RoleHandler: ResourceKindHandler = {
kind: 'Role',
apiVersionMatcher: '**',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_ACCESS_CONTROL, 'Roles'],
navigatorPath: [navSectionNames.K8S_RESOURCES, navSectionNames.ACCESS_CONTROL, 'Roles'],
clusterApiVersion: 'rbac.authorization.k8s.io/v1',
validationSchemaPrefix: 'io.k8s.api.rbac.v1',
description: '',
Expand Down
4 changes: 2 additions & 2 deletions src/kindhandlers/RoleBinding.handler.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_ACCESS_CONTROL} from '@constants/navigator';
import navSectionNames from '@constants/navSectionNames';

const RoleBindingHandler: ResourceKindHandler = {
kind: 'RoleBinding',
apiVersionMatcher: '**',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_ACCESS_CONTROL, 'RoleBindings'],
navigatorPath: [navSectionNames.K8S_RESOURCES, navSectionNames.ACCESS_CONTROL, 'RoleBindings'],
clusterApiVersion: 'rbac.authorization.k8s.io/v1',
validationSchemaPrefix: 'io.k8s.api.rbac.v1',
description: '',
Expand Down
4 changes: 2 additions & 2 deletions src/kindhandlers/Secret.handler.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_CONFIGURATION} from '@constants/navigator';
import navSectionNames from '@constants/navSectionNames';

const SecretHandler: ResourceKindHandler = {
kind: 'Secret',
apiVersionMatcher: '**',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_CONFIGURATION, 'Secrets'],
navigatorPath: [navSectionNames.K8S_RESOURCES, navSectionNames.CONFIGURATION, 'Secrets'],
clusterApiVersion: 'v1',
validationSchemaPrefix: 'io.k8s.api.core.v1',
description: '',
Expand Down
4 changes: 2 additions & 2 deletions src/kindhandlers/Service.handler.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_NETWORK} from '@constants/navigator';
import navSectionNames from '@constants/navSectionNames';

const ServiceHandler: ResourceKindHandler = {
kind: 'Service',
apiVersionMatcher: '**',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_NETWORK, 'Services'],
navigatorPath: [navSectionNames.K8S_RESOURCES, navSectionNames.NETWORK, 'Services'],
clusterApiVersion: 'v1',
validationSchemaPrefix: 'io.k8s.api.core.v1',
description: '',
Expand Down
4 changes: 2 additions & 2 deletions src/kindhandlers/ServiceAccount.handler.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_ACCESS_CONTROL} from '@constants/navigator';
import navSectionNames from '@constants/navSectionNames';

const ServiceAccountHandler: ResourceKindHandler = {
kind: 'ServiceAccount',
apiVersionMatcher: '**',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_ACCESS_CONTROL, 'Service Accounts'],
navigatorPath: [navSectionNames.K8S_RESOURCES, navSectionNames.ACCESS_CONTROL, 'Service Accounts'],
clusterApiVersion: 'v1',
validationSchemaPrefix: 'io.k8s.api.core.v1',
description: '',
Expand Down
4 changes: 2 additions & 2 deletions src/kindhandlers/StatefulSet.handler.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as k8s from '@kubernetes/client-node';
import {ResourceKindHandler} from '@models/resourcekindhandler';
import {NAV_K8S_RESOURCES, SECTION_WORKLOADS} from '@constants/navigator';
import navSectionNames from '@constants/navSectionNames';
import {PodOutgoingRefMappers} from './common/outgoingRefMappers';

const StatefulSetHandler: ResourceKindHandler = {
kind: 'StatefulSet',
apiVersionMatcher: '**',
navigatorPath: [NAV_K8S_RESOURCES, SECTION_WORKLOADS, 'StatefulSets'],
navigatorPath: [navSectionNames.K8S_RESOURCES, navSectionNames.WORKLOADS, 'StatefulSets'],
clusterApiVersion: 'apps/v1',
validationSchemaPrefix: 'io.k8s.api.apps.v1',
description: '',
Expand Down
4 changes: 3 additions & 1 deletion src/redux/initialState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import {UiState} from '@models/ui';
import electronStore from '@utils/electronStore';
import {ObjectNavigator, NavigatorSection, NavigatorSubSection} from '@models/navigator';
import {ResourceKindHandlers} from '@src/kindhandlers';
import {NAV_K8S_RESOURCES_SECTIONS_ORDER} from '@constants/navigator';
import navSectionNames from '@constants/navSectionNames';

const NAV_K8S_RESOURCES_SECTIONS_ORDER = navSectionNames.representation[navSectionNames.K8S_RESOURCES];

const initialAppState: AppState = {
selectionHistory: [],
Expand Down

0 comments on commit 87ac228

Please sign in to comment.