diff --git a/src/k8s/EDPCDPipeline/utils/editCDPipelineInstance/index.test.ts b/src/k8s/EDPCDPipeline/utils/editCDPipelineInstance/index.test.ts deleted file mode 100644 index c94930bf1..000000000 --- a/src/k8s/EDPCDPipeline/utils/editCDPipelineInstance/index.test.ts +++ /dev/null @@ -1,2 +0,0 @@ -// Todo: write new mocks -test('true', () => {}); diff --git a/src/k8s/EDPCDPipeline/utils/editCDPipelineInstance/index.ts b/src/k8s/EDPCDPipeline/utils/editCDPipelineInstance/index.ts deleted file mode 100644 index 994edca89..000000000 --- a/src/k8s/EDPCDPipeline/utils/editCDPipelineInstance/index.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { set } from 'lodash'; -import { FormNameObject } from '../../../../types/forms'; -import { EDPCDPipelineKubeObjectInterface } from '../../types'; - -export const editCDPipelineInstance = ( - names: { - [key: string]: FormNameObject; - }, - kubeObjectData: EDPCDPipelineKubeObjectInterface, - formValues: { - [key: string]: any; - } -): EDPCDPipelineKubeObjectInterface => { - const base = { ...kubeObjectData }; - - for (const [propKey, propValue] of Object.entries(formValues)) { - if (names[propKey].notUsedInFormData) { - continue; - } - - const propPath = names[propKey].path; - set(base, propPath, propValue); - } - - return base; -}; diff --git a/src/k8s/EDPCDPipelineStage/utils/editCDPipelineStageInstance/index.test.ts b/src/k8s/EDPCDPipelineStage/utils/editCDPipelineStageInstance/index.test.ts deleted file mode 100644 index c94930bf1..000000000 --- a/src/k8s/EDPCDPipelineStage/utils/editCDPipelineStageInstance/index.test.ts +++ /dev/null @@ -1,2 +0,0 @@ -// Todo: write new mocks -test('true', () => {}); diff --git a/src/k8s/EDPCDPipelineStage/utils/editCDPipelineStageInstance/index.ts b/src/k8s/EDPCDPipelineStage/utils/editCDPipelineStageInstance/index.ts deleted file mode 100644 index 8b2db8b0b..000000000 --- a/src/k8s/EDPCDPipelineStage/utils/editCDPipelineStageInstance/index.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { set } from 'lodash'; -import { FormNameObject } from '../../../../types/forms'; -import { EDPCDPipelineStageKubeObjectInterface } from '../../types'; - -export const editCDPipelineStageInstance = ( - names: { - [key: string]: FormNameObject; - }, - kubeObjectData: EDPCDPipelineStageKubeObjectInterface, - formValues: { - [key: string]: any; - } -): EDPCDPipelineStageKubeObjectInterface => { - const base = { ...kubeObjectData }; - - for (const [propKey, propValue] of Object.entries(formValues)) { - if (names[propKey].notUsedInFormData) { - continue; - } - - const propPath = names[propKey].path; - set(base, propPath, propValue); - } - - return base; -}; diff --git a/src/k8s/EDPCodebase/utils/editCodebaseInstance/index.test.ts b/src/k8s/EDPCodebase/utils/editCodebaseInstance/index.test.ts deleted file mode 100644 index c94930bf1..000000000 --- a/src/k8s/EDPCodebase/utils/editCodebaseInstance/index.test.ts +++ /dev/null @@ -1,2 +0,0 @@ -// Todo: write new mocks -test('true', () => {}); diff --git a/src/k8s/EDPCodebase/utils/editCodebaseInstance/index.ts b/src/k8s/EDPCodebase/utils/editCodebaseInstance/index.ts deleted file mode 100644 index 444320346..000000000 --- a/src/k8s/EDPCodebase/utils/editCodebaseInstance/index.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { set } from 'lodash'; -import { FormNameObject } from '../../../../types/forms'; -import { EDPCodebaseKubeObjectInterface } from '../../types'; - -export const editCodebaseInstance = ( - names: { - [key: string]: FormNameObject; - }, - kubeObjectData: EDPCodebaseKubeObjectInterface, - formValues: { - [key: string]: any; - } -): EDPCodebaseKubeObjectInterface => { - const base = { ...kubeObjectData }; - - for (const [propKey, propValue] of Object.entries(formValues)) { - if (names[propKey].notUsedInFormData) { - continue; - } - - const propPath = names[propKey].path; - set(base, propPath, propValue); - } - - return base; -}; diff --git a/src/k8s/EDPCodebaseBranch/utils/editCodebaseBranchInstance/index.test.ts b/src/k8s/EDPCodebaseBranch/utils/editCodebaseBranchInstance/index.test.ts deleted file mode 100644 index c94930bf1..000000000 --- a/src/k8s/EDPCodebaseBranch/utils/editCodebaseBranchInstance/index.test.ts +++ /dev/null @@ -1,2 +0,0 @@ -// Todo: write new mocks -test('true', () => {}); diff --git a/src/k8s/EDPCodebaseBranch/utils/editCodebaseBranchInstance/index.ts b/src/k8s/EDPCodebaseBranch/utils/editCodebaseBranchInstance/index.ts deleted file mode 100644 index 4e9ba1a69..000000000 --- a/src/k8s/EDPCodebaseBranch/utils/editCodebaseBranchInstance/index.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { set } from 'lodash'; -import { FormNameObject } from '../../../../types/forms'; -import { EDPCodebaseBranchKubeObjectInterface } from '../../types'; - -export const editCodebaseBranchInstance = ( - names: { - [key: string]: FormNameObject; - }, - kubeObjectData: EDPCodebaseBranchKubeObjectInterface, - formValues: { - [key: string]: any; - } -): EDPCodebaseBranchKubeObjectInterface => { - const base = { ...kubeObjectData }; - - for (const [propKey, propValue] of Object.entries(formValues)) { - if (names[propKey].notUsedInFormData) { - continue; - } - - const propPath = names[propKey].path; - set(base, propPath, propValue); - } - - return base; -}; diff --git a/src/k8s/EDPComponent/utils/editEDPComponentInstance/index.test.ts b/src/k8s/EDPComponent/utils/editEDPComponentInstance/index.test.ts deleted file mode 100644 index c94930bf1..000000000 --- a/src/k8s/EDPComponent/utils/editEDPComponentInstance/index.test.ts +++ /dev/null @@ -1,2 +0,0 @@ -// Todo: write new mocks -test('true', () => {}); diff --git a/src/k8s/EDPComponent/utils/editEDPComponentInstance/index.ts b/src/k8s/EDPComponent/utils/editEDPComponentInstance/index.ts deleted file mode 100644 index 7eb8b2a61..000000000 --- a/src/k8s/EDPComponent/utils/editEDPComponentInstance/index.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { set } from 'lodash'; -import { FormNameObject } from '../../../../types/forms'; -import { EDPComponentKubeObjectInterface } from '../../types'; - -export const editEDPComponentInstance = ( - names: { - [key: string]: FormNameObject; - }, - kubeObjectData: EDPComponentKubeObjectInterface, - formValues: { - [key: string]: any; - } -): EDPComponentKubeObjectInterface => { - const base = { ...kubeObjectData }; - - for (const [propKey, propValue] of Object.entries(formValues)) { - if (names[propKey].notUsedInFormData) { - continue; - } - - const propPath = names[propKey].path; - set(base, propPath, propValue); - } - - return base; -}; diff --git a/src/k8s/EDPGitServer/utils/editGitServerInstance/index.test.ts b/src/k8s/EDPGitServer/utils/editGitServerInstance/index.test.ts deleted file mode 100644 index c94930bf1..000000000 --- a/src/k8s/EDPGitServer/utils/editGitServerInstance/index.test.ts +++ /dev/null @@ -1,2 +0,0 @@ -// Todo: write new mocks -test('true', () => {}); diff --git a/src/k8s/EDPGitServer/utils/editGitServerInstance/index.ts b/src/k8s/EDPGitServer/utils/editGitServerInstance/index.ts deleted file mode 100644 index 246c19087..000000000 --- a/src/k8s/EDPGitServer/utils/editGitServerInstance/index.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { set } from 'lodash'; -import { FormNameObject } from '../../../../types/forms'; -import { EDPGitServerKubeObjectInterface } from '../../types'; - -export const editGitServerInstance = ( - names: { - [key: string]: FormNameObject; - }, - kubeObjectData: EDPGitServerKubeObjectInterface, - formValues: { - [key: string]: any; - } -): EDPGitServerKubeObjectInterface => { - const base = { ...kubeObjectData }; - - for (const [propKey, propValue] of Object.entries(formValues)) { - if (names[propKey].notUsedInFormData) { - continue; - } - - const propPath = names[propKey].path; - set(base, propPath, propValue); - } - - return base; -}; diff --git a/src/k8s/Secret/utils/editGitServerSecretInstance/index.ts b/src/k8s/Secret/utils/editGitServerSecretInstance/index.ts deleted file mode 100644 index 2947b5755..000000000 --- a/src/k8s/Secret/utils/editGitServerSecretInstance/index.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { set } from 'lodash'; -import { FormNameObject } from '../../../../types/forms'; -import { SecretKubeObjectInterface } from '../../types'; - -export const editGitServerSecretInstance = ( - names: { - [key: string]: FormNameObject; - }, - kubeObjectData: SecretKubeObjectInterface, - formValues: { - [key: string]: any; - } -): SecretKubeObjectInterface => { - const base = { ...kubeObjectData }; - - for (const [propKey, propValue] of Object.entries(formValues)) { - if (names[propKey].notUsedInFormData) { - continue; - } - - const propPath = names[propKey].path; - set(base, propPath, propValue); - } - - return base; -}; diff --git a/src/k8s/ServiceAccount/utils/editServiceAccount/index.test.ts b/src/k8s/ServiceAccount/utils/editServiceAccount/index.test.ts deleted file mode 100644 index c94930bf1..000000000 --- a/src/k8s/ServiceAccount/utils/editServiceAccount/index.test.ts +++ /dev/null @@ -1,2 +0,0 @@ -// Todo: write new mocks -test('true', () => {}); diff --git a/src/k8s/ServiceAccount/utils/editServiceAccount/index.ts b/src/k8s/ServiceAccount/utils/editServiceAccount/index.ts deleted file mode 100644 index 9dd326a76..000000000 --- a/src/k8s/ServiceAccount/utils/editServiceAccount/index.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { set } from 'lodash'; -import { FormNameObject } from '../../../../types/forms'; -import { ServiceAccountKubeObjectInterface } from '../../types'; - -export const editServiceAccountInstance = ( - names: { - [key: string]: FormNameObject; - }, - kubeObjectData: ServiceAccountKubeObjectInterface, - formValues: { - [key: string]: any; - } -): ServiceAccountKubeObjectInterface => { - const base = { ...kubeObjectData }; - - for (const [propKey, propValue] of Object.entries(formValues)) { - if (names[propKey].notUsedInFormData) { - continue; - } - - const propPath = names[propKey].path; - set(base, propPath, propValue); - } - - return base; -}; diff --git a/src/k8s/ConfigMap/utils/editEDPConfigConfigMap.ts b/src/k8s/common/editResource/index.ts similarity index 66% rename from src/k8s/ConfigMap/utils/editEDPConfigConfigMap.ts rename to src/k8s/common/editResource/index.ts index 19e0199af..b1f9d7849 100644 --- a/src/k8s/ConfigMap/utils/editEDPConfigConfigMap.ts +++ b/src/k8s/common/editResource/index.ts @@ -1,17 +1,17 @@ import { set } from 'lodash'; import { FormNameObject } from '../../../types/forms'; -import { ConfigMapKubeObjectInterface } from '../types'; +import { EDPKubeObjectInterface } from '../../../types/k8s'; -export const editEDPConfigConfigMap = ( +export const editResource = ( names: { [key: string]: FormNameObject; }, - currentConfigMap: ConfigMapKubeObjectInterface, + currentResource: T, formValues: { [key: string]: any; } -): ConfigMapKubeObjectInterface => { - const base = { ...currentConfigMap }; +): T => { + const base = { ...currentResource }; for (const [propKey, propValue] of Object.entries(formValues)) { if (names[propKey]?.notUsedInFormData) { diff --git a/src/widgets/CreateCodebaseBranch/components/FormActions/index.tsx b/src/widgets/CreateCodebaseBranch/components/FormActions/index.tsx index aa97d694e..04bf90e24 100644 --- a/src/widgets/CreateCodebaseBranch/components/FormActions/index.tsx +++ b/src/widgets/CreateCodebaseBranch/components/FormActions/index.tsx @@ -1,9 +1,9 @@ import { Button } from '@material-ui/core'; import React from 'react'; import { useFormContext } from 'react-hook-form'; +import { editResource } from '../../../../k8s/common/editResource'; import { useCreateCodebaseBranch } from '../../../../k8s/EDPCodebaseBranch/hooks/useCreateCodebaseBranch'; import { createCodebaseBranchInstance } from '../../../../k8s/EDPCodebaseBranch/utils/createCodebaseBranchInstance'; -import { editCodebaseBranchInstance } from '../../../../k8s/EDPCodebaseBranch/utils/editCodebaseBranchInstance'; import { useSpecificDialogContext } from '../../../../providers/Dialog/hooks'; import { createVersioningString } from '../../../../utils/createVersioningString'; import { getUsedValues } from '../../../../utils/forms/getUsedValues'; @@ -70,7 +70,7 @@ export const FormActions = () => { ); if (!!values.release) { - const newDefaultBranch = editCodebaseBranchInstance( + const newDefaultBranch = editResource( { version: { name: 'version', diff --git a/src/widgets/CreateEditCDPipeline/components/Edit/components/FormActions/index.tsx b/src/widgets/CreateEditCDPipeline/components/Edit/components/FormActions/index.tsx index ee9ad6c1a..6540ba220 100644 --- a/src/widgets/CreateEditCDPipeline/components/Edit/components/FormActions/index.tsx +++ b/src/widgets/CreateEditCDPipeline/components/Edit/components/FormActions/index.tsx @@ -1,8 +1,8 @@ import { Button } from '@material-ui/core'; import React from 'react'; import { useFormContext } from 'react-hook-form'; +import { editResource } from '../../../../../../k8s/common/editResource'; import { useEditCDPipeline } from '../../../../../../k8s/EDPCDPipeline/hooks/useEditCDPipeline'; -import { editCDPipelineInstance } from '../../../../../../k8s/EDPCDPipeline/utils/editCDPipelineInstance'; import { useSpecificDialogContext } from '../../../../../../providers/Dialog/hooks'; import { getUsedValues } from '../../../../../../utils/forms/getUsedValues'; import { CREATE_EDIT_CD_PIPELINE_DIALOG_NAME } from '../../../../constants'; @@ -49,7 +49,7 @@ export const FormActions = () => { const onSubmit = React.useCallback( async (values: CreateEditCDPipelineFormValues) => { const usedValues = getUsedValues(values, CDPIPELINE_FORM_NAMES); - const newCDPipelineData = editCDPipelineInstance( + const newCDPipelineData = editResource( CDPIPELINE_FORM_NAMES, CDPipelineData, usedValues diff --git a/src/widgets/CreateEditCodebase/components/Edit/components/FormActions/index.tsx b/src/widgets/CreateEditCodebase/components/Edit/components/FormActions/index.tsx index 3d6315610..03d135387 100644 --- a/src/widgets/CreateEditCodebase/components/Edit/components/FormActions/index.tsx +++ b/src/widgets/CreateEditCodebase/components/Edit/components/FormActions/index.tsx @@ -1,8 +1,8 @@ import { Button } from '@material-ui/core'; import React from 'react'; import { useFormContext } from 'react-hook-form'; +import { editResource } from '../../../../../../k8s/common/editResource'; import { useCodebaseCRUD } from '../../../../../../k8s/EDPCodebase/hooks/useCodebaseCRUD'; -import { editCodebaseInstance } from '../../../../../../k8s/EDPCodebase/utils/editCodebaseInstance'; import { useSpecificDialogContext } from '../../../../../../providers/Dialog/hooks'; import { getUsedValues } from '../../../../../../utils/forms/getUsedValues'; import { CREATE_EDIT_CODEBASE_DIALOG_NAME } from '../../../../constants'; @@ -51,11 +51,7 @@ export const FormActions = () => { jiraIssueMetadataPayload: null, }; - const updatedCodebaseData = editCodebaseInstance( - CODEBASE_FORM_NAMES, - codebaseData, - formValues - ); + const updatedCodebaseData = editResource(CODEBASE_FORM_NAMES, codebaseData, formValues); await editCodebase({ codebaseData: updatedCodebaseData, diff --git a/src/widgets/CreateEditStage/components/Edit/components/FormActions/index.tsx b/src/widgets/CreateEditStage/components/Edit/components/FormActions/index.tsx index 021700e0a..a61b54470 100644 --- a/src/widgets/CreateEditStage/components/Edit/components/FormActions/index.tsx +++ b/src/widgets/CreateEditStage/components/Edit/components/FormActions/index.tsx @@ -1,8 +1,8 @@ import { Button } from '@material-ui/core'; import React from 'react'; import { useFormContext } from 'react-hook-form'; +import { editResource } from '../../../../../../k8s/common/editResource'; import { useEditCDPipelineStage } from '../../../../../../k8s/EDPCDPipelineStage/hooks/useEditCDPipelineStage'; -import { editCDPipelineStageInstance } from '../../../../../../k8s/EDPCDPipelineStage/utils/editCDPipelineStageInstance'; import { useSpecificDialogContext } from '../../../../../../providers/Dialog/hooks'; import { getUsedValues } from '../../../../../../utils/forms/getUsedValues'; import { CREATE_EDIT_STAGE_DIALOG_NAME } from '../../../../constants'; @@ -46,11 +46,7 @@ export const FormActions = () => { const onSubmit = React.useCallback( async (values: CreateEditStageFormValues) => { const usedValues = getUsedValues(values, STAGE_FORM_NAMES); - const newCDPipelineStageData = editCDPipelineStageInstance( - STAGE_FORM_NAMES, - stage, - usedValues - ); + const newCDPipelineStageData = editResource(STAGE_FORM_NAMES, stage, usedValues); await editCDPipelineStage({ CDPipelineStageData: newCDPipelineStageData }); }, diff --git a/src/widgets/ManageEDPComponent/components/FormActions/index.tsx b/src/widgets/ManageEDPComponent/components/FormActions/index.tsx index 93147d639..93db4dc41 100644 --- a/src/widgets/ManageEDPComponent/components/FormActions/index.tsx +++ b/src/widgets/ManageEDPComponent/components/FormActions/index.tsx @@ -2,10 +2,10 @@ import { Button, Grid } from '@material-ui/core'; import React from 'react'; import { useFormContext as useReactHookFormContext } from 'react-hook-form'; import { Render } from '../../../../components/Render'; +import { editResource } from '../../../../k8s/common/editResource'; import { useCreateEDPComponent } from '../../../../k8s/EDPComponent/hooks/useCreateEDPComponent'; import { EDPComponentKubeObjectInterface } from '../../../../k8s/EDPComponent/types'; import { createEDPComponentInstance } from '../../../../k8s/EDPComponent/utils/createEDPComponentInstance'; -import { editEDPComponentInstance } from '../../../../k8s/EDPComponent/utils/editEDPComponentInstance'; import { useFormContext } from '../../../../providers/Form/hooks'; import { FORM_MODES } from '../../../../types/forms'; import { EDP_COMPONENT_FORM_NAMES } from '../../names'; @@ -49,7 +49,7 @@ export const FormActions = () => { values ); - const EDPComponentEditedInstance = editEDPComponentInstance( + const EDPComponentEditedInstance = editResource( EDP_COMPONENT_FORM_NAMES, currentElement as EDPComponentKubeObjectInterface, values diff --git a/src/widgets/ManageGitServer/components/Edit/components/FormActions/hooks/useUpdateGitServer.ts b/src/widgets/ManageGitServer/components/Edit/components/FormActions/hooks/useUpdateGitServer.ts index 27c259845..460be4080 100644 --- a/src/widgets/ManageGitServer/components/Edit/components/FormActions/hooks/useUpdateGitServer.ts +++ b/src/widgets/ManageGitServer/components/Edit/components/FormActions/hooks/useUpdateGitServer.ts @@ -1,7 +1,6 @@ import { GIT_PROVIDERS } from '../../../../../../../constants/gitProviders'; +import { editResource } from '../../../../../../../k8s/common/editResource'; import { useGitServerCRUD } from '../../../../../../../k8s/EDPGitServer/hooks/useGitServerCRUD'; -import { editGitServerInstance } from '../../../../../../../k8s/EDPGitServer/utils/editGitServerInstance'; -import { editGitServerSecretInstance } from '../../../../../../../k8s/Secret/utils/editGitServerSecretInstance'; import { useFormContext } from '../../../../../../../providers/Form/hooks'; import { EDPKubeObjectInterface } from '../../../../../../../types/k8s'; import { safeEncode } from '../../../../../../../utils/decodeEncode'; @@ -37,16 +36,12 @@ export const useUpdateGitServer = ({ onSuccess }) => { httpsPort: Number(formValues.httpsPort), }; const usedValues = getUsedValues(transformedValues, GIT_SERVER_FORM_NAMES); - const gitServerData = editGitServerInstance( - GIT_SERVER_FORM_NAMES, - gitServer.jsonData, - usedValues - ); + const gitServerData = editResource(GIT_SERVER_FORM_NAMES, gitServer.jsonData, usedValues); const editGerrit = async () => { const { sshPrivateKey, sshPublicKey, gitUser } = formValues; - const gitServerSecretData = editGitServerSecretInstance( + const gitServerSecretData = editResource( { sshPrivateKey: { name: 'sshPrivateKey', @@ -82,7 +77,7 @@ export const useUpdateGitServer = ({ onSuccess }) => { const editGithub = async () => { const { sshPrivateKey, token, gitUser } = formValues; - const gitServerSecretData = editGitServerSecretInstance( + const gitServerSecretData = editResource( { sshPrivateKey: { name: 'sshPrivateKey', @@ -118,7 +113,7 @@ export const useUpdateGitServer = ({ onSuccess }) => { const editGitlab = async () => { const { sshPrivateKey, secretString, token } = formValues; - const gitServerSecretData = editGitServerSecretInstance( + const gitServerSecretData = editResource( { sshPrivateKey: { name: 'sshPrivateKey', diff --git a/src/widgets/ManageRegistry/components/Create/components/FormActions/hooks/useSetupRegistry.ts b/src/widgets/ManageRegistry/components/Create/components/FormActions/hooks/useSetupRegistry.ts index 84fd43af6..4edc327cd 100644 --- a/src/widgets/ManageRegistry/components/Create/components/FormActions/hooks/useSetupRegistry.ts +++ b/src/widgets/ManageRegistry/components/Create/components/FormActions/hooks/useSetupRegistry.ts @@ -1,6 +1,6 @@ +import { editResource } from '../../../../../../../k8s/common/editResource'; import { CONTAINER_REGISTRY_TYPE } from '../../../../../../../k8s/ConfigMap/constants'; import { useConfigMapCRUD } from '../../../../../../../k8s/ConfigMap/hooks/useConfigMapCRUD'; -import { editEDPConfigConfigMap } from '../../../../../../../k8s/ConfigMap/utils/editEDPConfigConfigMap'; import { REGISTRY_SECRET_NAMES } from '../../../../../../../k8s/Secret/constants'; import { useSecretCRUD } from '../../../../../../../k8s/Secret/hooks/useSecretCRUD'; import { @@ -9,7 +9,6 @@ import { } from '../../../../../../../k8s/Secret/utils/createRegistrySecretInstance'; import { useEditServiceAccount } from '../../../../../../../k8s/ServiceAccount/hooks/useEditServiceAccount'; import { ServiceAccountKubeObjectInterface } from '../../../../../../../k8s/ServiceAccount/types'; -import { editServiceAccountInstance } from '../../../../../../../k8s/ServiceAccount/utils/editServiceAccount'; import { EDP_CONFIG_MAP_NAMES } from '../../../../../../../pages/edp-configuration/pages/edp-registry-list/names'; import { useFormContext } from '../../../../../../../providers/Form/hooks'; import { ManageRegistryDataContext, ManageRegistryValues } from '../../../../../types'; @@ -56,7 +55,7 @@ export const useSetupRegistry = ({ onSuccess }) => { name: REGISTRY_SECRET_NAMES.KANIKO_DOCKER_CONFIG, }); - const editedServiceAccount = editServiceAccountInstance( + const editedServiceAccount = editResource( { irsaRoleArn: { name: irsaRoleArn, @@ -69,7 +68,7 @@ export const useSetupRegistry = ({ onSuccess }) => { } ); - const newEDPConfigMap = editEDPConfigConfigMap(EDP_CONFIG_MAP_NAMES, EDPConfigMap, { + const newEDPConfigMap = editResource(EDP_CONFIG_MAP_NAMES, EDPConfigMap, { registryHost, registrySpace, registryType, @@ -100,7 +99,7 @@ export const useSetupRegistry = ({ onSuccess }) => { }), ]; - const newEDPConfigMap = editEDPConfigConfigMap(EDP_CONFIG_MAP_NAMES, EDPConfigMap, { + const newEDPConfigMap = editResource(EDP_CONFIG_MAP_NAMES, EDPConfigMap, { registryHost: 'docker.io', registrySpace, registryType, @@ -133,7 +132,7 @@ export const useSetupRegistry = ({ onSuccess }) => { }), ]; - const newEDPConfigMap = editEDPConfigConfigMap(EDP_CONFIG_MAP_NAMES, EDPConfigMap, { + const newEDPConfigMap = editResource(EDP_CONFIG_MAP_NAMES, EDPConfigMap, { registryHost, registrySpace, registryType, diff --git a/src/widgets/ManageRegistry/components/Edit/components/FormActions/hooks/useResetRegistry.ts b/src/widgets/ManageRegistry/components/Edit/components/FormActions/hooks/useResetRegistry.ts index 57c1f9cc1..271c68036 100644 --- a/src/widgets/ManageRegistry/components/Edit/components/FormActions/hooks/useResetRegistry.ts +++ b/src/widgets/ManageRegistry/components/Edit/components/FormActions/hooks/useResetRegistry.ts @@ -1,10 +1,9 @@ +import { editResource } from '../../../../../../../k8s/common/editResource'; import { CONTAINER_REGISTRY_TYPE } from '../../../../../../../k8s/ConfigMap/constants'; import { useConfigMapCRUD } from '../../../../../../../k8s/ConfigMap/hooks/useConfigMapCRUD'; -import { editEDPConfigConfigMap } from '../../../../../../../k8s/ConfigMap/utils/editEDPConfigConfigMap'; import { useSecretCRUD } from '../../../../../../../k8s/Secret/hooks/useSecretCRUD'; import { useEditServiceAccount } from '../../../../../../../k8s/ServiceAccount/hooks/useEditServiceAccount'; import { ServiceAccountKubeObjectInterface } from '../../../../../../../k8s/ServiceAccount/types'; -import { editServiceAccountInstance } from '../../../../../../../k8s/ServiceAccount/utils/editServiceAccount'; import { EDP_CONFIG_MAP_NAMES } from '../../../../../../../pages/edp-configuration/pages/edp-registry-list/names'; import { useFormContext } from '../../../../../../../providers/Form/hooks'; import { ManageRegistryDataContext, ManageRegistryValues } from '../../../../../types'; @@ -40,13 +39,13 @@ export const useResetRegistry = ({ onSuccess }) => { const { registryType, irsaRoleArn } = formValues; const resetECR = async () => { - const newEDPConfigMap = editEDPConfigConfigMap(EDP_CONFIG_MAP_NAMES, EDPConfigMap, { + const newEDPConfigMap = editResource(EDP_CONFIG_MAP_NAMES, EDPConfigMap, { registryHost: '', registrySpace: '', registryType: '', }); - const editedServiceAccount = editServiceAccountInstance( + const editedServiceAccount = editResource( { irsaRoleArn: { name: irsaRoleArn, @@ -71,7 +70,7 @@ export const useResetRegistry = ({ onSuccess }) => { }; const resetDockerHub = async () => { - const newEDPConfigMap = editEDPConfigConfigMap(EDP_CONFIG_MAP_NAMES, EDPConfigMap, { + const newEDPConfigMap = editResource(EDP_CONFIG_MAP_NAMES, EDPConfigMap, { registryHost: '', registrySpace: '', registryType: '', @@ -88,7 +87,7 @@ export const useResetRegistry = ({ onSuccess }) => { }; const resetHarbor = async () => { - const newEDPConfigMap = editEDPConfigConfigMap(EDP_CONFIG_MAP_NAMES, EDPConfigMap, { + const newEDPConfigMap = editResource(EDP_CONFIG_MAP_NAMES, EDPConfigMap, { registryHost: '', registrySpace: '', registryType: '', diff --git a/src/widgets/ManageRegistry/components/Edit/components/FormActions/hooks/useUpdateRegistry.ts b/src/widgets/ManageRegistry/components/Edit/components/FormActions/hooks/useUpdateRegistry.ts index 43aaa8b4d..9df96ac25 100644 --- a/src/widgets/ManageRegistry/components/Edit/components/FormActions/hooks/useUpdateRegistry.ts +++ b/src/widgets/ManageRegistry/components/Edit/components/FormActions/hooks/useUpdateRegistry.ts @@ -1,6 +1,6 @@ +import { editResource } from '../../../../../../../k8s/common/editResource'; import { CONTAINER_REGISTRY_TYPE } from '../../../../../../../k8s/ConfigMap/constants'; import { useConfigMapCRUD } from '../../../../../../../k8s/ConfigMap/hooks/useConfigMapCRUD'; -import { editEDPConfigConfigMap } from '../../../../../../../k8s/ConfigMap/utils/editEDPConfigConfigMap'; import { REGISTRY_SECRET_NAMES } from '../../../../../../../k8s/Secret/constants'; import { useSecretCRUD } from '../../../../../../../k8s/Secret/hooks/useSecretCRUD'; import { @@ -9,7 +9,6 @@ import { } from '../../../../../../../k8s/Secret/utils/createRegistrySecretInstance'; import { useEditServiceAccount } from '../../../../../../../k8s/ServiceAccount/hooks/useEditServiceAccount'; import { ServiceAccountKubeObjectInterface } from '../../../../../../../k8s/ServiceAccount/types'; -import { editServiceAccountInstance } from '../../../../../../../k8s/ServiceAccount/utils/editServiceAccount'; import { EDP_CONFIG_MAP_NAMES } from '../../../../../../../pages/edp-configuration/pages/edp-registry-list/names'; import { useFormContext } from '../../../../../../../providers/Form/hooks'; import { ManageRegistryDataContext, ManageRegistryValues } from '../../../../../types'; @@ -56,7 +55,7 @@ export const useUpdateRegistry = ({ onSuccess }) => { name: REGISTRY_SECRET_NAMES.KANIKO_DOCKER_CONFIG, }); - const editedServiceAccount = editServiceAccountInstance( + const editedServiceAccount = editResource( { irsaRoleArn: { name: irsaRoleArn, @@ -69,7 +68,7 @@ export const useUpdateRegistry = ({ onSuccess }) => { } ); - const newEDPConfigMap = editEDPConfigConfigMap(EDP_CONFIG_MAP_NAMES, EDPConfigMap, { + const newEDPConfigMap = editResource(EDP_CONFIG_MAP_NAMES, EDPConfigMap, { registryHost, registrySpace, registryType, @@ -100,7 +99,7 @@ export const useUpdateRegistry = ({ onSuccess }) => { }), ]; - const newEDPConfigMap = editEDPConfigConfigMap(EDP_CONFIG_MAP_NAMES, EDPConfigMap, { + const newEDPConfigMap = editResource(EDP_CONFIG_MAP_NAMES, EDPConfigMap, { registryHost: 'docker.io', registrySpace, registryType, @@ -133,7 +132,7 @@ export const useUpdateRegistry = ({ onSuccess }) => { }), ]; - const newEDPConfigMap = editEDPConfigConfigMap(EDP_CONFIG_MAP_NAMES, EDPConfigMap, { + const newEDPConfigMap = editResource(EDP_CONFIG_MAP_NAMES, EDPConfigMap, { registryHost, registrySpace, registryType,