1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-22 23:09:41 +02:00

feat(edge/templates): introduce edge app templates [EE-6209] (#10480)

This commit is contained in:
Chaim Lev-Ari 2023-11-14 14:54:44 +02:00 committed by GitHub
parent 95d96e1164
commit e1e90c9c1d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
58 changed files with 1142 additions and 365 deletions

View file

@ -0,0 +1,49 @@
import { useMutation, useQueryClient } from 'react-query';
import axios, { parseAxiosError } from '@/portainer/services/axios';
import { withError, withInvalidate } from '@/react-tools/react-query';
import { RegistryId } from '@/react/portainer/registries/types';
import { EdgeGroup } from '../../edge-groups/types';
import { DeploymentType, EdgeStack } from '../types';
import { buildUrl } from './buildUrl';
import { queryKeys } from './query-keys';
export function useCreateEdgeStackFromFileContent() {
const queryClient = useQueryClient();
return useMutation(createEdgeStackFromFileContent, {
...withError('Failed creating Edge stack'),
...withInvalidate(queryClient, [queryKeys.base()]),
});
}
interface FileContentPayload {
name: string;
stackFileContent: string;
edgeGroups: EdgeGroup['Id'][];
deploymentType: DeploymentType;
registries?: RegistryId[];
useManifestNamespaces?: boolean;
prePullImage?: boolean;
dryRun?: boolean;
}
export async function createEdgeStackFromFileContent({
dryRun,
...payload
}: FileContentPayload) {
try {
const { data } = await axios.post<EdgeStack>(
buildUrl(undefined, 'create/string'),
payload,
{
params: { dryrun: dryRun ? 'true' : 'false' },
}
);
return data;
} catch (e) {
throw parseAxiosError(e as Error);
}
}