@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.
Files changed (301) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +409 -2
  3. package/THIRD_PARTY_NOTICES.md +310 -0
  4. package/dist/cjs/client/BuildKit.d.ts +176 -0
  5. package/dist/cjs/client/BuildKit.js +536 -0
  6. package/dist/cjs/client/BuildKitMessages.d.ts +35 -0
  7. package/dist/cjs/client/BuildKitMessages.js +123 -0
  8. package/dist/cjs/client/ContainerStore.d.ts +558 -0
  9. package/dist/cjs/client/ContainerStore.js +1384 -0
  10. package/dist/cjs/client/ContainerdClient.d.ts +244 -0
  11. package/dist/cjs/client/ContainerdClient.js +455 -0
  12. package/dist/cjs/client/DockerIgnore.d.ts +44 -0
  13. package/dist/cjs/client/DockerIgnore.js +186 -0
  14. package/dist/cjs/client/Fifo.d.ts +31 -0
  15. package/dist/cjs/client/Fifo.js +66 -0
  16. package/dist/cjs/client/ImageStore.d.ts +258 -0
  17. package/dist/cjs/client/ImageStore.js +636 -0
  18. package/dist/cjs/client/Messages.d.ts +103 -0
  19. package/dist/cjs/client/Messages.js +397 -0
  20. package/dist/cjs/client/Networks.d.ts +221 -0
  21. package/dist/cjs/client/Networks.js +630 -0
  22. package/dist/cjs/client/Platforms.d.ts +53 -0
  23. package/dist/cjs/client/Platforms.js +169 -0
  24. package/dist/cjs/client/Reference.d.ts +33 -0
  25. package/dist/cjs/client/Reference.js +70 -0
  26. package/dist/cjs/client/Registry.d.ts +145 -0
  27. package/dist/cjs/client/Registry.js +272 -0
  28. package/dist/cjs/client/Rootfs.d.ts +83 -0
  29. package/dist/cjs/client/Rootfs.js +245 -0
  30. package/dist/cjs/client/Seccomp.d.ts +36 -0
  31. package/dist/cjs/client/Seccomp.js +156 -0
  32. package/dist/cjs/client/Spec.d.ts +151 -0
  33. package/dist/cjs/client/Spec.js +227 -0
  34. package/dist/cjs/client/Volumes.d.ts +42 -0
  35. package/dist/cjs/client/Volumes.js +80 -0
  36. package/dist/cjs/containerd/Containerd.d.ts +442 -0
  37. package/dist/cjs/containerd/Containerd.js +929 -0
  38. package/dist/cjs/containerd/exceptions/ContainerdConnectionException.d.ts +9 -0
  39. package/dist/cjs/containerd/exceptions/ContainerdConnectionException.js +16 -0
  40. package/dist/cjs/containerd/exceptions/ContainerdContainerNameConflictException.d.ts +8 -0
  41. package/dist/cjs/containerd/exceptions/ContainerdContainerNameConflictException.js +15 -0
  42. package/dist/cjs/containerd/exceptions/ContainerdContainerNotFoundException.d.ts +9 -0
  43. package/dist/cjs/containerd/exceptions/ContainerdContainerNotFoundException.js +16 -0
  44. package/dist/cjs/containerd/exceptions/ContainerdContainerStateException.d.ts +10 -0
  45. package/dist/cjs/containerd/exceptions/ContainerdContainerStateException.js +17 -0
  46. package/dist/cjs/containerd/exceptions/ContainerdImageBuildException.d.ts +9 -0
  47. package/dist/cjs/containerd/exceptions/ContainerdImageBuildException.js +16 -0
  48. package/dist/cjs/containerd/exceptions/ContainerdImageExportException.d.ts +9 -0
  49. package/dist/cjs/containerd/exceptions/ContainerdImageExportException.js +16 -0
  50. package/dist/cjs/containerd/exceptions/ContainerdImageImportException.d.ts +9 -0
  51. package/dist/cjs/containerd/exceptions/ContainerdImageImportException.js +16 -0
  52. package/dist/cjs/containerd/exceptions/ContainerdImageNotFoundException.d.ts +9 -0
  53. package/dist/cjs/containerd/exceptions/ContainerdImageNotFoundException.js +16 -0
  54. package/dist/cjs/containerd/exceptions/ContainerdImagePullException.d.ts +9 -0
  55. package/dist/cjs/containerd/exceptions/ContainerdImagePullException.js +16 -0
  56. package/dist/cjs/containerd/exceptions/ContainerdImagePushException.d.ts +8 -0
  57. package/dist/cjs/containerd/exceptions/ContainerdImagePushException.js +15 -0
  58. package/dist/cjs/containerd/exceptions/ContainerdNetworkConflictException.d.ts +9 -0
  59. package/dist/cjs/containerd/exceptions/ContainerdNetworkConflictException.js +16 -0
  60. package/dist/cjs/containerd/exceptions/ContainerdNetworkNotFoundException.d.ts +9 -0
  61. package/dist/cjs/containerd/exceptions/ContainerdNetworkNotFoundException.js +16 -0
  62. package/dist/cjs/containerd/exceptions/ContainerdPathNotFoundException.d.ts +8 -0
  63. package/dist/cjs/containerd/exceptions/ContainerdPathNotFoundException.js +15 -0
  64. package/dist/cjs/containerd/exceptions/ContainerdPlatformException.d.ts +9 -0
  65. package/dist/cjs/containerd/exceptions/ContainerdPlatformException.js +16 -0
  66. package/dist/cjs/containerd/exceptions/ContainerdVolumeInUseException.d.ts +8 -0
  67. package/dist/cjs/containerd/exceptions/ContainerdVolumeInUseException.js +15 -0
  68. package/dist/cjs/containerd/exceptions/ContainerdVolumeNotFoundException.d.ts +8 -0
  69. package/dist/cjs/containerd/exceptions/ContainerdVolumeNotFoundException.js +15 -0
  70. package/dist/cjs/containerd/lib/ContainerdContainer.d.ts +292 -0
  71. package/dist/cjs/containerd/lib/ContainerdContainer.js +536 -0
  72. package/dist/cjs/containerd/lib/ContainerdContainerTTY.d.ts +116 -0
  73. package/dist/cjs/containerd/lib/ContainerdContainerTTY.js +178 -0
  74. package/dist/cjs/containerd/lib/ContainerdErrors.d.ts +6 -0
  75. package/dist/cjs/containerd/lib/ContainerdErrors.js +37 -0
  76. package/dist/cjs/containerd/lib/ContainerdImage.d.ts +149 -0
  77. package/dist/cjs/containerd/lib/ContainerdImage.js +222 -0
  78. package/dist/cjs/containerd/options/ContainerdPruneOptions.d.ts +44 -0
  79. package/dist/cjs/containerd/options/ContainerdPruneOptions.js +51 -0
  80. package/dist/cjs/containerd/options/ContainerdRegistryAuthOptions.d.ts +32 -0
  81. package/dist/cjs/containerd/options/ContainerdRegistryAuthOptions.js +45 -0
  82. package/dist/cjs/containerd/options/container/ContainerCommitOptions.d.ts +57 -0
  83. package/dist/cjs/containerd/options/container/ContainerCommitOptions.js +66 -0
  84. package/dist/cjs/containerd/options/container/ContainerCreateOptions.d.ts +273 -0
  85. package/dist/cjs/containerd/options/container/ContainerCreateOptions.js +239 -0
  86. package/dist/cjs/containerd/options/container/ContainerExecOptions.d.ts +53 -0
  87. package/dist/cjs/containerd/options/container/ContainerExecOptions.js +63 -0
  88. package/dist/cjs/containerd/options/container/ContainerExportDirectoryOptions.d.ts +32 -0
  89. package/dist/cjs/containerd/options/container/ContainerExportDirectoryOptions.js +45 -0
  90. package/dist/cjs/containerd/options/container/ContainerKillOptions.d.ts +30 -0
  91. package/dist/cjs/containerd/options/container/ContainerKillOptions.js +41 -0
  92. package/dist/cjs/containerd/options/container/ContainerLogsOptions.d.ts +34 -0
  93. package/dist/cjs/containerd/options/container/ContainerLogsOptions.js +44 -0
  94. package/dist/cjs/containerd/options/container/ContainerRemoveOptions.d.ts +22 -0
  95. package/dist/cjs/containerd/options/container/ContainerRemoveOptions.js +34 -0
  96. package/dist/cjs/containerd/options/container/ContainerResourceOptions.d.ts +63 -0
  97. package/dist/cjs/containerd/options/container/ContainerResourceOptions.js +67 -0
  98. package/dist/cjs/containerd/options/container/ContainerStopOptions.d.ts +30 -0
  99. package/dist/cjs/containerd/options/container/ContainerStopOptions.js +41 -0
  100. package/dist/cjs/containerd/options/container/ContainerTTYConsoleSizeOptions.d.ts +26 -0
  101. package/dist/cjs/containerd/options/container/ContainerTTYConsoleSizeOptions.js +40 -0
  102. package/dist/cjs/containerd/options/container/ContainerTTYOptions.d.ts +50 -0
  103. package/dist/cjs/containerd/options/container/ContainerTTYOptions.js +63 -0
  104. package/dist/cjs/containerd/options/image/ImageBuildOptions.d.ts +88 -0
  105. package/dist/cjs/containerd/options/image/ImageBuildOptions.js +95 -0
  106. package/dist/cjs/containerd/options/image/ImageExportOptions.d.ts +25 -0
  107. package/dist/cjs/containerd/options/image/ImageExportOptions.js +39 -0
  108. package/dist/cjs/containerd/options/image/ImageImportOptions.d.ts +38 -0
  109. package/dist/cjs/containerd/options/image/ImageImportOptions.js +47 -0
  110. package/dist/cjs/containerd/options/image/ImagePullOptions.d.ts +53 -0
  111. package/dist/cjs/containerd/options/image/ImagePullOptions.js +66 -0
  112. package/dist/cjs/containerd/options/image/ImagePushOptions.d.ts +44 -0
  113. package/dist/cjs/containerd/options/image/ImagePushOptions.js +58 -0
  114. package/dist/cjs/containerd/options/network/NetworkCreateOptions.d.ts +82 -0
  115. package/dist/cjs/containerd/options/network/NetworkCreateOptions.js +83 -0
  116. package/dist/cjs/containerd/options/volume/VolumeCreateOptions.d.ts +26 -0
  117. package/dist/cjs/containerd/options/volume/VolumeCreateOptions.js +40 -0
  118. package/dist/cjs/containerd/types/ContainerdBind.d.ts +28 -0
  119. package/dist/cjs/containerd/types/ContainerdBind.js +2 -0
  120. package/dist/cjs/containerd/types/ContainerdBuildOutputCallback.d.ts +6 -0
  121. package/dist/cjs/containerd/types/ContainerdBuildOutputCallback.js +2 -0
  122. package/dist/cjs/containerd/types/ContainerdContainerNetwork.d.ts +40 -0
  123. package/dist/cjs/containerd/types/ContainerdContainerNetwork.js +2 -0
  124. package/dist/cjs/containerd/types/ContainerdContainerPort.d.ts +22 -0
  125. package/dist/cjs/containerd/types/ContainerdContainerPort.js +2 -0
  126. package/dist/cjs/containerd/types/ContainerdContainerState.d.ts +42 -0
  127. package/dist/cjs/containerd/types/ContainerdContainerState.js +2 -0
  128. package/dist/cjs/containerd/types/ContainerdContainerStats.d.ts +107 -0
  129. package/dist/cjs/containerd/types/ContainerdContainerStats.js +2 -0
  130. package/dist/cjs/containerd/types/ContainerdDevice.d.ts +25 -0
  131. package/dist/cjs/containerd/types/ContainerdDevice.js +2 -0
  132. package/dist/cjs/containerd/types/ContainerdExecResult.d.ts +18 -0
  133. package/dist/cjs/containerd/types/ContainerdExecResult.js +2 -0
  134. package/dist/cjs/containerd/types/ContainerdImageConfig.d.ts +46 -0
  135. package/dist/cjs/containerd/types/ContainerdImageConfig.js +2 -0
  136. package/dist/cjs/containerd/types/ContainerdNetworkInfo.d.ts +49 -0
  137. package/dist/cjs/containerd/types/ContainerdNetworkInfo.js +2 -0
  138. package/dist/cjs/containerd/types/ContainerdProgressCallback.d.ts +29 -0
  139. package/dist/cjs/containerd/types/ContainerdProgressCallback.js +2 -0
  140. package/dist/cjs/containerd/types/ContainerdPruneResult.d.ts +21 -0
  141. package/dist/cjs/containerd/types/ContainerdPruneResult.js +2 -0
  142. package/dist/cjs/containerd/types/ContainerdRestartPolicy.d.ts +13 -0
  143. package/dist/cjs/containerd/types/ContainerdRestartPolicy.js +2 -0
  144. package/dist/cjs/containerd/types/ContainerdTmpfs.d.ts +20 -0
  145. package/dist/cjs/containerd/types/ContainerdTmpfs.js +2 -0
  146. package/dist/cjs/containerd/types/ContainerdVolume.d.ts +19 -0
  147. package/dist/cjs/containerd/types/ContainerdVolume.js +2 -0
  148. package/dist/cjs/containerd/types/ContainerdVolumeInfo.d.ts +26 -0
  149. package/dist/cjs/containerd/types/ContainerdVolumeInfo.js +2 -0
  150. package/dist/cjs/exports/Containerd.d.ts +69 -0
  151. package/dist/cjs/exports/Containerd.js +87 -0
  152. package/dist/cjs/package.json +1 -0
  153. package/dist/esm/client/BuildKit.js +488 -0
  154. package/dist/esm/client/BuildKitMessages.js +120 -0
  155. package/dist/esm/client/ContainerStore.js +1339 -0
  156. package/dist/esm/client/ContainerdClient.js +416 -0
  157. package/dist/esm/client/DockerIgnore.js +179 -0
  158. package/dist/esm/client/Fifo.js +59 -0
  159. package/dist/esm/client/ImageStore.js +628 -0
  160. package/dist/esm/client/Messages.js +393 -0
  161. package/dist/esm/client/Networks.js +621 -0
  162. package/dist/esm/client/Platforms.js +156 -0
  163. package/dist/esm/client/Reference.js +66 -0
  164. package/dist/esm/client/Registry.js +263 -0
  165. package/dist/esm/client/Rootfs.js +234 -0
  166. package/dist/esm/client/Seccomp.js +152 -0
  167. package/dist/esm/client/Spec.js +220 -0
  168. package/dist/esm/client/Volumes.js +73 -0
  169. package/dist/esm/containerd/Containerd.js +923 -0
  170. package/dist/esm/containerd/exceptions/ContainerdConnectionException.js +12 -0
  171. package/dist/esm/containerd/exceptions/ContainerdContainerNameConflictException.js +11 -0
  172. package/dist/esm/containerd/exceptions/ContainerdContainerNotFoundException.js +12 -0
  173. package/dist/esm/containerd/exceptions/ContainerdContainerStateException.js +13 -0
  174. package/dist/esm/containerd/exceptions/ContainerdImageBuildException.js +12 -0
  175. package/dist/esm/containerd/exceptions/ContainerdImageExportException.js +12 -0
  176. package/dist/esm/containerd/exceptions/ContainerdImageImportException.js +12 -0
  177. package/dist/esm/containerd/exceptions/ContainerdImageNotFoundException.js +12 -0
  178. package/dist/esm/containerd/exceptions/ContainerdImagePullException.js +12 -0
  179. package/dist/esm/containerd/exceptions/ContainerdImagePushException.js +11 -0
  180. package/dist/esm/containerd/exceptions/ContainerdNetworkConflictException.js +12 -0
  181. package/dist/esm/containerd/exceptions/ContainerdNetworkNotFoundException.js +12 -0
  182. package/dist/esm/containerd/exceptions/ContainerdPathNotFoundException.js +11 -0
  183. package/dist/esm/containerd/exceptions/ContainerdPlatformException.js +12 -0
  184. package/dist/esm/containerd/exceptions/ContainerdVolumeInUseException.js +11 -0
  185. package/dist/esm/containerd/exceptions/ContainerdVolumeNotFoundException.js +11 -0
  186. package/dist/esm/containerd/lib/ContainerdContainer.js +533 -0
  187. package/dist/esm/containerd/lib/ContainerdContainerTTY.js +175 -0
  188. package/dist/esm/containerd/lib/ContainerdErrors.js +34 -0
  189. package/dist/esm/containerd/lib/ContainerdImage.js +219 -0
  190. package/dist/esm/containerd/options/ContainerdPruneOptions.js +47 -0
  191. package/dist/esm/containerd/options/ContainerdRegistryAuthOptions.js +41 -0
  192. package/dist/esm/containerd/options/container/ContainerCommitOptions.js +62 -0
  193. package/dist/esm/containerd/options/container/ContainerCreateOptions.js +235 -0
  194. package/dist/esm/containerd/options/container/ContainerExecOptions.js +59 -0
  195. package/dist/esm/containerd/options/container/ContainerExportDirectoryOptions.js +41 -0
  196. package/dist/esm/containerd/options/container/ContainerKillOptions.js +37 -0
  197. package/dist/esm/containerd/options/container/ContainerLogsOptions.js +40 -0
  198. package/dist/esm/containerd/options/container/ContainerRemoveOptions.js +30 -0
  199. package/dist/esm/containerd/options/container/ContainerResourceOptions.js +63 -0
  200. package/dist/esm/containerd/options/container/ContainerStopOptions.js +37 -0
  201. package/dist/esm/containerd/options/container/ContainerTTYConsoleSizeOptions.js +36 -0
  202. package/dist/esm/containerd/options/container/ContainerTTYOptions.js +59 -0
  203. package/dist/esm/containerd/options/image/ImageBuildOptions.js +91 -0
  204. package/dist/esm/containerd/options/image/ImageExportOptions.js +35 -0
  205. package/dist/esm/containerd/options/image/ImageImportOptions.js +43 -0
  206. package/dist/esm/containerd/options/image/ImagePullOptions.js +62 -0
  207. package/dist/esm/containerd/options/image/ImagePushOptions.js +54 -0
  208. package/dist/esm/containerd/options/network/NetworkCreateOptions.js +79 -0
  209. package/dist/esm/containerd/options/volume/VolumeCreateOptions.js +36 -0
  210. package/dist/esm/containerd/types/ContainerdBind.js +1 -0
  211. package/dist/esm/containerd/types/ContainerdBuildOutputCallback.js +1 -0
  212. package/dist/esm/containerd/types/ContainerdContainerNetwork.js +1 -0
  213. package/dist/esm/containerd/types/ContainerdContainerPort.js +1 -0
  214. package/dist/esm/containerd/types/ContainerdContainerState.js +1 -0
  215. package/dist/esm/containerd/types/ContainerdContainerStats.js +1 -0
  216. package/dist/esm/containerd/types/ContainerdDevice.js +1 -0
  217. package/dist/esm/containerd/types/ContainerdExecResult.js +1 -0
  218. package/dist/esm/containerd/types/ContainerdImageConfig.js +1 -0
  219. package/dist/esm/containerd/types/ContainerdNetworkInfo.js +1 -0
  220. package/dist/esm/containerd/types/ContainerdProgressCallback.js +1 -0
  221. package/dist/esm/containerd/types/ContainerdPruneResult.js +1 -0
  222. package/dist/esm/containerd/types/ContainerdRestartPolicy.js +1 -0
  223. package/dist/esm/containerd/types/ContainerdTmpfs.js +1 -0
  224. package/dist/esm/containerd/types/ContainerdVolume.js +1 -0
  225. package/dist/esm/containerd/types/ContainerdVolumeInfo.js +1 -0
  226. package/dist/esm/exports/Containerd.js +68 -0
  227. package/dist/types/client/BuildKit.d.ts +176 -0
  228. package/dist/types/client/BuildKitMessages.d.ts +35 -0
  229. package/dist/types/client/ContainerStore.d.ts +558 -0
  230. package/dist/types/client/ContainerdClient.d.ts +244 -0
  231. package/dist/types/client/DockerIgnore.d.ts +44 -0
  232. package/dist/types/client/Fifo.d.ts +31 -0
  233. package/dist/types/client/ImageStore.d.ts +258 -0
  234. package/dist/types/client/Messages.d.ts +103 -0
  235. package/dist/types/client/Networks.d.ts +221 -0
  236. package/dist/types/client/Platforms.d.ts +53 -0
  237. package/dist/types/client/Reference.d.ts +33 -0
  238. package/dist/types/client/Registry.d.ts +145 -0
  239. package/dist/types/client/Rootfs.d.ts +83 -0
  240. package/dist/types/client/Seccomp.d.ts +36 -0
  241. package/dist/types/client/Spec.d.ts +151 -0
  242. package/dist/types/client/Volumes.d.ts +42 -0
  243. package/dist/types/containerd/Containerd.d.ts +442 -0
  244. package/dist/types/containerd/exceptions/ContainerdConnectionException.d.ts +9 -0
  245. package/dist/types/containerd/exceptions/ContainerdContainerNameConflictException.d.ts +8 -0
  246. package/dist/types/containerd/exceptions/ContainerdContainerNotFoundException.d.ts +9 -0
  247. package/dist/types/containerd/exceptions/ContainerdContainerStateException.d.ts +10 -0
  248. package/dist/types/containerd/exceptions/ContainerdImageBuildException.d.ts +9 -0
  249. package/dist/types/containerd/exceptions/ContainerdImageExportException.d.ts +9 -0
  250. package/dist/types/containerd/exceptions/ContainerdImageImportException.d.ts +9 -0
  251. package/dist/types/containerd/exceptions/ContainerdImageNotFoundException.d.ts +9 -0
  252. package/dist/types/containerd/exceptions/ContainerdImagePullException.d.ts +9 -0
  253. package/dist/types/containerd/exceptions/ContainerdImagePushException.d.ts +8 -0
  254. package/dist/types/containerd/exceptions/ContainerdNetworkConflictException.d.ts +9 -0
  255. package/dist/types/containerd/exceptions/ContainerdNetworkNotFoundException.d.ts +9 -0
  256. package/dist/types/containerd/exceptions/ContainerdPathNotFoundException.d.ts +8 -0
  257. package/dist/types/containerd/exceptions/ContainerdPlatformException.d.ts +9 -0
  258. package/dist/types/containerd/exceptions/ContainerdVolumeInUseException.d.ts +8 -0
  259. package/dist/types/containerd/exceptions/ContainerdVolumeNotFoundException.d.ts +8 -0
  260. package/dist/types/containerd/lib/ContainerdContainer.d.ts +292 -0
  261. package/dist/types/containerd/lib/ContainerdContainerTTY.d.ts +116 -0
  262. package/dist/types/containerd/lib/ContainerdErrors.d.ts +6 -0
  263. package/dist/types/containerd/lib/ContainerdImage.d.ts +149 -0
  264. package/dist/types/containerd/options/ContainerdPruneOptions.d.ts +44 -0
  265. package/dist/types/containerd/options/ContainerdRegistryAuthOptions.d.ts +32 -0
  266. package/dist/types/containerd/options/container/ContainerCommitOptions.d.ts +57 -0
  267. package/dist/types/containerd/options/container/ContainerCreateOptions.d.ts +273 -0
  268. package/dist/types/containerd/options/container/ContainerExecOptions.d.ts +53 -0
  269. package/dist/types/containerd/options/container/ContainerExportDirectoryOptions.d.ts +32 -0
  270. package/dist/types/containerd/options/container/ContainerKillOptions.d.ts +30 -0
  271. package/dist/types/containerd/options/container/ContainerLogsOptions.d.ts +34 -0
  272. package/dist/types/containerd/options/container/ContainerRemoveOptions.d.ts +22 -0
  273. package/dist/types/containerd/options/container/ContainerResourceOptions.d.ts +63 -0
  274. package/dist/types/containerd/options/container/ContainerStopOptions.d.ts +30 -0
  275. package/dist/types/containerd/options/container/ContainerTTYConsoleSizeOptions.d.ts +26 -0
  276. package/dist/types/containerd/options/container/ContainerTTYOptions.d.ts +50 -0
  277. package/dist/types/containerd/options/image/ImageBuildOptions.d.ts +88 -0
  278. package/dist/types/containerd/options/image/ImageExportOptions.d.ts +25 -0
  279. package/dist/types/containerd/options/image/ImageImportOptions.d.ts +38 -0
  280. package/dist/types/containerd/options/image/ImagePullOptions.d.ts +53 -0
  281. package/dist/types/containerd/options/image/ImagePushOptions.d.ts +44 -0
  282. package/dist/types/containerd/options/network/NetworkCreateOptions.d.ts +82 -0
  283. package/dist/types/containerd/options/volume/VolumeCreateOptions.d.ts +26 -0
  284. package/dist/types/containerd/types/ContainerdBind.d.ts +28 -0
  285. package/dist/types/containerd/types/ContainerdBuildOutputCallback.d.ts +6 -0
  286. package/dist/types/containerd/types/ContainerdContainerNetwork.d.ts +40 -0
  287. package/dist/types/containerd/types/ContainerdContainerPort.d.ts +22 -0
  288. package/dist/types/containerd/types/ContainerdContainerState.d.ts +42 -0
  289. package/dist/types/containerd/types/ContainerdContainerStats.d.ts +107 -0
  290. package/dist/types/containerd/types/ContainerdDevice.d.ts +25 -0
  291. package/dist/types/containerd/types/ContainerdExecResult.d.ts +18 -0
  292. package/dist/types/containerd/types/ContainerdImageConfig.d.ts +46 -0
  293. package/dist/types/containerd/types/ContainerdNetworkInfo.d.ts +49 -0
  294. package/dist/types/containerd/types/ContainerdProgressCallback.d.ts +29 -0
  295. package/dist/types/containerd/types/ContainerdPruneResult.d.ts +21 -0
  296. package/dist/types/containerd/types/ContainerdRestartPolicy.d.ts +13 -0
  297. package/dist/types/containerd/types/ContainerdTmpfs.d.ts +20 -0
  298. package/dist/types/containerd/types/ContainerdVolume.d.ts +19 -0
  299. package/dist/types/containerd/types/ContainerdVolumeInfo.d.ts +26 -0
  300. package/dist/types/exports/Containerd.d.ts +69 -0
  301. package/package.json +51 -4
@@ -0,0 +1,10 @@
1
+ import { Exception } from '@lakutata/core';
2
+ /**
3
+ * Thrown when a container is not in the state an operation needs: `exec()`, `createTTY()`, `stats()`, `kill()`,
4
+ * `pause()`, `unpause()` and `processes()` on a container that is not running, `start()` on a paused one, `remove()`
5
+ * on a running one without `force`, or an `update()` needing a recreation for a container the component did not
6
+ * create. Its `errno` is `E_CONTAINERD_CONTAINER_STATE`.
7
+ */
8
+ export declare class ContainerdContainerStateException extends Exception {
9
+ errno: string | number;
10
+ }
@@ -0,0 +1,9 @@
1
+ import { Exception } from '@lakutata/core';
2
+ /**
3
+ * Thrown by {@link Containerd.buildImage}, {@link Containerd.buildkitVersion} and
4
+ * {@link Containerd.buildkitPlatforms} when BuildKit cannot be reached at `buildkitAddress`, when the build fails (its
5
+ * message has the failing step), or when the image built cannot be imported. Its `errno` is `E_CONTAINERD_IMAGE_BUILD`.
6
+ */
7
+ export declare class ContainerdImageBuildException extends Exception {
8
+ errno: string | number;
9
+ }
@@ -0,0 +1,9 @@
1
+ import { Exception } from '@lakutata/core';
2
+ /**
3
+ * Thrown when images cannot be exported into an archive ({@link Containerd.exportImages},
4
+ * {@link ContainerdImage.export}): the destination cannot be written, or their content is incomplete. Its `errno` is
5
+ * `E_CONTAINERD_IMAGE_EXPORT`.
6
+ */
7
+ export declare class ContainerdImageExportException extends Exception {
8
+ errno: string | number;
9
+ }
@@ -0,0 +1,9 @@
1
+ import { Exception } from '@lakutata/core';
2
+ /**
3
+ * Thrown by {@link Containerd.importImage} when the archive cannot be read, is not an OCI image layout nor a
4
+ * `docker save` archive, has no image, or has several images and a `name` is given; or when its images fail to be
5
+ * unpacked. Its `errno` is `E_CONTAINERD_IMAGE_IMPORT`.
6
+ */
7
+ export declare class ContainerdImageImportException extends Exception {
8
+ errno: string | number;
9
+ }
@@ -0,0 +1,9 @@
1
+ import { Exception } from '@lakutata/core';
2
+ /**
3
+ * Thrown when no image of the namespace has the name asked: by {@link Containerd.getImage}, the creation of a
4
+ * container of an image not pulled (images are never pulled implicitly), and the operations on an image removed. Its
5
+ * `errno` is `E_CONTAINERD_IMAGE_NOT_FOUND`.
6
+ */
7
+ export declare class ContainerdImageNotFoundException extends Exception {
8
+ errno: string | number;
9
+ }
@@ -0,0 +1,9 @@
1
+ import { Exception } from '@lakutata/core';
2
+ /**
3
+ * Thrown by {@link Containerd.pullImage} when the registry cannot be reached, refuses the credentials, does not
4
+ * have the reference, the transfer fails or is aborted (the component destroyed), or the unpacking fails. Its `errno`
5
+ * is `E_CONTAINERD_IMAGE_PULL`.
6
+ */
7
+ export declare class ContainerdImagePullException extends Exception {
8
+ errno: string | number;
9
+ }
@@ -0,0 +1,8 @@
1
+ import { Exception } from '@lakutata/core';
2
+ /**
3
+ * Thrown by {@link ContainerdImage.push} (and {@link Containerd.buildImage} with `push`) when the registry cannot be
4
+ * reached or refuses the push (credentials, rights). Its `errno` is `E_CONTAINERD_IMAGE_PUSH`.
5
+ */
6
+ export declare class ContainerdImagePushException extends Exception {
7
+ errno: string | number;
8
+ }
@@ -0,0 +1,9 @@
1
+ import { Exception } from '@lakutata/core';
2
+ /**
3
+ * Thrown when a network cannot be created or removed: its name is taken (`host`, `none` and `bridge` included),
4
+ * its subnet overlaps another network's, a container uses it, it is the default `bridge`, or it was not created by
5
+ * nerdctl. Its `errno` is `E_CONTAINERD_NETWORK_CONFLICT`.
6
+ */
7
+ export declare class ContainerdNetworkConflictException extends Exception {
8
+ errno: string | number;
9
+ }
@@ -0,0 +1,9 @@
1
+ import { Exception } from '@lakutata/core';
2
+ /**
3
+ * Thrown when no network has the name, identifier or prefix asked ({@link Containerd.getNetwork},
4
+ * {@link Containerd.removeNetwork}), or when a container is created on a CNI network that does not exist. Its `errno` is
5
+ * `E_CONTAINERD_NETWORK_NOT_FOUND`.
6
+ */
7
+ export declare class ContainerdNetworkNotFoundException extends Exception {
8
+ errno: string | number;
9
+ }
@@ -0,0 +1,8 @@
1
+ import { Exception } from '@lakutata/core';
2
+ /**
3
+ * Thrown by {@link ContainerdContainer.exportDirectory} when the path does not exist in the container (its symbolic
4
+ * links resolved inside it). Its `errno` is `E_CONTAINERD_PATH_NOT_FOUND`.
5
+ */
6
+ export declare class ContainerdPathNotFoundException extends Exception {
7
+ errno: string | number;
8
+ }
@@ -0,0 +1,9 @@
1
+ import { Exception } from '@lakutata/core';
2
+ /**
3
+ * Thrown when an image has no manifest for the platform asked: a pull or a push of a platform the image does not
4
+ * have, a container created for a platform not pulled, or an image none of whose platforms' content is present. Its
5
+ * `errno` is `E_CONTAINERD_PLATFORM`.
6
+ */
7
+ export declare class ContainerdPlatformException extends Exception {
8
+ errno: string | number;
9
+ }
@@ -0,0 +1,8 @@
1
+ import { Exception } from '@lakutata/core';
2
+ /**
3
+ * Thrown by {@link Containerd.removeVolume} when a container of the namespace mounts the volume, even a stopped one.
4
+ * Its `errno` is `E_CONTAINERD_VOLUME_IN_USE`.
5
+ */
6
+ export declare class ContainerdVolumeInUseException extends Exception {
7
+ errno: string | number;
8
+ }
@@ -0,0 +1,8 @@
1
+ import { Exception } from '@lakutata/core';
2
+ /**
3
+ * Thrown by {@link Containerd.getVolume} and {@link Containerd.removeVolume} when the volume does not exist. Its
4
+ * `errno` is `E_CONTAINERD_VOLUME_NOT_FOUND`.
5
+ */
6
+ export declare class ContainerdVolumeNotFoundException extends Exception {
7
+ errno: string | number;
8
+ }
@@ -0,0 +1,292 @@
1
+ import { Provider } from '@lakutata/core';
2
+ import { Time } from '@lakutata/utils/Time';
3
+ import type { Readable } from 'node:stream';
4
+ import { type Message } from '@lakutata/grpc';
5
+ import { ContainerStore } from '../../client/ContainerStore.js';
6
+ import type { ContainerdClient } from '../../client/ContainerdClient.js';
7
+ import { type Containerd } from '../Containerd.js';
8
+ import { type ContainerdImage } from './ContainerdImage.js';
9
+ import type { ContainerdContainerState } from '../types/ContainerdContainerState.js';
10
+ import type { ContainerdRestartPolicy } from '../types/ContainerdRestartPolicy.js';
11
+ import type { ContainerdExecResult } from '../types/ContainerdExecResult.js';
12
+ import type { ContainerdContainerNetwork } from '../types/ContainerdContainerNetwork.js';
13
+ import type { ContainerdContainerPort } from '../types/ContainerdContainerPort.js';
14
+ import { ContainerStopOptions } from '../options/container/ContainerStopOptions.js';
15
+ import { ContainerKillOptions } from '../options/container/ContainerKillOptions.js';
16
+ import { ContainerRemoveOptions } from '../options/container/ContainerRemoveOptions.js';
17
+ import { ContainerExecOptions } from '../options/container/ContainerExecOptions.js';
18
+ import { ContainerLogsOptions } from '../options/container/ContainerLogsOptions.js';
19
+ import { ContainerdContainerTTY } from './ContainerdContainerTTY.js';
20
+ import { ContainerTTYOptions } from '../options/container/ContainerTTYOptions.js';
21
+ import { ContainerCommitOptions } from '../options/container/ContainerCommitOptions.js';
22
+ import { ContainerExportDirectoryOptions } from '../options/container/ContainerExportDirectoryOptions.js';
23
+ import type { ContainerCreateOptions } from '../options/container/ContainerCreateOptions.js';
24
+ import type { ContainerdContainerStats } from '../types/ContainerdContainerStats.js';
25
+ /**
26
+ * A container of the {@link Containerd} component's namespace, with the operations of a Docker container: start, stop,
27
+ * kill, pause, exec, terminals, logs, stats, live updates or updates by recreation, commit and file export. Get it from
28
+ * {@link Containerd.getContainer}, {@link Containerd.listContainers} or {@link Containerd.createContainer}; do not create
29
+ * it yourself. Each call returns a new object (transient).
30
+ *
31
+ * Its properties are a snapshot taken when it was obtained: the operations changing the container (`start()`, `stop()`,
32
+ * `kill()`, `pause()`, `wait()`, `update()`…) take a new one when they end, and {@link ContainerdContainer.syncContainerInfo}
33
+ * takes one on demand. The state the container is in decides what works: `exec()`, `createTTY()` and `stats()` need it
34
+ * running, and `remove()` refuses a running container unless forced.
35
+ * @example
36
+ * ```typescript
37
+ * import {Containerd, type ContainerdContainer, type ContainerdContainerStats} from 'lakutata/com/containerd'
38
+ *
39
+ * declare const containerd: Containerd
40
+ *
41
+ * const container: ContainerdContainer = await containerd.getContainer('worker')
42
+ * if (!container.state.running) await container.start()
43
+ * //The last 100 lines, without following the output
44
+ * for await (const chunk of await container.logs({tail: 100, follow: false})) process.stdout.write(chunk)
45
+ * const stats: ContainerdContainerStats = await container.stats()
46
+ * console.log(stats.cpu.percent, stats.memory.usage)
47
+ * //Live, without a restart
48
+ * await container.update({memoryLimit: 256 * 1024 * 1024})
49
+ * //Its stop signal, then SIGKILL after 5 seconds
50
+ * await container.stop({timeout: 5})
51
+ * await container.remove()
52
+ * ```
53
+ */
54
+ export declare class ContainerdContainer extends Provider {
55
+ #private;
56
+ /**
57
+ * Gives the component's container store; set by the component.
58
+ */
59
+ protected readonly getStore: () => ContainerStore;
60
+ /**
61
+ * Gives the component's containerd client; set by the component.
62
+ */
63
+ protected readonly getClient: () => ContainerdClient;
64
+ /**
65
+ * Gives the component that created the object.
66
+ */
67
+ protected readonly getContainerd: () => Containerd;
68
+ /**
69
+ * The container's identifier (64 hexadecimal characters). The name or identifier prefix the object was asked with is
70
+ * resolved to it; it changes when {@link ContainerdContainer.update} creates the container again.
71
+ */
72
+ id: string;
73
+ /**
74
+ * The container's name (nerdctl's `nerdctl/name` label); its identifier when it has none.
75
+ */
76
+ name: string;
77
+ /**
78
+ * The container's hostname; empty for the containers created without nerdctl's labels.
79
+ */
80
+ hostname: string;
81
+ /**
82
+ * The name of the container's image (`docker.io/library/alpine:3.20`).
83
+ */
84
+ imageName: string;
85
+ /**
86
+ * The platform of the image the container runs (`linux/arm64/v8`); empty when unknown.
87
+ */
88
+ platform: string;
89
+ /**
90
+ * The container's labels: the ones given at its creation, its image's, and nerdctl's (`nerdctl/*`).
91
+ */
92
+ labels: Record<string, string>;
93
+ /**
94
+ * The container's restart policy, applied by containerd's restart monitor; `'no'` when it has none.
95
+ */
96
+ restartPolicy: ContainerdRestartPolicy;
97
+ /**
98
+ * The container's state when the snapshot was taken: its status, its process identifier, its last exit code, and
99
+ * when it started and finished.
100
+ */
101
+ state: ContainerdContainerState;
102
+ /**
103
+ * The networks the container joins: `['host']`, `['none']`, or the names of its CNI networks.
104
+ */
105
+ networkNames: string[];
106
+ /**
107
+ * The container's interfaces on its CNI networks (`eth0`, `eth1`…), with their addresses while it runs.
108
+ */
109
+ networks: ContainerdContainerNetwork[];
110
+ /**
111
+ * The container's ports published on the host, through its first CNI network.
112
+ */
113
+ ports: ContainerdContainerPort[];
114
+ /**
115
+ * The names of the named volumes the container mounts.
116
+ */
117
+ volumes: string[];
118
+ /**
119
+ * When the container was created.
120
+ */
121
+ createdAt: Time;
122
+ /**
123
+ * The container's record in containerd, as last read.
124
+ * @protected
125
+ */
126
+ protected record: Message;
127
+ /**
128
+ * Read the container's information.
129
+ * @throws {ContainerdContainerNotFoundException} No container matches the identifier or name.
130
+ * @protected
131
+ */
132
+ protected init(): Promise<void>;
133
+ /**
134
+ * End the log streams followed and the waits of the object.
135
+ * @protected
136
+ */
137
+ protected destroy(): Promise<void>;
138
+ /**
139
+ * Read the container's information and state again from containerd into the object's properties.
140
+ * @throws {ContainerdContainerNotFoundException} The container no longer exists.
141
+ */
142
+ syncContainerInfo(): Promise<void>;
143
+ /**
144
+ * Run an operation on the container, then read its information again (also when the operation fails).
145
+ * @param operation The operation, given the container's record.
146
+ * @returns What the operation returns.
147
+ * @throws {ContainerdContainerStateException} The container is not in the state the operation needs.
148
+ * @protected
149
+ */
150
+ protected operate<T>(operation: (record: Message) => Promise<T>): Promise<T>;
151
+ /**
152
+ * Get the container's image.
153
+ * @returns The image.
154
+ * @throws {ContainerdImageNotFoundException} The image was removed since the container was created.
155
+ */
156
+ image(): Promise<ContainerdImage>;
157
+ /**
158
+ * Start the container: a new task of its root file system, its output appended to its log file (rotated first beyond
159
+ * the component's `logMaxSize`), its CNI networks set up. Its restart policy applies from now on. A running container
160
+ * is left as it is.
161
+ * @throws {ContainerdContainerStateException} The container is paused: unpause it.
162
+ * @throws {Error} The task cannot be created or started (the command is not found, seccomp refuses it…).
163
+ */
164
+ start(): Promise<void>;
165
+ /**
166
+ * Stop the container: send its stop signal (the one of `options`, else its `stopSignal`, else `SIGTERM`), wait for it
167
+ * to exit, then kill all its processes with `SIGKILL` when the timeout ends. Its exit code is kept, and the restart
168
+ * monitor no longer restarts it. A paused container is resumed first; a stopped one is left as it is.
169
+ * @param options The time to wait in seconds (10 by default) and the signal.
170
+ */
171
+ stop(options?: ContainerStopOptions): Promise<void>;
172
+ /**
173
+ * Restart the container: stop it as {@link ContainerdContainer.stop} does, then start it.
174
+ * @param options How it is stopped: the time to wait in seconds (10 by default) and the signal.
175
+ * @throws {Error} The task cannot be started again.
176
+ */
177
+ restart(options?: ContainerStopOptions): Promise<void>;
178
+ /**
179
+ * Send a signal to the container's main process, or to all its processes. `SIGKILL` also tells the restart monitor
180
+ * not to restart it; other signals do not.
181
+ * @param options The signal (`SIGKILL` by default; a name or a number) and `all`.
182
+ * @throws {ContainerdContainerStateException} The container is not running.
183
+ */
184
+ kill(options?: ContainerKillOptions): Promise<void>;
185
+ /**
186
+ * Pause all the processes of the running container (cgroup freezer).
187
+ * @throws {ContainerdContainerStateException} The container is not running.
188
+ */
189
+ pause(): Promise<void>;
190
+ /**
191
+ * Resume the processes of the paused container.
192
+ * @throws {ContainerdContainerStateException} The container is not running.
193
+ */
194
+ unpause(): Promise<void>;
195
+ /**
196
+ * Wait for the container's main process to exit, as `docker wait` does. A container that is not running resolves at
197
+ * once: with the exit code of its last run when it exited or was stopped by {@link ContainerdContainer.stop}, with
198
+ * `0` when it was never started (or when the component did not keep its exit code: a container created by nerdctl
199
+ * or by another `dataRoot`). The wait ends with an error when the object is destroyed.
200
+ * @returns The exit code.
201
+ * @throws {GRPCError} The wait was aborted (from `@lakutata/grpc`, its `code` is `CANCELLED`).
202
+ */
203
+ wait(): Promise<number>;
204
+ /**
205
+ * Remove the container: its task, its CNI network interfaces, its record, its snapshot and its state directory (its
206
+ * logs included). The named volumes it mounts are kept. With `force`, a running or paused container is killed first.
207
+ * @param options `force` (false by default).
208
+ * @throws {ContainerdContainerStateException} The container is running and `force` is not set.
209
+ */
210
+ remove(options?: ContainerRemoveOptions): Promise<void>;
211
+ /**
212
+ * Run a command in the running container and wait for it to exit, its outputs captured in memory. The process gets
213
+ * the container's environment (with `env` added), working directory and user unless given. Its standard output and
214
+ * error are kept apart through FIFOs (`mkfifo` of the host); without `mkfifo`, both are in `stdout`.
215
+ * @param options The command (a string is run by `/bin/sh -c`, an array as is), `env`, `workingDir`, `user` (`name`,
216
+ * `uid`, `name:group`), `stdin` (written then closed) and `timeout` (milliseconds, then the process is killed with
217
+ * `SIGKILL`).
218
+ * @returns The exit code and the outputs; a command killed by its timeout resolves with exit code `137`.
219
+ * @throws {ContainerdContainerStateException} The container is not running (stopped or paused).
220
+ * @throws {Error} `stdin` is given and the host has no `mkfifo`; the user is not found in the container.
221
+ */
222
+ exec(options: ContainerExecOptions): Promise<ContainerdExecResult>;
223
+ /**
224
+ * Read the container's logs: its standard output and error interleaved in one stream, without timestamps, from its
225
+ * log file (and the previous rotated file). By default the stream follows the new output while the container runs
226
+ * (or is being restarted by the restart monitor), and ends once it stopped or when the object is destroyed.
227
+ * @param options `tail`, the number of last lines to start with (all by default), and `follow` (true by default).
228
+ * @returns A readable stream of buffers.
229
+ */
230
+ logs(options?: ContainerLogsOptions): Promise<Readable>;
231
+ /**
232
+ * Read the resources the running or paused container uses: its cgroup counters and its network interface counters,
233
+ * sampled twice to compute its CPU use over the interval.
234
+ * @param interval The time between the two samples, in milliseconds; `0` takes one sample and reports a CPU use of
235
+ * 0. 1000 by default.
236
+ * @returns The counters of the last sample, with the CPU use over the interval.
237
+ * @throws {ContainerdContainerStateException} The container is not running.
238
+ */
239
+ stats(interval?: number): Promise<ContainerdContainerStats>;
240
+ /**
241
+ * Open an interactive terminal in the running container: a process with a pseudo terminal (`TERM=xterm`), its input
242
+ * and output through FIFOs (`mkfifo` of the host). Close it with {@link ContainerdContainerTTY.close} when done.
243
+ * @param options The command (a string is run by `/bin/sh -c` as {@link ContainerdContainer.exec} runs it, an array
244
+ * as is; `['/bin/sh']` by default, so the image needs a shell), the initial console size, `env`, `workingDir` and
245
+ * `user`.
246
+ * @returns The terminal, its process started.
247
+ * @throws {ContainerdContainerStateException} The container is not running.
248
+ * @throws {Error} The host has no `mkfifo`; the user is not found in the container.
249
+ */
250
+ createTTY(options?: ContainerTTYOptions): Promise<ContainerdContainerTTY>;
251
+ /**
252
+ * Update the container's settings. When only resources and the restart policy change (`memoryLimit`, `memorySwap`,
253
+ * `cpus`, `cpuShares`, `cpuSet`, `pidsLimit`, `OOMKillDisable`, `restartPolicy`), they are applied live, without a
254
+ * restart, as `docker update` does: `0` (`[]` for `cpuSet`) removes a limit, from the running container too, and from
255
+ * the settings it is created again with ({@link ContainerResourceOptions}). Any other setting creates the container
256
+ * again with its creation settings and the changes: a new container with the same name (and a new identifier, which
257
+ * this object follows), started when the old one was running; the old one is removed. The recreation only works for
258
+ * the containers created by the component, whose settings it kept.
259
+ * @param options The settings to change, as {@link Containerd.createContainer} takes them.
260
+ * @throws {InvalidValueException} A live update gives a `memorySwap` (positive) to a container without a memory
261
+ * limit, or leaves its `memorySwap` below its `memoryLimit` (from `@lakutata/core`).
262
+ * @throws {ContainerdContainerStateException} The container must be created again but was not created by the
263
+ * component (nerdctl's, or created by another `dataRoot`).
264
+ * @throws {ContainerdImageNotFoundException} From the recreation, as {@link Containerd.createContainer} throws.
265
+ */
266
+ update(options: Partial<ContainerCreateOptions>): Promise<void>;
267
+ /**
268
+ * Commit the container: save the changes of its root file system (not its mounts) as a new layer on its image,
269
+ * with configuration changes, as `docker commit` does. A running container is paused meanwhile by default.
270
+ * @param options The name of the new image (`<registry>/<repository>:commit-<milliseconds>` of the container's image
271
+ * by default), `pauseBeforeCommitting` (true by default), the configuration `changes`, `comment` and `author`.
272
+ * @returns The new image.
273
+ * @throws {ContainerdImageNotFoundException} The container's image was removed.
274
+ */
275
+ commit(options?: ContainerCommitOptions): Promise<ContainerdImage>;
276
+ /**
277
+ * Copy a file or directory of the container out as a tar archive, as `docker cp` does: from the running process's
278
+ * file system (its mounts included), or from its root file system when it is not running (without its mounts). The
279
+ * symbolic links of the path are resolved inside the container; the devices, sockets and pipes are not archived.
280
+ * @param options The absolute path in the container, and the destination (a file path, created or replaced, or a
281
+ * writable stream).
282
+ * @throws {ContainerdPathNotFoundException} The path does not exist in the container.
283
+ * @throws {Error} The archive cannot be written.
284
+ */
285
+ exportDirectory(options: ContainerExportDirectoryOptions): Promise<void>;
286
+ /**
287
+ * List the processes of the running container.
288
+ * @returns Their process identifiers on the host.
289
+ * @throws {ContainerdContainerStateException} The container is not running.
290
+ */
291
+ processes(): Promise<number[]>;
292
+ }
@@ -0,0 +1,116 @@
1
+ import { Provider } from '@lakutata/core';
2
+ import { Duplex, type Readable, type Writable } from 'node:stream';
3
+ import { type Message } from '@lakutata/grpc';
4
+ import type { ContainerStore } from '../../client/ContainerStore.js';
5
+ import { ContainerTTYConsoleSizeOptions } from '../options/container/ContainerTTYConsoleSizeOptions.js';
6
+ /**
7
+ * An interactive terminal in a running container: a process (a shell by default) run with a pseudo terminal, as
8
+ * `docker exec -it` does. Get it from {@link ContainerdContainer.createTTY}; do not create it yourself. Write its input
9
+ * with {@link ContainerdContainerTTY.write} (or {@link ContainerdContainerTTY.writable}), read its output with
10
+ * {@link ContainerdContainerTTY.onData} (or {@link ContainerdContainerTTY.readable}), or pipe a socket into
11
+ * {@link ContainerdContainerTTY.raw}. The terminal ends when its process exits or when it is closed; it is closed when
12
+ * the object is destroyed.
13
+ * @example
14
+ * ```typescript
15
+ * import {type Containerd, type ContainerdContainer, type ContainerdContainerTTY} from 'lakutata/com/containerd'
16
+ *
17
+ * declare const containerd: Containerd
18
+ *
19
+ * const container: ContainerdContainer = await containerd.getContainer('worker')
20
+ * const tty: ContainerdContainerTTY = await container.createTTY({cmd: ['/bin/sh', '-l'], consoleSize: {cols: 120, rows: 40}})
21
+ * tty.onData((chunk: Buffer): void => {
22
+ * process.stdout.write(chunk)
23
+ * })
24
+ * tty.write('ls -la\n')
25
+ * await tty.resize({cols: 100, rows: 30})
26
+ * tty.write('exit\n')
27
+ * //The exit code of the shell
28
+ * console.log(await tty.wait())
29
+ * ```
30
+ */
31
+ export declare class ContainerdContainerTTY extends Provider {
32
+ #private;
33
+ /**
34
+ * Gives the component's container store; set by the container.
35
+ */
36
+ protected readonly getStore: () => ContainerStore;
37
+ /**
38
+ * Gives the container's record in containerd; set by the container.
39
+ */
40
+ protected readonly getRecord: () => Message;
41
+ /**
42
+ * The command run in the terminal: a command line run by `/bin/sh -c`, or an executable and its arguments.
43
+ */
44
+ protected readonly cmd: string | string[];
45
+ /**
46
+ * The console size the terminal starts with, in columns and rows.
47
+ * @default the runtime's default size
48
+ */
49
+ protected readonly initialConsoleSize?: ContainerTTYConsoleSizeOptions;
50
+ /**
51
+ * The environment variables added to the container's (`TERM` is `xterm` unless given).
52
+ * @default none
53
+ */
54
+ protected readonly env?: Record<string, string>;
55
+ /**
56
+ * The working directory of the process.
57
+ * @default the container's working directory
58
+ */
59
+ protected readonly workingDir?: string;
60
+ /**
61
+ * The user running the process (`name`, `uid`, `name:group`), looked up in the container's `/etc/passwd`.
62
+ * @default the container's user
63
+ */
64
+ protected readonly user?: string;
65
+ /**
66
+ * Start the terminal's process in the container.
67
+ * @throws {ContainerdContainerStateException} The container is not running.
68
+ * @throws {Error} The host has no `mkfifo`; the user is not found in the container.
69
+ * @protected
70
+ */
71
+ protected init(): Promise<void>;
72
+ /**
73
+ * Close the terminal, as {@link ContainerdContainerTTY.close} does.
74
+ * @protected
75
+ */
76
+ protected destroy(): Promise<void>;
77
+ /**
78
+ * The terminal as one duplex stream: writing sends input to the process, reading gives its output (to pipe a
79
+ * WebSocket or a socket into it). It is created at the first access and consumes the output from then on.
80
+ */
81
+ get raw(): Duplex;
82
+ /**
83
+ * The terminal's input: what is written is sent to the process, as typed on a keyboard (`\x03` for Ctrl+C).
84
+ */
85
+ get writable(): Writable;
86
+ /**
87
+ * The terminal's output: what the process prints, its standard error included; it ends when the process exits.
88
+ */
89
+ get readable(): Readable;
90
+ /**
91
+ * Resize the terminal's console; the process receives `SIGWINCH`.
92
+ * @param options The new size, in columns and rows (positive integers).
93
+ * @throws {GRPCError} The process has exited (from `@lakutata/grpc`).
94
+ */
95
+ resize(options: ContainerTTYConsoleSizeOptions): Promise<void>;
96
+ /**
97
+ * Listen to the terminal's output. Each call adds a listener.
98
+ * @param handler Called with each chunk of output.
99
+ */
100
+ onData(handler: (chunk: Buffer) => void): void;
101
+ /**
102
+ * Send input to the terminal's process.
103
+ * @param data The input, as text or bytes (`'ls\n'`, a newline to submit a line).
104
+ */
105
+ write(data: string | Buffer): void;
106
+ /**
107
+ * Wait for the terminal's process to exit; the terminal is then closed.
108
+ * @returns Its exit code (`137` when it was closed by {@link ContainerdContainerTTY.close}).
109
+ */
110
+ wait(): Promise<number>;
111
+ /**
112
+ * Close the terminal: kill its process with `SIGKILL` and release its FIFOs. Nothing happens when it is already
113
+ * closed.
114
+ */
115
+ close(): Promise<void>;
116
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The exception of an error of the client (by its code), or the one given
3
+ * @param error
4
+ * @param fallback the exception of the operation
5
+ */
6
+ export declare function containerdError(error: unknown, fallback?: new (message: string) => Error): Error;