@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,533 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Provider, DTO } from '@lakutata/core';
|
|
11
|
+
import { Transient, Configurable } from '@lakutata/core/decorator/di';
|
|
12
|
+
import { Accept } from '@lakutata/core/decorator/dto';
|
|
13
|
+
import { Time } from '@lakutata/utils/Time';
|
|
14
|
+
import { createWriteStream } from 'node:fs';
|
|
15
|
+
import { ContainerLabels, ContainerStore } from '../../client/ContainerStore.js';
|
|
16
|
+
import { ContainerStopOptions } from '../options/container/ContainerStopOptions.js';
|
|
17
|
+
import { ContainerKillOptions } from '../options/container/ContainerKillOptions.js';
|
|
18
|
+
import { ContainerRemoveOptions } from '../options/container/ContainerRemoveOptions.js';
|
|
19
|
+
import { ContainerExecOptions } from '../options/container/ContainerExecOptions.js';
|
|
20
|
+
import { ContainerLogsOptions } from '../options/container/ContainerLogsOptions.js';
|
|
21
|
+
import { ContainerdContainerNotFoundException } from '../exceptions/ContainerdContainerNotFoundException.js';
|
|
22
|
+
import { containerdError } from './ContainerdErrors.js';
|
|
23
|
+
import { ContainerdContainerTTY } from './ContainerdContainerTTY.js';
|
|
24
|
+
import { ContainerTTYOptions } from '../options/container/ContainerTTYOptions.js';
|
|
25
|
+
import { ContainerResourceOptions } from '../options/container/ContainerResourceOptions.js';
|
|
26
|
+
import { ContainerCommitOptions } from '../options/container/ContainerCommitOptions.js';
|
|
27
|
+
import { ContainerExportDirectoryOptions } from '../options/container/ContainerExportDirectoryOptions.js';
|
|
28
|
+
import { ContainerdContainerStateException } from '../exceptions/ContainerdContainerStateException.js';
|
|
29
|
+
import { parseReference } from '../../client/Reference.js';
|
|
30
|
+
/**
|
|
31
|
+
* A container of the {@link Containerd} component's namespace, with the operations of a Docker container: start, stop,
|
|
32
|
+
* kill, pause, exec, terminals, logs, stats, live updates or updates by recreation, commit and file export. Get it from
|
|
33
|
+
* {@link Containerd.getContainer}, {@link Containerd.listContainers} or {@link Containerd.createContainer}; do not create
|
|
34
|
+
* it yourself. Each call returns a new object (transient).
|
|
35
|
+
*
|
|
36
|
+
* Its properties are a snapshot taken when it was obtained: the operations changing the container (`start()`, `stop()`,
|
|
37
|
+
* `kill()`, `pause()`, `wait()`, `update()`…) take a new one when they end, and {@link ContainerdContainer.syncContainerInfo}
|
|
38
|
+
* takes one on demand. The state the container is in decides what works: `exec()`, `createTTY()` and `stats()` need it
|
|
39
|
+
* running, and `remove()` refuses a running container unless forced.
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* import {Containerd, type ContainerdContainer, type ContainerdContainerStats} from 'lakutata/com/containerd'
|
|
43
|
+
*
|
|
44
|
+
* declare const containerd: Containerd
|
|
45
|
+
*
|
|
46
|
+
* const container: ContainerdContainer = await containerd.getContainer('worker')
|
|
47
|
+
* if (!container.state.running) await container.start()
|
|
48
|
+
* //The last 100 lines, without following the output
|
|
49
|
+
* for await (const chunk of await container.logs({tail: 100, follow: false})) process.stdout.write(chunk)
|
|
50
|
+
* const stats: ContainerdContainerStats = await container.stats()
|
|
51
|
+
* console.log(stats.cpu.percent, stats.memory.usage)
|
|
52
|
+
* //Live, without a restart
|
|
53
|
+
* await container.update({memoryLimit: 256 * 1024 * 1024})
|
|
54
|
+
* //Its stop signal, then SIGKILL after 5 seconds
|
|
55
|
+
* await container.stop({timeout: 5})
|
|
56
|
+
* await container.remove()
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
let ContainerdContainer = class ContainerdContainer extends Provider {
|
|
60
|
+
#abortController = new AbortController();
|
|
61
|
+
/**
|
|
62
|
+
* Read the container's information.
|
|
63
|
+
* @throws {ContainerdContainerNotFoundException} No container matches the identifier or name.
|
|
64
|
+
* @protected
|
|
65
|
+
*/
|
|
66
|
+
async init() {
|
|
67
|
+
await this.syncContainerInfo();
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* End the log streams followed and the waits of the object.
|
|
71
|
+
* @protected
|
|
72
|
+
*/
|
|
73
|
+
async destroy() {
|
|
74
|
+
this.#abortController.abort();
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Read the container's information and state again from containerd into the object's properties.
|
|
78
|
+
* @throws {ContainerdContainerNotFoundException} The container no longer exists.
|
|
79
|
+
*/
|
|
80
|
+
async syncContainerInfo() {
|
|
81
|
+
const record = await this.getStore().find(this.id);
|
|
82
|
+
if (!record)
|
|
83
|
+
throw new ContainerdContainerNotFoundException(`The container ${this.id} does not exist`);
|
|
84
|
+
this.record = record;
|
|
85
|
+
this.id = record.id;
|
|
86
|
+
this.labels = record.labels ?? {};
|
|
87
|
+
this.name = ContainerStore.Name(record);
|
|
88
|
+
this.hostname = this.labels[ContainerLabels.HOSTNAME] ?? '';
|
|
89
|
+
this.imageName = record.image ?? '';
|
|
90
|
+
this.platform = this.labels[ContainerLabels.PLATFORM] ?? '';
|
|
91
|
+
this.restartPolicy = (this.labels[ContainerLabels.RESTART_POLICY] ?? 'no');
|
|
92
|
+
this.createdAt = new Time(record.createdAt ? Number(record.createdAt.seconds ?? 0) * 1000 : Date.now());
|
|
93
|
+
try {
|
|
94
|
+
this.networkNames = JSON.parse(this.labels[ContainerLabels.NETWORKS] ?? '[]');
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
this.networkNames = [];
|
|
98
|
+
}
|
|
99
|
+
this.networks = (await this.getStore().interfaces(record)).map((item) => ({
|
|
100
|
+
networkName: item.network,
|
|
101
|
+
interface: item.interface,
|
|
102
|
+
mac: item.mac ?? '',
|
|
103
|
+
ip: item.ip ?? '',
|
|
104
|
+
gateway: item.gateway ?? '',
|
|
105
|
+
ipPrefixLen: item.prefixLength ?? 0,
|
|
106
|
+
ipv6: item.ipv6 ?? '',
|
|
107
|
+
ipv6Gateway: item.ipv6Gateway ?? ''
|
|
108
|
+
}));
|
|
109
|
+
const ports = new Map();
|
|
110
|
+
try {
|
|
111
|
+
for (const port of JSON.parse(this.labels[ContainerLabels.PORTS] ?? '[]')) {
|
|
112
|
+
const key = `${port.HostIP}/${port.ContainerPort}/${port.Protocol}`;
|
|
113
|
+
const known = ports.get(key) ?? { host: port.HostIP, port: port.ContainerPort, type: port.Protocol, hostPorts: [] };
|
|
114
|
+
known.hostPorts.push(port.HostPort);
|
|
115
|
+
ports.set(key, known);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
//Not the labels of nerdctl
|
|
120
|
+
}
|
|
121
|
+
this.ports = [...ports.values()];
|
|
122
|
+
this.volumes = ContainerStore.Volumes(record);
|
|
123
|
+
const state = await this.getStore().state(record);
|
|
124
|
+
this.state = {
|
|
125
|
+
status: state.status,
|
|
126
|
+
running: state.running,
|
|
127
|
+
paused: state.paused,
|
|
128
|
+
restarting: state.status === 'restarting',
|
|
129
|
+
pid: state.pid,
|
|
130
|
+
exitCode: state.exitCode,
|
|
131
|
+
startedAt: state.startedAt ? new Time(state.startedAt) : null,
|
|
132
|
+
finishedAt: state.finishedAt ? new Time(state.finishedAt) : null
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Run an operation on the container, then read its information again (also when the operation fails).
|
|
137
|
+
* @param operation The operation, given the container's record.
|
|
138
|
+
* @returns What the operation returns.
|
|
139
|
+
* @throws {ContainerdContainerStateException} The container is not in the state the operation needs.
|
|
140
|
+
* @protected
|
|
141
|
+
*/
|
|
142
|
+
async operate(operation) {
|
|
143
|
+
try {
|
|
144
|
+
return await operation(this.record);
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
throw containerdError(error);
|
|
148
|
+
}
|
|
149
|
+
finally {
|
|
150
|
+
await this.syncContainerInfo().catch(() => undefined);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Get the container's image.
|
|
155
|
+
* @returns The image.
|
|
156
|
+
* @throws {ContainerdImageNotFoundException} The image was removed since the container was created.
|
|
157
|
+
*/
|
|
158
|
+
async image() {
|
|
159
|
+
return await this.getContainerd().getImage(this.imageName);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Start the container: a new task of its root file system, its output appended to its log file (rotated first beyond
|
|
163
|
+
* the component's `logMaxSize`), its CNI networks set up. Its restart policy applies from now on. A running container
|
|
164
|
+
* is left as it is.
|
|
165
|
+
* @throws {ContainerdContainerStateException} The container is paused: unpause it.
|
|
166
|
+
* @throws {Error} The task cannot be created or started (the command is not found, seccomp refuses it…).
|
|
167
|
+
*/
|
|
168
|
+
async start() {
|
|
169
|
+
await this.operate((record) => this.getStore().start(record));
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Stop the container: send its stop signal (the one of `options`, else its `stopSignal`, else `SIGTERM`), wait for it
|
|
173
|
+
* to exit, then kill all its processes with `SIGKILL` when the timeout ends. Its exit code is kept, and the restart
|
|
174
|
+
* monitor no longer restarts it. A paused container is resumed first; a stopped one is left as it is.
|
|
175
|
+
* @param options The time to wait in seconds (10 by default) and the signal.
|
|
176
|
+
*/
|
|
177
|
+
async stop(options) {
|
|
178
|
+
if (!options)
|
|
179
|
+
return await this.stop({});
|
|
180
|
+
await this.operate((record) => this.getStore().stop(record, { timeout: options.timeout, signal: options.signal }));
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Restart the container: stop it as {@link ContainerdContainer.stop} does, then start it.
|
|
184
|
+
* @param options How it is stopped: the time to wait in seconds (10 by default) and the signal.
|
|
185
|
+
* @throws {Error} The task cannot be started again.
|
|
186
|
+
*/
|
|
187
|
+
async restart(options) {
|
|
188
|
+
if (!options)
|
|
189
|
+
return await this.restart({});
|
|
190
|
+
await this.stop(options);
|
|
191
|
+
await this.start();
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Send a signal to the container's main process, or to all its processes. `SIGKILL` also tells the restart monitor
|
|
195
|
+
* not to restart it; other signals do not.
|
|
196
|
+
* @param options The signal (`SIGKILL` by default; a name or a number) and `all`.
|
|
197
|
+
* @throws {ContainerdContainerStateException} The container is not running.
|
|
198
|
+
*/
|
|
199
|
+
async kill(options) {
|
|
200
|
+
if (!options)
|
|
201
|
+
return await this.kill({});
|
|
202
|
+
await this.operate((record) => this.getStore().kill(record, options.signal, options.all));
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Pause all the processes of the running container (cgroup freezer).
|
|
206
|
+
* @throws {ContainerdContainerStateException} The container is not running.
|
|
207
|
+
*/
|
|
208
|
+
async pause() {
|
|
209
|
+
await this.operate((record) => this.getStore().pause(record));
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Resume the processes of the paused container.
|
|
213
|
+
* @throws {ContainerdContainerStateException} The container is not running.
|
|
214
|
+
*/
|
|
215
|
+
async unpause() {
|
|
216
|
+
await this.operate((record) => this.getStore().resume(record));
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Wait for the container's main process to exit, as `docker wait` does. A container that is not running resolves at
|
|
220
|
+
* once: with the exit code of its last run when it exited or was stopped by {@link ContainerdContainer.stop}, with
|
|
221
|
+
* `0` when it was never started (or when the component did not keep its exit code: a container created by nerdctl
|
|
222
|
+
* or by another `dataRoot`). The wait ends with an error when the object is destroyed.
|
|
223
|
+
* @returns The exit code.
|
|
224
|
+
* @throws {GRPCError} The wait was aborted (from `@lakutata/grpc`, its `code` is `CANCELLED`).
|
|
225
|
+
*/
|
|
226
|
+
async wait() {
|
|
227
|
+
try {
|
|
228
|
+
return await this.getStore().wait(this.record, this.#abortController.signal);
|
|
229
|
+
}
|
|
230
|
+
catch (error) {
|
|
231
|
+
throw containerdError(error);
|
|
232
|
+
}
|
|
233
|
+
finally {
|
|
234
|
+
await this.syncContainerInfo().catch(() => undefined);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Remove the container: its task, its CNI network interfaces, its record, its snapshot and its state directory (its
|
|
239
|
+
* logs included). The named volumes it mounts are kept. With `force`, a running or paused container is killed first.
|
|
240
|
+
* @param options `force` (false by default).
|
|
241
|
+
* @throws {ContainerdContainerStateException} The container is running and `force` is not set.
|
|
242
|
+
*/
|
|
243
|
+
async remove(options) {
|
|
244
|
+
if (!options)
|
|
245
|
+
return await this.remove({});
|
|
246
|
+
try {
|
|
247
|
+
await this.getStore().remove(this.record, !!options.force);
|
|
248
|
+
}
|
|
249
|
+
catch (error) {
|
|
250
|
+
throw containerdError(error);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Run a command in the running container and wait for it to exit, its outputs captured in memory. The process gets
|
|
255
|
+
* the container's environment (with `env` added), working directory and user unless given. Its standard output and
|
|
256
|
+
* error are kept apart through FIFOs (`mkfifo` of the host); without `mkfifo`, both are in `stdout`.
|
|
257
|
+
* @param options The command (a string is run by `/bin/sh -c`, an array as is), `env`, `workingDir`, `user` (`name`,
|
|
258
|
+
* `uid`, `name:group`), `stdin` (written then closed) and `timeout` (milliseconds, then the process is killed with
|
|
259
|
+
* `SIGKILL`).
|
|
260
|
+
* @returns The exit code and the outputs; a command killed by its timeout resolves with exit code `137`.
|
|
261
|
+
* @throws {ContainerdContainerStateException} The container is not running (stopped or paused).
|
|
262
|
+
* @throws {Error} `stdin` is given and the host has no `mkfifo`; the user is not found in the container.
|
|
263
|
+
*/
|
|
264
|
+
async exec(options) {
|
|
265
|
+
try {
|
|
266
|
+
return await this.getStore().exec(this.record, {
|
|
267
|
+
cmd: typeof options.cmd === 'string' ? ['/bin/sh', '-c', options.cmd] : options.cmd,
|
|
268
|
+
env: options.env,
|
|
269
|
+
workingDir: options.workingDir,
|
|
270
|
+
user: options.user,
|
|
271
|
+
stdin: options.stdin,
|
|
272
|
+
timeout: options.timeout
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
catch (error) {
|
|
276
|
+
throw containerdError(error);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Read the container's logs: its standard output and error interleaved in one stream, without timestamps, from its
|
|
281
|
+
* log file (and the previous rotated file). By default the stream follows the new output while the container runs
|
|
282
|
+
* (or is being restarted by the restart monitor), and ends once it stopped or when the object is destroyed.
|
|
283
|
+
* @param options `tail`, the number of last lines to start with (all by default), and `follow` (true by default).
|
|
284
|
+
* @returns A readable stream of buffers.
|
|
285
|
+
*/
|
|
286
|
+
async logs(options) {
|
|
287
|
+
if (!options)
|
|
288
|
+
return await this.logs({});
|
|
289
|
+
return this.getStore().logs(this.record, { tail: options.tail, follow: options.follow, signal: this.#abortController.signal });
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Read the resources the running or paused container uses: its cgroup counters and its network interface counters,
|
|
293
|
+
* sampled twice to compute its CPU use over the interval.
|
|
294
|
+
* @param interval The time between the two samples, in milliseconds; `0` takes one sample and reports a CPU use of
|
|
295
|
+
* 0. 1000 by default.
|
|
296
|
+
* @returns The counters of the last sample, with the CPU use over the interval.
|
|
297
|
+
* @throws {ContainerdContainerStateException} The container is not running.
|
|
298
|
+
*/
|
|
299
|
+
async stats(interval = 1000) {
|
|
300
|
+
try {
|
|
301
|
+
return await this.getStore().stats(this.record, interval);
|
|
302
|
+
}
|
|
303
|
+
catch (error) {
|
|
304
|
+
throw containerdError(error);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Open an interactive terminal in the running container: a process with a pseudo terminal (`TERM=xterm`), its input
|
|
309
|
+
* and output through FIFOs (`mkfifo` of the host). Close it with {@link ContainerdContainerTTY.close} when done.
|
|
310
|
+
* @param options The command (a string is run by `/bin/sh -c` as {@link ContainerdContainer.exec} runs it, an array
|
|
311
|
+
* as is; `['/bin/sh']` by default, so the image needs a shell), the initial console size, `env`, `workingDir` and
|
|
312
|
+
* `user`.
|
|
313
|
+
* @returns The terminal, its process started.
|
|
314
|
+
* @throws {ContainerdContainerStateException} The container is not running.
|
|
315
|
+
* @throws {Error} The host has no `mkfifo`; the user is not found in the container.
|
|
316
|
+
*/
|
|
317
|
+
async createTTY(options) {
|
|
318
|
+
return await this.getObject(ContainerdContainerTTY, {
|
|
319
|
+
getStore: this.getStore,
|
|
320
|
+
getRecord: () => this.record,
|
|
321
|
+
cmd: options?.cmd ?? ['/bin/sh'],
|
|
322
|
+
initialConsoleSize: options?.consoleSize,
|
|
323
|
+
env: options?.env,
|
|
324
|
+
workingDir: options?.workingDir,
|
|
325
|
+
user: options?.user
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Update the container's settings. When only resources and the restart policy change (`memoryLimit`, `memorySwap`,
|
|
330
|
+
* `cpus`, `cpuShares`, `cpuSet`, `pidsLimit`, `OOMKillDisable`, `restartPolicy`), they are applied live, without a
|
|
331
|
+
* restart, as `docker update` does: `0` (`[]` for `cpuSet`) removes a limit, from the running container too, and from
|
|
332
|
+
* the settings it is created again with ({@link ContainerResourceOptions}). Any other setting creates the container
|
|
333
|
+
* again with its creation settings and the changes: a new container with the same name (and a new identifier, which
|
|
334
|
+
* this object follows), started when the old one was running; the old one is removed. The recreation only works for
|
|
335
|
+
* the containers created by the component, whose settings it kept.
|
|
336
|
+
* @param options The settings to change, as {@link Containerd.createContainer} takes them.
|
|
337
|
+
* @throws {InvalidValueException} A live update gives a `memorySwap` (positive) to a container without a memory
|
|
338
|
+
* limit, or leaves its `memorySwap` below its `memoryLimit` (from `@lakutata/core`).
|
|
339
|
+
* @throws {ContainerdContainerStateException} The container must be created again but was not created by the
|
|
340
|
+
* component (nerdctl's, or created by another `dataRoot`).
|
|
341
|
+
* @throws {ContainerdImageNotFoundException} From the recreation, as {@link Containerd.createContainer} throws.
|
|
342
|
+
*/
|
|
343
|
+
async update(options) {
|
|
344
|
+
const keys = Object.keys(options).filter((key) => options[key] !== undefined);
|
|
345
|
+
const resourceKeys = ['memoryLimit', 'memorySwap', 'cpus', 'cpuShares', 'cpuSet', 'pidsLimit', 'OOMKillDisable', 'restartPolicy'];
|
|
346
|
+
if (keys.every((key) => resourceKeys.includes(key))) {
|
|
347
|
+
const resources = ContainerResourceOptions.validate(options);
|
|
348
|
+
await this.operate((record) => this.getStore().updateResources(record, {
|
|
349
|
+
memory: resources.memoryLimit,
|
|
350
|
+
memorySwap: resources.memorySwap,
|
|
351
|
+
cpus: resources.cpus,
|
|
352
|
+
cpuShares: resources.cpuShares,
|
|
353
|
+
cpuset: resources.cpuSet?.join(','),
|
|
354
|
+
pidsLimit: resources.pidsLimit,
|
|
355
|
+
oomKillDisable: resources.OOMKillDisable,
|
|
356
|
+
restart: resources.restartPolicy
|
|
357
|
+
}));
|
|
358
|
+
//Kept by its settings: the ones it is created again with, a limit removed (0, []) not kept
|
|
359
|
+
const current = await this.getStore().readSettings(this.id);
|
|
360
|
+
if (!current)
|
|
361
|
+
return;
|
|
362
|
+
const settings = { ...current, ...Object.fromEntries(keys.map((key) => [key, options[key]])) };
|
|
363
|
+
if (!settings.memoryLimit)
|
|
364
|
+
delete settings.memoryLimit;
|
|
365
|
+
//No swap limit: unlimited swap with a memory limit (twice the memory without memorySwap)
|
|
366
|
+
if (!settings.memoryLimit)
|
|
367
|
+
delete settings.memorySwap;
|
|
368
|
+
else if (settings.memorySwap === 0)
|
|
369
|
+
settings.memorySwap = -1;
|
|
370
|
+
for (const key of ['cpus', 'cpuShares', 'pidsLimit'])
|
|
371
|
+
if (!settings[key])
|
|
372
|
+
delete settings[key];
|
|
373
|
+
if (!settings.cpuSet?.length)
|
|
374
|
+
delete settings.cpuSet;
|
|
375
|
+
await this.getStore().writeSettings(this.id, settings);
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
const settings = await this.getStore().readSettings(this.id);
|
|
379
|
+
if (!settings)
|
|
380
|
+
throw new ContainerdContainerStateException(`The container ${this.name} was not created by the component (its settings are unknown): create it again`);
|
|
381
|
+
this.id = (await this.getContainerd().recreateContainer(this.record, { ...settings, ...options, name: options.name ?? this.name })).id;
|
|
382
|
+
await this.syncContainerInfo();
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Commit the container: save the changes of its root file system (not its mounts) as a new layer on its image,
|
|
386
|
+
* with configuration changes, as `docker commit` does. A running container is paused meanwhile by default.
|
|
387
|
+
* @param options The name of the new image (`<registry>/<repository>:commit-<milliseconds>` of the container's image
|
|
388
|
+
* by default), `pauseBeforeCommitting` (true by default), the configuration `changes`, `comment` and `author`.
|
|
389
|
+
* @returns The new image.
|
|
390
|
+
* @throws {ContainerdImageNotFoundException} The container's image was removed.
|
|
391
|
+
*/
|
|
392
|
+
async commit(options) {
|
|
393
|
+
if (!options)
|
|
394
|
+
return await this.commit({});
|
|
395
|
+
let name;
|
|
396
|
+
if (options.repoTag) {
|
|
397
|
+
name = options.repoTag;
|
|
398
|
+
}
|
|
399
|
+
else {
|
|
400
|
+
const reference = parseReference(this.imageName);
|
|
401
|
+
name = `${reference.registry}/${reference.repository}:commit-${Date.now()}`;
|
|
402
|
+
}
|
|
403
|
+
try {
|
|
404
|
+
name = await this.getStore().commit(this.record, {
|
|
405
|
+
name: name,
|
|
406
|
+
pause: options.pauseBeforeCommitting,
|
|
407
|
+
changes: options.changes ? { ...options.changes, env: options.changes.env ? Object.entries(options.changes.env).map(([key, value]) => `${key}=${value}`) : undefined } : undefined,
|
|
408
|
+
comment: options.comment,
|
|
409
|
+
author: options.author
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
catch (error) {
|
|
413
|
+
throw containerdError(error);
|
|
414
|
+
}
|
|
415
|
+
return await this.getContainerd().getImage(name);
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Copy a file or directory of the container out as a tar archive, as `docker cp` does: from the running process's
|
|
419
|
+
* file system (its mounts included), or from its root file system when it is not running (without its mounts). The
|
|
420
|
+
* symbolic links of the path are resolved inside the container; the devices, sockets and pipes are not archived.
|
|
421
|
+
* @param options The absolute path in the container, and the destination (a file path, created or replaced, or a
|
|
422
|
+
* writable stream).
|
|
423
|
+
* @throws {ContainerdPathNotFoundException} The path does not exist in the container.
|
|
424
|
+
* @throws {Error} The archive cannot be written.
|
|
425
|
+
*/
|
|
426
|
+
async exportDirectory(options) {
|
|
427
|
+
try {
|
|
428
|
+
await this.getStore().archive(this.record, options.path, typeof options.destination === 'string' ? createWriteStream(options.destination) : options.destination);
|
|
429
|
+
}
|
|
430
|
+
catch (error) {
|
|
431
|
+
throw containerdError(error);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* List the processes of the running container.
|
|
436
|
+
* @returns Their process identifiers on the host.
|
|
437
|
+
* @throws {ContainerdContainerStateException} The container is not running.
|
|
438
|
+
*/
|
|
439
|
+
async processes() {
|
|
440
|
+
try {
|
|
441
|
+
return await this.getStore().processes(this.record);
|
|
442
|
+
}
|
|
443
|
+
catch (error) {
|
|
444
|
+
throw containerdError(error);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
__decorate([
|
|
449
|
+
Configurable(DTO.Function()),
|
|
450
|
+
__metadata("design:type", Function)
|
|
451
|
+
], ContainerdContainer.prototype, "getStore", void 0);
|
|
452
|
+
__decorate([
|
|
453
|
+
Configurable(DTO.Function()),
|
|
454
|
+
__metadata("design:type", Function)
|
|
455
|
+
], ContainerdContainer.prototype, "getClient", void 0);
|
|
456
|
+
__decorate([
|
|
457
|
+
Configurable(DTO.Function()),
|
|
458
|
+
__metadata("design:type", Function)
|
|
459
|
+
], ContainerdContainer.prototype, "getContainerd", void 0);
|
|
460
|
+
__decorate([
|
|
461
|
+
Configurable(DTO.String()),
|
|
462
|
+
__metadata("design:type", String)
|
|
463
|
+
], ContainerdContainer.prototype, "id", void 0);
|
|
464
|
+
__decorate([
|
|
465
|
+
Accept(ContainerStopOptions.optional()),
|
|
466
|
+
__metadata("design:type", Function),
|
|
467
|
+
__metadata("design:paramtypes", [ContainerStopOptions]),
|
|
468
|
+
__metadata("design:returntype", Promise)
|
|
469
|
+
], ContainerdContainer.prototype, "stop", null);
|
|
470
|
+
__decorate([
|
|
471
|
+
Accept(ContainerStopOptions.optional()),
|
|
472
|
+
__metadata("design:type", Function),
|
|
473
|
+
__metadata("design:paramtypes", [ContainerStopOptions]),
|
|
474
|
+
__metadata("design:returntype", Promise)
|
|
475
|
+
], ContainerdContainer.prototype, "restart", null);
|
|
476
|
+
__decorate([
|
|
477
|
+
Accept(ContainerKillOptions.optional()),
|
|
478
|
+
__metadata("design:type", Function),
|
|
479
|
+
__metadata("design:paramtypes", [ContainerKillOptions]),
|
|
480
|
+
__metadata("design:returntype", Promise)
|
|
481
|
+
], ContainerdContainer.prototype, "kill", null);
|
|
482
|
+
__decorate([
|
|
483
|
+
Accept(ContainerRemoveOptions.optional()),
|
|
484
|
+
__metadata("design:type", Function),
|
|
485
|
+
__metadata("design:paramtypes", [ContainerRemoveOptions]),
|
|
486
|
+
__metadata("design:returntype", Promise)
|
|
487
|
+
], ContainerdContainer.prototype, "remove", null);
|
|
488
|
+
__decorate([
|
|
489
|
+
Accept(ContainerExecOptions.required()),
|
|
490
|
+
__metadata("design:type", Function),
|
|
491
|
+
__metadata("design:paramtypes", [ContainerExecOptions]),
|
|
492
|
+
__metadata("design:returntype", Promise)
|
|
493
|
+
], ContainerdContainer.prototype, "exec", null);
|
|
494
|
+
__decorate([
|
|
495
|
+
Accept(ContainerLogsOptions.optional()),
|
|
496
|
+
__metadata("design:type", Function),
|
|
497
|
+
__metadata("design:paramtypes", [ContainerLogsOptions]),
|
|
498
|
+
__metadata("design:returntype", Promise)
|
|
499
|
+
], ContainerdContainer.prototype, "logs", null);
|
|
500
|
+
__decorate([
|
|
501
|
+
Accept(DTO.Number().integer().min(0).optional()),
|
|
502
|
+
__metadata("design:type", Function),
|
|
503
|
+
__metadata("design:paramtypes", [Number]),
|
|
504
|
+
__metadata("design:returntype", Promise)
|
|
505
|
+
], ContainerdContainer.prototype, "stats", null);
|
|
506
|
+
__decorate([
|
|
507
|
+
Accept(ContainerTTYOptions.optional()),
|
|
508
|
+
__metadata("design:type", Function),
|
|
509
|
+
__metadata("design:paramtypes", [ContainerTTYOptions]),
|
|
510
|
+
__metadata("design:returntype", Promise)
|
|
511
|
+
], ContainerdContainer.prototype, "createTTY", null);
|
|
512
|
+
__decorate([
|
|
513
|
+
Accept(DTO.Object().required()),
|
|
514
|
+
__metadata("design:type", Function),
|
|
515
|
+
__metadata("design:paramtypes", [Object]),
|
|
516
|
+
__metadata("design:returntype", Promise)
|
|
517
|
+
], ContainerdContainer.prototype, "update", null);
|
|
518
|
+
__decorate([
|
|
519
|
+
Accept(ContainerCommitOptions.optional()),
|
|
520
|
+
__metadata("design:type", Function),
|
|
521
|
+
__metadata("design:paramtypes", [ContainerCommitOptions]),
|
|
522
|
+
__metadata("design:returntype", Promise)
|
|
523
|
+
], ContainerdContainer.prototype, "commit", null);
|
|
524
|
+
__decorate([
|
|
525
|
+
Accept(ContainerExportDirectoryOptions.required()),
|
|
526
|
+
__metadata("design:type", Function),
|
|
527
|
+
__metadata("design:paramtypes", [ContainerExportDirectoryOptions]),
|
|
528
|
+
__metadata("design:returntype", Promise)
|
|
529
|
+
], ContainerdContainer.prototype, "exportDirectory", null);
|
|
530
|
+
ContainerdContainer = __decorate([
|
|
531
|
+
Transient()
|
|
532
|
+
], ContainerdContainer);
|
|
533
|
+
export { ContainerdContainer };
|