hammerkit 1.9.1 → 1.9.2
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/dist/docker/pull.js
CHANGED
|
@@ -1,20 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pull = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
searchImageName += ':latest';
|
|
8
|
-
}
|
|
3
|
+
exports.splitImageName = exports.isImagePresent = exports.pull = void 0;
|
|
4
|
+
const registry_credentials_1 = require("../cache/backends/registry/registry-credentials");
|
|
5
|
+
const registry_reference_1 = require("../cache/backends/registry/registry-reference");
|
|
6
|
+
async function pull(status, docker, imageName, environment) {
|
|
9
7
|
const images = await docker.listImages({});
|
|
10
|
-
if (images
|
|
8
|
+
if (isImagePresent(images, imageName)) {
|
|
11
9
|
return;
|
|
12
10
|
}
|
|
13
11
|
status.write('debug', `pull image ${imageName}`);
|
|
14
|
-
const
|
|
12
|
+
const authconfig = await getPullAuth(imageName, environment);
|
|
13
|
+
const image = await docker.pull(imageName, authconfig ? { authconfig } : {});
|
|
15
14
|
await new Promise((resolve, reject) => {
|
|
16
15
|
docker.modem.followProgress(image, (err, res) => (err ? reject(err) : resolve(res)));
|
|
17
16
|
});
|
|
18
17
|
}
|
|
19
18
|
exports.pull = pull;
|
|
19
|
+
// A tag is present when an image carries it; an image pinned by digest
|
|
20
|
+
// (`repo:tag@sha256:…`) when an image was pulled with that digest, whatever
|
|
21
|
+
// tag it has now.
|
|
22
|
+
function isImagePresent(images, imageName) {
|
|
23
|
+
const { repository, tag, digest } = splitImageName(imageName);
|
|
24
|
+
if (digest) {
|
|
25
|
+
return images.some((i) => i.RepoDigests?.some((repoDigest) => repoDigest === `${repository}@${digest}`));
|
|
26
|
+
}
|
|
27
|
+
return images.some((i) => i.RepoTags?.some((repoTag) => repoTag === `${repository}:${tag ?? 'latest'}`));
|
|
28
|
+
}
|
|
29
|
+
exports.isImagePresent = isImagePresent;
|
|
30
|
+
function splitImageName(imageName) {
|
|
31
|
+
const [name, digest] = imageName.split('@');
|
|
32
|
+
const lastSlash = name.lastIndexOf('/');
|
|
33
|
+
const tagSeparator = name.indexOf(':', lastSlash + 1);
|
|
34
|
+
if (tagSeparator === -1) {
|
|
35
|
+
return { repository: name, tag: null, digest: digest ?? null };
|
|
36
|
+
}
|
|
37
|
+
return { repository: name.substring(0, tagSeparator), tag: name.substring(tagSeparator + 1), digest: digest ?? null };
|
|
38
|
+
}
|
|
39
|
+
exports.splitImageName = splitImageName;
|
|
40
|
+
// The credentials `docker login` stored for the image's registry, like the
|
|
41
|
+
// docker CLI uses them; dockerode sends none on its own, so a private image
|
|
42
|
+
// could only be used when it was already present.
|
|
43
|
+
async function getPullAuth(imageName, environment) {
|
|
44
|
+
const { repository } = splitImageName(imageName);
|
|
45
|
+
const { credentialHost } = (0, registry_reference_1.parseRegistryReference)(repository);
|
|
46
|
+
const credentials = await (0, registry_credentials_1.resolveRegistryCredentials)(credentialHost, environment);
|
|
47
|
+
if (!credentials) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
return { ...credentials, serveraddress: credentialHost };
|
|
51
|
+
}
|
|
20
52
|
//# sourceMappingURL=pull.js.map
|
|
@@ -23,7 +23,7 @@ async function dockerService(docker, item, options, environment) {
|
|
|
23
23
|
try {
|
|
24
24
|
await (0, execution_steps_1.prepareMounts)(item, environment);
|
|
25
25
|
(0, abort_1.checkForAbort)(options.abort);
|
|
26
|
-
await (0, execution_steps_1.pullImage)(item, docker);
|
|
26
|
+
await (0, execution_steps_1.pullImage)(item, docker, environment);
|
|
27
27
|
(0, abort_1.checkForAbort)(options.abort);
|
|
28
28
|
await (0, execution_steps_1.prepareVolume)(item, docker);
|
|
29
29
|
(0, abort_1.checkForAbort)(options.abort);
|
|
@@ -79,7 +79,7 @@ async function dockerTask(docker, item, environment, options) {
|
|
|
79
79
|
}
|
|
80
80
|
await (0, execution_steps_1.prepareMounts)(item, environment);
|
|
81
81
|
(0, abort_1.checkForAbort)(options.abort);
|
|
82
|
-
await (0, execution_steps_1.pullImage)(item, docker);
|
|
82
|
+
await (0, execution_steps_1.pullImage)(item, docker, environment);
|
|
83
83
|
(0, abort_1.checkForAbort)(options.abort);
|
|
84
84
|
await (0, execution_steps_1.prepareVolume)(item, docker);
|
|
85
85
|
(0, abort_1.checkForAbort)(options.abort);
|
|
@@ -8,8 +8,8 @@ const set_user_permission_1 = require("./set-user-permission");
|
|
|
8
8
|
const work_task_1 = require("../planner/work-task");
|
|
9
9
|
const work_service_1 = require("../planner/work-service");
|
|
10
10
|
const get_container_binds_1 = require("./get-container-binds");
|
|
11
|
-
async function pullImage(item, docker) {
|
|
12
|
-
await (0, pull_1.pull)(item.status, docker, item.data.image);
|
|
11
|
+
async function pullImage(item, docker, environment) {
|
|
12
|
+
await (0, pull_1.pull)(item.status, docker, item.data.image, environment);
|
|
13
13
|
}
|
|
14
14
|
exports.pullImage = pullImage;
|
|
15
15
|
async function prepareVolume(item, docker) {
|
package/package.json
CHANGED