1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-24 15:59:41 +02:00

refactor(app): details widget migration [EE-5352] (#8886)

This commit is contained in:
Ali 2023-05-29 15:06:14 +12:00 committed by GitHub
parent fdd79cece8
commit af77e33993
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
57 changed files with 2046 additions and 1079 deletions

View file

@ -1,12 +1,23 @@
import { Pod, PodList } from 'kubernetes-types/core/v1';
import axios, { parseAxiosError } from '@/portainer/services/axios';
import { EnvironmentId } from '@/react/portainer/environments/types';
import axios, { parseAxiosError } from '@/portainer/services/axios';
export async function getPods(environmentId: EnvironmentId, namespace: string) {
import { ApplicationPatch } from './types';
export async function getNamespacePods(
environmentId: EnvironmentId,
namespace: string,
labelSelector?: string
) {
try {
const { data } = await axios.get<PodList>(
buildUrl(environmentId, namespace)
buildUrl(environmentId, namespace),
{
params: {
labelSelector,
},
}
);
return data.items;
} catch (e) {
@ -33,20 +44,12 @@ export async function patchPod(
environmentId: EnvironmentId,
namespace: string,
name: string,
path: string,
value: string
patch: ApplicationPatch
) {
const payload = [
{
op: 'replace',
path,
value,
},
];
try {
return await axios.patch<Pod>(
buildUrl(environmentId, namespace, name),
payload,
patch,
{
headers: {
'Content-Type': 'application/json-patch+json',
@ -58,6 +61,18 @@ export async function patchPod(
}
}
export async function deletePod(
environmentId: EnvironmentId,
namespace: string,
name: string
) {
try {
return await axios.delete<Pod>(buildUrl(environmentId, namespace, name));
} catch (e) {
throw parseAxiosError(e as Error, 'Unable to delete pod');
}
}
export function buildUrl(
environmentId: EnvironmentId,
namespace: string,