-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathloadImages.js
More file actions
85 lines (80 loc) · 2.11 KB
/
loadImages.js
File metadata and controls
85 lines (80 loc) · 2.11 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
const path = require("path");
const { exec } = require("child_process");
const fs = require("fs");
const yaml = require("js-yaml");
function loadImages({
yamlFile,
skipImage = "",
kindCluster = "kind",
cb = () => {}
} = {}) {
try {
const parallel = true;
const doc = yaml.safeLoad(fs.readFileSync(path.resolve(yamlFile), "utf8"));
const images = doc.images
.filter(a => a.name !== skipImage)
.map(a => `${a.name}:${a.newTag}`);
console.log(`⌛pulling images: ${images.join("\n")}`);
const pullCommand = images.map(a => `docker pull ${a}`).join(";");
const loadCommand = images
.map(a => `kind load docker-image --name=${kindCluster} ${a}`)
.join(parallel ? " & " : " && ")
.concat(parallel ? " & wait" : "");
exec(pullCommand, (error, stdout, stderr) => {
if (error) {
console.log(error);
throw error;
}
console.log("🎰 Images pull complete");
console.log("👷 loading images: ", loadCommand);
exec(loadCommand, err1 => {
if (err1) {
console.log(err1);
throw error;
}
console.log("🙋 Load complete");
cb();
});
});
} catch (e) {
console.log(e);
throw e;
}
}
module.exports = loadImages;
// module.exports = {
// name: "load",
// command: "load filename",
// description: "load images to kind cluster",
// options: {
// kind: {
// required: false,
// default: "kind",
// type: "string"
// }
// },
// callback: console.log
// };
// exports.handler = argv => {
// loadImages({ filePath: argv._[0], imageName: argv._[1] });
// };
// exports.options = {
// kind: {
// }
// }
// exports.options = y => {
// y.option("kind", {
// default: "kind"
// });
// y.option("skip", {
// default: ""
// });
// y.option("clusterName", {
// default: ""
// });
// return y;
// };
// exports.command =
// "loadToKind <filename> --kind=[clusterName] --skip=[skipImage]";
// exports.describe =
// "kustomization <filename> with image tags to load to kind cluster [cluster-name] and skipping image [imageName]";