Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add virtual clusters creation #389

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading