Skip to content

Commit

Permalink
feat: Add virtual clusters creation (#388)
Browse files Browse the repository at this point in the history
  • Loading branch information
callmevladik committed Sep 20, 2024
1 parent 6820568 commit 8fb8055
Show file tree
Hide file tree
Showing 34 changed files with 726 additions and 1,044 deletions.
81 changes: 81 additions & 0 deletions src/k8s/groups/ArgoCD/Application/hooks/useArgoApplicationCRUD.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import React from 'react';
import { CRUD_TYPES } from '../../../../../constants/crudTypes';
import { useResourceCRUDMutation } from '../../../../../hooks/useResourceCRUDMutation';
import { ApplicationKubeObject } from '../index';
import { ApplicationKubeObjectInterface } from '../types';

interface DeleteArgoApplicationProps {
argoApplication: ApplicationKubeObjectInterface;
}

interface EditArgoApplicationProps {
argoApplication: ApplicationKubeObjectInterface;
}

interface CreateArgoApplicationProps {
argoApplication: ApplicationKubeObjectInterface;
}

export const useArgoApplicationCRUD = () => {
const argoApplicationCreateMutation = useResourceCRUDMutation<
ApplicationKubeObjectInterface,
CRUD_TYPES.CREATE
>('argoApplicationCreateMutation', ApplicationKubeObject, CRUD_TYPES.CREATE, {
customMessages: {
onMutate: 'Creating application...',
onError: 'Failed to create application',
onSuccess: 'Start creating application',
},
});

const argoApplicationDeleteMutation = useResourceCRUDMutation<
ApplicationKubeObjectInterface,
CRUD_TYPES.DELETE
>('argoApplicationDeleteMutation', ApplicationKubeObject, CRUD_TYPES.DELETE, {
customMessages: {
onMutate: 'Uninstalling application...',
onError: 'Failed to uninstall application',
onSuccess: 'Start uninstalling application',
},
});

const argoApplicationEditMutation = useResourceCRUDMutation<
ApplicationKubeObjectInterface,
CRUD_TYPES.EDIT
>('argoApplicationEditMutation', ApplicationKubeObject, CRUD_TYPES.EDIT, {
customMessages: {
onMutate: 'Updating application...',
onError: 'Failed to update application',
onSuccess: 'Start updating application',
},
});

const createArgoApplication = React.useCallback(
async ({ argoApplication }: CreateArgoApplicationProps): Promise<void> => {
argoApplicationCreateMutation.mutate(argoApplication);
},
[argoApplicationCreateMutation]
);

const deleteArgoApplication = React.useCallback(
async ({ argoApplication }: DeleteArgoApplicationProps): Promise<void> => {
argoApplicationDeleteMutation.mutate(argoApplication);
},
[argoApplicationDeleteMutation]
);

const editArgoApplication = React.useCallback(
async ({ argoApplication }: EditArgoApplicationProps): Promise<void> => {
argoApplicationEditMutation.mutate(argoApplication);
},
[argoApplicationEditMutation]
);

const mutations = {
argoApplicationCreateMutation,
argoApplicationEditMutation,
argoApplicationDeleteMutation,
};

return { createArgoApplication, editArgoApplication, deleteArgoApplication, mutations };
};
153 changes: 0 additions & 153 deletions src/k8s/groups/ArgoCD/Application/hooks/useCreateArgoApplication.ts

This file was deleted.

2 changes: 2 additions & 0 deletions src/k8s/groups/ArgoCD/Application/labels.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export const APPLICATION_LABEL_SELECTOR_PIPELINE = 'app.edp.epam.com/pipeline';
export const APPLICATION_LABEL_SELECTOR_STAGE = 'app.edp.epam.com/stage';
export const APPLICATION_LABEL_SELECTOR_APP_NAME = 'app.edp.epam.com/app-name';
export const APPLICATION_LABEL_SELECTOR_APP_TYPE = 'app.edp.epam.com/app-type';

11 changes: 0 additions & 11 deletions src/k8s/groups/ArgoCD/Application/mocks/CDPipeline.mock.ts

This file was deleted.

16 changes: 0 additions & 16 deletions src/k8s/groups/ArgoCD/Application/mocks/CDPipelineStage.mock.ts

This file was deleted.

Loading

0 comments on commit 8fb8055

Please sign in to comment.