From cff729fb431ee7ea3e9ae7fe98e4ddaa07029e75 Mon Sep 17 00:00:00 2001 From: typescreep Date: Wed, 11 Jun 2025 17:37:45 +0300 Subject: [PATCH] more envs --- .env | 3 +++ .env.options.dist | 5 ++++- server/index.ts | 14 +++++++++++--- .../organisms/ListProjects/ListProjects.tsx | 12 +++++++++--- src/constants/customizationApiGroupAndVersion.ts | 4 ++++ src/hooks/useNavSelector.ts | 13 ++++++++----- src/pages/TableApiPage/TableApiPage.tsx | 10 +++++++--- src/pages/TableBuiltinPage/TableBuiltinPage.tsx | 8 ++++++-- src/pages/TableCrdPage/TableCrdPage.tsx | 8 ++++++-- 9 files changed, 58 insertions(+), 19 deletions(-) diff --git a/.env b/.env index 0e26a87..7e23104 100644 --- a/.env +++ b/.env @@ -1,7 +1,10 @@ VITE_CUSTOMIZATION_API_GROUP=incloud.io VITE_CUSTOMIZATION_API_VERSION=v1alpha +VITE_PROJECTS_API_GROUP=incloud.io VITE_PROJECTS_VERSION=v1alpha VITE_PROJECTS_RESOURCE_NAME=projects VITE_MARKETPLACE_RESOURCE_NAME=marketplacepanels VITE_MARKETPLACE_KIND=MarketplacePanel +VITE_INSTANCES_API_GROUP=incloud.io VITE_INSTANCES_VERSION=v1alpha1 +VITE_INSTANCES_RESOURCE_NAME=v1alpha1 diff --git a/.env.options.dist b/.env.options.dist index 7a1facc..7f4a5af 100644 --- a/.env.options.dist +++ b/.env.options.dist @@ -1,8 +1,11 @@ KUBE_API_URL= CUSTOMIZATION_API_GROUP= CUSTOMIZATION_API_VERSION= -RPROJECTS_VERSION= +PROJECTS_API_GROUP= +PROJECTS_VERSION= PROJECTS_RESOURCE_NAME= MARKETPLACE_RESOURCE_NAME= MARKETPLACE_KIND= +INSTANCES_API_GROUP= INSTANCES_VERSION= +INSTANCES_RESOURCE_NAME= diff --git a/server/index.ts b/server/index.ts index 7dd1d9b..bc334a4 100644 --- a/server/index.ts +++ b/server/index.ts @@ -20,13 +20,18 @@ const CUSTOMIZATION_API_GROUP = process.env.LOCAL === 'true' ? options?.CUSTOMIZATION_API_GROUP : process.env.CUSTOMIZATION_API_GROUP const CUSTOMIZATION_API_VERSION = process.env.LOCAL === 'true' ? options?.CUSTOMIZATION_API_VERSION : process.env.CUSTOMIZATION_API_VERSION -const RPROJECTS_VERSION = process.env.LOCAL === 'true' ? options?.RPROJECTS_VERSION : process.env.RPROJECTS_VERSION +const PROJECTS_API_GROUP = process.env.LOCAL === 'true' ? options?.PROJECTS_API_GROUP : process.env.PROJECTS_API_GROUP +const PROJECTS_VERSION = process.env.LOCAL === 'true' ? options?.PROJECTS_VERSION : process.env.PROJECTS_VERSION const PROJECTS_RESOURCE_NAME = process.env.LOCAL === 'true' ? options?.PROJECTS_RESOURCE_NAME : process.env.PROJECTS_RESOURCE_NAME const MARKETPLACE_RESOURCE_NAME = process.env.LOCAL === 'true' ? options?.MARKETPLACE_RESOURCE_NAME : process.env.MARKETPLACE_RESOURCE_NAME const MARKETPLACE_KIND = process.env.LOCAL === 'true' ? options?.MARKETPLACE_KIND : process.env.MARKETPLACE_KIND +const INSTANCES_API_GROUP = + process.env.LOCAL === 'true' ? options?.INSTANCES_API_GROUP : process.env.INSTANCES_API_GROUP const INSTANCES_VERSION = process.env.LOCAL === 'true' ? options?.INSTANCES_VERSION : process.env.INSTANCES_VERSION +const INSTANCES_RESOURCE_NAME = + process.env.LOCAL === 'true' ? options?.INSTANCES_RESOURCE_NAME : process.env.INSTANCES_RESOURCE_NAME const healthcheck = require('express-healthcheck') const promBundle = require('express-prom-bundle') @@ -105,11 +110,14 @@ app.get(`${basePrefix ? basePrefix : ''}/env.js`, (_, res) => { ${basePrefix ? ` BASEPREFIX: "${basePrefix}",` : ''} CUSTOMIZATION_API_GROUP: ${JSON.stringify(CUSTOMIZATION_API_GROUP) || '"check envs"'}, CUSTOMIZATION_API_VERSION: ${JSON.stringify(CUSTOMIZATION_API_VERSION) || '"check envs"'}, - RPROJECTS_VERSION: ${JSON.stringify(RPROJECTS_VERSION) || '"check envs"'}, + PROJECTS_API_GROUP: ${JSON.stringify(PROJECTS_API_GROUP) || '"check envs"'}, + PROJECTS_VERSION: ${JSON.stringify(PROJECTS_VERSION) || '"check envs"'}, PROJECTS_RESOURCE_NAME: ${JSON.stringify(PROJECTS_RESOURCE_NAME) || '"check envs"'}, MARKETPLACE_RESOURCE_NAME: ${JSON.stringify(MARKETPLACE_RESOURCE_NAME) || '"check envs"'}, MARKETPLACE_KIND: ${JSON.stringify(MARKETPLACE_KIND) || '"check envs"'}, - INSTANCES_VERSION: ${JSON.stringify(INSTANCES_VERSION) || '"check envs"'} + INSTANCES_API_GROUP: ${JSON.stringify(INSTANCES_API_GROUP) || '"check envs"'}, + INSTANCES_VERSION: ${JSON.stringify(INSTANCES_VERSION) || '"check envs"'}, + INSTANCES_RESOURCE_NAME: ${JSON.stringify(INSTANCES_RESOURCE_NAME) || '"check envs"'} } `, ) diff --git a/src/components/organisms/ListProjects/ListProjects.tsx b/src/components/organisms/ListProjects/ListProjects.tsx index 35fc011..7c92c19 100644 --- a/src/components/organisms/ListProjects/ListProjects.tsx +++ b/src/components/organisms/ListProjects/ListProjects.tsx @@ -17,7 +17,13 @@ import { } from '@prorobotech/openapi-k8s-toolkit' import { useSelector } from 'react-redux' import { RootState } from 'store/store' -import { BASE_API_GROUP, BASE_API_VERSION, BASE_PROJECTS_VERSION } from 'constants/customizationApiGroupAndVersion' +import { + BASE_API_GROUP, + BASE_API_VERSION, + BASE_PROJECTS_API_GROUP, + BASE_PROJECTS_VERSION, + BASE_PROJECTS_RESOURCE_NAME, +} from 'constants/customizationApiGroupAndVersion' import { FlexGrow } from 'components' import { TABLE_PROPS } from 'constants/tableProps' @@ -30,9 +36,9 @@ export const ListProjects: FC = () => { const { clusterName } = useParams() const path = pathname const cluster = clusterName || '' - const apiGroup = BASE_API_GROUP + const apiGroup = BASE_PROJECTS_API_GROUP const apiVersion = BASE_PROJECTS_VERSION - const typeName = 'projects' + const typeName = BASE_PROJECTS_RESOURCE_NAME const isNamespaced = false const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false) diff --git a/src/constants/customizationApiGroupAndVersion.ts b/src/constants/customizationApiGroupAndVersion.ts index 84828cc..41a9420 100644 --- a/src/constants/customizationApiGroupAndVersion.ts +++ b/src/constants/customizationApiGroupAndVersion.ts @@ -1,10 +1,14 @@ /* eslint-disable no-underscore-dangle */ export const BASE_API_GROUP = window._env_.CUSTOMIZATION_API_GROUP || import.meta.env.VITE_CUSTOMIZATION_API_GROUP export const BASE_API_VERSION = window._env_.CUSTOMIZATION_API_VERSION || import.meta.env.VITE_CUSTOMIZATION_API_VERSION +export const BASE_PROJECTS_API_GROUP = window._env_.PROJECTS_API_GROUP || import.meta.env.VITE_PROJECTS_API_GROUP export const BASE_PROJECTS_VERSION = window._env_.PROJECTS_VERSION || import.meta.env.VITE_PROJECTS_VERSION export const BASE_PROJECTS_RESOURCE_NAME = window._env_.PROJECTS_RESOURCE_NAME || import.meta.env.VITE_PROJECTS_RESOURCE_NAME export const BASE_MARKETPLACE_RESOURCE_NAME = window._env_.MARKETPLACE_RESOURCE_NAME || import.meta.env.VITE_MARKETPLACE_RESOURCE_NAME export const BASE_MARKETPLACE_KIND = window._env_.MARKETPLACE_KIND || import.meta.env.VITE_MARKETPLACE_KIND +export const BASE_INSTANCES_API_GROUP = window._env_.INSTANCES_API_GROUP || import.meta.env.VITE_INSTANCES_API_GROUP export const BASE_INSTANCES_VERSION = window._env_.INSTANCES_VERSION || import.meta.env.VITE_INSTANCES_VERSION +export const BASE_INSTANCES_RESOURCE_NAME = + window._env_.INSTANCES_RESOURCE_NAME || import.meta.env.VITE_INSTANCES_RESOURCE_NAME diff --git a/src/hooks/useNavSelector.ts b/src/hooks/useNavSelector.ts index 45a5130..99742bd 100644 --- a/src/hooks/useNavSelector.ts +++ b/src/hooks/useNavSelector.ts @@ -2,9 +2,12 @@ import { useApiResources, TClusterList, TSingleResource } from '@prorobotech/ope import { useSelector } from 'react-redux' import { RootState } from 'store/store' import { - BASE_API_GROUP, + BASE_PROJECTS_API_GROUP, BASE_PROJECTS_VERSION, + BASE_PROJECTS_RESOURCE_NAME, + BASE_INSTANCES_API_GROUP, BASE_INSTANCES_VERSION, + BASE_INSTANCES_RESOURCE_NAME, } from 'constants/customizationApiGroupAndVersion' const mappedClusterToOptionInSidebar = ({ name }: TClusterList[number]): { value: string; label: string } => ({ @@ -23,18 +26,18 @@ export const useNavSelector = (clusterName?: string, projectName?: string) => { const { data: projects } = useApiResources({ clusterName: clusterName || '', namespace: '', - apiGroup: BASE_API_GROUP, + apiGroup: BASE_PROJECTS_API_GROUP, apiVersion: BASE_PROJECTS_VERSION, - typeName: 'projects', + typeName: BASE_PROJECTS_RESOURCE_NAME, limit: null, }) const { data: instances, isSuccess: allInstancesLoadingSuccess } = useApiResources({ clusterName: clusterName || '', namespace: '', - apiGroup: BASE_API_GROUP, + apiGroup: BASE_INSTANCES_API_GROUP, apiVersion: BASE_INSTANCES_VERSION, - typeName: 'instances', + typeName: BASE_INSTANCES_RESOURCE_NAME, limit: null, }) diff --git a/src/pages/TableApiPage/TableApiPage.tsx b/src/pages/TableApiPage/TableApiPage.tsx index 60d9100..a27547f 100644 --- a/src/pages/TableApiPage/TableApiPage.tsx +++ b/src/pages/TableApiPage/TableApiPage.tsx @@ -5,7 +5,11 @@ import { useSelector } from 'react-redux' import type { RootState } from 'store/store' import { TableNonCrdInfo, BackLink, ManageableBreadcrumbs } from 'components' import { BaseTemplate } from 'templates' -import { BASE_API_GROUP, BASE_INSTANCES_VERSION } from 'constants/customizationApiGroupAndVersion' +import { + BASE_INSTANCES_API_GROUP, + BASE_INSTANCES_VERSION, + BASE_INSTANCES_RESOURCE_NAME, +} from 'constants/customizationApiGroupAndVersion' type TTableApiPageProps = { forcedTheme?: 'light' | 'dark' @@ -21,14 +25,14 @@ export const TableApiPage: FC = ({ forcedTheme }) => { const customBacklink = possibleInstance ? // ? `${baseprefix}/${clusterName}/${possibleInstance}/${possibleProject}/api-table/apps/v1/deployments` - `${baseprefix}/${clusterName}/${possibleProject}/api-table/${BASE_API_GROUP}/${BASE_INSTANCES_VERSION}/instances` + `${baseprefix}/${clusterName}/${possibleProject}/api-table/${BASE_INSTANCES_API_GROUP}/${BASE_INSTANCES_VERSION}/${BASE_INSTANCES_RESOURCE_NAME}` : `${baseprefix}/clusters/${clusterName}/projects/${possibleProject}` const clustererBacklink = `${baseprefix}/clusters` // const instancesBacklink = // apiGroup === 'apps' && apiVersion === 'v1' && typeName === 'deployments' - // ? `${baseprefix}/${clusterName}/${possibleProject}/api-table/${BASE_API_GROUP}/${BASE_INSTANCES_VERSION}/instances` + // ? `${baseprefix}/${clusterName}/${possibleProject}/api-table/${BASE_INSTANCES_API_GROUP}/${BASE_INSTANCES_VERSION}/${BASE_INSTANCES_RESOURCE_NAME}` // : undefined // const nonInstanceBackLink = namespace ? customBacklink : clustererBacklink diff --git a/src/pages/TableBuiltinPage/TableBuiltinPage.tsx b/src/pages/TableBuiltinPage/TableBuiltinPage.tsx index bd685ae..79ced63 100644 --- a/src/pages/TableBuiltinPage/TableBuiltinPage.tsx +++ b/src/pages/TableBuiltinPage/TableBuiltinPage.tsx @@ -5,7 +5,11 @@ import { useSelector } from 'react-redux' import type { RootState } from 'store/store' import { TableBuiltinInfo, BackLink, ManageableBreadcrumbs } from 'components' import { BaseTemplate } from 'templates' -import { BASE_API_GROUP, BASE_INSTANCES_VERSION } from 'constants/customizationApiGroupAndVersion' +import { + BASE_INSTANCES_API_GROUP, + BASE_INSTANCES_VERSION, + BASE_INSTANCES_RESOURCE_NAME, +} from 'constants/customizationApiGroupAndVersion' type TTableBuiltinPageProps = { forcedTheme?: 'light' | 'dark' @@ -20,7 +24,7 @@ export const TableBuiltinPage: FC = ({ forcedTheme }) => const possibleInstance = syntheticProject && namespace ? namespace : undefined const customBacklink = possibleInstance - ? `${baseprefix}/${clusterName}/${possibleProject}/api-table/${BASE_API_GROUP}/${BASE_INSTANCES_VERSION}/instances` + ? `${baseprefix}/${clusterName}/${possibleProject}/api-table/${BASE_INSTANCES_API_GROUP}/${BASE_INSTANCES_VERSION}/${BASE_INSTANCES_RESOURCE_NAME}` : `${baseprefix}/clusters/${clusterName}/projects/${possibleProject}` const clustererBacklink = `${baseprefix}/clusters` diff --git a/src/pages/TableCrdPage/TableCrdPage.tsx b/src/pages/TableCrdPage/TableCrdPage.tsx index 96ad080..59e3b4a 100644 --- a/src/pages/TableCrdPage/TableCrdPage.tsx +++ b/src/pages/TableCrdPage/TableCrdPage.tsx @@ -5,7 +5,11 @@ import { useSelector } from 'react-redux' import type { RootState } from 'store/store' import { TableCrdInfo, BackLink, ManageableBreadcrumbs } from 'components' import { BaseTemplate } from 'templates' -import { BASE_API_GROUP, BASE_INSTANCES_VERSION } from 'constants/customizationApiGroupAndVersion' +import { + BASE_INSTANCES_API_GROUP, + BASE_INSTANCES_VERSION, + BASE_INSTANCES_RESOURCE_NAME, +} from 'constants/customizationApiGroupAndVersion' type TTableCrdPageProps = { forcedTheme?: 'light' | 'dark' @@ -19,7 +23,7 @@ export const TableCrdPage: FC = ({ forcedTheme }) => { const possibleInstance = syntheticProject && namespace ? namespace : undefined const customBacklink = possibleInstance - ? `${baseprefix}/${clusterName}/${possibleProject}/api-table/${BASE_API_GROUP}/${BASE_INSTANCES_VERSION}/instances` + ? `${baseprefix}/${clusterName}/${possibleProject}/api-table/${BASE_INSTANCES_API_GROUP}/${BASE_INSTANCES_VERSION}/${BASE_INSTANCES_RESOURCE_NAME}` : `${baseprefix}/clusters/${clusterName}/projects/${possibleProject}` const clustererBacklink = `${baseprefix}/clusters`