@lakutata/containerd 0.0.0-stage → 3.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +23 -0
- package/README.md +409 -2
- package/THIRD_PARTY_NOTICES.md +310 -0
- package/dist/cjs/client/BuildKit.d.ts +176 -0
- package/dist/cjs/client/BuildKit.js +536 -0
- package/dist/cjs/client/BuildKitMessages.d.ts +35 -0
- package/dist/cjs/client/BuildKitMessages.js +123 -0
- package/dist/cjs/client/ContainerStore.d.ts +558 -0
- package/dist/cjs/client/ContainerStore.js +1384 -0
- package/dist/cjs/client/ContainerdClient.d.ts +244 -0
- package/dist/cjs/client/ContainerdClient.js +455 -0
- package/dist/cjs/client/DockerIgnore.d.ts +44 -0
- package/dist/cjs/client/DockerIgnore.js +186 -0
- package/dist/cjs/client/Fifo.d.ts +31 -0
- package/dist/cjs/client/Fifo.js +66 -0
- package/dist/cjs/client/ImageStore.d.ts +258 -0
- package/dist/cjs/client/ImageStore.js +636 -0
- package/dist/cjs/client/Messages.d.ts +103 -0
- package/dist/cjs/client/Messages.js +397 -0
- package/dist/cjs/client/Networks.d.ts +221 -0
- package/dist/cjs/client/Networks.js +630 -0
- package/dist/cjs/client/Platforms.d.ts +53 -0
- package/dist/cjs/client/Platforms.js +169 -0
- package/dist/cjs/client/Reference.d.ts +33 -0
- package/dist/cjs/client/Reference.js +70 -0
- package/dist/cjs/client/Registry.d.ts +145 -0
- package/dist/cjs/client/Registry.js +272 -0
- package/dist/cjs/client/Rootfs.d.ts +83 -0
- package/dist/cjs/client/Rootfs.js +245 -0
- package/dist/cjs/client/Seccomp.d.ts +36 -0
- package/dist/cjs/client/Seccomp.js +156 -0
- package/dist/cjs/client/Spec.d.ts +151 -0
- package/dist/cjs/client/Spec.js +227 -0
- package/dist/cjs/client/Volumes.d.ts +42 -0
- package/dist/cjs/client/Volumes.js +80 -0
- package/dist/cjs/containerd/Containerd.d.ts +442 -0
- package/dist/cjs/containerd/Containerd.js +929 -0
- package/dist/cjs/containerd/exceptions/ContainerdConnectionException.d.ts +9 -0
- package/dist/cjs/containerd/exceptions/ContainerdConnectionException.js +16 -0
- package/dist/cjs/containerd/exceptions/ContainerdContainerNameConflictException.d.ts +8 -0
- package/dist/cjs/containerd/exceptions/ContainerdContainerNameConflictException.js +15 -0
- package/dist/cjs/containerd/exceptions/ContainerdContainerNotFoundException.d.ts +9 -0
- package/dist/cjs/containerd/exceptions/ContainerdContainerNotFoundException.js +16 -0
- package/dist/cjs/containerd/exceptions/ContainerdContainerStateException.d.ts +10 -0
- package/dist/cjs/containerd/exceptions/ContainerdContainerStateException.js +17 -0
- package/dist/cjs/containerd/exceptions/ContainerdImageBuildException.d.ts +9 -0
- package/dist/cjs/containerd/exceptions/ContainerdImageBuildException.js +16 -0
- package/dist/cjs/containerd/exceptions/ContainerdImageExportException.d.ts +9 -0
- package/dist/cjs/containerd/exceptions/ContainerdImageExportException.js +16 -0
- package/dist/cjs/containerd/exceptions/ContainerdImageImportException.d.ts +9 -0
- package/dist/cjs/containerd/exceptions/ContainerdImageImportException.js +16 -0
- package/dist/cjs/containerd/exceptions/ContainerdImageNotFoundException.d.ts +9 -0
- package/dist/cjs/containerd/exceptions/ContainerdImageNotFoundException.js +16 -0
- package/dist/cjs/containerd/exceptions/ContainerdImagePullException.d.ts +9 -0
- package/dist/cjs/containerd/exceptions/ContainerdImagePullException.js +16 -0
- package/dist/cjs/containerd/exceptions/ContainerdImagePushException.d.ts +8 -0
- package/dist/cjs/containerd/exceptions/ContainerdImagePushException.js +15 -0
- package/dist/cjs/containerd/exceptions/ContainerdNetworkConflictException.d.ts +9 -0
- package/dist/cjs/containerd/exceptions/ContainerdNetworkConflictException.js +16 -0
- package/dist/cjs/containerd/exceptions/ContainerdNetworkNotFoundException.d.ts +9 -0
- package/dist/cjs/containerd/exceptions/ContainerdNetworkNotFoundException.js +16 -0
- package/dist/cjs/containerd/exceptions/ContainerdPathNotFoundException.d.ts +8 -0
- package/dist/cjs/containerd/exceptions/ContainerdPathNotFoundException.js +15 -0
- package/dist/cjs/containerd/exceptions/ContainerdPlatformException.d.ts +9 -0
- package/dist/cjs/containerd/exceptions/ContainerdPlatformException.js +16 -0
- package/dist/cjs/containerd/exceptions/ContainerdVolumeInUseException.d.ts +8 -0
- package/dist/cjs/containerd/exceptions/ContainerdVolumeInUseException.js +15 -0
- package/dist/cjs/containerd/exceptions/ContainerdVolumeNotFoundException.d.ts +8 -0
- package/dist/cjs/containerd/exceptions/ContainerdVolumeNotFoundException.js +15 -0
- package/dist/cjs/containerd/lib/ContainerdContainer.d.ts +292 -0
- package/dist/cjs/containerd/lib/ContainerdContainer.js +536 -0
- package/dist/cjs/containerd/lib/ContainerdContainerTTY.d.ts +116 -0
- package/dist/cjs/containerd/lib/ContainerdContainerTTY.js +178 -0
- package/dist/cjs/containerd/lib/ContainerdErrors.d.ts +6 -0
- package/dist/cjs/containerd/lib/ContainerdErrors.js +37 -0
- package/dist/cjs/containerd/lib/ContainerdImage.d.ts +149 -0
- package/dist/cjs/containerd/lib/ContainerdImage.js +222 -0
- package/dist/cjs/containerd/options/ContainerdPruneOptions.d.ts +44 -0
- package/dist/cjs/containerd/options/ContainerdPruneOptions.js +51 -0
- package/dist/cjs/containerd/options/ContainerdRegistryAuthOptions.d.ts +32 -0
- package/dist/cjs/containerd/options/ContainerdRegistryAuthOptions.js +45 -0
- package/dist/cjs/containerd/options/container/ContainerCommitOptions.d.ts +57 -0
- package/dist/cjs/containerd/options/container/ContainerCommitOptions.js +66 -0
- package/dist/cjs/containerd/options/container/ContainerCreateOptions.d.ts +273 -0
- package/dist/cjs/containerd/options/container/ContainerCreateOptions.js +239 -0
- package/dist/cjs/containerd/options/container/ContainerExecOptions.d.ts +53 -0
- package/dist/cjs/containerd/options/container/ContainerExecOptions.js +63 -0
- package/dist/cjs/containerd/options/container/ContainerExportDirectoryOptions.d.ts +32 -0
- package/dist/cjs/containerd/options/container/ContainerExportDirectoryOptions.js +45 -0
- package/dist/cjs/containerd/options/container/ContainerKillOptions.d.ts +30 -0
- package/dist/cjs/containerd/options/container/ContainerKillOptions.js +41 -0
- package/dist/cjs/containerd/options/container/ContainerLogsOptions.d.ts +34 -0
- package/dist/cjs/containerd/options/container/ContainerLogsOptions.js +44 -0
- package/dist/cjs/containerd/options/container/ContainerRemoveOptions.d.ts +22 -0
- package/dist/cjs/containerd/options/container/ContainerRemoveOptions.js +34 -0
- package/dist/cjs/containerd/options/container/ContainerResourceOptions.d.ts +63 -0
- package/dist/cjs/containerd/options/container/ContainerResourceOptions.js +67 -0
- package/dist/cjs/containerd/options/container/ContainerStopOptions.d.ts +30 -0
- package/dist/cjs/containerd/options/container/ContainerStopOptions.js +41 -0
- package/dist/cjs/containerd/options/container/ContainerTTYConsoleSizeOptions.d.ts +26 -0
- package/dist/cjs/containerd/options/container/ContainerTTYConsoleSizeOptions.js +40 -0
- package/dist/cjs/containerd/options/container/ContainerTTYOptions.d.ts +50 -0
- package/dist/cjs/containerd/options/container/ContainerTTYOptions.js +63 -0
- package/dist/cjs/containerd/options/image/ImageBuildOptions.d.ts +88 -0
- package/dist/cjs/containerd/options/image/ImageBuildOptions.js +95 -0
- package/dist/cjs/containerd/options/image/ImageExportOptions.d.ts +25 -0
- package/dist/cjs/containerd/options/image/ImageExportOptions.js +39 -0
- package/dist/cjs/containerd/options/image/ImageImportOptions.d.ts +38 -0
- package/dist/cjs/containerd/options/image/ImageImportOptions.js +47 -0
- package/dist/cjs/containerd/options/image/ImagePullOptions.d.ts +53 -0
- package/dist/cjs/containerd/options/image/ImagePullOptions.js +66 -0
- package/dist/cjs/containerd/options/image/ImagePushOptions.d.ts +44 -0
- package/dist/cjs/containerd/options/image/ImagePushOptions.js +58 -0
- package/dist/cjs/containerd/options/network/NetworkCreateOptions.d.ts +82 -0
- package/dist/cjs/containerd/options/network/NetworkCreateOptions.js +83 -0
- package/dist/cjs/containerd/options/volume/VolumeCreateOptions.d.ts +26 -0
- package/dist/cjs/containerd/options/volume/VolumeCreateOptions.js +40 -0
- package/dist/cjs/containerd/types/ContainerdBind.d.ts +28 -0
- package/dist/cjs/containerd/types/ContainerdBind.js +2 -0
- package/dist/cjs/containerd/types/ContainerdBuildOutputCallback.d.ts +6 -0
- package/dist/cjs/containerd/types/ContainerdBuildOutputCallback.js +2 -0
- package/dist/cjs/containerd/types/ContainerdContainerNetwork.d.ts +40 -0
- package/dist/cjs/containerd/types/ContainerdContainerNetwork.js +2 -0
- package/dist/cjs/containerd/types/ContainerdContainerPort.d.ts +22 -0
- package/dist/cjs/containerd/types/ContainerdContainerPort.js +2 -0
- package/dist/cjs/containerd/types/ContainerdContainerState.d.ts +42 -0
- package/dist/cjs/containerd/types/ContainerdContainerState.js +2 -0
- package/dist/cjs/containerd/types/ContainerdContainerStats.d.ts +107 -0
- package/dist/cjs/containerd/types/ContainerdContainerStats.js +2 -0
- package/dist/cjs/containerd/types/ContainerdDevice.d.ts +25 -0
- package/dist/cjs/containerd/types/ContainerdDevice.js +2 -0
- package/dist/cjs/containerd/types/ContainerdExecResult.d.ts +18 -0
- package/dist/cjs/containerd/types/ContainerdExecResult.js +2 -0
- package/dist/cjs/containerd/types/ContainerdImageConfig.d.ts +46 -0
- package/dist/cjs/containerd/types/ContainerdImageConfig.js +2 -0
- package/dist/cjs/containerd/types/ContainerdNetworkInfo.d.ts +49 -0
- package/dist/cjs/containerd/types/ContainerdNetworkInfo.js +2 -0
- package/dist/cjs/containerd/types/ContainerdProgressCallback.d.ts +29 -0
- package/dist/cjs/containerd/types/ContainerdProgressCallback.js +2 -0
- package/dist/cjs/containerd/types/ContainerdPruneResult.d.ts +21 -0
- package/dist/cjs/containerd/types/ContainerdPruneResult.js +2 -0
- package/dist/cjs/containerd/types/ContainerdRestartPolicy.d.ts +13 -0
- package/dist/cjs/containerd/types/ContainerdRestartPolicy.js +2 -0
- package/dist/cjs/containerd/types/ContainerdTmpfs.d.ts +20 -0
- package/dist/cjs/containerd/types/ContainerdTmpfs.js +2 -0
- package/dist/cjs/containerd/types/ContainerdVolume.d.ts +19 -0
- package/dist/cjs/containerd/types/ContainerdVolume.js +2 -0
- package/dist/cjs/containerd/types/ContainerdVolumeInfo.d.ts +26 -0
- package/dist/cjs/containerd/types/ContainerdVolumeInfo.js +2 -0
- package/dist/cjs/exports/Containerd.d.ts +69 -0
- package/dist/cjs/exports/Containerd.js +87 -0
- package/dist/cjs/package.json +1 -0
- package/dist/esm/client/BuildKit.js +488 -0
- package/dist/esm/client/BuildKitMessages.js +120 -0
- package/dist/esm/client/ContainerStore.js +1339 -0
- package/dist/esm/client/ContainerdClient.js +416 -0
- package/dist/esm/client/DockerIgnore.js +179 -0
- package/dist/esm/client/Fifo.js +59 -0
- package/dist/esm/client/ImageStore.js +628 -0
- package/dist/esm/client/Messages.js +393 -0
- package/dist/esm/client/Networks.js +621 -0
- package/dist/esm/client/Platforms.js +156 -0
- package/dist/esm/client/Reference.js +66 -0
- package/dist/esm/client/Registry.js +263 -0
- package/dist/esm/client/Rootfs.js +234 -0
- package/dist/esm/client/Seccomp.js +152 -0
- package/dist/esm/client/Spec.js +220 -0
- package/dist/esm/client/Volumes.js +73 -0
- package/dist/esm/containerd/Containerd.js +923 -0
- package/dist/esm/containerd/exceptions/ContainerdConnectionException.js +12 -0
- package/dist/esm/containerd/exceptions/ContainerdContainerNameConflictException.js +11 -0
- package/dist/esm/containerd/exceptions/ContainerdContainerNotFoundException.js +12 -0
- package/dist/esm/containerd/exceptions/ContainerdContainerStateException.js +13 -0
- package/dist/esm/containerd/exceptions/ContainerdImageBuildException.js +12 -0
- package/dist/esm/containerd/exceptions/ContainerdImageExportException.js +12 -0
- package/dist/esm/containerd/exceptions/ContainerdImageImportException.js +12 -0
- package/dist/esm/containerd/exceptions/ContainerdImageNotFoundException.js +12 -0
- package/dist/esm/containerd/exceptions/ContainerdImagePullException.js +12 -0
- package/dist/esm/containerd/exceptions/ContainerdImagePushException.js +11 -0
- package/dist/esm/containerd/exceptions/ContainerdNetworkConflictException.js +12 -0
- package/dist/esm/containerd/exceptions/ContainerdNetworkNotFoundException.js +12 -0
- package/dist/esm/containerd/exceptions/ContainerdPathNotFoundException.js +11 -0
- package/dist/esm/containerd/exceptions/ContainerdPlatformException.js +12 -0
- package/dist/esm/containerd/exceptions/ContainerdVolumeInUseException.js +11 -0
- package/dist/esm/containerd/exceptions/ContainerdVolumeNotFoundException.js +11 -0
- package/dist/esm/containerd/lib/ContainerdContainer.js +533 -0
- package/dist/esm/containerd/lib/ContainerdContainerTTY.js +175 -0
- package/dist/esm/containerd/lib/ContainerdErrors.js +34 -0
- package/dist/esm/containerd/lib/ContainerdImage.js +219 -0
- package/dist/esm/containerd/options/ContainerdPruneOptions.js +47 -0
- package/dist/esm/containerd/options/ContainerdRegistryAuthOptions.js +41 -0
- package/dist/esm/containerd/options/container/ContainerCommitOptions.js +62 -0
- package/dist/esm/containerd/options/container/ContainerCreateOptions.js +235 -0
- package/dist/esm/containerd/options/container/ContainerExecOptions.js +59 -0
- package/dist/esm/containerd/options/container/ContainerExportDirectoryOptions.js +41 -0
- package/dist/esm/containerd/options/container/ContainerKillOptions.js +37 -0
- package/dist/esm/containerd/options/container/ContainerLogsOptions.js +40 -0
- package/dist/esm/containerd/options/container/ContainerRemoveOptions.js +30 -0
- package/dist/esm/containerd/options/container/ContainerResourceOptions.js +63 -0
- package/dist/esm/containerd/options/container/ContainerStopOptions.js +37 -0
- package/dist/esm/containerd/options/container/ContainerTTYConsoleSizeOptions.js +36 -0
- package/dist/esm/containerd/options/container/ContainerTTYOptions.js +59 -0
- package/dist/esm/containerd/options/image/ImageBuildOptions.js +91 -0
- package/dist/esm/containerd/options/image/ImageExportOptions.js +35 -0
- package/dist/esm/containerd/options/image/ImageImportOptions.js +43 -0
- package/dist/esm/containerd/options/image/ImagePullOptions.js +62 -0
- package/dist/esm/containerd/options/image/ImagePushOptions.js +54 -0
- package/dist/esm/containerd/options/network/NetworkCreateOptions.js +79 -0
- package/dist/esm/containerd/options/volume/VolumeCreateOptions.js +36 -0
- package/dist/esm/containerd/types/ContainerdBind.js +1 -0
- package/dist/esm/containerd/types/ContainerdBuildOutputCallback.js +1 -0
- package/dist/esm/containerd/types/ContainerdContainerNetwork.js +1 -0
- package/dist/esm/containerd/types/ContainerdContainerPort.js +1 -0
- package/dist/esm/containerd/types/ContainerdContainerState.js +1 -0
- package/dist/esm/containerd/types/ContainerdContainerStats.js +1 -0
- package/dist/esm/containerd/types/ContainerdDevice.js +1 -0
- package/dist/esm/containerd/types/ContainerdExecResult.js +1 -0
- package/dist/esm/containerd/types/ContainerdImageConfig.js +1 -0
- package/dist/esm/containerd/types/ContainerdNetworkInfo.js +1 -0
- package/dist/esm/containerd/types/ContainerdProgressCallback.js +1 -0
- package/dist/esm/containerd/types/ContainerdPruneResult.js +1 -0
- package/dist/esm/containerd/types/ContainerdRestartPolicy.js +1 -0
- package/dist/esm/containerd/types/ContainerdTmpfs.js +1 -0
- package/dist/esm/containerd/types/ContainerdVolume.js +1 -0
- package/dist/esm/containerd/types/ContainerdVolumeInfo.js +1 -0
- package/dist/esm/exports/Containerd.js +68 -0
- package/dist/types/client/BuildKit.d.ts +176 -0
- package/dist/types/client/BuildKitMessages.d.ts +35 -0
- package/dist/types/client/ContainerStore.d.ts +558 -0
- package/dist/types/client/ContainerdClient.d.ts +244 -0
- package/dist/types/client/DockerIgnore.d.ts +44 -0
- package/dist/types/client/Fifo.d.ts +31 -0
- package/dist/types/client/ImageStore.d.ts +258 -0
- package/dist/types/client/Messages.d.ts +103 -0
- package/dist/types/client/Networks.d.ts +221 -0
- package/dist/types/client/Platforms.d.ts +53 -0
- package/dist/types/client/Reference.d.ts +33 -0
- package/dist/types/client/Registry.d.ts +145 -0
- package/dist/types/client/Rootfs.d.ts +83 -0
- package/dist/types/client/Seccomp.d.ts +36 -0
- package/dist/types/client/Spec.d.ts +151 -0
- package/dist/types/client/Volumes.d.ts +42 -0
- package/dist/types/containerd/Containerd.d.ts +442 -0
- package/dist/types/containerd/exceptions/ContainerdConnectionException.d.ts +9 -0
- package/dist/types/containerd/exceptions/ContainerdContainerNameConflictException.d.ts +8 -0
- package/dist/types/containerd/exceptions/ContainerdContainerNotFoundException.d.ts +9 -0
- package/dist/types/containerd/exceptions/ContainerdContainerStateException.d.ts +10 -0
- package/dist/types/containerd/exceptions/ContainerdImageBuildException.d.ts +9 -0
- package/dist/types/containerd/exceptions/ContainerdImageExportException.d.ts +9 -0
- package/dist/types/containerd/exceptions/ContainerdImageImportException.d.ts +9 -0
- package/dist/types/containerd/exceptions/ContainerdImageNotFoundException.d.ts +9 -0
- package/dist/types/containerd/exceptions/ContainerdImagePullException.d.ts +9 -0
- package/dist/types/containerd/exceptions/ContainerdImagePushException.d.ts +8 -0
- package/dist/types/containerd/exceptions/ContainerdNetworkConflictException.d.ts +9 -0
- package/dist/types/containerd/exceptions/ContainerdNetworkNotFoundException.d.ts +9 -0
- package/dist/types/containerd/exceptions/ContainerdPathNotFoundException.d.ts +8 -0
- package/dist/types/containerd/exceptions/ContainerdPlatformException.d.ts +9 -0
- package/dist/types/containerd/exceptions/ContainerdVolumeInUseException.d.ts +8 -0
- package/dist/types/containerd/exceptions/ContainerdVolumeNotFoundException.d.ts +8 -0
- package/dist/types/containerd/lib/ContainerdContainer.d.ts +292 -0
- package/dist/types/containerd/lib/ContainerdContainerTTY.d.ts +116 -0
- package/dist/types/containerd/lib/ContainerdErrors.d.ts +6 -0
- package/dist/types/containerd/lib/ContainerdImage.d.ts +149 -0
- package/dist/types/containerd/options/ContainerdPruneOptions.d.ts +44 -0
- package/dist/types/containerd/options/ContainerdRegistryAuthOptions.d.ts +32 -0
- package/dist/types/containerd/options/container/ContainerCommitOptions.d.ts +57 -0
- package/dist/types/containerd/options/container/ContainerCreateOptions.d.ts +273 -0
- package/dist/types/containerd/options/container/ContainerExecOptions.d.ts +53 -0
- package/dist/types/containerd/options/container/ContainerExportDirectoryOptions.d.ts +32 -0
- package/dist/types/containerd/options/container/ContainerKillOptions.d.ts +30 -0
- package/dist/types/containerd/options/container/ContainerLogsOptions.d.ts +34 -0
- package/dist/types/containerd/options/container/ContainerRemoveOptions.d.ts +22 -0
- package/dist/types/containerd/options/container/ContainerResourceOptions.d.ts +63 -0
- package/dist/types/containerd/options/container/ContainerStopOptions.d.ts +30 -0
- package/dist/types/containerd/options/container/ContainerTTYConsoleSizeOptions.d.ts +26 -0
- package/dist/types/containerd/options/container/ContainerTTYOptions.d.ts +50 -0
- package/dist/types/containerd/options/image/ImageBuildOptions.d.ts +88 -0
- package/dist/types/containerd/options/image/ImageExportOptions.d.ts +25 -0
- package/dist/types/containerd/options/image/ImageImportOptions.d.ts +38 -0
- package/dist/types/containerd/options/image/ImagePullOptions.d.ts +53 -0
- package/dist/types/containerd/options/image/ImagePushOptions.d.ts +44 -0
- package/dist/types/containerd/options/network/NetworkCreateOptions.d.ts +82 -0
- package/dist/types/containerd/options/volume/VolumeCreateOptions.d.ts +26 -0
- package/dist/types/containerd/types/ContainerdBind.d.ts +28 -0
- package/dist/types/containerd/types/ContainerdBuildOutputCallback.d.ts +6 -0
- package/dist/types/containerd/types/ContainerdContainerNetwork.d.ts +40 -0
- package/dist/types/containerd/types/ContainerdContainerPort.d.ts +22 -0
- package/dist/types/containerd/types/ContainerdContainerState.d.ts +42 -0
- package/dist/types/containerd/types/ContainerdContainerStats.d.ts +107 -0
- package/dist/types/containerd/types/ContainerdDevice.d.ts +25 -0
- package/dist/types/containerd/types/ContainerdExecResult.d.ts +18 -0
- package/dist/types/containerd/types/ContainerdImageConfig.d.ts +46 -0
- package/dist/types/containerd/types/ContainerdNetworkInfo.d.ts +49 -0
- package/dist/types/containerd/types/ContainerdProgressCallback.d.ts +29 -0
- package/dist/types/containerd/types/ContainerdPruneResult.d.ts +21 -0
- package/dist/types/containerd/types/ContainerdRestartPolicy.d.ts +13 -0
- package/dist/types/containerd/types/ContainerdTmpfs.d.ts +20 -0
- package/dist/types/containerd/types/ContainerdVolume.d.ts +19 -0
- package/dist/types/containerd/types/ContainerdVolumeInfo.d.ts +26 -0
- package/dist/types/exports/Containerd.d.ts +69 -0
- package/package.json +51 -4
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { readdirSync, readFileSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
/**
|
|
4
|
+
* The architectures of OCI of the ones of Node.js
|
|
5
|
+
*/
|
|
6
|
+
const ARCHITECTURES = {
|
|
7
|
+
x64: 'amd64',
|
|
8
|
+
arm64: 'arm64',
|
|
9
|
+
arm: 'arm',
|
|
10
|
+
ia32: '386',
|
|
11
|
+
ppc64: 'ppc64le',
|
|
12
|
+
s390x: 's390x',
|
|
13
|
+
riscv64: 'riscv64',
|
|
14
|
+
loong64: 'loong64',
|
|
15
|
+
mips64el: 'mips64le'
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The platforms of the ELF binaries an entry of binfmt_misc runs (by the machine of the ELF header of its magic): the
|
|
19
|
+
* emulators of QEMU, Rosetta, whatever their names
|
|
20
|
+
* @param entry the content of the entry
|
|
21
|
+
*/
|
|
22
|
+
export function binfmtPlatforms(entry) {
|
|
23
|
+
if (!/^enabled$/m.test(entry))
|
|
24
|
+
return [];
|
|
25
|
+
const offset = entry.match(/^offset (\d+)$/m)?.[1];
|
|
26
|
+
const magic = entry.match(/^magic ([0-9a-f]+)$/m)?.[1];
|
|
27
|
+
if (!magic || (offset && offset !== '0'))
|
|
28
|
+
return [];
|
|
29
|
+
const bytes = Buffer.from(magic, 'hex');
|
|
30
|
+
if (bytes.length < 20 || bytes.readUInt32BE(0) !== 0x7f454c46)
|
|
31
|
+
return [];
|
|
32
|
+
const bits64 = bytes[4] === 2;
|
|
33
|
+
const little = bytes[5] === 1;
|
|
34
|
+
const machine = little ? bytes.readUInt16LE(18) : bytes.readUInt16BE(18);
|
|
35
|
+
const linux = (architecture, variant) => ({ os: 'linux', architecture: architecture, variant: variant });
|
|
36
|
+
switch (machine) {
|
|
37
|
+
case 0x3e:
|
|
38
|
+
return [linux('amd64')];
|
|
39
|
+
case 0x03:
|
|
40
|
+
return [linux('386')];
|
|
41
|
+
case 0xb7:
|
|
42
|
+
return [linux('arm64', 'v8')];
|
|
43
|
+
case 0x28:
|
|
44
|
+
return little ? [linux('arm', 'v7'), linux('arm', 'v6'), linux('arm', 'v5')] : [];
|
|
45
|
+
case 0xf3:
|
|
46
|
+
return bits64 ? [linux('riscv64')] : [];
|
|
47
|
+
case 0x15:
|
|
48
|
+
return bits64 ? [linux(little ? 'ppc64le' : 'ppc64')] : [];
|
|
49
|
+
case 0x16:
|
|
50
|
+
return [linux('s390x')];
|
|
51
|
+
case 0x08:
|
|
52
|
+
return [linux(bits64 ? (little ? 'mips64le' : 'mips64') : (little ? 'mipsle' : 'mips'))];
|
|
53
|
+
case 0x102:
|
|
54
|
+
return [linux('loong64')];
|
|
55
|
+
default:
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* A platform written as OCI writes it (linux/arm64/v8)
|
|
61
|
+
* @param platform
|
|
62
|
+
*/
|
|
63
|
+
export function formatPlatform(platform) {
|
|
64
|
+
return [platform.os, platform.architecture, platform.variant].filter(Boolean).join('/');
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The variant of an architecture given without it: the one its images are matched to (arm64 is v8, arm v7)
|
|
68
|
+
* @param platform
|
|
69
|
+
*/
|
|
70
|
+
export function normalizePlatform(platform) {
|
|
71
|
+
const architecture = { x86_64: 'amd64', aarch64: 'arm64', armhf: 'arm', armel: 'arm', i386: '386' }[platform.architecture] ?? platform.architecture;
|
|
72
|
+
let variant = platform.variant || undefined;
|
|
73
|
+
if (architecture === 'arm64' && !variant)
|
|
74
|
+
variant = 'v8';
|
|
75
|
+
if (architecture === 'arm' && !variant)
|
|
76
|
+
variant = 'v7';
|
|
77
|
+
return { os: platform.os || 'linux', architecture: architecture, variant: variant };
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Parse a platform: linux/arm64, linux/arm/v7, or an architecture (arm64), on Linux
|
|
81
|
+
* @param value
|
|
82
|
+
*/
|
|
83
|
+
export function parsePlatform(value) {
|
|
84
|
+
const parts = value.trim().toLowerCase().split('/').filter(Boolean);
|
|
85
|
+
if (!parts.length || parts.length > 3)
|
|
86
|
+
throw new Error(`The platform "${value}" is not valid (linux/arm64, linux/arm/v7)`);
|
|
87
|
+
const [os, architecture, variant] = parts.length === 1 ? ['linux', parts[0], undefined] : parts;
|
|
88
|
+
return normalizePlatform({ os: os, architecture: architecture, variant: variant });
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The platform of the machine running Node.js
|
|
92
|
+
*/
|
|
93
|
+
export function hostPlatform() {
|
|
94
|
+
const architecture = ARCHITECTURES[process.arch] ?? process.arch;
|
|
95
|
+
const arm = process.config.variables.arm_version;
|
|
96
|
+
return normalizePlatform({ os: process.platform === 'win32' ? 'windows' : process.platform, architecture: architecture, variant: architecture === 'arm' && arm ? `v${arm}` : undefined });
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Whether a platform of an image runs on a platform: the same system and architecture, a variant up to the one of the
|
|
100
|
+
* platform (an arm/v7 runs the images of arm/v6 and arm/v5)
|
|
101
|
+
* @param image
|
|
102
|
+
* @param platform
|
|
103
|
+
*/
|
|
104
|
+
export function matchPlatform(image, platform) {
|
|
105
|
+
const [a, b] = [normalizePlatform(image), normalizePlatform(platform)];
|
|
106
|
+
if (a.os !== b.os || a.architecture !== b.architecture)
|
|
107
|
+
return false;
|
|
108
|
+
if (a.architecture === 'arm')
|
|
109
|
+
return Number(a.variant?.slice(1) ?? 7) <= Number(b.variant?.slice(1) ?? 7);
|
|
110
|
+
return (a.variant ?? '') === (b.variant ?? '');
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* How much a platform of an image suits a platform: the exact one first (lower is better), undefined when it does not
|
|
114
|
+
* run there
|
|
115
|
+
* @param image
|
|
116
|
+
* @param platform
|
|
117
|
+
*/
|
|
118
|
+
export function platformRank(image, platform) {
|
|
119
|
+
if (!matchPlatform(image, platform))
|
|
120
|
+
return undefined;
|
|
121
|
+
const [a, b] = [normalizePlatform(image), normalizePlatform(platform)];
|
|
122
|
+
return a.architecture === 'arm' ? Number(b.variant?.slice(1) ?? 7) - Number(a.variant?.slice(1) ?? 7) : 0;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* The platforms the machine runs the containers of: its own one, and the ones of the emulators registered in
|
|
126
|
+
* binfmt_misc (enabled)
|
|
127
|
+
* @param binfmt the directory of binfmt_misc
|
|
128
|
+
*/
|
|
129
|
+
export function supportedPlatforms(binfmt = '/proc/sys/fs/binfmt_misc') {
|
|
130
|
+
const platforms = [hostPlatform()];
|
|
131
|
+
//The machines of x64 run the ones of 386
|
|
132
|
+
if (platforms[0].architecture === 'amd64')
|
|
133
|
+
platforms.push({ os: 'linux', architecture: '386' });
|
|
134
|
+
let entries = [];
|
|
135
|
+
try {
|
|
136
|
+
entries = readdirSync(binfmt);
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
//No binfmt_misc
|
|
140
|
+
}
|
|
141
|
+
for (const entry of entries) {
|
|
142
|
+
if (entry === 'status' || entry === 'register')
|
|
143
|
+
continue;
|
|
144
|
+
let emulated;
|
|
145
|
+
try {
|
|
146
|
+
emulated = binfmtPlatforms(readFileSync(path.join(binfmt, entry), 'utf8'));
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
for (const platform of emulated)
|
|
152
|
+
if (!platforms.some((known) => formatPlatform(known) === formatPlatform(platform)))
|
|
153
|
+
platforms.push(platform);
|
|
154
|
+
}
|
|
155
|
+
return platforms;
|
|
156
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The registry of the references without registry
|
|
3
|
+
*/
|
|
4
|
+
const DEFAULT_REGISTRY = 'docker.io';
|
|
5
|
+
/**
|
|
6
|
+
* Parse a reference of an image as Docker (and containerd) normalize it: busybox is docker.io/library/busybox:latest,
|
|
7
|
+
* user/app docker.io/user/app:latest, the first part of a reference is its registry when it has a dot, a port or is
|
|
8
|
+
* localhost
|
|
9
|
+
* @param reference
|
|
10
|
+
*/
|
|
11
|
+
export function parseReference(reference) {
|
|
12
|
+
const raw = reference.trim();
|
|
13
|
+
if (!raw || /\s/.test(raw))
|
|
14
|
+
throw new Error(`The reference of an image "${reference}" is not valid`);
|
|
15
|
+
let rest = raw;
|
|
16
|
+
let digest;
|
|
17
|
+
const at = rest.indexOf('@');
|
|
18
|
+
if (at >= 0) {
|
|
19
|
+
digest = rest.slice(at + 1);
|
|
20
|
+
rest = rest.slice(0, at);
|
|
21
|
+
if (!/^[a-z0-9]+(?:[.+_-][a-z0-9]+)*:[a-zA-Z0-9=_-]+$/.test(digest))
|
|
22
|
+
throw new Error(`The digest of the reference "${reference}" is not valid`);
|
|
23
|
+
}
|
|
24
|
+
let tag;
|
|
25
|
+
const colon = rest.lastIndexOf(':');
|
|
26
|
+
if (colon > rest.lastIndexOf('/')) {
|
|
27
|
+
tag = rest.slice(colon + 1);
|
|
28
|
+
rest = rest.slice(0, colon);
|
|
29
|
+
if (!/^[\w][\w.-]{0,127}$/.test(tag))
|
|
30
|
+
throw new Error(`The tag of the reference "${reference}" is not valid`);
|
|
31
|
+
}
|
|
32
|
+
const parts = rest.split('/');
|
|
33
|
+
let registry = DEFAULT_REGISTRY;
|
|
34
|
+
if (parts.length > 1 && (parts[0].includes('.') || parts[0].includes(':') || parts[0] === 'localhost'))
|
|
35
|
+
registry = parts.shift();
|
|
36
|
+
if (registry === 'index.docker.io' || registry === 'registry-1.docker.io')
|
|
37
|
+
registry = DEFAULT_REGISTRY;
|
|
38
|
+
let repository = parts.join('/');
|
|
39
|
+
if (registry === DEFAULT_REGISTRY && parts.length === 1)
|
|
40
|
+
repository = `library/${repository}`;
|
|
41
|
+
if (!/^[a-z0-9]+(?:(?:[._]|__|-+)[a-z0-9]+)*(?:\/[a-z0-9]+(?:(?:[._]|__|-+)[a-z0-9]+)*)*$/.test(repository))
|
|
42
|
+
throw new Error(`The repository of the reference "${reference}" is not valid (lower case letters, digits, separators)`);
|
|
43
|
+
if (!tag && !digest)
|
|
44
|
+
tag = 'latest';
|
|
45
|
+
return {
|
|
46
|
+
registry: registry,
|
|
47
|
+
host: registry === DEFAULT_REGISTRY ? 'registry-1.docker.io' : registry,
|
|
48
|
+
repository: repository,
|
|
49
|
+
tag: tag,
|
|
50
|
+
digest: digest,
|
|
51
|
+
name: `${registry}/${repository}${tag ? `:${tag}` : ''}${digest ? `@${digest}` : ''}`
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The name of an image in containerd of a reference given by the users (busybox → docker.io/library/busybox:latest),
|
|
56
|
+
* the reference itself when it is not one
|
|
57
|
+
* @param reference
|
|
58
|
+
*/
|
|
59
|
+
export function imageName(reference) {
|
|
60
|
+
try {
|
|
61
|
+
return parseReference(reference).name;
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return reference;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
/**
|
|
3
|
+
* The media types of the manifests and of the indexes (OCI, Docker)
|
|
4
|
+
*/
|
|
5
|
+
export const MediaTypes = {
|
|
6
|
+
OCI_INDEX: 'application/vnd.oci.image.index.v1+json',
|
|
7
|
+
OCI_MANIFEST: 'application/vnd.oci.image.manifest.v1+json',
|
|
8
|
+
OCI_CONFIG: 'application/vnd.oci.image.config.v1+json',
|
|
9
|
+
OCI_LAYER: 'application/vnd.oci.image.layer.v1.tar',
|
|
10
|
+
OCI_LAYER_GZIP: 'application/vnd.oci.image.layer.v1.tar+gzip',
|
|
11
|
+
DOCKER_LIST: 'application/vnd.docker.distribution.manifest.list.v2+json',
|
|
12
|
+
DOCKER_MANIFEST: 'application/vnd.docker.distribution.manifest.v2+json',
|
|
13
|
+
DOCKER_CONFIG: 'application/vnd.docker.container.image.v1+json',
|
|
14
|
+
DOCKER_LAYER: 'application/vnd.docker.image.rootfs.diff.tar',
|
|
15
|
+
DOCKER_LAYER_GZIP: 'application/vnd.docker.image.rootfs.diff.tar.gzip'
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Whether a media type is the one of an index (of the manifests of the platforms)
|
|
19
|
+
* @param mediaType
|
|
20
|
+
*/
|
|
21
|
+
export function isIndex(mediaType) {
|
|
22
|
+
return mediaType === MediaTypes.OCI_INDEX || mediaType === MediaTypes.DOCKER_LIST;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Whether a media type is the one of a manifest (of an image of a platform)
|
|
26
|
+
* @param mediaType
|
|
27
|
+
*/
|
|
28
|
+
export function isManifest(mediaType) {
|
|
29
|
+
return mediaType === MediaTypes.OCI_MANIFEST || mediaType === MediaTypes.DOCKER_MANIFEST;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The digest of bytes
|
|
33
|
+
* @param data
|
|
34
|
+
*/
|
|
35
|
+
export function digestOf(data) {
|
|
36
|
+
return `sha256:${createHash('sha256').update(data).digest('hex')}`;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The parameters of a challenge of WWW-Authenticate (Bearer realm="…",service="…",scope="…")
|
|
40
|
+
* @param header
|
|
41
|
+
*/
|
|
42
|
+
function parseChallenge(header) {
|
|
43
|
+
const space = header.indexOf(' ');
|
|
44
|
+
const scheme = (space < 0 ? header : header.slice(0, space)).toLowerCase();
|
|
45
|
+
const params = {};
|
|
46
|
+
for (const match of header.slice(space + 1).matchAll(/(\w+)="([^"]*)"/g))
|
|
47
|
+
params[match[1].toLowerCase()] = match[2];
|
|
48
|
+
return { scheme: scheme, params: params };
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The basic authorization of credentials
|
|
52
|
+
* @param credentials
|
|
53
|
+
*/
|
|
54
|
+
function basicAuthorization(credentials) {
|
|
55
|
+
return credentials?.username !== undefined ? `Basic ${Buffer.from(`${credentials.username}:${credentials.password ?? ''}`).toString('base64')}` : undefined;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The token of a registry for scopes, from its token service (its realm): with the credentials (an identity token by
|
|
59
|
+
* OAuth2, a user and its password by the basic authentication), or anonymous
|
|
60
|
+
* @param params
|
|
61
|
+
* @param credentials
|
|
62
|
+
* @param signal
|
|
63
|
+
*/
|
|
64
|
+
export async function fetchRegistryToken(params, credentials, signal) {
|
|
65
|
+
const url = new URL(params.realm);
|
|
66
|
+
if (params.service)
|
|
67
|
+
url.searchParams.set('service', params.service);
|
|
68
|
+
for (const scope of params.scopes)
|
|
69
|
+
url.searchParams.append('scope', scope);
|
|
70
|
+
let response;
|
|
71
|
+
if (credentials?.identityToken) {
|
|
72
|
+
//The refresh token of the registries (Docker Hub, ECR…): OAuth2
|
|
73
|
+
response = await fetch(url.origin + url.pathname, {
|
|
74
|
+
method: 'POST',
|
|
75
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
76
|
+
body: new URLSearchParams({ grant_type: 'refresh_token', refresh_token: credentials.identityToken, service: params.service ?? '', scope: params.scopes.join(' '), client_id: 'lakutata' }),
|
|
77
|
+
signal: signal
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
const basic = basicAuthorization(credentials);
|
|
82
|
+
response = await fetch(url, { headers: basic ? { Authorization: basic } : {}, signal: signal });
|
|
83
|
+
}
|
|
84
|
+
if (!response.ok)
|
|
85
|
+
throw new RegistryError(`The registry ${url.host} refuses the authentication (${response.status}): ${(await response.text()).slice(0, 200)}`, response.status);
|
|
86
|
+
const body = await response.json();
|
|
87
|
+
const token = body.token ?? body.access_token;
|
|
88
|
+
if (!token)
|
|
89
|
+
return undefined;
|
|
90
|
+
const issued = body.issued_at ? Date.parse(body.issued_at) : NaN;
|
|
91
|
+
return { token: token, expiresIn: body.expires_in, issuedAt: Number.isNaN(issued) ? undefined : Math.floor(issued / 1000) };
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* An error of a registry
|
|
95
|
+
*/
|
|
96
|
+
export class RegistryError extends Error {
|
|
97
|
+
constructor(message, status) {
|
|
98
|
+
super(message);
|
|
99
|
+
this.status = status;
|
|
100
|
+
this.name = 'RegistryError';
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The client of a repository of a registry (the distribution API of OCI): its manifests and its blobs, the tokens of
|
|
105
|
+
* its authentication requested as its challenges ask (Bearer, Basic), with its credentials or anonymously
|
|
106
|
+
*/
|
|
107
|
+
export class RegistryClient {
|
|
108
|
+
#tokens = new Map();
|
|
109
|
+
constructor(reference, options = {}) {
|
|
110
|
+
this.reference = reference;
|
|
111
|
+
this.options = options;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* The credentials of the registry (by its name or by its host)
|
|
115
|
+
*/
|
|
116
|
+
credentials() {
|
|
117
|
+
const all = this.options.credentials ?? {};
|
|
118
|
+
return all[this.reference.registry] ?? all[this.reference.host] ?? (this.reference.registry === 'docker.io' ? all['https://index.docker.io/v1/'] ?? all['index.docker.io'] : undefined);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* The base URL of the repository
|
|
122
|
+
*/
|
|
123
|
+
base() {
|
|
124
|
+
const insecure = (this.options.insecure ?? []).some((host) => host === this.reference.registry || host === this.reference.host);
|
|
125
|
+
return `${insecure ? 'http' : 'https'}://${this.reference.host}/v2/${this.reference.repository}`;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* The authorization of a challenge: a token of its realm (with the credentials when there are), or the credentials
|
|
129
|
+
* @param challenge
|
|
130
|
+
* @param scope
|
|
131
|
+
*/
|
|
132
|
+
async authorize(challenge, scope) {
|
|
133
|
+
const { scheme, params } = parseChallenge(challenge);
|
|
134
|
+
const credentials = this.credentials();
|
|
135
|
+
if (scheme === 'basic')
|
|
136
|
+
return basicAuthorization(credentials);
|
|
137
|
+
if (scheme !== 'bearer' || !params.realm)
|
|
138
|
+
return undefined;
|
|
139
|
+
const token = await fetchRegistryToken({ realm: params.realm, service: params.service, scopes: [scope] }, credentials, this.options.signal);
|
|
140
|
+
return token ? `Bearer ${token.token}` : undefined;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* A request to the repository, authenticated as its registry asks
|
|
144
|
+
* @param path the path under the repository (/manifests/latest), or a URL (the location of an upload)
|
|
145
|
+
* @param init
|
|
146
|
+
* @param actions the actions of its scope: pull, or push and pull
|
|
147
|
+
*/
|
|
148
|
+
async request(path, init = {}, actions = 'pull') {
|
|
149
|
+
const scope = `repository:${this.reference.repository}:${actions}`;
|
|
150
|
+
const url = /^https?:\/\//.test(path) ? path : `${this.base()}${path}`;
|
|
151
|
+
const send = (authorization) => fetch(url, {
|
|
152
|
+
...init,
|
|
153
|
+
headers: { ...init.headers, ...authorization ? { Authorization: authorization } : {} },
|
|
154
|
+
signal: this.options.signal,
|
|
155
|
+
//The bodies of the streams (the blobs pushed)
|
|
156
|
+
...init.body && typeof init.body.getReader === 'function' ? { duplex: 'half' } : {}
|
|
157
|
+
});
|
|
158
|
+
let response = await send(this.#tokens.get(scope));
|
|
159
|
+
if (response.status === 401) {
|
|
160
|
+
const challenge = response.headers.get('www-authenticate');
|
|
161
|
+
await response.body?.cancel();
|
|
162
|
+
const authorization = challenge ? await this.authorize(challenge, scope) : undefined;
|
|
163
|
+
if (!authorization)
|
|
164
|
+
throw new RegistryError(`The registry ${this.reference.registry} refuses the request of ${this.reference.repository} without authentication: give its credentials`, 401);
|
|
165
|
+
this.#tokens.set(scope, authorization);
|
|
166
|
+
response = await send(authorization);
|
|
167
|
+
}
|
|
168
|
+
return response;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Fail on an error response
|
|
172
|
+
* @param response
|
|
173
|
+
* @param what
|
|
174
|
+
*/
|
|
175
|
+
async check(response, what) {
|
|
176
|
+
if (response.ok)
|
|
177
|
+
return response;
|
|
178
|
+
const text = await response.text().catch(() => '');
|
|
179
|
+
let message = text.slice(0, 300);
|
|
180
|
+
try {
|
|
181
|
+
const errors = JSON.parse(text).errors;
|
|
182
|
+
if (errors?.length)
|
|
183
|
+
message = errors.map(({ code, message }) => `${code}: ${message}`).join(', ');
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
//Not JSON
|
|
187
|
+
}
|
|
188
|
+
throw new RegistryError(`${what} of ${this.reference.registry}/${this.reference.repository} failed (${response.status}): ${message}`, response.status);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Resolve a reference (a tag or a digest): the descriptor of its manifest or of its index, and its bytes
|
|
192
|
+
* @param reference
|
|
193
|
+
*/
|
|
194
|
+
async resolve(reference) {
|
|
195
|
+
const accept = [MediaTypes.OCI_INDEX, MediaTypes.DOCKER_LIST, MediaTypes.OCI_MANIFEST, MediaTypes.DOCKER_MANIFEST].join(', ');
|
|
196
|
+
const response = await this.check(await this.request(`/manifests/${reference}`, { headers: { Accept: accept } }), `The manifest ${reference}`);
|
|
197
|
+
const data = Buffer.from(await response.arrayBuffer());
|
|
198
|
+
const digest = digestOf(data);
|
|
199
|
+
if (reference.startsWith('sha256:') && reference !== digest)
|
|
200
|
+
throw new RegistryError(`The manifest ${reference} has the digest ${digest}`, 0);
|
|
201
|
+
const mediaType = response.headers.get('content-type')?.split(';')[0].trim() || JSON.parse(data.toString('utf8')).mediaType || MediaTypes.OCI_MANIFEST;
|
|
202
|
+
return { descriptor: { mediaType: mediaType, digest: digest, size: data.length }, data: data };
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Fetch a manifest (or an index) by its descriptor, checked by its digest
|
|
206
|
+
* @param descriptor
|
|
207
|
+
*/
|
|
208
|
+
async fetchManifest(descriptor) {
|
|
209
|
+
const response = await this.check(await this.request(`/manifests/${descriptor.digest}`, { headers: { Accept: descriptor.mediaType } }), `The manifest ${descriptor.digest}`);
|
|
210
|
+
const data = Buffer.from(await response.arrayBuffer());
|
|
211
|
+
if (digestOf(data) !== descriptor.digest)
|
|
212
|
+
throw new RegistryError(`The manifest ${descriptor.digest} has the digest ${digestOf(data)}`, 0);
|
|
213
|
+
return data;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Fetch a blob: its bytes streamed (the redirections of the registry to its storage followed)
|
|
217
|
+
* @param descriptor
|
|
218
|
+
*/
|
|
219
|
+
async fetchBlob(descriptor) {
|
|
220
|
+
const response = await this.check(await this.request(`/blobs/${descriptor.digest}`), `The blob ${descriptor.digest}`);
|
|
221
|
+
if (!response.body)
|
|
222
|
+
throw new RegistryError(`The blob ${descriptor.digest} has no body`, response.status);
|
|
223
|
+
return response.body;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Whether the repository has a blob
|
|
227
|
+
* @param digest
|
|
228
|
+
*/
|
|
229
|
+
async hasBlob(digest) {
|
|
230
|
+
const response = await this.request(`/blobs/${digest}`, { method: 'HEAD' }, 'push,pull');
|
|
231
|
+
await response.body?.cancel();
|
|
232
|
+
return response.ok;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Push a blob, unless the repository has it: uploaded at once
|
|
236
|
+
* @param descriptor
|
|
237
|
+
* @param data its bytes, or the function giving their stream
|
|
238
|
+
*/
|
|
239
|
+
async pushBlob(descriptor, data) {
|
|
240
|
+
if (await this.hasBlob(descriptor.digest))
|
|
241
|
+
return;
|
|
242
|
+
const started = await this.check(await this.request('/blobs/uploads/', { method: 'POST', headers: { 'Content-Length': '0' } }, 'push,pull'), `The upload of ${descriptor.digest}`);
|
|
243
|
+
await started.body?.cancel();
|
|
244
|
+
const location = started.headers.get('location');
|
|
245
|
+
if (!location)
|
|
246
|
+
throw new RegistryError(`The upload of ${descriptor.digest} has no location`, started.status);
|
|
247
|
+
const url = new URL(location, this.base());
|
|
248
|
+
url.searchParams.set('digest', descriptor.digest);
|
|
249
|
+
const body = data instanceof Uint8Array ? data : ReadableStream.from(data());
|
|
250
|
+
const put = await this.check(await this.request(url.toString(), { method: 'PUT', headers: { 'Content-Type': 'application/octet-stream', 'Content-Length': String(descriptor.size) }, body: body }, 'push,pull'), `The upload of ${descriptor.digest}`);
|
|
251
|
+
await put.body?.cancel();
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Push a manifest (or an index), by a tag or by its digest
|
|
255
|
+
* @param reference
|
|
256
|
+
* @param mediaType
|
|
257
|
+
* @param data
|
|
258
|
+
*/
|
|
259
|
+
async pushManifest(reference, mediaType, data) {
|
|
260
|
+
const response = await this.check(await this.request(`/manifests/${reference}`, { method: 'PUT', headers: { 'Content-Type': mediaType }, body: data }, 'push,pull'), `The push of the manifest ${reference}`);
|
|
261
|
+
await response.body?.cancel();
|
|
262
|
+
}
|
|
263
|
+
}
|