@leverege/build-tools 2.96.5 → 2.96.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 +1 -1
  2. package/src/helmup.sh +58 -27
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leverege/build-tools",
3
- "version": "2.96.5",
3
+ "version": "2.96.7",
4
4
  "description": "A collection of build / support tools for Leverege developers",
5
5
  "main": "index.js",
6
6
  "repository": {
package/src/helmup.sh CHANGED
@@ -8,6 +8,20 @@ export _FROM_HELMUP_="true"
8
8
  # Load the standard helper functions
9
9
  . `build-tools --bashfun`
10
10
 
11
+ if [[ ! -z "$BUILD_TOOLS_DEBUG" ]]; then
12
+ cat<<BAD_IDEA
13
+
14
+ `color y "***WARNING: enabling debugging for helmup is a bad idea..."`
15
+
16
+ Unfortunately, trying to debug this script by turning on verbose output
17
+ will only exacerbate the problems you're attempting to find. This is because
18
+ the additional output ends up fouling the execution of the script in bizarre
19
+ ways. Sorry, just don't do this, future you.
20
+
21
+ BAD_IDEA
22
+ exit 1
23
+ fi
24
+
11
25
  SHELMUP_ARGS=("$*")
12
26
 
13
27
  # artifact-registry => https://console.cloud.google.com/artifacts?project=leverege-registry
@@ -71,6 +85,7 @@ SYSTEM=(
71
85
  velero
72
86
  cnpg-db-psql-stack
73
87
  cnpg-db-tsdb-basic
88
+ # cnpg-db-tsdb-dh
74
89
  )
75
90
 
76
91
  SYSTEM_LEGACY=(
@@ -80,10 +95,36 @@ SYSTEM_LEGACY=(
80
95
  monitoring # do monitoring last to show password
81
96
  )
82
97
 
98
+ LEVEREGE_SERVICES=(
99
+ "${PLATFORM[@]}"
100
+ "${AUXILIARY[@]}"
101
+ "${SYSTEM_LEGACY[@]}"
102
+ "${SYSTEM[@]}"
103
+ )
104
+
105
+ SYSTEM_SERVICES=(
106
+ "${SYSTEM_LEGACY[@]}"
107
+ "${SYSTEM[@]}"
108
+ )
109
+
110
+ function in_array() {
111
+ local seeking=$1; shift
112
+ local item
113
+ for item in "$@"; do
114
+ [[ "$item" == "$seeking" ]] && return 0
115
+ done
116
+ return 1
117
+ }
118
+
83
119
  function isLeveregeService() {
84
- local answer=0
85
- [[ ${PLATFORM[@]} =~ $1 || ${AUXILIARY[@]} =~ $1 || ${SYSTEM_LEGACY[@]}} =~ $1 || ${SYSTEM[@]} =~ $1 ]] && answer=1
86
- echo $answer
120
+ in_array "$1" "${LEVEREGE_SERVICES[@]}"
121
+ }
122
+ function isSystemService() {
123
+ in_array "$1" "${SYSTEM_SERVICES[@]}"
124
+ }
125
+
126
+ isNotSystemService() {
127
+ ! isSystemService "$1"
87
128
  }
88
129
 
89
130
  # Accepts 3 paramaters - 1 mandatory.
@@ -449,19 +490,13 @@ BAD_SECRETS
449
490
 
450
491
  function findChartLocation() {
451
492
  local service_name="$1"
452
- local output
493
+ local output=""
453
494
 
454
- # check the compass for a chart location
455
- if output="$(chart-compass --service "$service_name")";
456
- then
457
- # chart exists in local chart-compass.yaml
458
- local chart_location="oci://$output"
495
+ if output="$(chart-compass --service "$service_name")" && [[ -n "$output" ]]; then
496
+ printf 'oci://%s\n' "$output"
459
497
  else
460
- # nope - fallback to using the legacy museum location
461
- local chart_location="leverege/$service_name"
498
+ printf 'leverege/%s\n' "$service_name"
462
499
  fi
463
-
464
- echo "$chart_location"
465
500
  }
466
501
 
467
502
  function getServiceAndChartInfo() {
@@ -474,24 +509,21 @@ function getServiceAndChartInfo() {
474
509
  local versions_file="./Versions.json"
475
510
 
476
511
  # Allows chart version from command line via <deployment>/<x.y.z>
477
- IFS="/" read SERVICE CHARTVER <<< "$1"
478
-
512
+ IFS="/" read -r SERVICE CHARTVER <<< "$input"
479
513
  [[ -z "$SERVICE" ]] && return 1
480
514
 
481
- CHARTLOC="$(findChartLocation $SERVICE)"
515
+ CHARTLOC="$(findChartLocation "$SERVICE")" || return 1
482
516
 
483
517
  # Allows chart version as <deployment>/x.y.z>
484
- if [[ -n "$CHARTVER" ]]; then
485
- return 0 # service and chart version from CLI
486
- fi
518
+ [[ -n "$CHARTVER" ]] && return 0
487
519
 
488
520
  # check for the top level Versions.json file
489
521
  if [[ -f "$versions_file" ]]; then
490
- CHARTVER=$(jq -r --arg svc "$SERVICE" '.[$svc].chart // ""' "$versions_file")
491
- if [[ -n "$CHARTVER" ]]; then
492
- FROM_VERSIONS=1
493
- fi
522
+ CHARTVER="$(jq -r --arg svc "$SERVICE" '.[$svc].chart // empty' "$versions_file")"
523
+ [[ -n "$CHARTVER" ]] && FROM_VERSIONS=1
494
524
  fi
525
+
526
+ return 0
495
527
  }
496
528
 
497
529
  function checkUpgradeNotes() {
@@ -562,8 +594,7 @@ function doInstall() {
562
594
  do
563
595
  # Allows chart version from command line via <deployment>/<x.y.z>
564
596
  getServiceAndChartInfo "$PARAM"
565
- #printf "SVC=[$SERVICE] CHT=[$CHARTVER]\n"
566
-
597
+
567
598
  # slap additional helm syntax in there if the version is set
568
599
  [ ! -z "$CHARTVER" ] && CHARTVER="--version $CHARTVER"
569
600
 
@@ -572,7 +603,7 @@ function doInstall() {
572
603
  [ "$INVOKED_AS" == "helmwhat" ] && HELM_WHAT="--dry-run --debug" && K8S_WHAT="--dry-run=server -o yaml"
573
604
 
574
605
  # helminit is used to redeploy an existing service
575
- if [ "$INVOKED_AS" == "helminit" ] && [[ $(isLeveregeService $SERVICE) -eq 1 ]];
606
+ if [[ "$INVOKED_AS" == "helminit" ]] && isLeveregeService $SERVICE;
576
607
  then
577
608
  yesToContinue "if are you `color y certain` you want to run `color y helminit`"
578
609
  local BACKUP_DIR="$SERVICE-bak"
@@ -662,7 +693,7 @@ REBOOTSTRAP
662
693
  *)
663
694
  # if the service dir is missing then check to see if it's a platform
664
695
  # service and if it is then try to bootstrap from charts in build-tools
665
- [ ! -d $SERVICE ] && [[ $(isLeveregeService $SERVICE) -eq 1 ]] && bootstrapLocalSetup $SERVICE
696
+ [ ! -d $SERVICE ] && isLeveregeService $SERVICE && bootstrapLocalSetup $SERVICE
666
697
 
667
698
  if [ ! -d $SERVICE ] || [ ! -f $SERVICE/values-local.yaml ];
668
699
  then