@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,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ContainerdContainerTTY = void 0;
|
|
13
|
+
const core_1 = require("@lakutata/core");
|
|
14
|
+
const di_1 = require("@lakutata/core/decorator/di");
|
|
15
|
+
const dto_1 = require("@lakutata/core/decorator/dto");
|
|
16
|
+
const node_stream_1 = require("node:stream");
|
|
17
|
+
const ContainerTTYConsoleSizeOptions_js_1 = require("../options/container/ContainerTTYConsoleSizeOptions.js");
|
|
18
|
+
const ContainerdErrors_js_1 = require("./ContainerdErrors.js");
|
|
19
|
+
/**
|
|
20
|
+
* An interactive terminal in a running container: a process (a shell by default) run with a pseudo terminal, as
|
|
21
|
+
* `docker exec -it` does. Get it from {@link ContainerdContainer.createTTY}; do not create it yourself. Write its input
|
|
22
|
+
* with {@link ContainerdContainerTTY.write} (or {@link ContainerdContainerTTY.writable}), read its output with
|
|
23
|
+
* {@link ContainerdContainerTTY.onData} (or {@link ContainerdContainerTTY.readable}), or pipe a socket into
|
|
24
|
+
* {@link ContainerdContainerTTY.raw}. The terminal ends when its process exits or when it is closed; it is closed when
|
|
25
|
+
* the object is destroyed.
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* import {type Containerd, type ContainerdContainer, type ContainerdContainerTTY} from 'lakutata/com/containerd'
|
|
29
|
+
*
|
|
30
|
+
* declare const containerd: Containerd
|
|
31
|
+
*
|
|
32
|
+
* const container: ContainerdContainer = await containerd.getContainer('worker')
|
|
33
|
+
* const tty: ContainerdContainerTTY = await container.createTTY({cmd: ['/bin/sh', '-l'], consoleSize: {cols: 120, rows: 40}})
|
|
34
|
+
* tty.onData((chunk: Buffer): void => {
|
|
35
|
+
* process.stdout.write(chunk)
|
|
36
|
+
* })
|
|
37
|
+
* tty.write('ls -la\n')
|
|
38
|
+
* await tty.resize({cols: 100, rows: 30})
|
|
39
|
+
* tty.write('exit\n')
|
|
40
|
+
* //The exit code of the shell
|
|
41
|
+
* console.log(await tty.wait())
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
let ContainerdContainerTTY = class ContainerdContainerTTY extends core_1.Provider {
|
|
45
|
+
#terminal;
|
|
46
|
+
#duplexStream;
|
|
47
|
+
/**
|
|
48
|
+
* Start the terminal's process in the container.
|
|
49
|
+
* @throws {ContainerdContainerStateException} The container is not running.
|
|
50
|
+
* @throws {Error} The host has no `mkfifo`; the user is not found in the container.
|
|
51
|
+
* @protected
|
|
52
|
+
*/
|
|
53
|
+
async init() {
|
|
54
|
+
try {
|
|
55
|
+
this.#terminal = await this.getStore().terminal(this.getRecord(), {
|
|
56
|
+
cmd: Array.isArray(this.cmd) ? this.cmd : ['/bin/sh', '-c', this.cmd],
|
|
57
|
+
cols: this.initialConsoleSize?.cols,
|
|
58
|
+
rows: this.initialConsoleSize?.rows,
|
|
59
|
+
env: this.env,
|
|
60
|
+
workingDir: this.workingDir,
|
|
61
|
+
user: this.user
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
throw (0, ContainerdErrors_js_1.containerdError)(error);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Close the terminal, as {@link ContainerdContainerTTY.close} does.
|
|
70
|
+
* @protected
|
|
71
|
+
*/
|
|
72
|
+
async destroy() {
|
|
73
|
+
await this.close();
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The terminal as one duplex stream: writing sends input to the process, reading gives its output (to pipe a
|
|
77
|
+
* WebSocket or a socket into it). It is created at the first access and consumes the output from then on.
|
|
78
|
+
*/
|
|
79
|
+
get raw() {
|
|
80
|
+
//Created once asked: it reads the output (which onData would not have otherwise)
|
|
81
|
+
if (!this.#duplexStream) {
|
|
82
|
+
this.#duplexStream = node_stream_1.Duplex.from({ readable: this.#terminal.output, writable: this.#terminal.input });
|
|
83
|
+
this.#duplexStream.on('error', () => undefined);
|
|
84
|
+
}
|
|
85
|
+
return this.#duplexStream;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The terminal's input: what is written is sent to the process, as typed on a keyboard (`\x03` for Ctrl+C).
|
|
89
|
+
*/
|
|
90
|
+
get writable() {
|
|
91
|
+
return this.#terminal.input;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* The terminal's output: what the process prints, its standard error included; it ends when the process exits.
|
|
95
|
+
*/
|
|
96
|
+
get readable() {
|
|
97
|
+
return this.#terminal.output;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Resize the terminal's console; the process receives `SIGWINCH`.
|
|
101
|
+
* @param options The new size, in columns and rows (positive integers).
|
|
102
|
+
* @throws {GRPCError} The process has exited (from `@lakutata/grpc`).
|
|
103
|
+
*/
|
|
104
|
+
async resize(options) {
|
|
105
|
+
await this.#terminal.resize(options.cols, options.rows);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Listen to the terminal's output. Each call adds a listener.
|
|
109
|
+
* @param handler Called with each chunk of output.
|
|
110
|
+
*/
|
|
111
|
+
onData(handler) {
|
|
112
|
+
this.#terminal.output.on('data', handler);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Send input to the terminal's process.
|
|
116
|
+
* @param data The input, as text or bytes (`'ls\n'`, a newline to submit a line).
|
|
117
|
+
*/
|
|
118
|
+
write(data) {
|
|
119
|
+
this.#terminal.input.write(data);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Wait for the terminal's process to exit; the terminal is then closed.
|
|
123
|
+
* @returns Its exit code (`137` when it was closed by {@link ContainerdContainerTTY.close}).
|
|
124
|
+
*/
|
|
125
|
+
async wait() {
|
|
126
|
+
return await this.#terminal.exited;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Close the terminal: kill its process with `SIGKILL` and release its FIFOs. Nothing happens when it is already
|
|
130
|
+
* closed.
|
|
131
|
+
*/
|
|
132
|
+
async close() {
|
|
133
|
+
await this.#terminal?.close();
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
exports.ContainerdContainerTTY = ContainerdContainerTTY;
|
|
137
|
+
__decorate([
|
|
138
|
+
(0, di_1.Configurable)(core_1.DTO.Function()),
|
|
139
|
+
__metadata("design:type", Function)
|
|
140
|
+
], ContainerdContainerTTY.prototype, "getStore", void 0);
|
|
141
|
+
__decorate([
|
|
142
|
+
(0, di_1.Configurable)(core_1.DTO.Function()),
|
|
143
|
+
__metadata("design:type", Function)
|
|
144
|
+
], ContainerdContainerTTY.prototype, "getRecord", void 0);
|
|
145
|
+
__decorate([
|
|
146
|
+
(0, di_1.Configurable)(core_1.DTO.Alternatives(core_1.DTO.String(), core_1.DTO.Array(core_1.DTO.String()).min(1))),
|
|
147
|
+
__metadata("design:type", Object)
|
|
148
|
+
], ContainerdContainerTTY.prototype, "cmd", void 0);
|
|
149
|
+
__decorate([
|
|
150
|
+
(0, di_1.Configurable)(ContainerTTYConsoleSizeOptions_js_1.ContainerTTYConsoleSizeOptions.optional()),
|
|
151
|
+
__metadata("design:type", ContainerTTYConsoleSizeOptions_js_1.ContainerTTYConsoleSizeOptions
|
|
152
|
+
/**
|
|
153
|
+
* The environment variables added to the container's (`TERM` is `xterm` unless given).
|
|
154
|
+
* @default none
|
|
155
|
+
*/
|
|
156
|
+
)
|
|
157
|
+
], ContainerdContainerTTY.prototype, "initialConsoleSize", void 0);
|
|
158
|
+
__decorate([
|
|
159
|
+
(0, di_1.Configurable)(core_1.DTO.Object().optional()),
|
|
160
|
+
__metadata("design:type", Object)
|
|
161
|
+
], ContainerdContainerTTY.prototype, "env", void 0);
|
|
162
|
+
__decorate([
|
|
163
|
+
(0, di_1.Configurable)(core_1.DTO.String().optional()),
|
|
164
|
+
__metadata("design:type", String)
|
|
165
|
+
], ContainerdContainerTTY.prototype, "workingDir", void 0);
|
|
166
|
+
__decorate([
|
|
167
|
+
(0, di_1.Configurable)(core_1.DTO.String().optional()),
|
|
168
|
+
__metadata("design:type", String)
|
|
169
|
+
], ContainerdContainerTTY.prototype, "user", void 0);
|
|
170
|
+
__decorate([
|
|
171
|
+
(0, dto_1.Accept)(ContainerTTYConsoleSizeOptions_js_1.ContainerTTYConsoleSizeOptions.required()),
|
|
172
|
+
__metadata("design:type", Function),
|
|
173
|
+
__metadata("design:paramtypes", [ContainerTTYConsoleSizeOptions_js_1.ContainerTTYConsoleSizeOptions]),
|
|
174
|
+
__metadata("design:returntype", Promise)
|
|
175
|
+
], ContainerdContainerTTY.prototype, "resize", null);
|
|
176
|
+
exports.ContainerdContainerTTY = ContainerdContainerTTY = __decorate([
|
|
177
|
+
(0, di_1.Transient)()
|
|
178
|
+
], ContainerdContainerTTY);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.containerdError = containerdError;
|
|
4
|
+
const core_1 = require("@lakutata/core");
|
|
5
|
+
const ContainerdImageNotFoundException_js_1 = require("../exceptions/ContainerdImageNotFoundException.js");
|
|
6
|
+
const ContainerdPlatformException_js_1 = require("../exceptions/ContainerdPlatformException.js");
|
|
7
|
+
const ContainerdContainerNameConflictException_js_1 = require("../exceptions/ContainerdContainerNameConflictException.js");
|
|
8
|
+
const ContainerdContainerStateException_js_1 = require("../exceptions/ContainerdContainerStateException.js");
|
|
9
|
+
const ContainerdNetworkNotFoundException_js_1 = require("../exceptions/ContainerdNetworkNotFoundException.js");
|
|
10
|
+
const ContainerdPathNotFoundException_js_1 = require("../exceptions/ContainerdPathNotFoundException.js");
|
|
11
|
+
/**
|
|
12
|
+
* The exception of an error of the client (by its code), or the one given
|
|
13
|
+
* @param error
|
|
14
|
+
* @param fallback the exception of the operation
|
|
15
|
+
*/
|
|
16
|
+
function containerdError(error, fallback) {
|
|
17
|
+
const message = error?.message ?? String(error);
|
|
18
|
+
switch (error?.code) {
|
|
19
|
+
case 'NOT_FOUND':
|
|
20
|
+
return new ContainerdImageNotFoundException_js_1.ContainerdImageNotFoundException(message);
|
|
21
|
+
case 'PLATFORM':
|
|
22
|
+
return new ContainerdPlatformException_js_1.ContainerdPlatformException(message);
|
|
23
|
+
case 'CONFLICT':
|
|
24
|
+
return new ContainerdContainerNameConflictException_js_1.ContainerdContainerNameConflictException(message);
|
|
25
|
+
case 'NETWORK_NOT_FOUND':
|
|
26
|
+
return new ContainerdNetworkNotFoundException_js_1.ContainerdNetworkNotFoundException(message);
|
|
27
|
+
case 'INVALID_VALUE':
|
|
28
|
+
return new core_1.InvalidValueException(message);
|
|
29
|
+
case 'PATH_NOT_FOUND':
|
|
30
|
+
return new ContainerdPathNotFoundException_js_1.ContainerdPathNotFoundException(message);
|
|
31
|
+
case 'RUNNING':
|
|
32
|
+
case 'NOT_RUNNING':
|
|
33
|
+
case 'PAUSED':
|
|
34
|
+
return new ContainerdContainerStateException_js_1.ContainerdContainerStateException(message);
|
|
35
|
+
}
|
|
36
|
+
return fallback ? new fallback(message) : error;
|
|
37
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { Provider } from '@lakutata/core';
|
|
2
|
+
import { Time } from '@lakutata/utils/Time';
|
|
3
|
+
import type { ImageStore } from '../../client/ImageStore.js';
|
|
4
|
+
import type { RegistryOptions } from '../../client/Registry.js';
|
|
5
|
+
import { type Containerd } from '../Containerd.js';
|
|
6
|
+
import type { ContainerdImageConfig } from '../types/ContainerdImageConfig.js';
|
|
7
|
+
import { ImagePushOptions } from '../options/image/ImagePushOptions.js';
|
|
8
|
+
import { ImageExportOptions } from '../options/image/ImageExportOptions.js';
|
|
9
|
+
/**
|
|
10
|
+
* An image of the {@link Containerd} component's namespace: its name, digest, platforms, size and configuration, and
|
|
11
|
+
* the operations tag, push, export and remove. Get it from {@link Containerd.getImage}, {@link Containerd.listImages},
|
|
12
|
+
* {@link Containerd.pullImage}, {@link Containerd.buildImage}, {@link Containerd.importImage} or
|
|
13
|
+
* {@link ContainerdContainer.commit}; do not create it yourself. Each call returns a new object (transient).
|
|
14
|
+
*
|
|
15
|
+
* An image may hold several platforms (an index): the object describes one of them, the first one the machine runs
|
|
16
|
+
* ({@link Containerd.supportedPlatforms}), or the first one present. Its properties are a snapshot taken when it was
|
|
17
|
+
* obtained; {@link ContainerdImage.syncImageInfo} takes a new one.
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* import {type Containerd, type ContainerdImage} from 'lakutata/com/containerd'
|
|
21
|
+
*
|
|
22
|
+
* declare const containerd: Containerd
|
|
23
|
+
*
|
|
24
|
+
* const image: ContainerdImage = await containerd.pullImage({image: 'alpine:3.20', platform: ['linux/amd64', 'linux/arm64']})
|
|
25
|
+
* //docker.io/library/alpine:3.20, its platforms, the command its containers run
|
|
26
|
+
* console.log(image.name, image.platforms, image.config.cmd)
|
|
27
|
+
* const tagged: ContainerdImage = await image.tag('registry.example.com/team/alpine:3.20')
|
|
28
|
+
* await tagged.push({auth: {username: 'deploy', password: 'secret'}})
|
|
29
|
+
* //An archive loaded by docker load and nerdctl load
|
|
30
|
+
* await image.export({destination: '/tmp/alpine.tar'})
|
|
31
|
+
* await tagged.remove()
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare class ContainerdImage extends Provider {
|
|
35
|
+
/**
|
|
36
|
+
* Gives the component's image store; set by the component.
|
|
37
|
+
*/
|
|
38
|
+
protected readonly getStore: () => ImageStore;
|
|
39
|
+
/**
|
|
40
|
+
* Gives the component that created the object.
|
|
41
|
+
*/
|
|
42
|
+
protected readonly getContainerd: () => Containerd;
|
|
43
|
+
/**
|
|
44
|
+
* Gives the component's registry options (credentials, insecure registries) for the pushes.
|
|
45
|
+
*/
|
|
46
|
+
protected readonly getRegistryOptions: () => RegistryOptions;
|
|
47
|
+
/**
|
|
48
|
+
* The image's name, normalized as Docker does (`docker.io/library/alpine:3.20`).
|
|
49
|
+
*/
|
|
50
|
+
name: string;
|
|
51
|
+
/**
|
|
52
|
+
* The digest of the image's target: its index for a multi-platform image, else its manifest (`sha256:…`), as a
|
|
53
|
+
* registry knows it.
|
|
54
|
+
*/
|
|
55
|
+
digest: string;
|
|
56
|
+
/**
|
|
57
|
+
* The media type of the image's target: an OCI or Docker index, or a manifest.
|
|
58
|
+
*/
|
|
59
|
+
mediaType: string;
|
|
60
|
+
/**
|
|
61
|
+
* The labels of the image's containerd record (not the ones of its configuration: see `config.labels`).
|
|
62
|
+
*/
|
|
63
|
+
labels: Record<string, string>;
|
|
64
|
+
/**
|
|
65
|
+
* When the image was created in containerd (pulled, imported, built).
|
|
66
|
+
*/
|
|
67
|
+
createdAt: Time;
|
|
68
|
+
/**
|
|
69
|
+
* When the image's record was last updated in containerd (pulled again, tagged over).
|
|
70
|
+
*/
|
|
71
|
+
updatedAt: Time;
|
|
72
|
+
/**
|
|
73
|
+
* The platforms whose content is present (the ones pulled), formatted `os/architecture[/variant]`.
|
|
74
|
+
*/
|
|
75
|
+
platforms: string[];
|
|
76
|
+
/**
|
|
77
|
+
* The platform the object describes: the first one the machine runs, or the first one present.
|
|
78
|
+
*/
|
|
79
|
+
platform: string;
|
|
80
|
+
/**
|
|
81
|
+
* The operating system of the platform described (`linux`).
|
|
82
|
+
*/
|
|
83
|
+
os: string;
|
|
84
|
+
/**
|
|
85
|
+
* The architecture of the platform described (`amd64`, `arm64`).
|
|
86
|
+
*/
|
|
87
|
+
arch: string;
|
|
88
|
+
/**
|
|
89
|
+
* The variant of the platform described (`v8`, `v7`); `undefined` when it has none.
|
|
90
|
+
*/
|
|
91
|
+
variant: string | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* The size of the platform described, in bytes: its configuration and its compressed layers.
|
|
94
|
+
*/
|
|
95
|
+
size: number;
|
|
96
|
+
/**
|
|
97
|
+
* The configuration the image gives its containers, for the platform described: environment, command, entry point,
|
|
98
|
+
* working directory, user, exposed ports, volumes, labels and stop signal.
|
|
99
|
+
*/
|
|
100
|
+
config: ContainerdImageConfig;
|
|
101
|
+
/**
|
|
102
|
+
* Read the image's information.
|
|
103
|
+
* @throws {ContainerdImageNotFoundException} The image does not exist.
|
|
104
|
+
* @throws {ContainerdPlatformException} The content of none of its platforms is present.
|
|
105
|
+
* @protected
|
|
106
|
+
*/
|
|
107
|
+
protected init(): Promise<void>;
|
|
108
|
+
/**
|
|
109
|
+
* Read the image's information again from containerd into the object's properties.
|
|
110
|
+
* @throws {ContainerdImageNotFoundException} The image no longer exists.
|
|
111
|
+
* @throws {ContainerdPlatformException} The content of none of its platforms is present.
|
|
112
|
+
*/
|
|
113
|
+
syncImageInfo(): Promise<void>;
|
|
114
|
+
/**
|
|
115
|
+
* Give the image another name, as `docker tag` does: a new image record with the same content. An image that has
|
|
116
|
+
* this name already is replaced. This object keeps its name.
|
|
117
|
+
* @param name The new name or reference (`registry.example.com/team/alpine:3.20`), normalized as Docker does.
|
|
118
|
+
* @returns The image under its new name.
|
|
119
|
+
* @throws {ContainerdImageNotFoundException} The image no longer exists.
|
|
120
|
+
*/
|
|
121
|
+
tag(name: string): Promise<ContainerdImage>;
|
|
122
|
+
/**
|
|
123
|
+
* Push the image to its registry, or to another reference. With `platform`, only the manifest of that platform is
|
|
124
|
+
* pushed under the tag. Without it, when the content of all the platforms of its index is present, all of them and
|
|
125
|
+
* the index are pushed; otherwise only the manifest of the machine's platform. The credentials are `auth`, else the
|
|
126
|
+
* component's `registryAuths`. The push is aborted when the component is destroyed.
|
|
127
|
+
* @param options The `reference` to push to (the image's name by default), the `platform`, the credentials and the
|
|
128
|
+
* progress callback.
|
|
129
|
+
* @throws {ContainerdImageNotFoundException} The image no longer exists.
|
|
130
|
+
* @throws {ContainerdPlatformException} The platform to push (`platform`, or the machine's when only some platforms
|
|
131
|
+
* are present) is not present.
|
|
132
|
+
* @throws {ContainerdImagePushException} The registry cannot be reached or refuses the push (credentials, rights).
|
|
133
|
+
*/
|
|
134
|
+
push(options?: ImagePushOptions): Promise<void>;
|
|
135
|
+
/**
|
|
136
|
+
* Export the image into an archive: an OCI image layout with the `manifest.json` of `docker load`, loaded by
|
|
137
|
+
* `docker load`, `nerdctl load` and {@link Containerd.importImage}.
|
|
138
|
+
* @param options The destination: a file path (created or replaced) or a writable stream.
|
|
139
|
+
* @throws {ContainerdImageNotFoundException} The image no longer exists.
|
|
140
|
+
* @throws {ContainerdImageExportException} The archive cannot be written.
|
|
141
|
+
*/
|
|
142
|
+
export(options: ImageExportOptions): Promise<void>;
|
|
143
|
+
/**
|
|
144
|
+
* Remove the image's name. Its content and snapshots are collected by containerd once no other image and no
|
|
145
|
+
* container uses them; the containers of the image keep working.
|
|
146
|
+
* @throws {ContainerdImageNotFoundException} The image no longer exists.
|
|
147
|
+
*/
|
|
148
|
+
remove(): Promise<void>;
|
|
149
|
+
}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ContainerdImage = void 0;
|
|
13
|
+
const core_1 = require("@lakutata/core");
|
|
14
|
+
const di_1 = require("@lakutata/core/decorator/di");
|
|
15
|
+
const dto_1 = require("@lakutata/core/decorator/dto");
|
|
16
|
+
const Time_1 = require("@lakutata/utils/Time");
|
|
17
|
+
const Platforms_js_1 = require("../../client/Platforms.js");
|
|
18
|
+
const Reference_js_1 = require("../../client/Reference.js");
|
|
19
|
+
const ImagePushOptions_js_1 = require("../options/image/ImagePushOptions.js");
|
|
20
|
+
const ImageExportOptions_js_1 = require("../options/image/ImageExportOptions.js");
|
|
21
|
+
const ContainerdImagePushException_js_1 = require("../exceptions/ContainerdImagePushException.js");
|
|
22
|
+
const ContainerdImageExportException_js_1 = require("../exceptions/ContainerdImageExportException.js");
|
|
23
|
+
const ContainerdErrors_js_1 = require("./ContainerdErrors.js");
|
|
24
|
+
/**
|
|
25
|
+
* An image of the {@link Containerd} component's namespace: its name, digest, platforms, size and configuration, and
|
|
26
|
+
* the operations tag, push, export and remove. Get it from {@link Containerd.getImage}, {@link Containerd.listImages},
|
|
27
|
+
* {@link Containerd.pullImage}, {@link Containerd.buildImage}, {@link Containerd.importImage} or
|
|
28
|
+
* {@link ContainerdContainer.commit}; do not create it yourself. Each call returns a new object (transient).
|
|
29
|
+
*
|
|
30
|
+
* An image may hold several platforms (an index): the object describes one of them, the first one the machine runs
|
|
31
|
+
* ({@link Containerd.supportedPlatforms}), or the first one present. Its properties are a snapshot taken when it was
|
|
32
|
+
* obtained; {@link ContainerdImage.syncImageInfo} takes a new one.
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* import {type Containerd, type ContainerdImage} from 'lakutata/com/containerd'
|
|
36
|
+
*
|
|
37
|
+
* declare const containerd: Containerd
|
|
38
|
+
*
|
|
39
|
+
* const image: ContainerdImage = await containerd.pullImage({image: 'alpine:3.20', platform: ['linux/amd64', 'linux/arm64']})
|
|
40
|
+
* //docker.io/library/alpine:3.20, its platforms, the command its containers run
|
|
41
|
+
* console.log(image.name, image.platforms, image.config.cmd)
|
|
42
|
+
* const tagged: ContainerdImage = await image.tag('registry.example.com/team/alpine:3.20')
|
|
43
|
+
* await tagged.push({auth: {username: 'deploy', password: 'secret'}})
|
|
44
|
+
* //An archive loaded by docker load and nerdctl load
|
|
45
|
+
* await image.export({destination: '/tmp/alpine.tar'})
|
|
46
|
+
* await tagged.remove()
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
let ContainerdImage = class ContainerdImage extends core_1.Provider {
|
|
50
|
+
/**
|
|
51
|
+
* Read the image's information.
|
|
52
|
+
* @throws {ContainerdImageNotFoundException} The image does not exist.
|
|
53
|
+
* @throws {ContainerdPlatformException} The content of none of its platforms is present.
|
|
54
|
+
* @protected
|
|
55
|
+
*/
|
|
56
|
+
async init() {
|
|
57
|
+
await this.syncImageInfo();
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Read the image's information again from containerd into the object's properties.
|
|
61
|
+
* @throws {ContainerdImageNotFoundException} The image no longer exists.
|
|
62
|
+
* @throws {ContainerdPlatformException} The content of none of its platforms is present.
|
|
63
|
+
*/
|
|
64
|
+
async syncImageInfo() {
|
|
65
|
+
const store = this.getStore();
|
|
66
|
+
let resolved;
|
|
67
|
+
let platforms;
|
|
68
|
+
try {
|
|
69
|
+
platforms = await store.platforms(this.name);
|
|
70
|
+
const supported = this.getContainerd().supportedPlatforms();
|
|
71
|
+
const preferred = platforms.find((platform) => supported.includes((0, Platforms_js_1.formatPlatform)(platform))) ?? platforms[0];
|
|
72
|
+
resolved = await store.resolve(this.name, preferred);
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
throw (0, ContainerdErrors_js_1.containerdError)(error);
|
|
76
|
+
}
|
|
77
|
+
const image = resolved.image;
|
|
78
|
+
const config = resolved.config.config ?? {};
|
|
79
|
+
this.name = image.name;
|
|
80
|
+
this.digest = image.target.digest;
|
|
81
|
+
this.mediaType = image.target.mediaType;
|
|
82
|
+
this.labels = image.labels ?? {};
|
|
83
|
+
this.createdAt = new Time_1.Time(timestampMilliseconds(image.createdAt));
|
|
84
|
+
this.updatedAt = new Time_1.Time(timestampMilliseconds(image.updatedAt));
|
|
85
|
+
this.platforms = platforms.map(Platforms_js_1.formatPlatform);
|
|
86
|
+
this.platform = (0, Platforms_js_1.formatPlatform)(resolved.platform);
|
|
87
|
+
this.os = resolved.platform.os;
|
|
88
|
+
this.arch = resolved.platform.architecture;
|
|
89
|
+
this.variant = resolved.platform.variant;
|
|
90
|
+
this.size = Number(resolved.manifest.config.size) + resolved.manifest.layers.reduce((size, layer) => size + Number(layer.size), 0);
|
|
91
|
+
this.config = {
|
|
92
|
+
env: Object.fromEntries((config.Env ?? []).map((entry) => [entry.split('=')[0], entry.slice(entry.indexOf('=') + 1)])),
|
|
93
|
+
cmd: config.Cmd ?? [],
|
|
94
|
+
entrypoint: config.Entrypoint ?? [],
|
|
95
|
+
workingDir: config.WorkingDir ?? '',
|
|
96
|
+
user: config.User ?? '',
|
|
97
|
+
exposedPorts: Object.keys(config.ExposedPorts ?? {}).map((key) => {
|
|
98
|
+
const [port, type] = key.split('/');
|
|
99
|
+
return { port: Number(port), type: (type ?? 'tcp') };
|
|
100
|
+
}),
|
|
101
|
+
volumes: Object.keys(config.Volumes ?? {}),
|
|
102
|
+
labels: config.Labels ?? {},
|
|
103
|
+
stopSignal: config.StopSignal
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Give the image another name, as `docker tag` does: a new image record with the same content. An image that has
|
|
108
|
+
* this name already is replaced. This object keeps its name.
|
|
109
|
+
* @param name The new name or reference (`registry.example.com/team/alpine:3.20`), normalized as Docker does.
|
|
110
|
+
* @returns The image under its new name.
|
|
111
|
+
* @throws {ContainerdImageNotFoundException} The image no longer exists.
|
|
112
|
+
*/
|
|
113
|
+
async tag(name) {
|
|
114
|
+
try {
|
|
115
|
+
return await this.getContainerd().getImage(await this.getStore().tag(this.name, name));
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
throw (0, ContainerdErrors_js_1.containerdError)(error);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Push the image to its registry, or to another reference. With `platform`, only the manifest of that platform is
|
|
123
|
+
* pushed under the tag. Without it, when the content of all the platforms of its index is present, all of them and
|
|
124
|
+
* the index are pushed; otherwise only the manifest of the machine's platform. The credentials are `auth`, else the
|
|
125
|
+
* component's `registryAuths`. The push is aborted when the component is destroyed.
|
|
126
|
+
* @param options The `reference` to push to (the image's name by default), the `platform`, the credentials and the
|
|
127
|
+
* progress callback.
|
|
128
|
+
* @throws {ContainerdImageNotFoundException} The image no longer exists.
|
|
129
|
+
* @throws {ContainerdPlatformException} The platform to push (`platform`, or the machine's when only some platforms
|
|
130
|
+
* are present) is not present.
|
|
131
|
+
* @throws {ContainerdImagePushException} The registry cannot be reached or refuses the push (credentials, rights).
|
|
132
|
+
*/
|
|
133
|
+
async push(options) {
|
|
134
|
+
if (!options)
|
|
135
|
+
return await this.push({});
|
|
136
|
+
const registry = this.getRegistryOptions();
|
|
137
|
+
try {
|
|
138
|
+
await this.getStore().push(this.name, {
|
|
139
|
+
reference: options.reference,
|
|
140
|
+
platform: options.platform ? (0, Platforms_js_1.parsePlatform)(options.platform) : undefined,
|
|
141
|
+
registry: options.auth ? { ...registry, credentials: { ...registry.credentials, [(0, Reference_js_1.parseReference)(options.reference ?? this.name).registry]: options.auth } } : registry,
|
|
142
|
+
progress: options.progressCallback
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
throw (0, ContainerdErrors_js_1.containerdError)(error, ContainerdImagePushException_js_1.ContainerdImagePushException);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Export the image into an archive: an OCI image layout with the `manifest.json` of `docker load`, loaded by
|
|
151
|
+
* `docker load`, `nerdctl load` and {@link Containerd.importImage}.
|
|
152
|
+
* @param options The destination: a file path (created or replaced) or a writable stream.
|
|
153
|
+
* @throws {ContainerdImageNotFoundException} The image no longer exists.
|
|
154
|
+
* @throws {ContainerdImageExportException} The archive cannot be written.
|
|
155
|
+
*/
|
|
156
|
+
async export(options) {
|
|
157
|
+
try {
|
|
158
|
+
await this.getStore().export([this.name], options.destination);
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
throw (0, ContainerdErrors_js_1.containerdError)(error, ContainerdImageExportException_js_1.ContainerdImageExportException);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Remove the image's name. Its content and snapshots are collected by containerd once no other image and no
|
|
166
|
+
* container uses them; the containers of the image keep working.
|
|
167
|
+
* @throws {ContainerdImageNotFoundException} The image no longer exists.
|
|
168
|
+
*/
|
|
169
|
+
async remove() {
|
|
170
|
+
try {
|
|
171
|
+
await this.getStore().remove(this.name);
|
|
172
|
+
}
|
|
173
|
+
catch (error) {
|
|
174
|
+
throw (0, ContainerdErrors_js_1.containerdError)(error);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
exports.ContainerdImage = ContainerdImage;
|
|
179
|
+
__decorate([
|
|
180
|
+
(0, di_1.Configurable)(core_1.DTO.Function()),
|
|
181
|
+
__metadata("design:type", Function)
|
|
182
|
+
], ContainerdImage.prototype, "getStore", void 0);
|
|
183
|
+
__decorate([
|
|
184
|
+
(0, di_1.Configurable)(core_1.DTO.Function()),
|
|
185
|
+
__metadata("design:type", Function)
|
|
186
|
+
], ContainerdImage.prototype, "getContainerd", void 0);
|
|
187
|
+
__decorate([
|
|
188
|
+
(0, di_1.Configurable)(core_1.DTO.Function()),
|
|
189
|
+
__metadata("design:type", Function)
|
|
190
|
+
], ContainerdImage.prototype, "getRegistryOptions", void 0);
|
|
191
|
+
__decorate([
|
|
192
|
+
(0, di_1.Configurable)(core_1.DTO.String()),
|
|
193
|
+
__metadata("design:type", String)
|
|
194
|
+
], ContainerdImage.prototype, "name", void 0);
|
|
195
|
+
__decorate([
|
|
196
|
+
(0, dto_1.Accept)(core_1.DTO.String().required()),
|
|
197
|
+
__metadata("design:type", Function),
|
|
198
|
+
__metadata("design:paramtypes", [String]),
|
|
199
|
+
__metadata("design:returntype", Promise)
|
|
200
|
+
], ContainerdImage.prototype, "tag", null);
|
|
201
|
+
__decorate([
|
|
202
|
+
(0, dto_1.Accept)(ImagePushOptions_js_1.ImagePushOptions.optional()),
|
|
203
|
+
__metadata("design:type", Function),
|
|
204
|
+
__metadata("design:paramtypes", [ImagePushOptions_js_1.ImagePushOptions]),
|
|
205
|
+
__metadata("design:returntype", Promise)
|
|
206
|
+
], ContainerdImage.prototype, "push", null);
|
|
207
|
+
__decorate([
|
|
208
|
+
(0, dto_1.Accept)(ImageExportOptions_js_1.ImageExportOptions.required()),
|
|
209
|
+
__metadata("design:type", Function),
|
|
210
|
+
__metadata("design:paramtypes", [ImageExportOptions_js_1.ImageExportOptions]),
|
|
211
|
+
__metadata("design:returntype", Promise)
|
|
212
|
+
], ContainerdImage.prototype, "export", null);
|
|
213
|
+
exports.ContainerdImage = ContainerdImage = __decorate([
|
|
214
|
+
(0, di_1.Transient)()
|
|
215
|
+
], ContainerdImage);
|
|
216
|
+
/**
|
|
217
|
+
* The milliseconds of a Timestamp
|
|
218
|
+
* @param timestamp
|
|
219
|
+
*/
|
|
220
|
+
function timestampMilliseconds(timestamp) {
|
|
221
|
+
return timestamp ? Number(timestamp.seconds ?? 0) * 1000 + Math.floor(Number(timestamp.nanos ?? 0) / 1e6) : Date.now();
|
|
222
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { DTO } from '@lakutata/core';
|
|
2
|
+
/**
|
|
3
|
+
* What {@link Containerd.prune} removes; every field is optional. A resource whose removal fails is skipped. Unlike the
|
|
4
|
+
* Docker component's options, the volumes are kept by default, and `allImages` removes the tagged images too.
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* import {Containerd} from 'lakutata/com/containerd'
|
|
8
|
+
*
|
|
9
|
+
* declare const containerd: Containerd
|
|
10
|
+
*
|
|
11
|
+
* //The stopped containers and the dangling images (the defaults), and the unused volumes with their data
|
|
12
|
+
* const removed = await containerd.prune({volumes: true})
|
|
13
|
+
* console.log(removed.containers, removed.images, removed.volumes)
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare class ContainerdPruneOptions extends DTO {
|
|
17
|
+
/**
|
|
18
|
+
* Remove the containers which do not run (their status `'created'` or `'exited'`), with their snapshots and their
|
|
19
|
+
* logs.
|
|
20
|
+
* @default true
|
|
21
|
+
*/
|
|
22
|
+
containers?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Remove the dangling images (named by a digest, without a tag) no container uses.
|
|
25
|
+
* @default true
|
|
26
|
+
*/
|
|
27
|
+
images?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Remove all the images no container uses, the tagged ones too (whatever `images` is).
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
allImages?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Remove the networks no container uses, among the ones created by nerdctl or the component; never `host`, `none`
|
|
35
|
+
* nor the default `bridge` network.
|
|
36
|
+
* @default false
|
|
37
|
+
*/
|
|
38
|
+
networks?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Remove the volumes no container uses, with their data.
|
|
41
|
+
* @default false
|
|
42
|
+
*/
|
|
43
|
+
volumes?: boolean;
|
|
44
|
+
}
|