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:
parent
95d96e1164
commit
e1e90c9c1d
58 changed files with 1142 additions and 365 deletions
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue