@leverege/build-tools 2.38.2 → 2.39.0-beta.2
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 +12 -16
- package/src/Utils.mjs +30 -0
- package/src/{build-tools.js → build-tools.mjs} +28 -12
- package/src/circle-lib.yml +150 -0
- package/src/circle-srv.yml +213 -0
- package/src/firebaseDeploy.mjs +2 -1
- package/src/firebaseServe.mjs +2 -1
- package/src/getjson.mjs +3 -3
- package/src/helm-charts/firebase-rules/.nohelm +0 -0
- package/src/helm-charts/firebase-rules/firebase.json +5 -0
- package/src/helm-charts/firebase-rules/firebaserc.ovh +24 -0
- package/src/helm-charts/firebase-rules/gitignore +2 -0
- package/src/helm-charts/firebase-rules/helmup.plugin +14 -0
- package/src/helm-charts/firebase-rules/leverege.rules.json +65 -0
- package/src/helm-charts/geotile-server/.nohelm +0 -0
- package/src/helm-charts/geotile-server/gitignore +1 -0
- package/src/helm-charts/geotile-server/helmup.plugin +6 -0
- package/src/helm-charts/velero/helmup.plugin +16 -0
- package/src/helmup.sh +47 -1
- package/src/overwhelm.mjs +55 -63
- package/src/push-my-chart.mjs +7 -6
- package/src/refresh-npm-token.mjs +142 -40
- package/src/unleash.mjs +4 -2
- package/leverege-build-tools-2.21.13.tgz +0 -0
- package/lib/server/build-tools.js +0 -138
- package/lib/server/firebaseDeploy.js +0 -195
- package/lib/server/firebaseServe.js +0 -116
- package/lib/server/getfbcfg.js +0 -25
- package/lib/server/getjson.js +0 -70
- package/lib/server/overwhelm.js +0 -447
- package/lib/server/push-my-chart.js +0 -18
- package/lib/server/refresh-npm-token.js +0 -135
- package/lib/server/tag-release.js +0 -681
- package/lib/server/unleash.js +0 -50
- package/lib/web/build-tools.js +0 -138
- package/lib/web/firebaseDeploy.js +0 -195
- package/lib/web/firebaseServe.js +0 -116
- package/lib/web/getfbcfg.js +0 -25
- package/lib/web/getjson.js +0 -70
- package/lib/web/overwhelm.js +0 -447
- package/lib/web/push-my-chart.js +0 -18
- package/lib/web/refresh-npm-token.js +0 -135
- package/lib/web/tag-release.js +0 -681
- package/lib/web/unleash.js +0 -50
- package/src/overwhelm.js +0 -396
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"rules": {
|
|
3
|
+
"projectRefs": {
|
|
4
|
+
"$project_id": {
|
|
5
|
+
"member": {
|
|
6
|
+
".indexOn": ["created"]
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
"blueprint": {
|
|
11
|
+
".indexOn": "lastModified"
|
|
12
|
+
},
|
|
13
|
+
"blueprintChildren": {
|
|
14
|
+
"$bp_id": {
|
|
15
|
+
"attributes": {
|
|
16
|
+
".indexOn": ".value"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"attribute":{
|
|
21
|
+
".indexOn" : [ "path", "blueprintId" ]
|
|
22
|
+
},
|
|
23
|
+
"systemChildren": {
|
|
24
|
+
"$sys_id": {
|
|
25
|
+
"device": {
|
|
26
|
+
".indexOn": ".value"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"device": {
|
|
31
|
+
".indexOn": ["id", "networkId", "simNetworkId"]
|
|
32
|
+
},
|
|
33
|
+
"deviceRefs": {
|
|
34
|
+
"$dev_id": {
|
|
35
|
+
"member": {
|
|
36
|
+
".indexOn": ["created"]
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"user": {
|
|
41
|
+
".indexOn": ["username", "email"]
|
|
42
|
+
},
|
|
43
|
+
"project": {
|
|
44
|
+
".indexOn": ["id"]
|
|
45
|
+
},
|
|
46
|
+
"rt": {
|
|
47
|
+
"$sys_id": {
|
|
48
|
+
".read": "auth.systemId === $sys_id",
|
|
49
|
+
"dev": {
|
|
50
|
+
"$dev_id": {
|
|
51
|
+
".read": "auth.deviceId === $dev_id",
|
|
52
|
+
"outbound": {
|
|
53
|
+
".indexOn": ["initiated", "sent", "ack"]
|
|
54
|
+
},
|
|
55
|
+
"events": {
|
|
56
|
+
"$evt_type": {
|
|
57
|
+
".indexOn": ["time", "id"]
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
geotile-local.yaml
|
|
@@ -31,6 +31,22 @@ helm upgrade \
|
|
|
31
31
|
--set configuration.backupStorageLocation[0].config.serviceAccount="$GCE_SA_EMAIL" \
|
|
32
32
|
--set configuration.volumeSnapshotLocation[0].config.snapshotLocation="$GCE_REGION"
|
|
33
33
|
|
|
34
|
+
if [ $? -ne 0 ];
|
|
35
|
+
then
|
|
36
|
+
cat<<VELERROR
|
|
37
|
+
|
|
38
|
+
`color r ***ERROR:` helm upgrade has failed! If upgrading from an older chart there
|
|
39
|
+
may be residual velero components that need to be cleaned up. Try running the
|
|
40
|
+
following kubectl commands and then rerun helmup:
|
|
41
|
+
|
|
42
|
+
kubectl delete backupstoragelocations.velero.io -n velero default
|
|
43
|
+
kubectl delete volumesnapshotlocations.velero.io -n velero default
|
|
44
|
+
helmup velero
|
|
45
|
+
|
|
46
|
+
VELERROR
|
|
47
|
+
exit 1
|
|
48
|
+
fi
|
|
49
|
+
|
|
34
50
|
velero schedule get
|
|
35
51
|
cat<<DONE_VELERO
|
|
36
52
|
|
package/src/helmup.sh
CHANGED
|
@@ -152,10 +152,29 @@ MISSING_HELMUP_PLUGIN
|
|
|
152
152
|
# because npm tends to not allow .gitinore files the easy way...
|
|
153
153
|
[ -f "$SERVICE/gitignore" ] && mv $SERVICE/gitignore $SERVICE/.gitignore
|
|
154
154
|
git add $SERVICE
|
|
155
|
-
overwhelm
|
|
155
|
+
overwhelm --genvals
|
|
156
156
|
ifPluggedIn $SERVICE
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
+
function installDefaultConfigs() {
|
|
160
|
+
showInstalling "Default Configs"
|
|
161
|
+
|
|
162
|
+
clearlyWarn 'without clearing'
|
|
163
|
+
cat<<INSTALLDEFAULTCONFIGS
|
|
164
|
+
Continuing with applying the default-configs.yaml will cause all non-system
|
|
165
|
+
services to `color r restart`. Make certain people are made aware that this is about
|
|
166
|
+
to happen.
|
|
167
|
+
|
|
168
|
+
INSTALLDEFAULTCONFIGS
|
|
169
|
+
yesToContinue "to apply the default-configs to the cluster"
|
|
170
|
+
|
|
171
|
+
kubecmd="kubectl apply -f default-configs.yaml"
|
|
172
|
+
|
|
173
|
+
printf "\nRunning => `color y \"$kubecmd\"`\n\n"
|
|
174
|
+
eval $kubecmd
|
|
175
|
+
postToSlack "$kubecmd"
|
|
176
|
+
}
|
|
177
|
+
|
|
159
178
|
function errorIfMissingSecret() {
|
|
160
179
|
SECRET="$1"
|
|
161
180
|
kubectl get secret $SECRET &> $DEVNULL
|
|
@@ -165,6 +184,24 @@ function errorIfMissingSecret() {
|
|
|
165
184
|
fi
|
|
166
185
|
}
|
|
167
186
|
|
|
187
|
+
function installFirebaseDatabases() {
|
|
188
|
+
showInstalling "Firebase Realtime Databases"
|
|
189
|
+
|
|
190
|
+
open https://console.firebase.google.com/u/0/project/${GCP_PROJECT_ID}/authentication/users
|
|
191
|
+
yesToContinue "when you have pressed Get Started on the Firebase Authentication page"
|
|
192
|
+
|
|
193
|
+
# create the firebase primary db
|
|
194
|
+
firebase --project $GCP_PROJECT_ID database:instances:create ${PROJECT}
|
|
195
|
+
|
|
196
|
+
# TODO: should maybe be more flexible with number of shards in the future
|
|
197
|
+
for SHARD in {0..9}
|
|
198
|
+
do
|
|
199
|
+
SHARD="${GCP_PROJECT_ID}-rt-${SHARD}"
|
|
200
|
+
printf "Creating shard $SHARD\n"
|
|
201
|
+
firebase --project $GCP_PROJECT_ID database:instances:create ${SHARD}
|
|
202
|
+
done
|
|
203
|
+
}
|
|
204
|
+
|
|
168
205
|
function installStackdriverExporterEnvironment() {
|
|
169
206
|
showInstalling "Stackdriver Exporter Service Account Binding"
|
|
170
207
|
|
|
@@ -627,6 +664,10 @@ CATBACKUP
|
|
|
627
664
|
kubectl create -f https://raw.githubusercontent.com/GoogleCloudPlatform/k8s-stackdriver/master/custom-metrics-stackdriver-adapter/deploy/production/adapter.yaml
|
|
628
665
|
;;
|
|
629
666
|
|
|
667
|
+
default-configs*)
|
|
668
|
+
installDefaultConfigs
|
|
669
|
+
;;
|
|
670
|
+
|
|
630
671
|
db-curator*)
|
|
631
672
|
# db-curator / db-curator-dh diffs are defined in values-local.yaml
|
|
632
673
|
HELMUP="helm upgrade --install $SERVICE leverege/db-curator --values $SERVICE/values.yaml $CHARTVER $HELM_WHAT"
|
|
@@ -649,6 +690,11 @@ CATBACKUP
|
|
|
649
690
|
installPreemptibleKiller # the gke preemptible node spreader outer
|
|
650
691
|
;;
|
|
651
692
|
|
|
693
|
+
"firebase")
|
|
694
|
+
installFirebaseDatabases
|
|
695
|
+
bootstrapLocalSetup firebase-rules
|
|
696
|
+
;;
|
|
697
|
+
|
|
652
698
|
"grafana")
|
|
653
699
|
bootstrapLocalSetup $SERVICE
|
|
654
700
|
;;
|
package/src/overwhelm.mjs
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// XXX console.log( `TOP=>[${process.cwd()}] PWD=[${process.env.PWD}]` )
|
|
4
|
-
/* eslint-disable no-console */
|
|
5
4
|
/* eslint-disable security/detect-non-literal-fs-filename */
|
|
6
5
|
|
|
7
6
|
import path from 'node:path'
|
|
8
|
-
import { execSync as exec } from 'node:child_process'
|
|
9
7
|
import fs from 'node:fs'
|
|
10
8
|
|
|
11
9
|
import chalk from 'chalk'
|
|
12
10
|
import cliArgs from 'command-line-args'
|
|
13
11
|
// const cliHelp = require( 'command-line-usage' )
|
|
14
12
|
import deepmerge from 'deepmerge'
|
|
15
|
-
import glob from 'glob'
|
|
13
|
+
import { glob } from 'glob'
|
|
16
14
|
import parse from 'parse-gitignore'
|
|
17
15
|
import ask from 'readline-sync'
|
|
18
16
|
import YAML from 'js-yaml'
|
|
19
17
|
|
|
18
|
+
import { debug, log, shellCmd } from './Utils.mjs'
|
|
19
|
+
|
|
20
20
|
const optionsDefinitions = [
|
|
21
21
|
/* eslint-disable no-multi-spaces */
|
|
22
22
|
{ name : 'context', alias : 'x', type : String, default : '' },
|
|
@@ -34,29 +34,26 @@ const optionsDefinitions = [
|
|
|
34
34
|
const args = cliArgs( optionsDefinitions )
|
|
35
35
|
|
|
36
36
|
// See if we are in a monorepo, which changes some of the rules.
|
|
37
|
-
const gitTop =
|
|
38
|
-
|
|
39
|
-
).toString().trim()
|
|
37
|
+
const gitTop = await shellCmd( 'git rev-parse --show-toplevel' )
|
|
38
|
+
|
|
40
39
|
let monoTop
|
|
41
40
|
if ( fs.existsSync( `${gitTop}/packages` ) ) {
|
|
42
41
|
monoTop = path.basename( path.resolve() ) // process.env.PWD
|
|
43
|
-
|
|
42
|
+
log( `MONO=[${monoTop}]` )
|
|
44
43
|
}
|
|
45
44
|
|
|
46
45
|
// The kubernetes context is equal to the git branch name.
|
|
47
|
-
const gitBranch =
|
|
48
|
-
'git rev-parse --abbrev-ref HEAD', { stdio : [ undefined ] }
|
|
49
|
-
).toString().trim()
|
|
46
|
+
const gitBranch = await shellCmd( 'git rev-parse --abbrev-ref HEAD' )
|
|
50
47
|
|
|
51
48
|
const context = args.context || monoTop || gitBranch
|
|
52
49
|
|
|
53
50
|
if ( context === 'master' ) {
|
|
54
|
-
|
|
51
|
+
log( '***ERROR: master context is forbidden; change to a different branch\n\n' )
|
|
55
52
|
process.exit( 1 )
|
|
56
53
|
}
|
|
57
54
|
|
|
58
55
|
if ( !fs.existsSync( 'overwhelm.yaml' ) ) {
|
|
59
|
-
|
|
56
|
+
log( chalk.red.bold( `
|
|
60
57
|
|
|
61
58
|
***ERROR overwhelm => missing the overwhelm.yaml file - this command expects
|
|
62
59
|
to execute from within a platform-k8s branch
|
|
@@ -79,9 +76,8 @@ if ( !fs.existsSync( 'overwhelm.yaml' ) ) {
|
|
|
79
76
|
//
|
|
80
77
|
const yaml = YAML.load( fs.readFileSync( 'overwhelm.yaml', 'utf-8' ) )
|
|
81
78
|
const over = yaml.default
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
79
|
+
|
|
80
|
+
debug( { over, yaml, }, '<==Contents of the over and yaml structs' )
|
|
85
81
|
|
|
86
82
|
let cfgs = yaml[context]
|
|
87
83
|
|
|
@@ -89,12 +85,12 @@ let cfgs = yaml[context]
|
|
|
89
85
|
if ( args.checkctx ) { process.exit( !cfgs ) }
|
|
90
86
|
|
|
91
87
|
if ( !cfgs ) {
|
|
92
|
-
|
|
93
|
-
|
|
88
|
+
log( `***ERROR: Unknown context => [${context}]\n` )
|
|
89
|
+
log( ' Known k8s contexts are:' )
|
|
94
90
|
Object.keys( yaml ).forEach( ( key ) => {
|
|
95
|
-
if ( key !== 'default' ) {
|
|
91
|
+
if ( key !== 'default' ) { log( ` ${key}` ) }
|
|
96
92
|
} )
|
|
97
|
-
|
|
93
|
+
log( `Add a section into overwhelm.yaml for ${context}\n\n` )
|
|
98
94
|
process.exit( 1 )
|
|
99
95
|
}
|
|
100
96
|
|
|
@@ -104,8 +100,8 @@ if ( cfgs.PROJECT_BASE ) {
|
|
|
104
100
|
const tempCfgs = cfgs
|
|
105
101
|
cfgs = yaml[baseName]
|
|
106
102
|
Object.keys( tempCfgs ).forEach( ( key ) => { cfgs[key] = tempCfgs[key] } )
|
|
107
|
-
|
|
108
|
-
|
|
103
|
+
log( 'PROJECT_BASE still under evaluation' )
|
|
104
|
+
log( '\n cfgs=', cfgs )
|
|
109
105
|
process.exit( 1 ) // XXX HERE
|
|
110
106
|
}
|
|
111
107
|
|
|
@@ -148,11 +144,11 @@ Object.keys( over ).forEach( ( key ) => {
|
|
|
148
144
|
} )
|
|
149
145
|
|
|
150
146
|
if ( varErrors.length > 0 ) {
|
|
151
|
-
|
|
147
|
+
log( '***ERROR: unkown variable reference(s) in overwhelm.yaml:\n' )
|
|
152
148
|
varErrors.forEach( ( error ) => {
|
|
153
|
-
|
|
149
|
+
log( ` ${error}` )
|
|
154
150
|
} )
|
|
155
|
-
|
|
151
|
+
log( '' )
|
|
156
152
|
process.exit( 1 )
|
|
157
153
|
}
|
|
158
154
|
|
|
@@ -170,7 +166,7 @@ const doReplacements = ( yamls, replacements ) => {
|
|
|
170
166
|
}
|
|
171
167
|
|
|
172
168
|
Object.keys( replacements ).forEach( ( repl ) => {
|
|
173
|
-
const replaceThis = new RegExp( `OVH:<${repl}>`, 'g' )
|
|
169
|
+
const replaceThis = new RegExp( `OVH:<${repl}>`, 'g' ) // eslint-disable-line security/detect-non-literal-regexp
|
|
174
170
|
const withThat = quoteSpecials( `${replacements[repl]}` )
|
|
175
171
|
replYaml = replYaml.replace( replaceThis, withThat )
|
|
176
172
|
} )
|
|
@@ -179,11 +175,11 @@ const doReplacements = ( yamls, replacements ) => {
|
|
|
179
175
|
const missed = replYaml.match( /OVH:<(.*)>/g )
|
|
180
176
|
|
|
181
177
|
if ( missed ) {
|
|
182
|
-
|
|
178
|
+
log( '\n***ERROR: missing replacements in overwhelm.yaml for these tags:\n' )
|
|
183
179
|
missed.forEach( ( miss ) => {
|
|
184
|
-
|
|
180
|
+
log( ` TAG: ${miss.match( /OVH:<(.*)>/ )[1]}` )
|
|
185
181
|
} )
|
|
186
|
-
|
|
182
|
+
log( '' )
|
|
187
183
|
process.exit( 1 )
|
|
188
184
|
}
|
|
189
185
|
|
|
@@ -199,7 +195,7 @@ const buildYaml = ( yamls, replacements ) => {
|
|
|
199
195
|
|
|
200
196
|
values.forEach( ( yaml ) => {
|
|
201
197
|
if ( !fs.existsSync( yaml ) ) {
|
|
202
|
-
|
|
198
|
+
log( `\n***ERROR: yaml file missing => ${yaml}\n` )
|
|
203
199
|
process.exit( 1 )
|
|
204
200
|
}
|
|
205
201
|
|
|
@@ -221,14 +217,11 @@ const values = buildYaml( yams, over )
|
|
|
221
217
|
if ( args.key ) {
|
|
222
218
|
const section = args.section || 'default'
|
|
223
219
|
const keys = yaml[section]
|
|
224
|
-
|
|
225
|
-
console.log( 'replacements' )
|
|
226
|
-
console.log( keys )
|
|
227
|
-
}
|
|
220
|
+
debug( { keys }, '<==Replacements' )
|
|
228
221
|
if ( args.export ) {
|
|
229
|
-
|
|
222
|
+
log( `export ${args.key}=${keys[args.key]}` )
|
|
230
223
|
} else {
|
|
231
|
-
|
|
224
|
+
log( keys[args.key] )
|
|
232
225
|
}
|
|
233
226
|
if ( !args.continue ) process.exit()
|
|
234
227
|
}
|
|
@@ -241,22 +234,19 @@ const opt = {
|
|
|
241
234
|
|
|
242
235
|
const ahoy = glob.sync( '*/', opt )
|
|
243
236
|
|
|
244
|
-
// .
|
|
245
|
-
// .nohelm = overwhelm and helmup will skip the deployment entirely
|
|
237
|
+
// .nohelm = skips generation of values.yaml but allows helmup to run
|
|
246
238
|
ahoy.forEach( ( dir ) => {
|
|
247
|
-
if ( fs.existsSync( `${dir}/.
|
|
248
|
-
|
|
249
|
-
} else if ( !fs.existsSync( `${dir}/.nohelm` ) ) {
|
|
250
|
-
args.verbose && console.log( `Generating values in ${dir}` ) // eslint-disable-line no-unused-expressions
|
|
239
|
+
if ( !fs.existsSync( `${dir}/.nohelm` ) ) {
|
|
240
|
+
// debug( { dir }, 'Generating values' ) // eslint-disable-line no-unused-expressions
|
|
251
241
|
|
|
252
242
|
let valuesOut = [] // An accumulator for all of the output values.
|
|
253
243
|
|
|
254
244
|
// Add support for localized values for things like keel (or whatever)
|
|
255
|
-
const valuesLocal = `${dir}values-local.yaml`
|
|
245
|
+
const valuesLocal = `${dir}/values-local.yaml`
|
|
256
246
|
|
|
257
247
|
if ( fs.existsSync( valuesLocal ) ) {
|
|
258
|
-
|
|
259
|
-
valuesOut += '\n#
|
|
248
|
+
debug( { valuesLocal }, 'rendering values.yaml' )
|
|
249
|
+
valuesOut += '\n# OVERWHELM => values-local.yaml\n\n'
|
|
260
250
|
valuesOut += fs.readFileSync( valuesLocal, { encoding : 'utf-8' } )
|
|
261
251
|
}
|
|
262
252
|
valuesOut += `\n${values}`
|
|
@@ -283,7 +273,7 @@ ahoy.forEach( ( dir ) => {
|
|
|
283
273
|
const valuesOverride = `${dir}/values-override.yaml`
|
|
284
274
|
|
|
285
275
|
if ( fs.existsSync( valuesOverride ) ) {
|
|
286
|
-
|
|
276
|
+
log( `===>Applying Overrides=> ${valuesOverride}` )
|
|
287
277
|
const overrides = YAML.load( fs.readFileSync( valuesOverride, { encofind : 'utf-8' } ) )
|
|
288
278
|
const allValues = YAML.load( valuesOut )
|
|
289
279
|
valuesOut = YAML.dump( deepmerge( allValues, overrides ), { quotingType : '"' } )
|
|
@@ -313,7 +303,8 @@ const projectId = over.PROJECT_ID
|
|
|
313
303
|
const zone = over.GCE_REGION + ( over.GCE_ZONE ? `-${over.GCE_ZONE}` : '' )
|
|
314
304
|
|
|
315
305
|
if ( !clusterName ) {
|
|
316
|
-
|
|
306
|
+
/* eslint-disable quotes */
|
|
307
|
+
log( chalk.yellow(
|
|
317
308
|
`
|
|
318
309
|
|
|
319
310
|
The overwhelm.yaml file in this branch is missing a CLUSTER_NAME setting,
|
|
@@ -322,24 +313,25 @@ if ( !clusterName ) {
|
|
|
322
313
|
adding this line following PROJECT_NAME in the default section of
|
|
323
314
|
overwhelm.yaml:
|
|
324
315
|
|
|
325
|
-
${chalk.bold.green(
|
|
316
|
+
${chalk.bold.green( `CLUSTER_NAME : '\${PROJECT_NAME}'` )}
|
|
326
317
|
|
|
327
318
|
However, if the CLUSTER_NAME is not the same as the PROJECT_NAME then go
|
|
328
319
|
ahead and add the CLUSTER_NAME setting to the ${chalk.bold.green( projectId )} section of the
|
|
329
320
|
overwhelm.yaml file.
|
|
330
321
|
|
|
331
322
|
` ) )
|
|
323
|
+
/* eslint-enable quotes */
|
|
332
324
|
process.exit( 1 )
|
|
333
325
|
}
|
|
334
326
|
|
|
335
|
-
|
|
327
|
+
// the kubectl call will throw if there isn't an existing context
|
|
328
|
+
let currentCtx = '_no_current_context_'
|
|
336
329
|
try {
|
|
337
|
-
|
|
330
|
+
currentCtx = await shellCmd( 'kubectl config current-context' )
|
|
338
331
|
} catch ( err ) {
|
|
339
|
-
// err &&
|
|
332
|
+
// err && log( `Caught Error =>[${err}]` )
|
|
340
333
|
}
|
|
341
334
|
|
|
342
|
-
const currentCtx = kubeout.toString().trim()
|
|
343
335
|
const desiredCtx = `gke_${projectId}_${zone}_${clusterName}`
|
|
344
336
|
const cmd = `gcloud container clusters get-credentials ${clusterName} --zone ${zone} --project ${projectId}`
|
|
345
337
|
|
|
@@ -353,7 +345,7 @@ if ( args.matchk8s ) {
|
|
|
353
345
|
if ( args.fetchctx ) {
|
|
354
346
|
if ( !matchedCtx ) {
|
|
355
347
|
try {
|
|
356
|
-
|
|
348
|
+
await shellCmd( cmd )
|
|
357
349
|
} catch ( err ) {
|
|
358
350
|
process.exit( 61 ) // ECONNREFUSED
|
|
359
351
|
}
|
|
@@ -362,13 +354,13 @@ if ( args.fetchctx ) {
|
|
|
362
354
|
}
|
|
363
355
|
|
|
364
356
|
if ( matchedCtx ) {
|
|
365
|
-
|
|
357
|
+
log( `
|
|
366
358
|
|
|
367
359
|
Current context matches => ${chalk.bold.green( currentCtx )}
|
|
368
360
|
|
|
369
361
|
` )
|
|
370
362
|
} else {
|
|
371
|
-
|
|
363
|
+
log( `
|
|
372
364
|
You are about to change your Kubernetes context to:
|
|
373
365
|
CLUSTER_NAME => ${chalk.bold.green( clusterName )}
|
|
374
366
|
PROJECT_ID => ${chalk.bold.green( projectId )}
|
|
@@ -380,18 +372,18 @@ const operation = matchedCtx ? 'refetch the credentials' : 'switch your context'
|
|
|
380
372
|
const ans = ask.question( `Enter "${chalk.bold.green( 'yes' )}" if you wish to ${operation} => ` )
|
|
381
373
|
if ( ans !== 'yes' ) {
|
|
382
374
|
if ( matchedCtx ) {
|
|
383
|
-
|
|
375
|
+
log( chalk.bold.yellow( '\n\nSkipping a refetch of your Kubernetes context and credentials\n\n' ) )
|
|
384
376
|
process.exit( 0 )
|
|
385
377
|
}
|
|
386
378
|
|
|
387
|
-
|
|
379
|
+
log( chalk.bold.red( '\n\nYour Kubernetes context and credentials do NOT match - this could be bad!\n\n' ) )
|
|
388
380
|
process.exit( 1 )
|
|
389
381
|
}
|
|
390
382
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
}
|
|
383
|
+
log( `\n\nExecuting: ${chalk.bold.yellow( cmd )}\n\n` )
|
|
384
|
+
try {
|
|
385
|
+
await shellCmd( cmd )
|
|
386
|
+
} catch ( error ) {
|
|
387
|
+
log( { error, cmd }, '***ERROR overwhelm' )
|
|
388
|
+
process.exit( 1 )
|
|
389
|
+
}
|
package/src/push-my-chart.mjs
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import execa from 'execa'
|
|
4
3
|
import { lt as semverLt } from 'semver'
|
|
5
4
|
|
|
5
|
+
import { log, shellCmd } from './Utils.mjs'
|
|
6
|
+
|
|
6
7
|
const pushItGood = async () => {
|
|
7
|
-
const version = await
|
|
8
|
-
const pusher = ( semverLt( version
|
|
8
|
+
const version = await shellCmd( 'helm version --short' )
|
|
9
|
+
const pusher = ( semverLt( version, '3.7.0' ) ? 'push' : 'cm-push' )
|
|
9
10
|
|
|
10
11
|
try {
|
|
11
|
-
const museum = await
|
|
12
|
-
|
|
12
|
+
const museum = await shellCmd( `helm ${pusher} helm leverege` )
|
|
13
|
+
log( museum )
|
|
13
14
|
} catch ( ex ) {
|
|
14
|
-
|
|
15
|
+
log( ex.stderr )
|
|
15
16
|
process.exit( 1 )
|
|
16
17
|
}
|
|
17
18
|
}
|