mirror of
https://github.com/portainer/portainer.git
synced 2025-08-04 21:35:23 +02:00
feat(app): limit the docker API version supported by the frontend (#11855)
Some checks are pending
ci / build_images (map[arch:amd64 platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
ci / build_images (map[arch:arm platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:arm64 platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:ppc64le platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:s390x platform:linux version:]) (push) Waiting to run
ci / build_manifests (push) Blocked by required conditions
/ triage (push) Waiting to run
Lint / Run linters (push) Waiting to run
Test / test-client (push) Waiting to run
Test / test-server (map[arch:amd64 platform:linux]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
Test / test-server (map[arch:arm64 platform:linux]) (push) Waiting to run
Some checks are pending
ci / build_images (map[arch:amd64 platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
ci / build_images (map[arch:arm platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:arm64 platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:ppc64le platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:s390x platform:linux version:]) (push) Waiting to run
ci / build_manifests (push) Blocked by required conditions
/ triage (push) Waiting to run
Lint / Run linters (push) Waiting to run
Test / test-client (push) Waiting to run
Test / test-server (map[arch:amd64 platform:linux]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
Test / test-server (map[arch:arm64 platform:linux]) (push) Waiting to run
This commit is contained in:
parent
4ba16f1b04
commit
6a8e6734f3
212 changed files with 4439 additions and 3281 deletions
31
app/react/docker/proxy/queries/images/useDownloadImages.ts
Normal file
31
app/react/docker/proxy/queries/images/useDownloadImages.ts
Normal file
|
@ -0,0 +1,31 @@
|
|||
import axios, { parseAxiosError } from '@/portainer/services/axios';
|
||||
import { EnvironmentId } from '@/react/portainer/environments/types';
|
||||
|
||||
import { buildDockerProxyUrl } from '../buildDockerProxyUrl';
|
||||
import { formatArrayQueryParamsForDockerAPI } from '../utils';
|
||||
|
||||
/**
|
||||
* Raw docker API proxy
|
||||
*/
|
||||
export async function downloadImages(
|
||||
environmentId: EnvironmentId,
|
||||
images: { tags: string[]; id: string }[]
|
||||
) {
|
||||
const names = images.map((image) =>
|
||||
image.tags[0] !== '<none>:<none>' ? image.tags[0] : image.id
|
||||
);
|
||||
|
||||
try {
|
||||
const { data } = await axios.get(
|
||||
buildDockerProxyUrl(environmentId, 'images', 'get'),
|
||||
{
|
||||
params: { names },
|
||||
responseType: 'blob',
|
||||
paramsSerializer: formatArrayQueryParamsForDockerAPI,
|
||||
}
|
||||
);
|
||||
return data;
|
||||
} catch (e) {
|
||||
throw parseAxiosError(e, 'Unable to download images');
|
||||
}
|
||||
}
|
26
app/react/docker/proxy/queries/images/useImage.ts
Normal file
26
app/react/docker/proxy/queries/images/useImage.ts
Normal file
|
@ -0,0 +1,26 @@
|
|||
import { ImageInspect } from 'docker-types/generated/1.41';
|
||||
|
||||
import axios, { parseAxiosError } from '@/portainer/services/axios';
|
||||
import { EnvironmentId } from '@/react/portainer/environments/types';
|
||||
|
||||
import { buildDockerProxyUrl } from '../buildDockerProxyUrl';
|
||||
|
||||
/**
|
||||
* Raw docker API proxy
|
||||
* @param environmentId
|
||||
* @param id
|
||||
* @returns
|
||||
*/
|
||||
export async function getImage(
|
||||
environmentId: EnvironmentId,
|
||||
id: Required<ImageInspect['Id']>
|
||||
) {
|
||||
try {
|
||||
const { data } = await axios.get<ImageInspect>(
|
||||
buildDockerProxyUrl(environmentId, 'images', id, 'json')
|
||||
);
|
||||
return data;
|
||||
} catch (e) {
|
||||
throw parseAxiosError(e, 'Unable to retrieve image');
|
||||
}
|
||||
}
|
32
app/react/docker/proxy/queries/images/useImageHistory.ts
Normal file
32
app/react/docker/proxy/queries/images/useImageHistory.ts
Normal file
|
@ -0,0 +1,32 @@
|
|||
import { EnvironmentId } from '@/react/portainer/environments/types';
|
||||
import axios, { parseAxiosError } from '@/portainer/services/axios';
|
||||
|
||||
import { buildDockerProxyUrl } from '../buildDockerProxyUrl';
|
||||
|
||||
export type ImageLayer = {
|
||||
Id: string;
|
||||
Created: number;
|
||||
CreatedBy: string;
|
||||
Tags: string[];
|
||||
Size: number;
|
||||
Comment: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Raw docker API proxy
|
||||
* @param environmentId
|
||||
* @returns
|
||||
*/
|
||||
export async function getImageHistory(
|
||||
environmentId: EnvironmentId,
|
||||
id: ImageLayer['Id']
|
||||
) {
|
||||
try {
|
||||
const { data } = await axios.get<ImageLayer[]>(
|
||||
buildDockerProxyUrl(environmentId, 'images', id, 'history')
|
||||
);
|
||||
return data;
|
||||
} catch (err) {
|
||||
throw parseAxiosError(err as Error, 'Unable to retrieve image layers');
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@ import { ImageSummary } from 'docker-types/generated/1.41';
|
|||
import axios, { parseAxiosError } from '@/portainer/services/axios';
|
||||
import { EnvironmentId } from '@/react/portainer/environments/types';
|
||||
|
||||
import { buildUrl } from '../build-url';
|
||||
import { buildDockerProxyUrl } from '../buildDockerProxyUrl';
|
||||
|
||||
import { queryKeys } from './queryKeys';
|
||||
|
||||
|
@ -24,10 +24,15 @@ export function useImages<T = ImagesListResponse>(
|
|||
);
|
||||
}
|
||||
|
||||
async function getImages(environmentId: EnvironmentId) {
|
||||
/**
|
||||
* Raw docker API proxy
|
||||
* @param environmentId
|
||||
* @returns
|
||||
*/
|
||||
export async function getImages(environmentId: EnvironmentId) {
|
||||
try {
|
||||
const { data } = await axios.get<ImagesListResponse>(
|
||||
buildUrl(environmentId, 'images', 'json')
|
||||
buildDockerProxyUrl(environmentId, 'images', 'json')
|
||||
);
|
||||
return data;
|
||||
} catch (err) {
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
import axios, { parseAxiosError } from '@/portainer/services/axios';
|
||||
import { EnvironmentId } from '@/react/portainer/environments/types';
|
||||
import { ImageId, ImageName } from '@/docker/models/image';
|
||||
|
||||
import { buildDockerProxyUrl } from '../buildDockerProxyUrl';
|
||||
|
||||
/**
|
||||
* Raw docker API proxy
|
||||
* @param environmentId
|
||||
* @param id
|
||||
* @param force
|
||||
* @returns
|
||||
*/
|
||||
export async function removeImage(
|
||||
environmentId: EnvironmentId,
|
||||
id: ImageId | ImageName,
|
||||
force?: boolean
|
||||
) {
|
||||
try {
|
||||
const { data } = await axios.delete(
|
||||
buildDockerProxyUrl(environmentId, 'images', id),
|
||||
{ params: { force } }
|
||||
);
|
||||
return data;
|
||||
} catch (e) {
|
||||
throw parseAxiosError(e, 'Unable to remove image');
|
||||
}
|
||||
}
|
29
app/react/docker/proxy/queries/images/useTagImageMutation.ts
Normal file
29
app/react/docker/proxy/queries/images/useTagImageMutation.ts
Normal file
|
@ -0,0 +1,29 @@
|
|||
import { EnvironmentId } from '@/react/portainer/environments/types';
|
||||
import axios, { parseAxiosError } from '@/portainer/services/axios';
|
||||
import { ImageId, ImageName } from '@/docker/models/image';
|
||||
|
||||
import { buildDockerProxyUrl } from '../buildDockerProxyUrl';
|
||||
|
||||
/**
|
||||
* Raw docker API proxy
|
||||
* @param environmentId
|
||||
* @param id
|
||||
* @param repo string generated by `buildImageFullURIFromModel` or `buildImageFullURI`
|
||||
* @returns
|
||||
*/
|
||||
export async function tagImage(
|
||||
environmentId: EnvironmentId,
|
||||
id: ImageId | ImageName,
|
||||
repo: string
|
||||
) {
|
||||
try {
|
||||
const { data } = await axios.post(
|
||||
buildDockerProxyUrl(environmentId, 'images', id, 'tag'),
|
||||
{},
|
||||
{ params: { repo } }
|
||||
);
|
||||
return data;
|
||||
} catch (e) {
|
||||
throw parseAxiosError(e, 'Unable to tag image');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
import axios, { parseAxiosError } from '@/portainer/services/axios';
|
||||
import { EnvironmentId } from '@/react/portainer/environments/types';
|
||||
|
||||
import { buildDockerProxyUrl } from '../buildDockerProxyUrl';
|
||||
|
||||
/**
|
||||
* Raw docker API proxy
|
||||
* @param environmentId
|
||||
* @param file
|
||||
* @returns
|
||||
*/
|
||||
export async function uploadImages(environmentId: EnvironmentId, file: File) {
|
||||
try {
|
||||
return await axios.post(
|
||||
buildDockerProxyUrl(environmentId, 'images', 'load'),
|
||||
file,
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': file.type, // 'application/x-tar',
|
||||
},
|
||||
}
|
||||
);
|
||||
} catch (e) {
|
||||
throw parseAxiosError(e, 'Unable to upload image');
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue