@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,416 @@
|
|
|
1
|
+
import { randomBytes } from 'node:crypto';
|
|
2
|
+
import { GRPCConnection, GRPCError, GRPCStatus, decode } from '@lakutata/grpc';
|
|
3
|
+
import * as M from './Messages.js';
|
|
4
|
+
/**
|
|
5
|
+
* The prefix of the paths of the services of containerd
|
|
6
|
+
*/
|
|
7
|
+
const SERVICES = '/containerd.services';
|
|
8
|
+
/**
|
|
9
|
+
* The type URL of the specifications of the containers and of their processes (OCI runtime spec, JSON)
|
|
10
|
+
*/
|
|
11
|
+
export const SPEC_TYPE_URL = 'types.containerd.io/opencontainers/runtime-spec/1/Spec';
|
|
12
|
+
export const PROCESS_TYPE_URL = 'types.containerd.io/opencontainers/runtime-spec/1/Process';
|
|
13
|
+
export const RESOURCES_TYPE_URL = 'types.containerd.io/opencontainers/runtime-spec/1/LinuxResources';
|
|
14
|
+
/**
|
|
15
|
+
* A date of a Timestamp
|
|
16
|
+
* @param timestamp
|
|
17
|
+
*/
|
|
18
|
+
export function timestampDate(timestamp) {
|
|
19
|
+
if (!timestamp)
|
|
20
|
+
return undefined;
|
|
21
|
+
return new Date(Number(timestamp.seconds ?? 0) * 1000 + Math.floor(Number(timestamp.nanos ?? 0) / 1e6));
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Whether an error is the one of a call of a code
|
|
25
|
+
* @param error
|
|
26
|
+
* @param code
|
|
27
|
+
*/
|
|
28
|
+
export function isGRPCError(error, code) {
|
|
29
|
+
return error instanceof GRPCError && error.code === code;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The client of the API of containerd (its services of the version 1), in a namespace: its calls are the ones of
|
|
33
|
+
* ctr and nerdctl
|
|
34
|
+
*/
|
|
35
|
+
export class ContainerdClient {
|
|
36
|
+
constructor(socketPath, namespace) {
|
|
37
|
+
this.namespace = namespace;
|
|
38
|
+
this.grpc = new GRPCConnection(socketPath);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The options of a call: its namespace, its lease (the content and the snapshots it creates are kept by it until
|
|
42
|
+
* they are referenced)
|
|
43
|
+
* @param lease
|
|
44
|
+
* @param signal
|
|
45
|
+
*/
|
|
46
|
+
options(lease, signal) {
|
|
47
|
+
return { metadata: { 'containerd-namespace': this.namespace, 'containerd-lease': lease }, signal: signal };
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Call a method of a service
|
|
51
|
+
* @param service its name and its version (images.v1.Images)
|
|
52
|
+
* @param method
|
|
53
|
+
* @param requestSchema
|
|
54
|
+
* @param request
|
|
55
|
+
* @param responseSchema
|
|
56
|
+
* @param lease
|
|
57
|
+
* @param signal
|
|
58
|
+
*/
|
|
59
|
+
call(service, method, requestSchema, request, responseSchema = M.Empty, lease, signal) {
|
|
60
|
+
return this.grpc.unary(`${SERVICES}.${service}/${method}`, requestSchema, request, responseSchema, this.options(lease, signal));
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Call a method, undefined when what it reads does not exist
|
|
64
|
+
* @param promise
|
|
65
|
+
*/
|
|
66
|
+
async orUndefined(promise) {
|
|
67
|
+
try {
|
|
68
|
+
return await promise;
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
if (isGRPCError(error, GRPCStatus.NOT_FOUND))
|
|
72
|
+
return undefined;
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/*
|
|
77
|
+
* Version, namespaces
|
|
78
|
+
*/
|
|
79
|
+
async version() {
|
|
80
|
+
return await this.call('version.v1.Version', 'Version', M.Empty, {}, M.VersionResponse);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Create the namespace of the client, when it does not exist
|
|
84
|
+
*/
|
|
85
|
+
async ensureNamespace() {
|
|
86
|
+
try {
|
|
87
|
+
await this.call('namespaces.v1.Namespaces', 'Create', M.CreateNamespaceRequest, { namespace: { name: this.namespace } }, M.Empty);
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
if (!isGRPCError(error, GRPCStatus.ALREADY_EXISTS))
|
|
91
|
+
throw error;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/*
|
|
95
|
+
* Leases
|
|
96
|
+
*/
|
|
97
|
+
/**
|
|
98
|
+
* Create a lease, which keeps what is created under it until it is deleted (or expired)
|
|
99
|
+
* @param expireSeconds
|
|
100
|
+
*/
|
|
101
|
+
async createLease(expireSeconds = 24 * 3600) {
|
|
102
|
+
const id = `lakutata-${Date.now()}-${randomBytes(4).toString('hex')}`;
|
|
103
|
+
const expire = new Date(Date.now() + expireSeconds * 1000).toISOString();
|
|
104
|
+
await this.call('leases.v1.Leases', 'Create', M.CreateLeaseRequest, { id: id, labels: { 'containerd.io/gc.expire': expire } }, M.CreateLeaseResponse);
|
|
105
|
+
return id;
|
|
106
|
+
}
|
|
107
|
+
async deleteLease(id) {
|
|
108
|
+
await this.orUndefined(this.call('leases.v1.Leases', 'Delete', M.DeleteLeaseRequest, { id: id }));
|
|
109
|
+
}
|
|
110
|
+
/*
|
|
111
|
+
* Images
|
|
112
|
+
*/
|
|
113
|
+
async getImage(name) {
|
|
114
|
+
return (await this.orUndefined(this.call('images.v1.Images', 'Get', M.GetImageRequest, { name: name }, M.ImageResponse)))?.image;
|
|
115
|
+
}
|
|
116
|
+
async listImages(filters = []) {
|
|
117
|
+
return (await this.call('images.v1.Images', 'List', M.ListImagesRequest, { filters: filters }, M.ListImagesResponse)).images;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Create an image, or update it when it exists (its target and its labels)
|
|
121
|
+
* @param image
|
|
122
|
+
* @param lease
|
|
123
|
+
*/
|
|
124
|
+
async putImage(image, lease) {
|
|
125
|
+
try {
|
|
126
|
+
return (await this.call('images.v1.Images', 'Create', M.CreateImageRequest, { image: image }, M.ImageResponse, lease)).image;
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
if (!isGRPCError(error, GRPCStatus.ALREADY_EXISTS))
|
|
130
|
+
throw error;
|
|
131
|
+
return (await this.call('images.v1.Images', 'Update', M.UpdateImageRequest, { image: image, updateMask: { paths: ['target', 'labels'] } }, M.ImageResponse, lease)).image;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
async deleteImage(name, sync = false) {
|
|
135
|
+
await this.call('images.v1.Images', 'Delete', M.DeleteImageRequest, { name: name, sync: sync });
|
|
136
|
+
}
|
|
137
|
+
/*
|
|
138
|
+
* Content
|
|
139
|
+
*/
|
|
140
|
+
async contentInfo(digest) {
|
|
141
|
+
return (await this.orUndefined(this.call('content.v1.Content', 'Info', M.InfoRequest, { digest: digest }, M.InfoResponse)))?.info;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Set labels of a content
|
|
145
|
+
* @param digest
|
|
146
|
+
* @param labels
|
|
147
|
+
*/
|
|
148
|
+
async labelContent(digest, labels) {
|
|
149
|
+
if (!Object.keys(labels).length)
|
|
150
|
+
return;
|
|
151
|
+
await this.call('content.v1.Content', 'Update', M.UpdateContentRequest, {
|
|
152
|
+
info: { digest: digest, labels: labels },
|
|
153
|
+
updateMask: { paths: Object.keys(labels).map((key) => `labels.${key}`) }
|
|
154
|
+
}, M.InfoResponse);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Read a content, by its chunks
|
|
158
|
+
* @param digest
|
|
159
|
+
* @param signal
|
|
160
|
+
*/
|
|
161
|
+
async *readContent(digest, signal) {
|
|
162
|
+
const responses = this.grpc.serverStream(`${SERVICES}.content.v1.Content/Read`, M.ReadContentRequest, { digest: digest }, M.ReadContentResponse, this.options(undefined, signal));
|
|
163
|
+
for await (const response of responses)
|
|
164
|
+
if (response.data?.length)
|
|
165
|
+
yield response.data;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Read a content whole
|
|
169
|
+
* @param digest
|
|
170
|
+
*/
|
|
171
|
+
async readAll(digest) {
|
|
172
|
+
const chunks = [];
|
|
173
|
+
for await (const chunk of this.readContent(digest))
|
|
174
|
+
chunks.push(chunk);
|
|
175
|
+
return Buffer.concat(chunks);
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Write a content, checked by its digest (a content which exists is kept), its labels set
|
|
179
|
+
* @param descriptor its digest and its size
|
|
180
|
+
* @param data its bytes, or their chunks
|
|
181
|
+
* @param lease
|
|
182
|
+
* @param labels
|
|
183
|
+
* @param signal
|
|
184
|
+
*/
|
|
185
|
+
async writeContent(descriptor, data, lease, labels = {}, signal) {
|
|
186
|
+
if (await this.contentInfo(descriptor.digest)) {
|
|
187
|
+
await this.labelContent(descriptor.digest, labels);
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
const ref = `lakutata-${descriptor.digest}-${randomBytes(4).toString('hex')}`;
|
|
191
|
+
const stream = this.grpc.bidi(`${SERVICES}.content.v1.Content/Write`, M.WriteContentRequest, M.WriteContentResponse, this.options(lease, signal));
|
|
192
|
+
//The responses read while the requests are sent (one by request)
|
|
193
|
+
const responses = (async () => {
|
|
194
|
+
const all = [];
|
|
195
|
+
for await (const response of stream.responses)
|
|
196
|
+
all.push(response);
|
|
197
|
+
return all;
|
|
198
|
+
})();
|
|
199
|
+
responses.catch(() => undefined);
|
|
200
|
+
try {
|
|
201
|
+
let offset = 0;
|
|
202
|
+
const send = async (chunk) => {
|
|
203
|
+
//Messages of 1 MiB at most (the maximum message of gRPC is 4 MiB)
|
|
204
|
+
for (let start = 0; start < chunk.length; start += 1024 * 1024) {
|
|
205
|
+
const part = chunk.subarray(start, start + 1024 * 1024);
|
|
206
|
+
await stream.send({ action: M.WriteAction.WRITE, ref: ref, total: descriptor.size, expected: descriptor.digest, offset: offset, data: part });
|
|
207
|
+
offset += part.length;
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
if (data instanceof Uint8Array)
|
|
211
|
+
await send(data);
|
|
212
|
+
else
|
|
213
|
+
for await (const chunk of data)
|
|
214
|
+
await send(chunk);
|
|
215
|
+
await stream.send({ action: M.WriteAction.COMMIT, ref: ref, total: descriptor.size, expected: descriptor.digest, offset: offset, labels: labels });
|
|
216
|
+
stream.end();
|
|
217
|
+
const answers = await responses;
|
|
218
|
+
const committed = answers.find((answer) => answer.action === M.WriteAction.COMMIT);
|
|
219
|
+
if (committed && committed.digest !== descriptor.digest)
|
|
220
|
+
throw new Error(`The content written is ${committed.digest}, not ${descriptor.digest}`);
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
stream.cancel();
|
|
224
|
+
//Written by another writer meanwhile
|
|
225
|
+
if (isGRPCError(error, GRPCStatus.ALREADY_EXISTS) || (await this.contentInfo(descriptor.digest))) {
|
|
226
|
+
await this.labelContent(descriptor.digest, labels);
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
await this.orUndefined(this.call('content.v1.Content', 'Abort', M.AbortRequest, { ref: ref }));
|
|
230
|
+
throw error;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
async deleteContent(digest) {
|
|
234
|
+
await this.orUndefined(this.call('content.v1.Content', 'Delete', M.DeleteContentRequest, { digest: digest }));
|
|
235
|
+
}
|
|
236
|
+
/*
|
|
237
|
+
* Snapshots, diff
|
|
238
|
+
*/
|
|
239
|
+
async prepareSnapshot(snapshotter, key, parent, labels = {}, lease) {
|
|
240
|
+
return (await this.call('snapshots.v1.Snapshots', 'Prepare', M.PrepareSnapshotRequest, { snapshotter: snapshotter, key: key, parent: parent, labels: labels }, M.MountsResponse, lease)).mounts;
|
|
241
|
+
}
|
|
242
|
+
async snapshotMounts(snapshotter, key) {
|
|
243
|
+
return (await this.call('snapshots.v1.Snapshots', 'Mounts', M.MountsRequest, { snapshotter: snapshotter, key: key }, M.MountsResponse)).mounts;
|
|
244
|
+
}
|
|
245
|
+
async commitSnapshot(snapshotter, name, key, labels = {}, lease) {
|
|
246
|
+
await this.call('snapshots.v1.Snapshots', 'Commit', M.CommitSnapshotRequest, { snapshotter: snapshotter, name: name, key: key, labels: labels }, M.Empty, lease);
|
|
247
|
+
}
|
|
248
|
+
async viewSnapshot(snapshotter, key, parent, lease) {
|
|
249
|
+
return (await this.call('snapshots.v1.Snapshots', 'View', M.PrepareSnapshotRequest, { snapshotter: snapshotter, key: key, parent: parent }, M.MountsResponse, lease)).mounts;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* The layer of the changes of a snapshot from another one (tar+gzip), written into the content store
|
|
253
|
+
* @param left the older one
|
|
254
|
+
* @param right the newer one
|
|
255
|
+
* @param lease
|
|
256
|
+
*/
|
|
257
|
+
async diff(left, right, lease) {
|
|
258
|
+
return (await this.call('diff.v1.Diff', 'Diff', M.DiffRequest, { left: left, right: right, mediaType: 'application/vnd.oci.image.layer.v1.tar+gzip' }, M.DiffResponse, lease)).diff;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* The metrics of the cgroup of a task: their type (io.containerd.cgroups.v1.Metrics, …v2.Metrics) and their bytes
|
|
262
|
+
* @param containerId
|
|
263
|
+
*/
|
|
264
|
+
async metrics(containerId) {
|
|
265
|
+
return (await this.call('tasks.v1.Tasks', 'Metrics', M.MetricsRequest, { filters: [`id==${containerId}`] }, M.MetricsResponse)).metrics[0];
|
|
266
|
+
}
|
|
267
|
+
async removeSnapshot(snapshotter, key) {
|
|
268
|
+
await this.orUndefined(this.call('snapshots.v1.Snapshots', 'Remove', M.SnapshotKeyRequest, { snapshotter: snapshotter, key: key }));
|
|
269
|
+
}
|
|
270
|
+
async statSnapshot(snapshotter, key) {
|
|
271
|
+
return (await this.orUndefined(this.call('snapshots.v1.Snapshots', 'Stat', M.SnapshotKeyRequest, { snapshotter: snapshotter, key: key }, M.StatSnapshotResponse)))?.info;
|
|
272
|
+
}
|
|
273
|
+
async snapshotUsage(snapshotter, key) {
|
|
274
|
+
return await this.call('snapshots.v1.Snapshots', 'Usage', M.SnapshotKeyRequest, { snapshotter: snapshotter, key: key }, M.UsageResponse);
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Apply a layer (its content) to the mounts of a snapshot
|
|
278
|
+
* @param layer
|
|
279
|
+
* @param mounts
|
|
280
|
+
* @param lease
|
|
281
|
+
*/
|
|
282
|
+
async applyLayer(layer, mounts, lease) {
|
|
283
|
+
return (await this.call('diff.v1.Diff', 'Apply', M.ApplyRequest, { diff: { mediaType: layer.mediaType, digest: layer.digest, size: layer.size }, mounts: mounts }, M.ApplyResponse, lease)).applied;
|
|
284
|
+
}
|
|
285
|
+
/*
|
|
286
|
+
* Containers
|
|
287
|
+
*/
|
|
288
|
+
async getContainer(id) {
|
|
289
|
+
return (await this.orUndefined(this.call('containers.v1.Containers', 'Get', M.GetContainerRequest, { id: id }, M.ContainerResponse)))?.container;
|
|
290
|
+
}
|
|
291
|
+
async listContainers(filters = []) {
|
|
292
|
+
return (await this.call('containers.v1.Containers', 'List', M.ListContainersRequest, { filters: filters }, M.ListContainersResponse)).containers;
|
|
293
|
+
}
|
|
294
|
+
async createContainer(container, lease) {
|
|
295
|
+
return (await this.call('containers.v1.Containers', 'Create', M.CreateContainerRequest, { container: container }, M.ContainerResponse, lease)).container;
|
|
296
|
+
}
|
|
297
|
+
async updateContainer(container, paths) {
|
|
298
|
+
return (await this.call('containers.v1.Containers', 'Update', M.UpdateContainerRequest, { container: container, updateMask: { paths: paths } }, M.ContainerResponse)).container;
|
|
299
|
+
}
|
|
300
|
+
async deleteContainer(id) {
|
|
301
|
+
await this.orUndefined(this.call('containers.v1.Containers', 'Delete', M.DeleteContainerRequest, { id: id }));
|
|
302
|
+
}
|
|
303
|
+
/*
|
|
304
|
+
* Tasks
|
|
305
|
+
*/
|
|
306
|
+
async createTask(request) {
|
|
307
|
+
return (await this.call('tasks.v1.Tasks', 'Create', M.CreateTaskRequest, request, M.CreateTaskResponse)).pid ?? 0;
|
|
308
|
+
}
|
|
309
|
+
async startTask(containerId, execId = '') {
|
|
310
|
+
return (await this.call('tasks.v1.Tasks', 'Start', M.ProcessRequest, { containerId: containerId, execId: execId }, M.StartResponse)).pid ?? 0;
|
|
311
|
+
}
|
|
312
|
+
async deleteTask(containerId) {
|
|
313
|
+
return await this.orUndefined(this.call('tasks.v1.Tasks', 'Delete', M.DeleteTaskRequest, { containerId: containerId }, M.DeleteTaskResponse));
|
|
314
|
+
}
|
|
315
|
+
async deleteProcess(containerId, execId) {
|
|
316
|
+
return await this.orUndefined(this.call('tasks.v1.Tasks', 'DeleteProcess', M.ProcessRequest, { containerId: containerId, execId: execId }, M.DeleteTaskResponse));
|
|
317
|
+
}
|
|
318
|
+
async getTask(containerId, execId = '') {
|
|
319
|
+
return (await this.orUndefined(this.call('tasks.v1.Tasks', 'Get', M.ProcessRequest, { containerId: containerId, execId: execId }, M.GetTaskResponse)))?.process;
|
|
320
|
+
}
|
|
321
|
+
async listTasks() {
|
|
322
|
+
return (await this.call('tasks.v1.Tasks', 'List', M.ListTasksRequest, {}, M.ListTasksResponse)).tasks;
|
|
323
|
+
}
|
|
324
|
+
async kill(containerId, signal, options = {}) {
|
|
325
|
+
await this.call('tasks.v1.Tasks', 'Kill', M.KillRequest, { containerId: containerId, execId: options.execId ?? '', signal: signal, all: options.all ?? false });
|
|
326
|
+
}
|
|
327
|
+
async exec(request) {
|
|
328
|
+
await this.call('tasks.v1.Tasks', 'Exec', M.ExecProcessRequest, request);
|
|
329
|
+
}
|
|
330
|
+
async resizePty(containerId, execId, width, height) {
|
|
331
|
+
await this.call('tasks.v1.Tasks', 'ResizePty', M.ResizePtyRequest, { containerId: containerId, execId: execId, width: width, height: height });
|
|
332
|
+
}
|
|
333
|
+
async closeIO(containerId, execId) {
|
|
334
|
+
await this.call('tasks.v1.Tasks', 'CloseIO', M.CloseIORequest, { containerId: containerId, execId: execId, stdin: true });
|
|
335
|
+
}
|
|
336
|
+
async pause(containerId) {
|
|
337
|
+
await this.call('tasks.v1.Tasks', 'Pause', M.ContainerIdRequest, { containerId: containerId });
|
|
338
|
+
}
|
|
339
|
+
async resume(containerId) {
|
|
340
|
+
await this.call('tasks.v1.Tasks', 'Resume', M.ContainerIdRequest, { containerId: containerId });
|
|
341
|
+
}
|
|
342
|
+
async listPids(containerId) {
|
|
343
|
+
return (await this.call('tasks.v1.Tasks', 'ListPids', M.ContainerIdRequest, { containerId: containerId }, M.ListPidsResponse)).processes.map((process) => process.pid);
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Wait for a process to exit (the task, an exec)
|
|
347
|
+
* @param containerId
|
|
348
|
+
* @param execId
|
|
349
|
+
* @param signal
|
|
350
|
+
*/
|
|
351
|
+
async wait(containerId, execId = '', signal) {
|
|
352
|
+
const response = await this.call('tasks.v1.Tasks', 'Wait', M.ProcessRequest, { containerId: containerId, execId: execId }, M.WaitResponse, undefined, signal);
|
|
353
|
+
return { exitStatus: response.exitStatus ?? 0, exitedAt: timestampDate(response.exitedAt) };
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Update the resources of a task (OCI LinuxResources)
|
|
357
|
+
* @param containerId
|
|
358
|
+
* @param resources
|
|
359
|
+
*/
|
|
360
|
+
async updateTask(containerId, resources) {
|
|
361
|
+
await this.call('tasks.v1.Tasks', 'Update', M.UpdateTaskRequest, { containerId: containerId, resources: { typeUrl: RESOURCES_TYPE_URL, value: Buffer.from(JSON.stringify(resources)) } });
|
|
362
|
+
}
|
|
363
|
+
/*
|
|
364
|
+
* Events
|
|
365
|
+
*/
|
|
366
|
+
/**
|
|
367
|
+
* The events of containerd, their fields decoded (the ones of the tasks, the containers and the images)
|
|
368
|
+
* @param filters the filters of containerd (topic~="/tasks/", namespace==default)
|
|
369
|
+
* @param signal its end
|
|
370
|
+
*/
|
|
371
|
+
async *subscribe(filters = [], signal) {
|
|
372
|
+
//The events of all the namespaces: filtered by namespace
|
|
373
|
+
const responses = this.grpc.serverStream(`${SERVICES}.events.v1.Events/Subscribe`, M.SubscribeRequest, { filters: filters }, M.Envelope, { signal: signal });
|
|
374
|
+
try {
|
|
375
|
+
for await (const envelope of responses) {
|
|
376
|
+
const type = String(envelope.event?.typeUrl ?? '');
|
|
377
|
+
const schema = M.EVENTS[type];
|
|
378
|
+
yield {
|
|
379
|
+
timestamp: timestampDate(envelope.timestamp) ?? new Date(),
|
|
380
|
+
namespace: envelope.namespace ?? '',
|
|
381
|
+
topic: envelope.topic ?? '',
|
|
382
|
+
type: type,
|
|
383
|
+
event: schema && envelope.event?.value ? decode(schema, envelope.event.value) : {}
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
catch (error) {
|
|
388
|
+
if (signal?.aborted && isGRPCError(error, GRPCStatus.CANCELLED))
|
|
389
|
+
return;
|
|
390
|
+
throw error;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* An Any of JSON (the specifications of OCI)
|
|
395
|
+
* @param typeUrl
|
|
396
|
+
* @param value
|
|
397
|
+
*/
|
|
398
|
+
static Json(typeUrl, value) {
|
|
399
|
+
return { typeUrl: typeUrl, value: Buffer.from(JSON.stringify(value)) };
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* The value of an Any of JSON
|
|
403
|
+
* @param any
|
|
404
|
+
*/
|
|
405
|
+
static FromJson(any) {
|
|
406
|
+
if (!any?.value?.length)
|
|
407
|
+
return undefined;
|
|
408
|
+
return JSON.parse(Buffer.from(any.value).toString('utf8'));
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Close the connection
|
|
412
|
+
*/
|
|
413
|
+
close() {
|
|
414
|
+
this.grpc.close();
|
|
415
|
+
}
|
|
416
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The rules of the .dockerignore files, rewritten from @balena/dockerignore (Copyright 2020 Balena Ltd., Apache License
|
|
3
|
+
* 2.0, and Copyright 2018 Zeit, Inc., MIT License, see THIRD_PARTY_NOTICES.md), which follows the implementation of
|
|
4
|
+
* Docker (moby/moby builder/dockerignore and pkg/fileutils)
|
|
5
|
+
*/
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
/**
|
|
8
|
+
* The separators of the paths of the platform: on Windows, "/" and "\" separate the paths and "\" does not escape
|
|
9
|
+
*/
|
|
10
|
+
const SEPARATOR = path.sep;
|
|
11
|
+
/**
|
|
12
|
+
* filepath.Clean of Go
|
|
13
|
+
* @param file
|
|
14
|
+
*/
|
|
15
|
+
function cleanPath(file) {
|
|
16
|
+
return path.normalize(file).replace(SEPARATOR === '\\' ? /(?<=.)\\$/ : /(?<=.)\/$/, '');
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* filepath.ToSlash of Go
|
|
20
|
+
* @param file
|
|
21
|
+
*/
|
|
22
|
+
function toSlash(file) {
|
|
23
|
+
return SEPARATOR === '/' ? file : file.replace(/\\/g, '/');
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* filepath.FromSlash of Go
|
|
27
|
+
* @param file
|
|
28
|
+
*/
|
|
29
|
+
function fromSlash(file) {
|
|
30
|
+
return SEPARATOR === '/' ? file : file.replace(/\//g, SEPARATOR);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The rules of a .dockerignore file: the files of a build context they exclude
|
|
34
|
+
*/
|
|
35
|
+
export class DockerIgnore {
|
|
36
|
+
#rules = [];
|
|
37
|
+
#cache = new Map();
|
|
38
|
+
/**
|
|
39
|
+
* @param content the content of a .dockerignore file
|
|
40
|
+
* @param ignoreCase match the case-insensitively, as Docker does not (false by default)
|
|
41
|
+
*/
|
|
42
|
+
constructor(content = '', ignoreCase = false) {
|
|
43
|
+
this.ignoreCase = ignoreCase;
|
|
44
|
+
this.add(content);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Add the rules of a content
|
|
48
|
+
* @param content
|
|
49
|
+
*/
|
|
50
|
+
add(content) {
|
|
51
|
+
for (const line of content.split(/\r?\n/)) {
|
|
52
|
+
if (!line.trim() || line.startsWith('#'))
|
|
53
|
+
continue;
|
|
54
|
+
const rule = this.rule(line.trim());
|
|
55
|
+
if (rule)
|
|
56
|
+
this.#rules.push(rule);
|
|
57
|
+
}
|
|
58
|
+
this.#cache.clear();
|
|
59
|
+
return this;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* A rule of a line (moby/moby builder/dockerignore/dockerignore.go and pkg/fileutils/fileutils.go)
|
|
63
|
+
* @param line
|
|
64
|
+
*/
|
|
65
|
+
rule(line) {
|
|
66
|
+
let pattern = line;
|
|
67
|
+
let negative = false;
|
|
68
|
+
if (pattern.startsWith('!')) {
|
|
69
|
+
negative = true;
|
|
70
|
+
pattern = pattern.substring(1).trim();
|
|
71
|
+
}
|
|
72
|
+
if (pattern.length > 0) {
|
|
73
|
+
pattern = toSlash(cleanPath(pattern));
|
|
74
|
+
if (pattern.length > 1 && pattern.startsWith('/'))
|
|
75
|
+
pattern = pattern.slice(1);
|
|
76
|
+
}
|
|
77
|
+
if (negative)
|
|
78
|
+
pattern = `!${pattern}`;
|
|
79
|
+
pattern = pattern.trim();
|
|
80
|
+
if (!pattern)
|
|
81
|
+
return undefined;
|
|
82
|
+
pattern = cleanPath(pattern);
|
|
83
|
+
if (pattern.startsWith('!')) {
|
|
84
|
+
if (pattern.length === 1)
|
|
85
|
+
return undefined;
|
|
86
|
+
negative = true;
|
|
87
|
+
pattern = pattern.substring(1);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
negative = false;
|
|
91
|
+
}
|
|
92
|
+
return { pattern: pattern, directories: pattern.split(SEPARATOR), negative: negative };
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The regular expression of a rule (fileutils.go regexpMatch)
|
|
96
|
+
* @param rule
|
|
97
|
+
*/
|
|
98
|
+
expression(rule) {
|
|
99
|
+
if (rule.expression)
|
|
100
|
+
return rule.expression;
|
|
101
|
+
const separator = SEPARATOR === '\\' ? '\\\\' : SEPARATOR;
|
|
102
|
+
let source = '^';
|
|
103
|
+
const pattern = rule.pattern;
|
|
104
|
+
for (let index = 0; index < pattern.length; index++) {
|
|
105
|
+
const character = pattern[index];
|
|
106
|
+
if (character === '*') {
|
|
107
|
+
if (pattern[index + 1] === '*') {
|
|
108
|
+
index++;
|
|
109
|
+
//"**/" is "**"
|
|
110
|
+
if (pattern[index + 1] === SEPARATOR)
|
|
111
|
+
index++;
|
|
112
|
+
source += pattern[index + 1] === undefined ? '.*' : `(.*${separator})?`;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
source += `[^${separator}]*`;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
else if (character === '?') {
|
|
119
|
+
source += `[^${separator}]`;
|
|
120
|
+
}
|
|
121
|
+
else if (character === '.' || character === '$') {
|
|
122
|
+
source += `\\${character}`;
|
|
123
|
+
}
|
|
124
|
+
else if (character === '\\') {
|
|
125
|
+
if (SEPARATOR === '\\') {
|
|
126
|
+
source += separator;
|
|
127
|
+
}
|
|
128
|
+
else if (pattern[index + 1] !== undefined) {
|
|
129
|
+
source += `\\${pattern[++index]}`;
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
source += '\\';
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
source += character;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return rule.expression = new RegExp(`${source}$`, this.ignoreCase ? 'i' : '');
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Whether a file of the context is excluded by the rules (its path relative to the context, "/" separated)
|
|
143
|
+
* @param file
|
|
144
|
+
*/
|
|
145
|
+
ignores(file) {
|
|
146
|
+
if (!file)
|
|
147
|
+
return true;
|
|
148
|
+
let ignored = this.#cache.get(file);
|
|
149
|
+
if (ignored === undefined)
|
|
150
|
+
this.#cache.set(file, ignored = this.test(file));
|
|
151
|
+
return ignored;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Whether a file is excluded: the last rule matching it or one of its parent directories decides
|
|
155
|
+
* @param file
|
|
156
|
+
*/
|
|
157
|
+
test(file) {
|
|
158
|
+
const local = fromSlash(file);
|
|
159
|
+
const parent = cleanPath(path.dirname(local));
|
|
160
|
+
const parentDirectories = parent.split(SEPARATOR);
|
|
161
|
+
let matched = false;
|
|
162
|
+
for (const rule of this.#rules) {
|
|
163
|
+
let match = this.expression(rule).test(local);
|
|
164
|
+
if (!match && parent !== '.') {
|
|
165
|
+
if (rule.directories.includes('**')) {
|
|
166
|
+
for (let index = rule.directories.filter((directory) => directory !== '**').length; index <= parentDirectories.length; index++) {
|
|
167
|
+
match = match || this.expression(rule).test(parentDirectories.slice(0, index).join(SEPARATOR));
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
else if (rule.directories.length <= parentDirectories.length) {
|
|
171
|
+
match = this.expression(rule).test(parentDirectories.slice(0, rule.directories.length).join(SEPARATOR));
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (match)
|
|
175
|
+
matched = !rule.negative;
|
|
176
|
+
}
|
|
177
|
+
return matched;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { closeSync, constants, openSync } from 'node:fs';
|
|
3
|
+
import net from 'node:net';
|
|
4
|
+
/**
|
|
5
|
+
* The FIFOs of the standard streams of a process of containerd (the ones of its cio): created by mkfifo, the shim
|
|
6
|
+
* writing (or reading) them, read (or written) from the event loop
|
|
7
|
+
*/
|
|
8
|
+
export class ProcessFifo {
|
|
9
|
+
#keeper;
|
|
10
|
+
#socket;
|
|
11
|
+
constructor(path, direction) {
|
|
12
|
+
this.path = path;
|
|
13
|
+
this.direction = direction;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Whether the FIFOs can be created (mkfifo of the system: coreutils, busybox)
|
|
17
|
+
*/
|
|
18
|
+
static Supported() {
|
|
19
|
+
return spawnSync('mkfifo', ['--help'], { stdio: 'ignore' }).error === undefined;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Create a FIFO, kept open (read and write) for the shim to open its end without waiting
|
|
23
|
+
* @param path
|
|
24
|
+
* @param direction read: the shim writes it (stdout, stderr), write: the shim reads it (stdin)
|
|
25
|
+
*/
|
|
26
|
+
static Create(path, direction) {
|
|
27
|
+
const result = spawnSync('mkfifo', ['-m', '0600', path], { stdio: ['ignore', 'ignore', 'pipe'] });
|
|
28
|
+
if (result.error || result.status !== 0)
|
|
29
|
+
throw new Error(`The FIFO ${path} is not created: ${result.error?.message ?? result.stderr.toString().trim()}`);
|
|
30
|
+
const fifo = new ProcessFifo(path, direction);
|
|
31
|
+
fifo.#keeper = openSync(path, constants.O_RDWR | constants.O_NONBLOCK);
|
|
32
|
+
return fifo;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Its end opened, once the shim has opened its own one (after the creation of the process): the one kept closed,
|
|
36
|
+
* the end of the stream is the one of the shim
|
|
37
|
+
*/
|
|
38
|
+
open() {
|
|
39
|
+
if (this.#socket)
|
|
40
|
+
return this.#socket;
|
|
41
|
+
const flags = (this.direction === 'read' ? constants.O_RDONLY : constants.O_WRONLY) | constants.O_NONBLOCK;
|
|
42
|
+
this.#socket = new net.Socket({ fd: openSync(this.path, flags), readable: this.direction === 'read', writable: this.direction === 'write' });
|
|
43
|
+
this.releaseKeeper();
|
|
44
|
+
return this.#socket;
|
|
45
|
+
}
|
|
46
|
+
releaseKeeper() {
|
|
47
|
+
if (this.#keeper === undefined)
|
|
48
|
+
return;
|
|
49
|
+
closeSync(this.#keeper);
|
|
50
|
+
this.#keeper = undefined;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Close it
|
|
54
|
+
*/
|
|
55
|
+
close() {
|
|
56
|
+
this.releaseKeeper();
|
|
57
|
+
this.#socket?.destroy();
|
|
58
|
+
}
|
|
59
|
+
}
|