mirror of
https://github.com/portainer/portainer.git
synced 2025-07-22 23:09:41 +02:00
refactor(containers): migrate resources tab to react [EE-5214] (#10355)
This commit is contained in:
parent
ec091efe3b
commit
ffac83864d
28 changed files with 1114 additions and 537 deletions
40
app/react/docker/containers/queries/useUpdateContainer.ts
Normal file
40
app/react/docker/containers/queries/useUpdateContainer.ts
Normal file
|
@ -0,0 +1,40 @@
|
|||
import { Resources, RestartPolicy } from 'docker-types/generated/1.41';
|
||||
import { AxiosRequestHeaders } from 'axios';
|
||||
|
||||
import axios, { parseAxiosError } from '@/portainer/services/axios';
|
||||
import { EnvironmentId } from '@/react/portainer/environments/types';
|
||||
|
||||
import { urlBuilder } from '../containers.service';
|
||||
|
||||
/**
|
||||
* UpdateConfig holds the mutable attributes of a Container.
|
||||
* Those attributes can be updated at runtime.
|
||||
*/
|
||||
interface UpdateConfig extends Resources {
|
||||
// Contains container's resources (cgroups, ulimits)
|
||||
|
||||
RestartPolicy?: RestartPolicy;
|
||||
}
|
||||
|
||||
export async function updateContainer(
|
||||
environmentId: EnvironmentId,
|
||||
containerId: string,
|
||||
config: UpdateConfig,
|
||||
{ nodeName }: { nodeName?: string } = {}
|
||||
) {
|
||||
const headers: AxiosRequestHeaders = {};
|
||||
|
||||
if (nodeName) {
|
||||
headers['X-PortainerAgent-Target'] = nodeName;
|
||||
}
|
||||
|
||||
try {
|
||||
await axios.post<{ Warnings: string[] }>(
|
||||
urlBuilder(environmentId, containerId, 'update'),
|
||||
config,
|
||||
{ headers }
|
||||
);
|
||||
} catch (err) {
|
||||
throw parseAxiosError(err, 'failed updating container');
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue