feat(external-registry): Implement CRUD operations and connection verification for external registries
This commit is contained in:
@@ -47,6 +47,7 @@ export interface IDataState {
|
||||
secretGroups?: plugins.interfaces.data.ISecretGroup[];
|
||||
secretBundles?: plugins.interfaces.data.ISecretBundle[];
|
||||
clusters?: plugins.interfaces.data.ICluster[];
|
||||
externalRegistries?: plugins.interfaces.data.IExternalRegistry[];
|
||||
images?: any[];
|
||||
services?: plugins.interfaces.data.IService[];
|
||||
deployments?: plugins.interfaces.data.IDeployment[];
|
||||
@@ -64,6 +65,7 @@ export const dataState = await appstate.getStatePart<IDataState>(
|
||||
secretGroups: [],
|
||||
secretBundles: [],
|
||||
clusters: [],
|
||||
externalRegistries: [],
|
||||
images: [],
|
||||
services: [],
|
||||
deployments: [],
|
||||
@@ -138,6 +140,28 @@ export const getAllDataAction = dataState.createAction(async (statePartArg) => {
|
||||
clusters: responseClusters.clusters,
|
||||
}
|
||||
|
||||
// External Registries
|
||||
const trGetExternalRegistries =
|
||||
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.externalRegistry.IReq_GetRegistries>(
|
||||
'/typedrequest',
|
||||
'getExternalRegistries'
|
||||
);
|
||||
try {
|
||||
const responseExternalRegistries = await trGetExternalRegistries.fire({
|
||||
identity: loginStatePart.getState().identity,
|
||||
});
|
||||
currentState = {
|
||||
...currentState,
|
||||
externalRegistries: responseExternalRegistries?.registries || [],
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch external registries:', error);
|
||||
currentState = {
|
||||
...currentState,
|
||||
externalRegistries: [],
|
||||
};
|
||||
}
|
||||
|
||||
// Services
|
||||
const trGetServices =
|
||||
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.service.IRequest_Any_Cloudly_GetServices>(
|
||||
@@ -559,6 +583,86 @@ export const verifyDomainAction = dataState.createAction(
|
||||
}
|
||||
);
|
||||
|
||||
// External Registry Actions
|
||||
export const createExternalRegistryAction = dataState.createAction(
|
||||
async (statePartArg, payloadArg: { registryData: plugins.interfaces.data.IExternalRegistry['data'] }) => {
|
||||
let currentState = statePartArg.getState();
|
||||
const trCreateRegistry =
|
||||
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.externalRegistry.IReq_CreateRegistry>(
|
||||
'/typedrequest',
|
||||
'createExternalRegistry'
|
||||
);
|
||||
const response = await trCreateRegistry.fire({
|
||||
identity: loginStatePart.getState().identity,
|
||||
registryData: payloadArg.registryData,
|
||||
});
|
||||
currentState = await dataState.dispatchAction(getAllDataAction, null);
|
||||
return currentState;
|
||||
}
|
||||
);
|
||||
|
||||
export const updateExternalRegistryAction = dataState.createAction(
|
||||
async (statePartArg, payloadArg: { registryId: string; registryData: plugins.interfaces.data.IExternalRegistry['data'] }) => {
|
||||
let currentState = statePartArg.getState();
|
||||
const trUpdateRegistry =
|
||||
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.externalRegistry.IReq_UpdateRegistry>(
|
||||
'/typedrequest',
|
||||
'updateExternalRegistry'
|
||||
);
|
||||
const response = await trUpdateRegistry.fire({
|
||||
identity: loginStatePart.getState().identity,
|
||||
registryId: payloadArg.registryId,
|
||||
registryData: payloadArg.registryData,
|
||||
});
|
||||
currentState = await dataState.dispatchAction(getAllDataAction, null);
|
||||
return currentState;
|
||||
}
|
||||
);
|
||||
|
||||
export const deleteExternalRegistryAction = dataState.createAction(
|
||||
async (statePartArg, payloadArg: { registryId: string }) => {
|
||||
let currentState = statePartArg.getState();
|
||||
const trDeleteRegistry =
|
||||
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.externalRegistry.IReq_DeleteRegistryById>(
|
||||
'/typedrequest',
|
||||
'deleteExternalRegistryById'
|
||||
);
|
||||
const response = await trDeleteRegistry.fire({
|
||||
identity: loginStatePart.getState().identity,
|
||||
registryId: payloadArg.registryId,
|
||||
});
|
||||
currentState = await dataState.dispatchAction(getAllDataAction, null);
|
||||
return currentState;
|
||||
}
|
||||
);
|
||||
|
||||
export const verifyExternalRegistryAction = dataState.createAction(
|
||||
async (statePartArg, payloadArg: { registryId: string }) => {
|
||||
let currentState = statePartArg.getState();
|
||||
const trVerifyRegistry =
|
||||
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.externalRegistry.IReq_VerifyRegistry>(
|
||||
'/typedrequest',
|
||||
'verifyExternalRegistry'
|
||||
);
|
||||
const response = await trVerifyRegistry.fire({
|
||||
identity: loginStatePart.getState().identity,
|
||||
registryId: payloadArg.registryId,
|
||||
});
|
||||
|
||||
if (response.success && response.registry) {
|
||||
// Update the registry in the state with the verified status
|
||||
currentState = {
|
||||
...currentState,
|
||||
externalRegistries: currentState.externalRegistries?.map(reg =>
|
||||
reg.id === payloadArg.registryId ? response.registry : reg
|
||||
) || [],
|
||||
};
|
||||
}
|
||||
|
||||
return currentState;
|
||||
}
|
||||
);
|
||||
|
||||
// cluster
|
||||
export const addClusterAction = dataState.createAction(
|
||||
async (
|
||||
|
Reference in New Issue
Block a user