@leverege/build-tools 2.0.15 → 2.1.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.
- package/package.json +1 -1
- package/src/overwhelm +21 -33
package/package.json
CHANGED
package/src/overwhelm
CHANGED
|
@@ -200,26 +200,6 @@ const opt = {
|
|
|
200
200
|
|
|
201
201
|
const ahoy = glob.sync( '*/', opt )
|
|
202
202
|
|
|
203
|
-
// Keel supports a "never" policy which will cause it to skip over a release
|
|
204
|
-
// if it is properly set. Adding a .nokeel file to a release directoy will
|
|
205
|
-
// cause the creation of the file if it does not already exist.
|
|
206
|
-
const generateKeelNeverPolicy = ( fileName ) => {
|
|
207
|
-
if ( fs.existsSync( fileName ) ) return
|
|
208
|
-
const neverPolicy = `
|
|
209
|
-
keel:
|
|
210
|
-
# keel policy (all/major/minor/patch/force)
|
|
211
|
-
policy: "never"
|
|
212
|
-
# approvals
|
|
213
|
-
# approvals: 1
|
|
214
|
-
# approvalDeadline: 24
|
|
215
|
-
# # images to track and update
|
|
216
|
-
# images:
|
|
217
|
-
# - repository: never.IMAGE # [1]
|
|
218
|
-
# tag: never.VERSION # [2]
|
|
219
|
-
`
|
|
220
|
-
fs.writeFileSync( fileName, neverPolicy )
|
|
221
|
-
}
|
|
222
|
-
|
|
223
203
|
// Generate the values.yaml files in directories not marked with .nohelm.
|
|
224
204
|
ahoy.forEach( ( dir ) => {
|
|
225
205
|
if ( !fs.existsSync( `${dir}/.nohelm` ) ) {
|
|
@@ -230,10 +210,6 @@ ahoy.forEach( ( dir ) => {
|
|
|
230
210
|
// Add support for localized values for things like keel (or whatever)
|
|
231
211
|
const valuesLocal = `${dir}values-local.yaml`
|
|
232
212
|
|
|
233
|
-
if ( fs.existsSync( `${dir}.nokeel` ) ) {
|
|
234
|
-
generateKeelNeverPolicy( valuesLocal )
|
|
235
|
-
}
|
|
236
|
-
|
|
237
213
|
if ( fs.existsSync( valuesLocal ) ) {
|
|
238
214
|
console.log( ` Local values in ${valuesLocal}` )
|
|
239
215
|
valuesOut += `\n# AHOY => values-local.yaml\n\n`
|
|
@@ -246,10 +222,11 @@ ahoy.forEach( ( dir ) => {
|
|
|
246
222
|
}
|
|
247
223
|
} )
|
|
248
224
|
|
|
225
|
+
|
|
249
226
|
// Set the GCP context for safety!
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
227
|
+
let clusterName = over['CLUSTER_NAME']
|
|
228
|
+
let projectId = over['PROJECT_ID']
|
|
229
|
+
let zone = over['GCE_REGION'] + ( over['GCE_ZONE'] ? `-${over['GCE_ZONE']}` : '' )
|
|
253
230
|
|
|
254
231
|
if ( !clusterName ) {
|
|
255
232
|
console.log( chalk.yellow(
|
|
@@ -278,9 +255,20 @@ ahoy.forEach( ( dir ) => {
|
|
|
278
255
|
} catch (err) { }
|
|
279
256
|
|
|
280
257
|
const currentCtx = kubeout.toString().trim()
|
|
281
|
-
|
|
258
|
+
let desiredCtx = `gke_${projectId}_${zone}_${clusterName}`
|
|
259
|
+
let cmd = `gcloud container clusters get-credentials ${clusterName} --zone ${zone} --project ${projectId}`
|
|
260
|
+
|
|
261
|
+
// Check if we are using AWS
|
|
262
|
+
if(cfgs['CLOUD'] === 'aws'){
|
|
263
|
+
const awsAcctId = cfgs['AWS_ACCT_ID']
|
|
264
|
+
zone = over['AWS_REGION']
|
|
265
|
+
desiredCtx = `arn:aws:eks:${zone}:${awsAcctId}:cluster/${clusterName}`
|
|
266
|
+
cmd = `aws eks --region ${zone} update-kubeconfig --name ${clusterName}`
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// TODO - FETCH AWS CLUSTER CREDENTIALS
|
|
270
|
+
|
|
282
271
|
const matchedCtx = ( currentCtx === desiredCtx )
|
|
283
|
-
const cmd = `gcloud container clusters get-credentials ${clusterName} --zone ${zone} --project ${projectId}`
|
|
284
272
|
|
|
285
273
|
if ( matchedCtx ) {
|
|
286
274
|
console.log( `
|
|
@@ -293,21 +281,21 @@ ahoy.forEach( ( dir ) => {
|
|
|
293
281
|
else {
|
|
294
282
|
console.log( `
|
|
295
283
|
|
|
296
|
-
You are about to change your
|
|
284
|
+
You are about to change your Kubernetes context to:
|
|
297
285
|
CLUSTER_NAME => ${chalk.bold.green(clusterName)}
|
|
298
286
|
PROJECT_ID => ${chalk.bold.green(projectId)}
|
|
299
|
-
|
|
287
|
+
REGION => ${chalk.bold.green(zone)}
|
|
300
288
|
|
|
301
289
|
` )
|
|
302
290
|
}
|
|
303
291
|
const ans = ask.question( `Enter "${chalk.bold.green( 'yes' )}" if you wish to fetch the credentials => ` )
|
|
304
292
|
if ( ans !== 'yes' ) {
|
|
305
293
|
if ( matchedCtx ) {
|
|
306
|
-
console.log( chalk.bold.yellow( `\n\nSkipping a refetch of your
|
|
294
|
+
console.log( chalk.bold.yellow( `\n\nSkipping a refetch of your Kubernetes context and credentials\n\n` ) )
|
|
307
295
|
process.exit( 0 )
|
|
308
296
|
}
|
|
309
297
|
|
|
310
|
-
console.log( chalk.bold.red( `\n\nYour
|
|
298
|
+
console.log( chalk.bold.red( `\n\nYour Kubernetes context and credentials do NOT match - this could be bad!\n\n` ) )
|
|
311
299
|
process.exit( 1 )
|
|
312
300
|
}
|
|
313
301
|
|