@magda/scripts 2.0.0-alpha.4 → 2.0.0-alpha.7

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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/set-scss-vars.js +32 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magda/scripts",
3
- "version": "2.0.0-alpha.4",
3
+ "version": "2.0.0-alpha.7",
4
4
  "description": "Scripts for building, running, and deploying MAGDA",
5
5
  "license": "Apache-2.0",
6
6
  "bin": {
@@ -28,7 +28,7 @@
28
28
  "release": "npm publish || echo \"Skip releasing npm package @magda/scripts.\""
29
29
  },
30
30
  "devDependencies": {
31
- "@types/pg": "^7.4.14",
31
+ "@types/pg": "^8.6.5",
32
32
  "@types/request": "^2.48.1"
33
33
  },
34
34
  "magda": {
@@ -58,7 +58,7 @@
58
58
  "lodash": "^4.17.5",
59
59
  "moment": "^2.19.4",
60
60
  "nodemon": "^1.11.0",
61
- "pg": "^7.11.0",
61
+ "pg": "^8.7.3",
62
62
  "pkg": "^4.3.4",
63
63
  "pwgen": "0.1.6",
64
64
  "request": "^2.88.0",
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(env, namespace, COMPILER_CONFIG_MAP_NAME, {
52
- [COMPILER_CONFIG_MAP_KEY]: JSON.stringify(vars)
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
- return configObj.data.image;
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
- return {
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