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