@magda/scripts 2.0.0-alpha.4 → 2.0.0-alpha.5
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/package.json +1 -1
- package/set-scss-vars.js +32 -9
package/package.json
CHANGED
package/set-scss-vars.js
CHANGED
|
@@ -48,9 +48,14 @@ async function run(programOptions) {
|
|
|
48
48
|
const env = getEnvByClusterType(programOptions.isMinikube === true);
|
|
49
49
|
checkIfKubectlValid(env);
|
|
50
50
|
checkNamespace(env, namespace);
|
|
51
|
-
const image = createConfigMap(
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
const [image, pullSecrets] = createConfigMap(
|
|
52
|
+
env,
|
|
53
|
+
namespace,
|
|
54
|
+
COMPILER_CONFIG_MAP_NAME,
|
|
55
|
+
{
|
|
56
|
+
[COMPILER_CONFIG_MAP_KEY]: JSON.stringify(vars)
|
|
57
|
+
}
|
|
58
|
+
);
|
|
54
59
|
console.log(
|
|
55
60
|
chalk.green(
|
|
56
61
|
`Successfully created config \`${COMPILER_CONFIG_MAP_NAME}\` in namespace \`${namespace}\`.`
|
|
@@ -59,7 +64,7 @@ async function run(programOptions) {
|
|
|
59
64
|
console.log(
|
|
60
65
|
chalk.yellow(`Creating updating job in namespace \`${namespace}\`...`)
|
|
61
66
|
);
|
|
62
|
-
const jobId = createJob(env, namespace, image);
|
|
67
|
+
const jobId = createJob(env, namespace, image, pullSecrets);
|
|
63
68
|
console.log(
|
|
64
69
|
chalk.green(
|
|
65
70
|
`Job \`${jobId}\` in namespace \`${namespace}\` has been created.`
|
|
@@ -192,11 +197,21 @@ function createConfigMap(env, namespace, configMapName, data) {
|
|
|
192
197
|
input: configContent,
|
|
193
198
|
env: env
|
|
194
199
|
});
|
|
195
|
-
|
|
200
|
+
|
|
201
|
+
let pullSecrets;
|
|
202
|
+
if (configObj.data.pullSecrets) {
|
|
203
|
+
try {
|
|
204
|
+
pullSecrets = JSON.parse(configObj.data.pullSecrets);
|
|
205
|
+
} catch (e) {
|
|
206
|
+
console.log("No valid pullSecrets info found from configMap.");
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return [configObj.data.image, pullSecrets];
|
|
196
211
|
}
|
|
197
212
|
|
|
198
|
-
function buildJobTemplateObject(namespace, jobId, image) {
|
|
199
|
-
|
|
213
|
+
function buildJobTemplateObject(namespace, jobId, image, pullSecrets) {
|
|
214
|
+
const manifest = {
|
|
200
215
|
kind: "Job",
|
|
201
216
|
apiVersion: "batch/v1",
|
|
202
217
|
metadata: {
|
|
@@ -257,11 +272,19 @@ function buildJobTemplateObject(namespace, jobId, image) {
|
|
|
257
272
|
}
|
|
258
273
|
}
|
|
259
274
|
};
|
|
275
|
+
if (pullSecrets && pullSecrets.length) {
|
|
276
|
+
manifest.spec.template.spec.imagePullSecrets = pullSecrets.map(
|
|
277
|
+
(item) => ({
|
|
278
|
+
name: item
|
|
279
|
+
})
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
return manifest;
|
|
260
283
|
}
|
|
261
284
|
|
|
262
|
-
function createJob(env, namespace, image) {
|
|
285
|
+
function createJob(env, namespace, image, pullSecrets) {
|
|
263
286
|
const jobId = uniqid("scss-compiler-");
|
|
264
|
-
const jobObj = buildJobTemplateObject(namespace, jobId, image);
|
|
287
|
+
const jobObj = buildJobTemplateObject(namespace, jobId, image, pullSecrets);
|
|
265
288
|
|
|
266
289
|
const configContent = JSON.stringify(jobObj);
|
|
267
290
|
|