mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 07:19:41 +02:00
feat(edge/stacks): sync EE codechanges [EE-498] (#8580)
This commit is contained in:
parent
0ec7dfce69
commit
93bf630105
53 changed files with 1572 additions and 424 deletions
|
@ -0,0 +1,41 @@
|
|||
import { useMutation } from 'react-query';
|
||||
|
||||
import axios, { parseAxiosError } from '@/portainer/services/axios';
|
||||
import { withError } 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';
|
||||
|
||||
export function useCreateStackFromFileContent() {
|
||||
return useMutation(createStackFromFileContent, {
|
||||
...withError('Failed creating Edge stack'),
|
||||
});
|
||||
}
|
||||
|
||||
interface FileContentPayload {
|
||||
name: string;
|
||||
stackFileContent: string;
|
||||
edgeGroups: EdgeGroup['Id'][];
|
||||
deploymentType: DeploymentType;
|
||||
registries?: RegistryId[];
|
||||
useManifestNamespaces?: boolean;
|
||||
prePullImage?: boolean;
|
||||
dryRun?: boolean;
|
||||
}
|
||||
|
||||
export async function createStackFromFileContent({
|
||||
dryRun,
|
||||
...payload
|
||||
}: FileContentPayload) {
|
||||
try {
|
||||
const { data } = await axios.post<EdgeStack>(buildUrl(), payload, {
|
||||
params: { method: 'string', dryrun: dryRun ? 'true' : 'false' },
|
||||
});
|
||||
return data;
|
||||
} catch (e) {
|
||||
throw parseAxiosError(e as Error);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue