@leverege/build-tools 2.1.8 → 2.2.0

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.
@@ -6,8 +6,12 @@ require("core-js/modules/es.symbol.description");
6
6
 
7
7
  require("core-js/modules/es.symbol.iterator");
8
8
 
9
+ require("core-js/modules/es.array.from");
10
+
9
11
  require("core-js/modules/es.array.iterator");
10
12
 
13
+ require("core-js/modules/es.array.slice");
14
+
11
15
  require("core-js/modules/es.object.to-string");
12
16
 
13
17
  require("core-js/modules/es.promise");
@@ -20,11 +24,15 @@ require("core-js/modules/web.dom-collections.iterator");
20
24
 
21
25
  require("regenerator-runtime/runtime");
22
26
 
23
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
27
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
28
+
29
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
30
+
31
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
24
32
 
25
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
33
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
26
34
 
27
- function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
35
+ function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
28
36
 
29
37
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
30
38
 
@@ -82,8 +90,8 @@ var CloudflareAPI = /*#__PURE__*/function () {
82
90
  contentsBuffer,
83
91
  name,
84
92
  ciphertext,
85
- _ref,
86
- _ref2,
93
+ _yield$client$decrypt,
94
+ _yield$client$decrypt2,
87
95
  result,
88
96
  writeFile,
89
97
  _args = arguments;
@@ -119,9 +127,9 @@ var CloudflareAPI = /*#__PURE__*/function () {
119
127
  });
120
128
 
121
129
  case 16:
122
- _ref = _context.sent;
123
- _ref2 = _slicedToArray(_ref, 1);
124
- result = _ref2[0];
130
+ _yield$client$decrypt = _context.sent;
131
+ _yield$client$decrypt2 = _slicedToArray(_yield$client$decrypt, 1);
132
+ result = _yield$client$decrypt2[0];
125
133
  // Writes the decrypted file to disk
126
134
  writeFile = promisify(fs.writeFile);
127
135
  _context.next = 22;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leverege/build-tools",
3
- "version": "2.1.8",
3
+ "version": "2.2.0",
4
4
  "description": "A collection of build / support tools for Leverege developers",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -52,17 +52,17 @@
52
52
  "parse-gitignore": "^1.0.1",
53
53
  "readline-sync": "^1.4.10",
54
54
  "recursive-copy": "^2.0.10",
55
- "regenerator-runtime": "^0.13.3",
55
+ "regenerator-runtime": "^0.13.5",
56
56
  "semver": "^6.3.0",
57
57
  "tar": "^5.0.5"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@babel/cli": "^7.8.4",
61
- "@babel/core": "^7.8.7",
61
+ "@babel/core": "^7.9.0",
62
62
  "@babel/plugin-proposal-class-properties": "^7.8.3",
63
- "@babel/plugin-proposal-optional-chaining": "^7.8.3",
64
- "@babel/preset-env": "^7.8.7",
65
- "@babel/register": "^7.8.6",
63
+ "@babel/plugin-proposal-optional-chaining": "^7.9.0",
64
+ "@babel/preset-env": "^7.9.0",
65
+ "@babel/register": "^7.9.0",
66
66
  "@leverege/eslint-config-leverege": "^2.0.10",
67
67
  "core-js": "^3.6.4"
68
68
  }
package/src/helmup CHANGED
@@ -3,7 +3,7 @@
3
3
  # This script is used to ease the pain of transition testing to chart museum
4
4
  # for adding / updating deployments on a fluster.
5
5
  #
6
- # printf "\nRUNNING LOCALLY\n" && sleep 2
6
+ # printf "\n***** RUNNING LOCALLY *****\n" && sleep 2
7
7
  PLATFORM=(
8
8
  api-server
9
9
  db-curator
@@ -16,7 +16,6 @@ PLATFORM=(
16
16
  transponder-bq
17
17
  transponder-fb
18
18
  transponder-postgres
19
- # transponder-sql
20
19
  )
21
20
 
22
21
  SYSTEM=(
@@ -25,6 +24,8 @@ SYSTEM=(
25
24
  polaris
26
25
  redis
27
26
  velero
27
+ reloader
28
+ tiller
28
29
  # monitoring
29
30
  # custom-metrics
30
31
  )
@@ -359,7 +360,21 @@ function doInstall() {
359
360
 
360
361
  for PARAM in "$@";
361
362
  do
363
+ # Allows chart version from command line via <deployment>/<x.y.z>
362
364
  IFS="/" read SERVICE CHARTVER <<< "$PARAM"
365
+
366
+ # Allows chart version as <deployment>/.chart-x.y.z>
367
+ if [ -z "$CHARTVER" ];
368
+ then
369
+ for PARAM in $SERVICE/.chart-?.?.?; do
370
+ IFS="-" read JUNK VERSION <<< "$PARAM"
371
+ [ $VERSION != "?.?.?" ] && CHARTVER=$VERSION
372
+ printf "PARAM=[$PARAM] SVC=[$SERVICE] CHT=[$CHARTVER]\n"
373
+ break
374
+ done
375
+ fi
376
+
377
+ # slap additional helm syntax in there if the version is set
363
378
  [ ! -z "$CHARTVER" ] && CHARTVER="--version $CHARTVER"
364
379
 
365
380
  # If we're referencing a plugin the execute it and continue
@@ -379,11 +394,6 @@ function doInstall() {
379
394
  printf "\nGithub repo is here => https://github.com/helm/charts/tree/master/stable/coredns\n\n"
380
395
  ;;
381
396
 
382
- # "disks") DEPRECATED
383
- # checkSSDStorageClass
384
- # helm upgrade --install disks ./disks
385
- # ;;
386
-
387
397
  "elastic"|"elasticsearch")
388
398
  checkSSDStorageClass
389
399
  helm repo add elastic https://helm.elastic.co
@@ -423,6 +433,12 @@ function doInstall() {
423
433
  printf "To start a specific version => `color c 'REDIS_HELM_CHART="v9.1.5" helmup redis'`\n\n"
424
434
  ;;
425
435
 
436
+ "tiller")
437
+ kubectl create -f $GITTOP/k8s-utils/tiller.yaml &> /dev/null
438
+ helm init --service-account tiller --upgrade --history-max 5
439
+ sleep 3
440
+ ;;
441
+
426
442
  "timescale-db")
427
443
  checkTimescalePassword
428
444
  helm upgrade --install timescale-db leverege/timescale-db
@@ -440,6 +456,10 @@ function doInstall() {
440
456
  installVelero # because it's a little more involved
441
457
  ;;
442
458
 
459
+ "reloader")
460
+ helm upgrade --install reloader stable/reloader
461
+ ;;
462
+
443
463
  *)
444
464
  if [ ! -d $SERVICE ] || [ ! -f $SERVICE/values-local.yaml ];
445
465
  then
package/src/overwhelm CHANGED
@@ -17,6 +17,7 @@ const optionsDefinitions = [
17
17
  { name : 'export', alias : 'e', type : Boolean, default : false },
18
18
  { name : 'continue', alias : 'c', type : Boolean, default : false },
19
19
  { name : 'checkctx', alias : 't', type : Boolean, default : false },
20
+ { name : 'fetchctx', alias : 'f', type : Boolean, default : false },
20
21
  { name : 'verbose', alias : 'v', type : Boolean, default : false },
21
22
  ]
22
23
  const args = cliArgs( optionsDefinitions )
@@ -200,10 +201,14 @@ const opt = {
200
201
 
201
202
  const ahoy = glob.sync( '*/', opt )
202
203
 
203
- // Generate the values.yaml files in directories not marked with .nohelm.
204
+ // .noahoy = skips generation of values.yaml but allows helmup to run
205
+ // .nohelm = overwhelm and helmup will skip the deployment entirely
204
206
  ahoy.forEach( ( dir ) => {
205
- if ( !fs.existsSync( `${dir}/.nohelm` ) ) {
206
- console.log( `Generating values in ${dir}` )
207
+ if ( fs.existsSync( `${dir}/.noahoy` ) ) {
208
+ !args.fetchctx && console.log( chalk.yellow( `***WARNING: .noahoy detected, not regenerating ${dir}values.yaml` ) )
209
+ }
210
+ else if ( !fs.existsSync( `${dir}/.nohelm` ) ) {
211
+ args.verbose && console.log( `Generating values in ${dir}` )
207
212
 
208
213
  let valuesOut = [] // An accumulator for all of the output values.
209
214
 
@@ -211,7 +216,7 @@ ahoy.forEach( ( dir ) => {
211
216
  const valuesLocal = `${dir}values-local.yaml`
212
217
 
213
218
  if ( fs.existsSync( valuesLocal ) ) {
214
- console.log( ` Local values in ${valuesLocal}` )
219
+ args.verbose && console.log( ` Local values in ${valuesLocal}` )
215
220
  valuesOut += `\n# AHOY => values-local.yaml\n\n`
216
221
  valuesOut += fs.readFileSync( valuesLocal, { encoding : 'utf-8' } )
217
222
  }
@@ -250,9 +255,10 @@ ahoy.forEach( ( dir ) => {
250
255
 
251
256
  let kubeout = '_no_current_context_'
252
257
  try {
253
- // if current is not set exec will throw
254
- kubeout = exec( 'kubectl config current-context' )
255
- } catch (err) { }
258
+ kubeout = exec( 'kubectl config current-context', { stdio: [ undefined ] } )
259
+ } catch (err) {
260
+ // err && console.log( `Caught Error =>[${err}]` )
261
+ }
256
262
 
257
263
  const currentCtx = kubeout.toString().trim()
258
264
  let desiredCtx = `gke_${projectId}_${zone}_${clusterName}`
@@ -270,17 +276,27 @@ ahoy.forEach( ( dir ) => {
270
276
 
271
277
  const matchedCtx = ( currentCtx === desiredCtx )
272
278
 
279
+ // just fetch the context and exit if -f is specified
280
+ if ( args.fetchctx ) {
281
+ if ( !matchedCtx ) {
282
+ try {
283
+ exec( `${cmd}`, { stdio: [ undefined ] } )
284
+ } catch (err) {
285
+ process.exit( 61 ) // ECONNREFUSED
286
+ }
287
+ }
288
+ process.exit( 0 )
289
+ }
290
+
273
291
  if ( matchedCtx ) {
274
292
  console.log( `
275
293
 
276
- Current context ${chalk.bold.green(currentCtx)} matches the desired
277
- context. Do you want to update credentials anyway?
294
+ Current context matches => ${chalk.bold.green(currentCtx)}
278
295
 
279
296
  ` )
280
297
  }
281
298
  else {
282
299
  console.log( `
283
-
284
300
  You are about to change your Kubernetes context to:
285
301
  CLUSTER_NAME => ${chalk.bold.green(clusterName)}
286
302
  PROJECT_ID => ${chalk.bold.green(projectId)}
@@ -288,7 +304,8 @@ ahoy.forEach( ( dir ) => {
288
304
 
289
305
  ` )
290
306
  }
291
- const ans = ask.question( `Enter "${chalk.bold.green( 'yes' )}" if you wish to fetch the credentials => ` )
307
+ const operation = matchedCtx ? 'refetch the credentials' : 'switch your context'
308
+ const ans = ask.question( `Enter "${chalk.bold.green( 'yes' )}" if you wish to ${operation} => ` )
292
309
  if ( ans !== 'yes' ) {
293
310
  if ( matchedCtx ) {
294
311
  console.log( chalk.bold.yellow( `\n\nSkipping a refetch of your Kubernetes context and credentials\n\n` ) )
@@ -299,7 +316,7 @@ ahoy.forEach( ( dir ) => {
299
316
  process.exit( 1 )
300
317
  }
301
318
 
302
- console.log( `\n\nExecuting: ${cmd}\n\n` )
319
+ console.log( `\n\nExecuting: ${chalk.bold.yellow(cmd)}\n\n` )
303
320
  exec( `${cmd}`, ( error, out ) => {
304
321
  if ( error ) {
305
322
  console.log( `\n\n***ERROR ${error}\n\n` )