-
Notifications
You must be signed in to change notification settings - Fork 309
Expand file tree
/
Copy pathdocker-util.js
More file actions
37 lines (33 loc) · 1.09 KB
/
docker-util.js
File metadata and controls
37 lines (33 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
exports.getVersions = function getVersions(local, version) {
return version.length > 0
? version
: [
!local && process.env.npm_package_version
? process.env.npm_package_version
: "latest"
];
};
exports.getName = function getName(name) {
if (name && typeof name === "string") {
return name;
}
return process.env.npm_package_config_docker_name
? process.env.npm_package_config_docker_name
: process.env.npm_package_name
? "data61/magda-" + process.env.npm_package_name.split("/")[1]
: "UnnamedImage";
};
exports.getTags = function getTags(tag, local, repository, version, name) {
if (tag === "auto") {
return exports.getVersions(local, version).map((version) => {
const tagPrefix = exports.getRepository(local, repository);
const imageName = exports.getName(name);
return tagPrefix + imageName + ":" + version;
});
} else {
return tag ? [tag] : [];
}
};
exports.getRepository = function getRepository(local, repository) {
return (repository && repository + "/") || (local ? "localhost:5000/" : "");
};