@lakutata/docker 3.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +23 -0
- package/README.md +309 -0
- package/THIRD_PARTY_NOTICES.md +299 -0
- package/dist/cjs/client/BuildContext.d.ts +22 -0
- package/dist/cjs/client/BuildContext.js +76 -0
- package/dist/cjs/client/BuildKitProgress.d.ts +81 -0
- package/dist/cjs/client/BuildKitProgress.js +195 -0
- package/dist/cjs/client/DockerClient.d.ts +196 -0
- package/dist/cjs/client/DockerClient.js +312 -0
- package/dist/cjs/client/DockerConnection.d.ts +154 -0
- package/dist/cjs/client/DockerConnection.js +397 -0
- package/dist/cjs/client/DockerIgnore.d.ts +44 -0
- package/dist/cjs/client/DockerIgnore.js +186 -0
- package/dist/cjs/client/DockerRequestError.d.ts +17 -0
- package/dist/cjs/client/DockerRequestError.js +24 -0
- package/dist/cjs/client/DockerStreams.d.ts +35 -0
- package/dist/cjs/client/DockerStreams.js +117 -0
- package/dist/cjs/client/types/ContainerCreateResponse.d.ts +7 -0
- package/dist/cjs/client/types/ContainerCreateResponse.js +2 -0
- package/dist/cjs/client/types/ContainerStopQuery.d.ts +13 -0
- package/dist/cjs/client/types/ContainerStopQuery.js +2 -0
- package/dist/cjs/client/types/DeviceMapping.d.ts +8 -0
- package/dist/cjs/client/types/DeviceMapping.js +2 -0
- package/dist/cjs/client/types/IdResponse.d.ts +6 -0
- package/dist/cjs/client/types/IdResponse.js +2 -0
- package/dist/cjs/client/types/NetworkCreateResponse.d.ts +7 -0
- package/dist/cjs/client/types/NetworkCreateResponse.js +2 -0
- package/dist/cjs/client/types/PortBinding.d.ts +10 -0
- package/dist/cjs/client/types/PortBinding.js +2 -0
- package/dist/cjs/docker/ConnectionOptionsBuilder.d.ts +128 -0
- package/dist/cjs/docker/ConnectionOptionsBuilder.js +150 -0
- package/dist/cjs/docker/Docker.d.ts +301 -0
- package/dist/cjs/docker/Docker.js +703 -0
- package/dist/cjs/docker/exceptions/DockerConnectionException.d.ts +9 -0
- package/dist/cjs/docker/exceptions/DockerConnectionException.js +16 -0
- package/dist/cjs/docker/exceptions/DockerContainerNotFoundException.d.ts +9 -0
- package/dist/cjs/docker/exceptions/DockerContainerNotFoundException.js +16 -0
- package/dist/cjs/docker/exceptions/DockerImageBuildException.d.ts +9 -0
- package/dist/cjs/docker/exceptions/DockerImageBuildException.js +16 -0
- package/dist/cjs/docker/exceptions/DockerImageImportException.d.ts +9 -0
- package/dist/cjs/docker/exceptions/DockerImageImportException.js +16 -0
- package/dist/cjs/docker/exceptions/DockerImageNotFoundException.d.ts +10 -0
- package/dist/cjs/docker/exceptions/DockerImageNotFoundException.js +17 -0
- package/dist/cjs/docker/exceptions/DockerImagePullException.d.ts +9 -0
- package/dist/cjs/docker/exceptions/DockerImagePullException.js +16 -0
- package/dist/cjs/docker/exceptions/DockerImagePushException.d.ts +8 -0
- package/dist/cjs/docker/exceptions/DockerImagePushException.js +15 -0
- package/dist/cjs/docker/exceptions/DockerImageRepoTagNotFoundException.d.ts +8 -0
- package/dist/cjs/docker/exceptions/DockerImageRepoTagNotFoundException.js +15 -0
- package/dist/cjs/docker/exceptions/DockerNetworkNotFoundException.d.ts +9 -0
- package/dist/cjs/docker/exceptions/DockerNetworkNotFoundException.js +16 -0
- package/dist/cjs/docker/exceptions/DockerRequestException.d.ts +22 -0
- package/dist/cjs/docker/exceptions/DockerRequestException.js +24 -0
- package/dist/cjs/docker/interfaces/IDockerConnectionOptions.d.ts +75 -0
- package/dist/cjs/docker/interfaces/IDockerConnectionOptions.js +2 -0
- package/dist/cjs/docker/interfaces/IDockerHttpConnectionOptions.d.ts +16 -0
- package/dist/cjs/docker/interfaces/IDockerHttpConnectionOptions.js +2 -0
- package/dist/cjs/docker/interfaces/IDockerHttpsConnectionOptions.d.ts +16 -0
- package/dist/cjs/docker/interfaces/IDockerHttpsConnectionOptions.js +2 -0
- package/dist/cjs/docker/interfaces/IDockerKeyObject.d.ts +14 -0
- package/dist/cjs/docker/interfaces/IDockerKeyObject.js +2 -0
- package/dist/cjs/docker/interfaces/IDockerSSHConnectionOptions.d.ts +16 -0
- package/dist/cjs/docker/interfaces/IDockerSSHConnectionOptions.js +2 -0
- package/dist/cjs/docker/interfaces/IDockerSocketConnectionOptions.d.ts +7 -0
- package/dist/cjs/docker/interfaces/IDockerSocketConnectionOptions.js +2 -0
- package/dist/cjs/docker/lib/DockerContainer.d.ts +315 -0
- package/dist/cjs/docker/lib/DockerContainer.js +742 -0
- package/dist/cjs/docker/lib/DockerContainerTTY.d.ts +99 -0
- package/dist/cjs/docker/lib/DockerContainerTTY.js +157 -0
- package/dist/cjs/docker/lib/DockerImage.d.ts +153 -0
- package/dist/cjs/docker/lib/DockerImage.js +273 -0
- package/dist/cjs/docker/lib/EngineSettings.d.ts +41 -0
- package/dist/cjs/docker/lib/EngineSettings.js +86 -0
- package/dist/cjs/docker/lib/ParseBaseImages.d.ts +9 -0
- package/dist/cjs/docker/lib/ParseBaseImages.js +50 -0
- package/dist/cjs/docker/lib/ParseEnvToRecord.d.ts +14 -0
- package/dist/cjs/docker/lib/ParseEnvToRecord.js +25 -0
- package/dist/cjs/docker/lib/ParseRepositoryTag.d.ts +17 -0
- package/dist/cjs/docker/lib/ParseRepositoryTag.js +48 -0
- package/dist/cjs/docker/lib/RegistryAuth.d.ts +8 -0
- package/dist/cjs/docker/lib/RegistryAuth.js +15 -0
- package/dist/cjs/docker/options/DockerPruneOptions.d.ts +38 -0
- package/dist/cjs/docker/options/DockerPruneOptions.js +47 -0
- package/dist/cjs/docker/options/auth/DockerAuthOptions.d.ts +46 -0
- package/dist/cjs/docker/options/auth/DockerAuthOptions.js +59 -0
- package/dist/cjs/docker/options/container/ContainerCommitOptions.d.ts +28 -0
- package/dist/cjs/docker/options/container/ContainerCommitOptions.js +39 -0
- package/dist/cjs/docker/options/container/ContainerCreateTTYOptions.d.ts +32 -0
- package/dist/cjs/docker/options/container/ContainerCreateTTYOptions.js +43 -0
- package/dist/cjs/docker/options/container/ContainerExecOptions.d.ts +26 -0
- package/dist/cjs/docker/options/container/ContainerExecOptions.js +38 -0
- package/dist/cjs/docker/options/container/ContainerExportDirectoryOptions.d.ts +27 -0
- package/dist/cjs/docker/options/container/ContainerExportDirectoryOptions.js +39 -0
- package/dist/cjs/docker/options/container/ContainerKillOptions.d.ts +25 -0
- package/dist/cjs/docker/options/container/ContainerKillOptions.js +36 -0
- package/dist/cjs/docker/options/container/ContainerLogsOptions.d.ts +48 -0
- package/dist/cjs/docker/options/container/ContainerLogsOptions.js +56 -0
- package/dist/cjs/docker/options/container/ContainerRemoveOptions.d.ts +22 -0
- package/dist/cjs/docker/options/container/ContainerRemoveOptions.js +34 -0
- package/dist/cjs/docker/options/container/ContainerSettingOptions.d.ts +137 -0
- package/dist/cjs/docker/options/container/ContainerSettingOptions.js +136 -0
- package/dist/cjs/docker/options/container/ContainerStopOptions.d.ts +28 -0
- package/dist/cjs/docker/options/container/ContainerStopOptions.js +40 -0
- package/dist/cjs/docker/options/container/ContainerTTYConsoleSizeOptions.d.ts +26 -0
- package/dist/cjs/docker/options/container/ContainerTTYConsoleSizeOptions.js +40 -0
- package/dist/cjs/docker/options/image/ImageBuildOptions.d.ts +117 -0
- package/dist/cjs/docker/options/image/ImageBuildOptions.js +111 -0
- package/dist/cjs/docker/options/image/ImageExportOptions.d.ts +33 -0
- package/dist/cjs/docker/options/image/ImageExportOptions.js +44 -0
- package/dist/cjs/docker/options/image/ImageImportOptions.d.ts +28 -0
- package/dist/cjs/docker/options/image/ImageImportOptions.js +42 -0
- package/dist/cjs/docker/options/image/ImagePullOptions.d.ts +49 -0
- package/dist/cjs/docker/options/image/ImagePullOptions.js +63 -0
- package/dist/cjs/docker/options/image/ImagePushOptions.d.ts +41 -0
- package/dist/cjs/docker/options/image/ImagePushOptions.js +56 -0
- package/dist/cjs/docker/options/image/ImageRemoveOptions.d.ts +26 -0
- package/dist/cjs/docker/options/image/ImageRemoveOptions.js +38 -0
- package/dist/cjs/docker/options/image/ImageTagOptions.d.ts +25 -0
- package/dist/cjs/docker/options/image/ImageTagOptions.js +38 -0
- package/dist/cjs/docker/options/network/NetworkCreateOptions.d.ts +54 -0
- package/dist/cjs/docker/options/network/NetworkCreateOptions.js +63 -0
- package/dist/cjs/docker/types/ContainerBind.d.ts +19 -0
- package/dist/cjs/docker/types/ContainerBind.js +2 -0
- package/dist/cjs/docker/types/ContainerCapability.d.ts +286 -0
- package/dist/cjs/docker/types/ContainerCapability.js +290 -0
- package/dist/cjs/docker/types/ContainerConfig.d.ts +67 -0
- package/dist/cjs/docker/types/ContainerConfig.js +2 -0
- package/dist/cjs/docker/types/ContainerDevice.d.ts +19 -0
- package/dist/cjs/docker/types/ContainerDevice.js +2 -0
- package/dist/cjs/docker/types/ContainerExecResult.d.ts +20 -0
- package/dist/cjs/docker/types/ContainerExecResult.js +2 -0
- package/dist/cjs/docker/types/ContainerNetwork.d.ts +46 -0
- package/dist/cjs/docker/types/ContainerNetwork.js +2 -0
- package/dist/cjs/docker/types/ContainerPort.d.ts +25 -0
- package/dist/cjs/docker/types/ContainerPort.js +2 -0
- package/dist/cjs/docker/types/ContainerRestartPolicy.d.ts +11 -0
- package/dist/cjs/docker/types/ContainerRestartPolicy.js +2 -0
- package/dist/cjs/docker/types/ContainerState.d.ts +48 -0
- package/dist/cjs/docker/types/ContainerState.js +2 -0
- package/dist/cjs/docker/types/ContainerStats.d.ts +408 -0
- package/dist/cjs/docker/types/ContainerStats.js +2 -0
- package/dist/cjs/docker/types/DockerOutputCallback.d.ts +8 -0
- package/dist/cjs/docker/types/DockerOutputCallback.js +2 -0
- package/dist/cjs/docker/types/ImageConfig.d.ts +34 -0
- package/dist/cjs/docker/types/ImageConfig.js +2 -0
- package/dist/cjs/docker/types/ImageExposePort.d.ts +17 -0
- package/dist/cjs/docker/types/ImageExposePort.js +2 -0
- package/dist/cjs/docker/types/NetworkInfo.d.ts +59 -0
- package/dist/cjs/docker/types/NetworkInfo.js +2 -0
- package/dist/cjs/docker/types/RepositoryTag.d.ts +15 -0
- package/dist/cjs/docker/types/RepositoryTag.js +2 -0
- package/dist/cjs/exports/Docker.d.ts +73 -0
- package/dist/cjs/exports/Docker.js +92 -0
- package/dist/cjs/package.json +1 -0
- package/dist/esm/client/BuildContext.js +70 -0
- package/dist/esm/client/BuildKitProgress.js +190 -0
- package/dist/esm/client/DockerClient.js +307 -0
- package/dist/esm/client/DockerConnection.js +355 -0
- package/dist/esm/client/DockerIgnore.js +179 -0
- package/dist/esm/client/DockerRequestError.js +20 -0
- package/dist/esm/client/DockerStreams.js +111 -0
- package/dist/esm/client/types/ContainerCreateResponse.js +1 -0
- package/dist/esm/client/types/ContainerStopQuery.js +1 -0
- package/dist/esm/client/types/DeviceMapping.js +1 -0
- package/dist/esm/client/types/IdResponse.js +1 -0
- package/dist/esm/client/types/NetworkCreateResponse.js +1 -0
- package/dist/esm/client/types/PortBinding.js +1 -0
- package/dist/esm/docker/ConnectionOptionsBuilder.js +142 -0
- package/dist/esm/docker/Docker.js +697 -0
- package/dist/esm/docker/exceptions/DockerConnectionException.js +12 -0
- package/dist/esm/docker/exceptions/DockerContainerNotFoundException.js +12 -0
- package/dist/esm/docker/exceptions/DockerImageBuildException.js +12 -0
- package/dist/esm/docker/exceptions/DockerImageImportException.js +12 -0
- package/dist/esm/docker/exceptions/DockerImageNotFoundException.js +13 -0
- package/dist/esm/docker/exceptions/DockerImagePullException.js +12 -0
- package/dist/esm/docker/exceptions/DockerImagePushException.js +11 -0
- package/dist/esm/docker/exceptions/DockerImageRepoTagNotFoundException.js +11 -0
- package/dist/esm/docker/exceptions/DockerNetworkNotFoundException.js +12 -0
- package/dist/esm/docker/exceptions/DockerRequestException.js +20 -0
- package/dist/esm/docker/interfaces/IDockerConnectionOptions.js +1 -0
- package/dist/esm/docker/interfaces/IDockerHttpConnectionOptions.js +1 -0
- package/dist/esm/docker/interfaces/IDockerHttpsConnectionOptions.js +1 -0
- package/dist/esm/docker/interfaces/IDockerKeyObject.js +1 -0
- package/dist/esm/docker/interfaces/IDockerSSHConnectionOptions.js +1 -0
- package/dist/esm/docker/interfaces/IDockerSocketConnectionOptions.js +1 -0
- package/dist/esm/docker/lib/DockerContainer.js +739 -0
- package/dist/esm/docker/lib/DockerContainerTTY.js +154 -0
- package/dist/esm/docker/lib/DockerImage.js +270 -0
- package/dist/esm/docker/lib/EngineSettings.js +78 -0
- package/dist/esm/docker/lib/ParseBaseImages.js +47 -0
- package/dist/esm/docker/lib/ParseEnvToRecord.js +22 -0
- package/dist/esm/docker/lib/ParseRepositoryTag.js +45 -0
- package/dist/esm/docker/lib/RegistryAuth.js +12 -0
- package/dist/esm/docker/options/DockerPruneOptions.js +43 -0
- package/dist/esm/docker/options/auth/DockerAuthOptions.js +55 -0
- package/dist/esm/docker/options/container/ContainerCommitOptions.js +35 -0
- package/dist/esm/docker/options/container/ContainerCreateTTYOptions.js +39 -0
- package/dist/esm/docker/options/container/ContainerExecOptions.js +34 -0
- package/dist/esm/docker/options/container/ContainerExportDirectoryOptions.js +35 -0
- package/dist/esm/docker/options/container/ContainerKillOptions.js +32 -0
- package/dist/esm/docker/options/container/ContainerLogsOptions.js +52 -0
- package/dist/esm/docker/options/container/ContainerRemoveOptions.js +30 -0
- package/dist/esm/docker/options/container/ContainerSettingOptions.js +132 -0
- package/dist/esm/docker/options/container/ContainerStopOptions.js +36 -0
- package/dist/esm/docker/options/container/ContainerTTYConsoleSizeOptions.js +36 -0
- package/dist/esm/docker/options/image/ImageBuildOptions.js +107 -0
- package/dist/esm/docker/options/image/ImageExportOptions.js +40 -0
- package/dist/esm/docker/options/image/ImageImportOptions.js +38 -0
- package/dist/esm/docker/options/image/ImagePullOptions.js +59 -0
- package/dist/esm/docker/options/image/ImagePushOptions.js +52 -0
- package/dist/esm/docker/options/image/ImageRemoveOptions.js +34 -0
- package/dist/esm/docker/options/image/ImageTagOptions.js +34 -0
- package/dist/esm/docker/options/network/NetworkCreateOptions.js +59 -0
- package/dist/esm/docker/types/ContainerBind.js +1 -0
- package/dist/esm/docker/types/ContainerCapability.js +287 -0
- package/dist/esm/docker/types/ContainerConfig.js +1 -0
- package/dist/esm/docker/types/ContainerDevice.js +1 -0
- package/dist/esm/docker/types/ContainerExecResult.js +1 -0
- package/dist/esm/docker/types/ContainerNetwork.js +1 -0
- package/dist/esm/docker/types/ContainerPort.js +1 -0
- package/dist/esm/docker/types/ContainerRestartPolicy.js +1 -0
- package/dist/esm/docker/types/ContainerState.js +1 -0
- package/dist/esm/docker/types/ContainerStats.js +1 -0
- package/dist/esm/docker/types/DockerOutputCallback.js +1 -0
- package/dist/esm/docker/types/ImageConfig.js +1 -0
- package/dist/esm/docker/types/ImageExposePort.js +1 -0
- package/dist/esm/docker/types/NetworkInfo.js +1 -0
- package/dist/esm/docker/types/RepositoryTag.js +1 -0
- package/dist/esm/exports/Docker.js +73 -0
- package/dist/types/client/BuildContext.d.ts +22 -0
- package/dist/types/client/BuildKitProgress.d.ts +81 -0
- package/dist/types/client/DockerClient.d.ts +196 -0
- package/dist/types/client/DockerConnection.d.ts +154 -0
- package/dist/types/client/DockerIgnore.d.ts +44 -0
- package/dist/types/client/DockerRequestError.d.ts +17 -0
- package/dist/types/client/DockerStreams.d.ts +35 -0
- package/dist/types/client/types/ContainerCreateResponse.d.ts +7 -0
- package/dist/types/client/types/ContainerStopQuery.d.ts +13 -0
- package/dist/types/client/types/DeviceMapping.d.ts +8 -0
- package/dist/types/client/types/IdResponse.d.ts +6 -0
- package/dist/types/client/types/NetworkCreateResponse.d.ts +7 -0
- package/dist/types/client/types/PortBinding.d.ts +10 -0
- package/dist/types/docker/ConnectionOptionsBuilder.d.ts +128 -0
- package/dist/types/docker/Docker.d.ts +301 -0
- package/dist/types/docker/exceptions/DockerConnectionException.d.ts +9 -0
- package/dist/types/docker/exceptions/DockerContainerNotFoundException.d.ts +9 -0
- package/dist/types/docker/exceptions/DockerImageBuildException.d.ts +9 -0
- package/dist/types/docker/exceptions/DockerImageImportException.d.ts +9 -0
- package/dist/types/docker/exceptions/DockerImageNotFoundException.d.ts +10 -0
- package/dist/types/docker/exceptions/DockerImagePullException.d.ts +9 -0
- package/dist/types/docker/exceptions/DockerImagePushException.d.ts +8 -0
- package/dist/types/docker/exceptions/DockerImageRepoTagNotFoundException.d.ts +8 -0
- package/dist/types/docker/exceptions/DockerNetworkNotFoundException.d.ts +9 -0
- package/dist/types/docker/exceptions/DockerRequestException.d.ts +22 -0
- package/dist/types/docker/interfaces/IDockerConnectionOptions.d.ts +75 -0
- package/dist/types/docker/interfaces/IDockerHttpConnectionOptions.d.ts +16 -0
- package/dist/types/docker/interfaces/IDockerHttpsConnectionOptions.d.ts +16 -0
- package/dist/types/docker/interfaces/IDockerKeyObject.d.ts +14 -0
- package/dist/types/docker/interfaces/IDockerSSHConnectionOptions.d.ts +16 -0
- package/dist/types/docker/interfaces/IDockerSocketConnectionOptions.d.ts +7 -0
- package/dist/types/docker/lib/DockerContainer.d.ts +315 -0
- package/dist/types/docker/lib/DockerContainerTTY.d.ts +99 -0
- package/dist/types/docker/lib/DockerImage.d.ts +153 -0
- package/dist/types/docker/lib/EngineSettings.d.ts +41 -0
- package/dist/types/docker/lib/ParseBaseImages.d.ts +9 -0
- package/dist/types/docker/lib/ParseEnvToRecord.d.ts +14 -0
- package/dist/types/docker/lib/ParseRepositoryTag.d.ts +17 -0
- package/dist/types/docker/lib/RegistryAuth.d.ts +8 -0
- package/dist/types/docker/options/DockerPruneOptions.d.ts +38 -0
- package/dist/types/docker/options/auth/DockerAuthOptions.d.ts +46 -0
- package/dist/types/docker/options/container/ContainerCommitOptions.d.ts +28 -0
- package/dist/types/docker/options/container/ContainerCreateTTYOptions.d.ts +32 -0
- package/dist/types/docker/options/container/ContainerExecOptions.d.ts +26 -0
- package/dist/types/docker/options/container/ContainerExportDirectoryOptions.d.ts +27 -0
- package/dist/types/docker/options/container/ContainerKillOptions.d.ts +25 -0
- package/dist/types/docker/options/container/ContainerLogsOptions.d.ts +48 -0
- package/dist/types/docker/options/container/ContainerRemoveOptions.d.ts +22 -0
- package/dist/types/docker/options/container/ContainerSettingOptions.d.ts +137 -0
- package/dist/types/docker/options/container/ContainerStopOptions.d.ts +28 -0
- package/dist/types/docker/options/container/ContainerTTYConsoleSizeOptions.d.ts +26 -0
- package/dist/types/docker/options/image/ImageBuildOptions.d.ts +117 -0
- package/dist/types/docker/options/image/ImageExportOptions.d.ts +33 -0
- package/dist/types/docker/options/image/ImageImportOptions.d.ts +28 -0
- package/dist/types/docker/options/image/ImagePullOptions.d.ts +49 -0
- package/dist/types/docker/options/image/ImagePushOptions.d.ts +41 -0
- package/dist/types/docker/options/image/ImageRemoveOptions.d.ts +26 -0
- package/dist/types/docker/options/image/ImageTagOptions.d.ts +25 -0
- package/dist/types/docker/options/network/NetworkCreateOptions.d.ts +54 -0
- package/dist/types/docker/types/ContainerBind.d.ts +19 -0
- package/dist/types/docker/types/ContainerCapability.d.ts +286 -0
- package/dist/types/docker/types/ContainerConfig.d.ts +67 -0
- package/dist/types/docker/types/ContainerDevice.d.ts +19 -0
- package/dist/types/docker/types/ContainerExecResult.d.ts +20 -0
- package/dist/types/docker/types/ContainerNetwork.d.ts +46 -0
- package/dist/types/docker/types/ContainerPort.d.ts +25 -0
- package/dist/types/docker/types/ContainerRestartPolicy.d.ts +11 -0
- package/dist/types/docker/types/ContainerState.d.ts +48 -0
- package/dist/types/docker/types/ContainerStats.d.ts +408 -0
- package/dist/types/docker/types/DockerOutputCallback.d.ts +8 -0
- package/dist/types/docker/types/ImageConfig.d.ts +34 -0
- package/dist/types/docker/types/ImageExposePort.d.ts +17 -0
- package/dist/types/docker/types/NetworkInfo.d.ts +59 -0
- package/dist/types/docker/types/RepositoryTag.d.ts +15 -0
- package/dist/types/exports/Docker.d.ts +73 -0
- package/package.json +57 -0
|
@@ -0,0 +1,397 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.DockerConnection = exports.DOCKER_MIN_API_VERSION = exports.DOCKER_API_VERSION = void 0;
|
|
40
|
+
exports.compareAPIVersions = compareAPIVersions;
|
|
41
|
+
exports.defaultConnectionOptions = defaultConnectionOptions;
|
|
42
|
+
/*
|
|
43
|
+
* The connection to the Docker Engine API, rewritten from docker-modem (Copyright Pedro Dias, Apache License 2.0,
|
|
44
|
+
* see THIRD_PARTY_NOTICES.md), modified: the requests are promises, the API version is negotiated, and the requests
|
|
45
|
+
* streaming a body close their connection (see Request)
|
|
46
|
+
*/
|
|
47
|
+
const node_fs_1 = require("node:fs");
|
|
48
|
+
const node_http_1 = __importDefault(require("node:http"));
|
|
49
|
+
const node_https_1 = __importDefault(require("node:https"));
|
|
50
|
+
const node_os_1 = require("node:os");
|
|
51
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
52
|
+
const node_stream_1 = require("node:stream");
|
|
53
|
+
const DockerRequestError_js_1 = require("./DockerRequestError.js");
|
|
54
|
+
/**
|
|
55
|
+
* The newest API version this client is tested with (Docker 29.8): the one negotiated when the daemon supports it, so that
|
|
56
|
+
* a newer daemon answers as the tested one. An older daemon answers with its version: the fields a version does not have
|
|
57
|
+
* are missing or null
|
|
58
|
+
*/
|
|
59
|
+
exports.DOCKER_API_VERSION = '1.56';
|
|
60
|
+
/**
|
|
61
|
+
* The oldest API version this client works with
|
|
62
|
+
*/
|
|
63
|
+
exports.DOCKER_MIN_API_VERSION = '1.41';
|
|
64
|
+
/**
|
|
65
|
+
* Compare two API versions
|
|
66
|
+
* @param a
|
|
67
|
+
* @param b
|
|
68
|
+
*/
|
|
69
|
+
function compareAPIVersions(a, b) {
|
|
70
|
+
const [x, y] = [a, b].map((version) => version.replace(/^v/, '').split('.').map(Number));
|
|
71
|
+
return (x[0] - y[0]) || ((x[1] ?? 0) - (y[1] ?? 0));
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The certificates of a CA file, split (a file may have several)
|
|
75
|
+
* @param file
|
|
76
|
+
*/
|
|
77
|
+
function splitCA(file) {
|
|
78
|
+
return (0, node_fs_1.readFileSync)(file, 'utf8').split(/(?<=-----END CERTIFICATE-----)\s*/).map((certificate) => certificate.trim()).filter(Boolean);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The connection options given by the environment (DOCKER_HOST, DOCKER_TLS_VERIFY, DOCKER_CERT_PATH,
|
|
82
|
+
* DOCKER_CLIENT_TIMEOUT), else the socket of the platform: the named pipe on Windows, the socket of the user (Docker
|
|
83
|
+
* Desktop) or /var/run/docker.sock
|
|
84
|
+
*/
|
|
85
|
+
function defaultConnectionOptions() {
|
|
86
|
+
const dockerHost = process.env.DOCKER_HOST;
|
|
87
|
+
if (!dockerHost) {
|
|
88
|
+
if ((0, node_os_1.platform)() === 'win32')
|
|
89
|
+
return { socketPath: '//./pipe/docker_engine' };
|
|
90
|
+
const userSocket = node_path_1.default.join((0, node_os_1.homedir)(), '.docker', 'run', 'docker.sock');
|
|
91
|
+
return { socketPath: (0, node_fs_1.existsSync)(userSocket) ? userSocket : '/var/run/docker.sock' };
|
|
92
|
+
}
|
|
93
|
+
if (dockerHost.startsWith('unix://'))
|
|
94
|
+
return { socketPath: dockerHost.slice(7) || '/var/run/docker.sock' };
|
|
95
|
+
if (dockerHost.startsWith('npipe://'))
|
|
96
|
+
return { socketPath: dockerHost.slice(8) || '//./pipe/docker_engine' };
|
|
97
|
+
let url;
|
|
98
|
+
try {
|
|
99
|
+
url = new URL(dockerHost.includes('//') ? dockerHost : `tcp://${dockerHost}`);
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
throw new Error('DOCKER_HOST should be something like tcp://localhost:2375');
|
|
103
|
+
}
|
|
104
|
+
const options = { host: url.hostname, port: url.port };
|
|
105
|
+
if (url.protocol === 'ssh:') {
|
|
106
|
+
options.protocol = 'ssh';
|
|
107
|
+
options.username = url.username || undefined;
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
options.protocol = process.env.DOCKER_TLS_VERIFY === '1' || url.port === '2376' ? 'https' : 'http';
|
|
111
|
+
}
|
|
112
|
+
const certPath = process.env.DOCKER_CERT_PATH;
|
|
113
|
+
if (certPath) {
|
|
114
|
+
options.ca = splitCA(node_path_1.default.join(certPath, 'ca.pem'));
|
|
115
|
+
options.cert = (0, node_fs_1.readFileSync)(node_path_1.default.join(certPath, 'cert.pem'));
|
|
116
|
+
options.key = (0, node_fs_1.readFileSync)(node_path_1.default.join(certPath, 'key.pem'));
|
|
117
|
+
}
|
|
118
|
+
if (process.env.DOCKER_CLIENT_TIMEOUT)
|
|
119
|
+
options.timeout = Number.parseInt(process.env.DOCKER_CLIENT_TIMEOUT, 10);
|
|
120
|
+
return options;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* The query string of the parameters of a request
|
|
124
|
+
* @param query
|
|
125
|
+
*/
|
|
126
|
+
function queryString(query = {}) {
|
|
127
|
+
const parameters = new URLSearchParams();
|
|
128
|
+
for (const [key, value] of Object.entries(query)) {
|
|
129
|
+
if (value === undefined || value === null)
|
|
130
|
+
continue;
|
|
131
|
+
if (Array.isArray(value)) {
|
|
132
|
+
value.forEach((item) => parameters.append(key, String(item)));
|
|
133
|
+
}
|
|
134
|
+
else if (typeof value === 'object') {
|
|
135
|
+
parameters.append(key, JSON.stringify(value));
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
parameters.append(key, String(value));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
const text = parameters.toString();
|
|
142
|
+
return text ? `?${text}` : '';
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Whether a body is a stream
|
|
146
|
+
* @param body
|
|
147
|
+
*/
|
|
148
|
+
function isStream(body) {
|
|
149
|
+
return !!body && typeof body.pipe === 'function';
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* The connection to a Docker daemon
|
|
153
|
+
*/
|
|
154
|
+
class DockerConnection {
|
|
155
|
+
#options;
|
|
156
|
+
#protocol;
|
|
157
|
+
/**
|
|
158
|
+
* The agent of the requests: the connections are kept alive
|
|
159
|
+
*/
|
|
160
|
+
#agent;
|
|
161
|
+
/**
|
|
162
|
+
* The agent of the requests streaming their body: their connections are closed after them. Docker answers a build
|
|
163
|
+
* while it reads its context: on a kept alive connection, its HTTP server discards a part of the unread body when it
|
|
164
|
+
* answers, which corrupts the context ("unpigz: corrupted -- invalid deflate data")
|
|
165
|
+
*/
|
|
166
|
+
#closingAgent;
|
|
167
|
+
/**
|
|
168
|
+
* The negotiated API version
|
|
169
|
+
*/
|
|
170
|
+
#version;
|
|
171
|
+
#sshAgent;
|
|
172
|
+
constructor(options = {}) {
|
|
173
|
+
//The options given (a timeout, headers…) apply over the ones of the environment, the ones not given keep them
|
|
174
|
+
const given = Object.fromEntries(Object.entries(options).filter(([, value]) => value !== undefined));
|
|
175
|
+
this.#options = given.socketPath || given.host ? given : { ...defaultConnectionOptions(), ...given };
|
|
176
|
+
this.#protocol = this.#options.protocol ?? (this.#options.key && this.#options.cert && this.#options.ca ? 'https' : 'http');
|
|
177
|
+
if (this.#options.version)
|
|
178
|
+
this.#version = this.#options.version.replace(/^v/, '');
|
|
179
|
+
if (this.#protocol !== 'ssh') {
|
|
180
|
+
const module = this.#protocol === 'https' ? node_https_1.default : node_http_1.default;
|
|
181
|
+
this.#agent = new module.Agent({ keepAlive: true });
|
|
182
|
+
this.#closingAgent = new module.Agent({ keepAlive: false });
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* The API version of the requests, once negotiated
|
|
187
|
+
*/
|
|
188
|
+
get version() {
|
|
189
|
+
return this.#version;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Negotiate the API version with the daemon: the newest one both support
|
|
193
|
+
*/
|
|
194
|
+
async negotiate() {
|
|
195
|
+
if (this.#version)
|
|
196
|
+
return this.#version;
|
|
197
|
+
const version = await this.request({ method: 'GET', path: '/version', statusCodes: { 200: true, 500: 'server error' } });
|
|
198
|
+
const daemon = version.ApiVersion ?? exports.DOCKER_MIN_API_VERSION;
|
|
199
|
+
let negotiated = compareAPIVersions(daemon, exports.DOCKER_API_VERSION) < 0 ? daemon : exports.DOCKER_API_VERSION;
|
|
200
|
+
//The daemon no longer supports the version of the client
|
|
201
|
+
if (version.MinAPIVersion && compareAPIVersions(negotiated, version.MinAPIVersion) < 0)
|
|
202
|
+
negotiated = version.MinAPIVersion;
|
|
203
|
+
this.#version = negotiated;
|
|
204
|
+
return negotiated;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* The agent of an SSH connection: the requests are sent to "docker system dial-stdio" (ssh2, an optional dependency)
|
|
208
|
+
*/
|
|
209
|
+
sshAgent() {
|
|
210
|
+
return this.#sshAgent ??= (async () => {
|
|
211
|
+
let ssh2;
|
|
212
|
+
try {
|
|
213
|
+
//An optional dependency, loaded where it is installed
|
|
214
|
+
const ssh2Module = 'ssh2';
|
|
215
|
+
ssh2 = await Promise.resolve(`${ssh2Module}`).then(s => __importStar(require(s)));
|
|
216
|
+
}
|
|
217
|
+
catch {
|
|
218
|
+
throw new Error('The SSH connections to Docker need the package ssh2: npm install ssh2');
|
|
219
|
+
}
|
|
220
|
+
const Client = ssh2.Client ?? ssh2.default?.Client;
|
|
221
|
+
const agent = new node_http_1.default.Agent();
|
|
222
|
+
const options = this.#options;
|
|
223
|
+
agent.createConnection = ((_, callback) => {
|
|
224
|
+
const client = new Client();
|
|
225
|
+
const fail = (error) => {
|
|
226
|
+
client.end();
|
|
227
|
+
callback(error);
|
|
228
|
+
};
|
|
229
|
+
client.once('ready', () => {
|
|
230
|
+
client.exec('docker system dial-stdio', (error, stream) => {
|
|
231
|
+
if (error)
|
|
232
|
+
return fail(error);
|
|
233
|
+
callback(null, stream);
|
|
234
|
+
stream.once('close', () => client.end());
|
|
235
|
+
});
|
|
236
|
+
}).once('error', fail).connect({
|
|
237
|
+
host: options.host,
|
|
238
|
+
port: Number(options.port ?? 22),
|
|
239
|
+
username: options.username,
|
|
240
|
+
password: options.password,
|
|
241
|
+
agent: options.sshAuthAgent ?? process.env.SSH_AUTH_SOCK
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
return agent;
|
|
245
|
+
})();
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* The options of a request
|
|
249
|
+
* @param request
|
|
250
|
+
* @param streamingBody
|
|
251
|
+
*/
|
|
252
|
+
async requestOptions(request, streamingBody) {
|
|
253
|
+
const headers = { ...this.#options.headers, ...request.headers };
|
|
254
|
+
if (request.auth)
|
|
255
|
+
headers['X-Registry-Auth'] = Buffer.from(JSON.stringify(request.auth)).toString('base64url');
|
|
256
|
+
if (request.registryConfig)
|
|
257
|
+
headers['X-Registry-Config'] = Buffer.from(JSON.stringify(request.registryConfig)).toString('base64');
|
|
258
|
+
const versioned = this.#version ? `/v${this.#version}${request.path}` : request.path;
|
|
259
|
+
const options = {
|
|
260
|
+
method: request.method,
|
|
261
|
+
path: `${versioned}${queryString(request.query)}`,
|
|
262
|
+
headers: headers,
|
|
263
|
+
signal: request.signal,
|
|
264
|
+
timeout: this.#options.timeout
|
|
265
|
+
};
|
|
266
|
+
if (this.#protocol === 'ssh') {
|
|
267
|
+
options.agent = await this.sshAgent();
|
|
268
|
+
options.host = 'localhost';
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
options.agent = streamingBody ? this.#closingAgent : this.#agent;
|
|
272
|
+
if (this.#options.socketPath) {
|
|
273
|
+
options.socketPath = this.#options.socketPath;
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
options.host = this.#options.host;
|
|
277
|
+
options.port = this.#options.port;
|
|
278
|
+
}
|
|
279
|
+
if (this.#protocol === 'https')
|
|
280
|
+
Object.assign(options, { ca: this.#options.ca, cert: this.#options.cert, key: this.#options.key });
|
|
281
|
+
}
|
|
282
|
+
return options;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Send a request: the response, once its status is known
|
|
286
|
+
* @param request
|
|
287
|
+
* @param hijack upgrade the connection to a raw stream (the TTYs, the attached executions)
|
|
288
|
+
*/
|
|
289
|
+
async send(request, hijack = false) {
|
|
290
|
+
const streamingBody = isStream(request.body);
|
|
291
|
+
const options = await this.requestOptions(request, streamingBody);
|
|
292
|
+
const headers = options.headers;
|
|
293
|
+
let payload;
|
|
294
|
+
if (request.body !== undefined && !streamingBody) {
|
|
295
|
+
payload = JSON.stringify(request.body);
|
|
296
|
+
headers['Content-Type'] = 'application/json';
|
|
297
|
+
headers['Content-Length'] = String(Buffer.byteLength(payload));
|
|
298
|
+
}
|
|
299
|
+
else if (streamingBody) {
|
|
300
|
+
headers['Content-Type'] = 'application/x-tar';
|
|
301
|
+
}
|
|
302
|
+
if (hijack) {
|
|
303
|
+
headers.Connection = 'Upgrade';
|
|
304
|
+
headers.Upgrade = 'tcp';
|
|
305
|
+
}
|
|
306
|
+
const module = this.#protocol === 'https' ? node_https_1.default : node_http_1.default;
|
|
307
|
+
return new Promise((resolve, reject) => {
|
|
308
|
+
const req = module.request(options);
|
|
309
|
+
req.once('error', reject);
|
|
310
|
+
req.once('timeout', () => req.destroy(new Error(`Timeout of ${this.#options.timeout} ms exceeded`)));
|
|
311
|
+
if (hijack) {
|
|
312
|
+
req.once('upgrade', (response, socket, head) => {
|
|
313
|
+
if (head.length)
|
|
314
|
+
socket.unshift(head);
|
|
315
|
+
resolve({ response: response, socket: socket, request: req });
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
req.once('response', (response) => resolve({ response: response, request: req }));
|
|
319
|
+
if (streamingBody) {
|
|
320
|
+
const body = request.body;
|
|
321
|
+
//An error of the body (the packing of a build context) fails the request, instead of ending its stream
|
|
322
|
+
body.once('error', (error) => req.destroy(error));
|
|
323
|
+
body.pipe(req);
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
req.end(payload);
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* The error of a failed response
|
|
332
|
+
* @param request
|
|
333
|
+
* @param response
|
|
334
|
+
*/
|
|
335
|
+
async failure(request, response) {
|
|
336
|
+
const text = Buffer.concat(await response.toArray()).toString();
|
|
337
|
+
let json;
|
|
338
|
+
try {
|
|
339
|
+
json = JSON.parse(text);
|
|
340
|
+
}
|
|
341
|
+
catch {
|
|
342
|
+
json = undefined;
|
|
343
|
+
}
|
|
344
|
+
const reason = typeof request.statusCodes[response.statusCode] === 'string' ? request.statusCodes[response.statusCode] : 'unexpected';
|
|
345
|
+
return new DockerRequestError_js_1.DockerRequestError(response.statusCode, reason, json?.message ?? text.trim(), json);
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* A request whose response is JSON (or nothing)
|
|
349
|
+
* @param request
|
|
350
|
+
*/
|
|
351
|
+
async request(request) {
|
|
352
|
+
const { response } = await this.send(request);
|
|
353
|
+
if (request.statusCodes[response.statusCode] !== true)
|
|
354
|
+
throw await this.failure(request, response);
|
|
355
|
+
const text = Buffer.concat(await response.toArray()).toString();
|
|
356
|
+
if (!text)
|
|
357
|
+
return undefined;
|
|
358
|
+
try {
|
|
359
|
+
return JSON.parse(text);
|
|
360
|
+
}
|
|
361
|
+
catch {
|
|
362
|
+
return text;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* A request whose response is a stream (the progress of a pull, the logs, an archive)
|
|
367
|
+
* @param request
|
|
368
|
+
*/
|
|
369
|
+
async stream(request) {
|
|
370
|
+
const { response } = await this.send(request);
|
|
371
|
+
if (request.statusCodes[response.statusCode] !== true)
|
|
372
|
+
throw await this.failure(request, response);
|
|
373
|
+
return response;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* A request upgraded to a raw stream, read and written (the TTYs, the attached executions)
|
|
377
|
+
* @param request
|
|
378
|
+
*/
|
|
379
|
+
async hijack(request) {
|
|
380
|
+
const { response, socket } = await this.send(request, true);
|
|
381
|
+
if (socket)
|
|
382
|
+
return socket;
|
|
383
|
+
if (request.statusCodes[response.statusCode] !== true)
|
|
384
|
+
throw await this.failure(request, response);
|
|
385
|
+
//A daemon answering without upgrading: its response is the output, what is written is discarded
|
|
386
|
+
return node_stream_1.Duplex.from({ readable: response, writable: new node_stream_1.Writable({ write: (_chunk, _encoding, callback) => callback() }) });
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Close the kept alive connections
|
|
390
|
+
*/
|
|
391
|
+
close() {
|
|
392
|
+
this.#agent?.destroy();
|
|
393
|
+
this.#closingAgent?.destroy();
|
|
394
|
+
this.#sshAgent?.then((agent) => agent.destroy()).catch(() => undefined);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
exports.DockerConnection = DockerConnection;
|
|
@@ -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;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A request to the Docker Engine API which failed: its message is the one of docker-modem, "(HTTP code 404) no such
|
|
3
|
+
* container - No such container: x", the status and the body of the response are given
|
|
4
|
+
*/
|
|
5
|
+
export declare class DockerRequestError extends Error {
|
|
6
|
+
readonly statusCode: number;
|
|
7
|
+
readonly reason: string;
|
|
8
|
+
readonly detail: string;
|
|
9
|
+
readonly json?: unknown | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* @param statusCode the status of the response
|
|
12
|
+
* @param reason the meaning of the status for the request
|
|
13
|
+
* @param detail the message of the daemon
|
|
14
|
+
* @param json the body of the response
|
|
15
|
+
*/
|
|
16
|
+
constructor(statusCode: number, reason: string, detail: string, json?: unknown | undefined);
|
|
17
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DockerRequestError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* A request to the Docker Engine API which failed: its message is the one of docker-modem, "(HTTP code 404) no such
|
|
6
|
+
* container - No such container: x", the status and the body of the response are given
|
|
7
|
+
*/
|
|
8
|
+
class DockerRequestError extends Error {
|
|
9
|
+
/**
|
|
10
|
+
* @param statusCode the status of the response
|
|
11
|
+
* @param reason the meaning of the status for the request
|
|
12
|
+
* @param detail the message of the daemon
|
|
13
|
+
* @param json the body of the response
|
|
14
|
+
*/
|
|
15
|
+
constructor(statusCode, reason, detail, json) {
|
|
16
|
+
super(`(HTTP code ${statusCode}) ${reason} - ${detail} `);
|
|
17
|
+
this.statusCode = statusCode;
|
|
18
|
+
this.reason = reason;
|
|
19
|
+
this.detail = detail;
|
|
20
|
+
this.json = json;
|
|
21
|
+
this.name = 'DockerRequestError';
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.DockerRequestError = DockerRequestError;
|