@leverege/build-tools 2.37.1 → 2.38.0-john.1
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/lib/server/getjson.js +7 -7
- package/lib/server/overwhelm.js +6 -17
- package/lib/server/push-my-chart.js +18 -0
- package/lib/server/refresh-npm-token.js +52 -13
- package/lib/server/unleash.js +5 -4
- package/lib/web/getjson.js +7 -7
- package/lib/web/overwhelm.js +6 -17
- package/lib/web/push-my-chart.js +18 -0
- package/lib/web/refresh-npm-token.js +52 -13
- package/lib/web/unleash.js +5 -4
- package/package.json +13 -13
- package/src/bash-funcs +10 -4
- package/src/dockreate +1 -0
- package/src/{getjson.js → getjson.mjs} +3 -3
- package/src/helm-charts/velero/helmup.plugin +1 -1
- package/src/{helmup → helmup.sh} +20 -20
- package/src/overwhelm.js +11 -20
- package/src/{push-my-chart → push-my-chart.mjs} +3 -3
- package/src/refresh-npm-token.mjs +49 -18
- package/src/{unleash.js → unleash.mjs} +2 -2
- /package/src/{circleate → circleate.sh} +0 -0
- /package/src/{getfbcfg.js → getfbcfg.mjs} +0 -0
- /package/src/{k8cryo → k8cryo.sh} +0 -0
- /package/src/{k8scale → k8scale.sh} +0 -0
- /package/src/{k8x → k8x.sh} +0 -0
package/lib/server/getjson.js
CHANGED
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
*/
|
|
21
21
|
"use strict";
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
24
|
+
var _commandLineArgs = _interopRequireDefault(require("command-line-args"));
|
|
25
|
+
var _commandLineUsage = _interopRequireDefault(require("command-line-usage"));
|
|
26
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
27
|
/* eslint-disable no-console */
|
|
28
28
|
const optionList = [
|
|
29
29
|
// Use optionList to tie into the Usage statements
|
|
@@ -51,17 +51,17 @@ const sections = [{
|
|
|
51
51
|
header: 'Options',
|
|
52
52
|
optionList
|
|
53
53
|
}];
|
|
54
|
-
const args =
|
|
54
|
+
const args = (0, _commandLineArgs.default)(optionList, {
|
|
55
55
|
partial: true
|
|
56
56
|
});
|
|
57
|
-
const help =
|
|
57
|
+
const help = (0, _commandLineUsage.default)(sections);
|
|
58
58
|
if (!args.file) {
|
|
59
59
|
console.error('\n***ERROR: Missing a --file param\n');
|
|
60
60
|
console.log(help);
|
|
61
61
|
process.exit(1);
|
|
62
62
|
}
|
|
63
63
|
try {
|
|
64
|
-
const json = JSON.parse(
|
|
64
|
+
const json = JSON.parse(_fs.default.readFileSync(args.file, 'utf8'));
|
|
65
65
|
const value = json[args.key];
|
|
66
66
|
const match = new RegExp(args.regex || '.*').exec(value);
|
|
67
67
|
console.log(match ? match[match.length - 1] : '');
|
package/lib/server/overwhelm.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
//XXX console.log( `TOP=>[${process.cwd()}] PWD=[${process.env.PWD}]` )
|
|
3
|
+
// XXX console.log( `TOP=>[${process.cwd()}] PWD=[${process.env.PWD}]` )
|
|
4
4
|
/* eslint-disable no-console */
|
|
5
5
|
"use strict";
|
|
6
6
|
|
|
7
7
|
const path = require('node:path');
|
|
8
|
+
const exec = require('node:child_process').execSync;
|
|
9
|
+
const fs = require('node:fs');
|
|
8
10
|
const chalk = require('chalk');
|
|
9
11
|
const cliArgs = require('command-line-args');
|
|
10
12
|
// const cliHelp = require( 'command-line-usage' )
|
|
11
13
|
const deepmerge = require('deepmerge');
|
|
12
|
-
const exec = require('child_process').execSync;
|
|
13
|
-
const fs = require('fs');
|
|
14
14
|
const glob = require('glob');
|
|
15
15
|
const parse = require('parse-gitignore');
|
|
16
16
|
const ask = require('readline-sync');
|
|
@@ -146,8 +146,8 @@ if (!cfgs) {
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
// Check to see if we are deriving from another configuration.
|
|
149
|
-
if (cfgs
|
|
150
|
-
const baseName = cfgs
|
|
149
|
+
if (cfgs.PROJECT_BASE) {
|
|
150
|
+
const baseName = cfgs.PROJECT_BASE;
|
|
151
151
|
const tempCfgs = cfgs;
|
|
152
152
|
cfgs = yaml[baseName];
|
|
153
153
|
Object.keys(tempCfgs).forEach(key => {
|
|
@@ -362,7 +362,7 @@ if (over.PROJECT_NAME === 'minikube') {
|
|
|
362
362
|
process.exit(0);
|
|
363
363
|
}
|
|
364
364
|
const projectId = over.PROJECT_ID;
|
|
365
|
-
let zone = over
|
|
365
|
+
let zone = over.GCE_REGION + (over.GCE_ZONE ? `-${over.GCE_ZONE}` : '');
|
|
366
366
|
if (!clusterName) {
|
|
367
367
|
console.log(chalk.yellow(`
|
|
368
368
|
|
|
@@ -392,17 +392,6 @@ try {
|
|
|
392
392
|
const currentCtx = kubeout.toString().trim();
|
|
393
393
|
let desiredCtx = `gke_${projectId}_${zone}_${clusterName}`;
|
|
394
394
|
let cmd = `gcloud container clusters get-credentials ${clusterName} --zone ${zone} --project ${projectId}`;
|
|
395
|
-
|
|
396
|
-
// Check if we are using AWS
|
|
397
|
-
if (cfgs.CLOUD === 'aws') {
|
|
398
|
-
const awsAcctId = cfgs['AWS_ACCT_ID'];
|
|
399
|
-
zone = over['AWS_REGION'];
|
|
400
|
-
desiredCtx = `arn:aws:eks:${zone}:${awsAcctId}:cluster/${clusterName}`;
|
|
401
|
-
cmd = `aws eks --region ${zone} update-kubeconfig --name ${clusterName}`;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
// TODO - FETCH AWS CLUSTER CREDENTIALS
|
|
405
|
-
|
|
406
395
|
const matchedCtx = currentCtx === desiredCtx;
|
|
407
396
|
if (args.matchk8s) {
|
|
408
397
|
process.exit(matchedCtx ? 0 : 1);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var _execa = _interopRequireDefault(require("execa"));
|
|
5
|
+
var _semver = require("semver");
|
|
6
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
7
|
+
const pushItGood = async () => {
|
|
8
|
+
const version = await (0, _execa.default)('helm', ['version', '--short']);
|
|
9
|
+
const pusher = (0, _semver.lt)(version.stdout, '3.7.0') ? 'push' : 'cm-push';
|
|
10
|
+
try {
|
|
11
|
+
const museum = await (0, _execa.default)('helm', [pusher, 'helm', 'leverege']);
|
|
12
|
+
console.log(museum.stdout);
|
|
13
|
+
} catch (ex) {
|
|
14
|
+
console.log(ex.stderr);
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
pushItGood();
|
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
/*
|
|
3
|
+
* refresh-npm-token will check the access time of the $HOME/.npmrc npm token
|
|
4
|
+
* file and if it is older than 24 hours then it will be updated to whatever
|
|
5
|
+
* value is currently in the NPM_DEVELOPER_SECRET on leverege-artifacts. It
|
|
6
|
+
* will also check to see if the deprecated $HOME/.npmrc.ro file exists and
|
|
7
|
+
* will suggest to the user to remove it. If either of the token files exist
|
|
8
|
+
* the first 6 and last four characters of the token will be extracted and
|
|
9
|
+
* reported via slack to allow DevOps operators to clean up old tokens in npm.
|
|
10
|
+
*
|
|
11
|
+
* For testing the Unix touch command may be used to modify the access access
|
|
12
|
+
* time of the npmrc token. The REFRESH_NPM_TOKEN_DEBUG env variable may also
|
|
13
|
+
* be set to enable debugging and disable the slack channel spam.
|
|
14
|
+
*
|
|
15
|
+
* touch -d 2023-08-20 ~/.npmrc; REFRESH_NPM_TOKEN_DEBUG=1 refresh-npm-token.mjs
|
|
16
|
+
*/
|
|
17
|
+
|
|
2
18
|
/* eslint-disable security/detect-non-literal-fs-filename */
|
|
3
19
|
"use strict";
|
|
4
20
|
|
|
@@ -6,13 +22,24 @@ var _nodeFs = _interopRequireDefault(require("node:fs"));
|
|
|
6
22
|
var _nodeOs = _interopRequireDefault(require("node:os"));
|
|
7
23
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
8
24
|
var _execa = _interopRequireDefault(require("execa"));
|
|
25
|
+
var _semver = require("semver");
|
|
9
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
27
|
// we can't use $ until we upgrade to ESM execa
|
|
28
|
+
if ((0, _semver.lt)(process.version, '18.0.0')) {
|
|
29
|
+
console.log(_chalk.default.red('\n\n***ERROR: must be running at least node 18\n'));
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
|
|
11
33
|
// max age in seconds of the npmrc file before refresh
|
|
12
34
|
const refreshThreshold = 3600 * 24; // 1 day
|
|
13
35
|
|
|
14
36
|
// eslint-disable-next-line no-console
|
|
15
37
|
const log = console.log;
|
|
38
|
+
const debug = (obj, text) => {
|
|
39
|
+
if (process.env.REFRESH_NPM_TOKEN_DEBUG) {
|
|
40
|
+
log(obj, _chalk.default.yellow(text));
|
|
41
|
+
}
|
|
42
|
+
};
|
|
16
43
|
const fetchToken = filename => {
|
|
17
44
|
const results = {
|
|
18
45
|
filename,
|
|
@@ -43,8 +70,10 @@ const fetchToken = filename => {
|
|
|
43
70
|
// fetch the tokens - note the RO token is deprecated and may not exist
|
|
44
71
|
const npmrc = fetchToken(`${_nodeOs.default.homedir()}/.npmrc`);
|
|
45
72
|
const npmrcRo = fetchToken(`${_nodeOs.default.homedir()}/.npmrc.ro`);
|
|
46
|
-
|
|
47
|
-
|
|
73
|
+
debug({
|
|
74
|
+
npmrc,
|
|
75
|
+
npmrcRo
|
|
76
|
+
}, '<==Your current tokens'); // debug
|
|
48
77
|
|
|
49
78
|
if (npmrc.exists && npmrc.lastUpdated < refreshThreshold) {
|
|
50
79
|
process.exit(0);
|
|
@@ -52,11 +81,14 @@ if (npmrc.exists && npmrc.lastUpdated < refreshThreshold) {
|
|
|
52
81
|
|
|
53
82
|
// fetch the contents of the npmrc secret stored on leverege-registry
|
|
54
83
|
let npmrcSecret;
|
|
84
|
+
const execaOpts = ['secrets', 'versions', 'access', 'latest', '--secret=NPM_DEVELOPER_NPMRC', '--project=leverege-registry'];
|
|
55
85
|
try {
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
86
|
+
const execaOut = await (0, _execa.default)('gcloud', execaOpts);
|
|
87
|
+
npmrcSecret = execaOut.stdout;
|
|
88
|
+
debug({
|
|
89
|
+
execaOut,
|
|
90
|
+
execaOpts
|
|
91
|
+
}, '<==exec info'); // debug
|
|
60
92
|
} catch (err) {
|
|
61
93
|
log(_chalk.default.yellow(`\nFailed Command => [${err.escapedCommand}]\n\n`), _chalk.default.red(err.stderr));
|
|
62
94
|
process.exit(1);
|
|
@@ -81,13 +113,20 @@ const slackData = {
|
|
|
81
113
|
text: `--- npmrc refreshed by \`${process.env.USER}\` at ${now}\n tokens RW [\`${npmrc.token}\`] RO [\`${npmrcRo.token}\`]`,
|
|
82
114
|
channel: '#dev-ops-helm'
|
|
83
115
|
};
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
116
|
+
if (process.env.REFRESH_NPM_TOKEN_DEBUG) {
|
|
117
|
+
log({
|
|
118
|
+
slackURL,
|
|
119
|
+
slackData
|
|
120
|
+
}, '<==Slack skipped');
|
|
121
|
+
} else {
|
|
122
|
+
fetch(slackURL, {
|
|
123
|
+
method: 'POST',
|
|
124
|
+
body: JSON.stringify(slackData),
|
|
125
|
+
headers: {
|
|
126
|
+
'Content-Type': 'application/json'
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
91
130
|
if (npmrcRo.exists) {
|
|
92
131
|
log(_chalk.default.red('\nWARNING - the need for the ~/.npmrc.ro file has been eliminated - please remove'));
|
|
93
132
|
process.exit(1);
|
package/lib/server/unleash.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
var _execa = _interopRequireDefault(require("execa"));
|
|
5
|
+
var _simpleGit = _interopRequireDefault(require("simple-git"));
|
|
6
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
7
|
+
const git = new _simpleGit.default();
|
|
7
8
|
const getCurrentBranchName = async () => {
|
|
8
9
|
const branchInfo = await git.branch();
|
|
9
10
|
|
|
@@ -28,7 +29,7 @@ const isProtected = async () => {
|
|
|
28
29
|
};
|
|
29
30
|
const npmRunner = async script => {
|
|
30
31
|
try {
|
|
31
|
-
const results = await
|
|
32
|
+
const results = await (0, _execa.default)('npm', ['run', script], {
|
|
32
33
|
stdio: 'inherit'
|
|
33
34
|
});
|
|
34
35
|
return results;
|
package/lib/web/getjson.js
CHANGED
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
*/
|
|
21
21
|
"use strict";
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
24
|
+
var _commandLineArgs = _interopRequireDefault(require("command-line-args"));
|
|
25
|
+
var _commandLineUsage = _interopRequireDefault(require("command-line-usage"));
|
|
26
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
27
|
/* eslint-disable no-console */
|
|
28
28
|
const optionList = [
|
|
29
29
|
// Use optionList to tie into the Usage statements
|
|
@@ -51,17 +51,17 @@ const sections = [{
|
|
|
51
51
|
header: 'Options',
|
|
52
52
|
optionList
|
|
53
53
|
}];
|
|
54
|
-
const args =
|
|
54
|
+
const args = (0, _commandLineArgs.default)(optionList, {
|
|
55
55
|
partial: true
|
|
56
56
|
});
|
|
57
|
-
const help =
|
|
57
|
+
const help = (0, _commandLineUsage.default)(sections);
|
|
58
58
|
if (!args.file) {
|
|
59
59
|
console.error('\n***ERROR: Missing a --file param\n');
|
|
60
60
|
console.log(help);
|
|
61
61
|
process.exit(1);
|
|
62
62
|
}
|
|
63
63
|
try {
|
|
64
|
-
const json = JSON.parse(
|
|
64
|
+
const json = JSON.parse(_fs.default.readFileSync(args.file, 'utf8'));
|
|
65
65
|
const value = json[args.key];
|
|
66
66
|
const match = new RegExp(args.regex || '.*').exec(value);
|
|
67
67
|
console.log(match ? match[match.length - 1] : '');
|
package/lib/web/overwhelm.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
//XXX console.log( `TOP=>[${process.cwd()}] PWD=[${process.env.PWD}]` )
|
|
3
|
+
// XXX console.log( `TOP=>[${process.cwd()}] PWD=[${process.env.PWD}]` )
|
|
4
4
|
/* eslint-disable no-console */
|
|
5
5
|
"use strict";
|
|
6
6
|
|
|
7
7
|
const path = require('node:path');
|
|
8
|
+
const exec = require('node:child_process').execSync;
|
|
9
|
+
const fs = require('node:fs');
|
|
8
10
|
const chalk = require('chalk');
|
|
9
11
|
const cliArgs = require('command-line-args');
|
|
10
12
|
// const cliHelp = require( 'command-line-usage' )
|
|
11
13
|
const deepmerge = require('deepmerge');
|
|
12
|
-
const exec = require('child_process').execSync;
|
|
13
|
-
const fs = require('fs');
|
|
14
14
|
const glob = require('glob');
|
|
15
15
|
const parse = require('parse-gitignore');
|
|
16
16
|
const ask = require('readline-sync');
|
|
@@ -146,8 +146,8 @@ if (!cfgs) {
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
// Check to see if we are deriving from another configuration.
|
|
149
|
-
if (cfgs
|
|
150
|
-
const baseName = cfgs
|
|
149
|
+
if (cfgs.PROJECT_BASE) {
|
|
150
|
+
const baseName = cfgs.PROJECT_BASE;
|
|
151
151
|
const tempCfgs = cfgs;
|
|
152
152
|
cfgs = yaml[baseName];
|
|
153
153
|
Object.keys(tempCfgs).forEach(key => {
|
|
@@ -362,7 +362,7 @@ if (over.PROJECT_NAME === 'minikube') {
|
|
|
362
362
|
process.exit(0);
|
|
363
363
|
}
|
|
364
364
|
const projectId = over.PROJECT_ID;
|
|
365
|
-
let zone = over
|
|
365
|
+
let zone = over.GCE_REGION + (over.GCE_ZONE ? `-${over.GCE_ZONE}` : '');
|
|
366
366
|
if (!clusterName) {
|
|
367
367
|
console.log(chalk.yellow(`
|
|
368
368
|
|
|
@@ -392,17 +392,6 @@ try {
|
|
|
392
392
|
const currentCtx = kubeout.toString().trim();
|
|
393
393
|
let desiredCtx = `gke_${projectId}_${zone}_${clusterName}`;
|
|
394
394
|
let cmd = `gcloud container clusters get-credentials ${clusterName} --zone ${zone} --project ${projectId}`;
|
|
395
|
-
|
|
396
|
-
// Check if we are using AWS
|
|
397
|
-
if (cfgs.CLOUD === 'aws') {
|
|
398
|
-
const awsAcctId = cfgs['AWS_ACCT_ID'];
|
|
399
|
-
zone = over['AWS_REGION'];
|
|
400
|
-
desiredCtx = `arn:aws:eks:${zone}:${awsAcctId}:cluster/${clusterName}`;
|
|
401
|
-
cmd = `aws eks --region ${zone} update-kubeconfig --name ${clusterName}`;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
// TODO - FETCH AWS CLUSTER CREDENTIALS
|
|
405
|
-
|
|
406
395
|
const matchedCtx = currentCtx === desiredCtx;
|
|
407
396
|
if (args.matchk8s) {
|
|
408
397
|
process.exit(matchedCtx ? 0 : 1);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var _execa = _interopRequireDefault(require("execa"));
|
|
5
|
+
var _semver = require("semver");
|
|
6
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
7
|
+
const pushItGood = async () => {
|
|
8
|
+
const version = await (0, _execa.default)('helm', ['version', '--short']);
|
|
9
|
+
const pusher = (0, _semver.lt)(version.stdout, '3.7.0') ? 'push' : 'cm-push';
|
|
10
|
+
try {
|
|
11
|
+
const museum = await (0, _execa.default)('helm', [pusher, 'helm', 'leverege']);
|
|
12
|
+
console.log(museum.stdout);
|
|
13
|
+
} catch (ex) {
|
|
14
|
+
console.log(ex.stderr);
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
pushItGood();
|
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
/*
|
|
3
|
+
* refresh-npm-token will check the access time of the $HOME/.npmrc npm token
|
|
4
|
+
* file and if it is older than 24 hours then it will be updated to whatever
|
|
5
|
+
* value is currently in the NPM_DEVELOPER_SECRET on leverege-artifacts. It
|
|
6
|
+
* will also check to see if the deprecated $HOME/.npmrc.ro file exists and
|
|
7
|
+
* will suggest to the user to remove it. If either of the token files exist
|
|
8
|
+
* the first 6 and last four characters of the token will be extracted and
|
|
9
|
+
* reported via slack to allow DevOps operators to clean up old tokens in npm.
|
|
10
|
+
*
|
|
11
|
+
* For testing the Unix touch command may be used to modify the access access
|
|
12
|
+
* time of the npmrc token. The REFRESH_NPM_TOKEN_DEBUG env variable may also
|
|
13
|
+
* be set to enable debugging and disable the slack channel spam.
|
|
14
|
+
*
|
|
15
|
+
* touch -d 2023-08-20 ~/.npmrc; REFRESH_NPM_TOKEN_DEBUG=1 refresh-npm-token.mjs
|
|
16
|
+
*/
|
|
17
|
+
|
|
2
18
|
/* eslint-disable security/detect-non-literal-fs-filename */
|
|
3
19
|
"use strict";
|
|
4
20
|
|
|
@@ -6,13 +22,24 @@ var _nodeFs = _interopRequireDefault(require("node:fs"));
|
|
|
6
22
|
var _nodeOs = _interopRequireDefault(require("node:os"));
|
|
7
23
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
8
24
|
var _execa = _interopRequireDefault(require("execa"));
|
|
25
|
+
var _semver = require("semver");
|
|
9
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
27
|
// we can't use $ until we upgrade to ESM execa
|
|
28
|
+
if ((0, _semver.lt)(process.version, '18.0.0')) {
|
|
29
|
+
console.log(_chalk.default.red('\n\n***ERROR: must be running at least node 18\n'));
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
|
|
11
33
|
// max age in seconds of the npmrc file before refresh
|
|
12
34
|
const refreshThreshold = 3600 * 24; // 1 day
|
|
13
35
|
|
|
14
36
|
// eslint-disable-next-line no-console
|
|
15
37
|
const log = console.log;
|
|
38
|
+
const debug = (obj, text) => {
|
|
39
|
+
if (process.env.REFRESH_NPM_TOKEN_DEBUG) {
|
|
40
|
+
log(obj, _chalk.default.yellow(text));
|
|
41
|
+
}
|
|
42
|
+
};
|
|
16
43
|
const fetchToken = filename => {
|
|
17
44
|
const results = {
|
|
18
45
|
filename,
|
|
@@ -43,8 +70,10 @@ const fetchToken = filename => {
|
|
|
43
70
|
// fetch the tokens - note the RO token is deprecated and may not exist
|
|
44
71
|
const npmrc = fetchToken(`${_nodeOs.default.homedir()}/.npmrc`);
|
|
45
72
|
const npmrcRo = fetchToken(`${_nodeOs.default.homedir()}/.npmrc.ro`);
|
|
46
|
-
|
|
47
|
-
|
|
73
|
+
debug({
|
|
74
|
+
npmrc,
|
|
75
|
+
npmrcRo
|
|
76
|
+
}, '<==Your current tokens'); // debug
|
|
48
77
|
|
|
49
78
|
if (npmrc.exists && npmrc.lastUpdated < refreshThreshold) {
|
|
50
79
|
process.exit(0);
|
|
@@ -52,11 +81,14 @@ if (npmrc.exists && npmrc.lastUpdated < refreshThreshold) {
|
|
|
52
81
|
|
|
53
82
|
// fetch the contents of the npmrc secret stored on leverege-registry
|
|
54
83
|
let npmrcSecret;
|
|
84
|
+
const execaOpts = ['secrets', 'versions', 'access', 'latest', '--secret=NPM_DEVELOPER_NPMRC', '--project=leverege-registry'];
|
|
55
85
|
try {
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
86
|
+
const execaOut = await (0, _execa.default)('gcloud', execaOpts);
|
|
87
|
+
npmrcSecret = execaOut.stdout;
|
|
88
|
+
debug({
|
|
89
|
+
execaOut,
|
|
90
|
+
execaOpts
|
|
91
|
+
}, '<==exec info'); // debug
|
|
60
92
|
} catch (err) {
|
|
61
93
|
log(_chalk.default.yellow(`\nFailed Command => [${err.escapedCommand}]\n\n`), _chalk.default.red(err.stderr));
|
|
62
94
|
process.exit(1);
|
|
@@ -81,13 +113,20 @@ const slackData = {
|
|
|
81
113
|
text: `--- npmrc refreshed by \`${process.env.USER}\` at ${now}\n tokens RW [\`${npmrc.token}\`] RO [\`${npmrcRo.token}\`]`,
|
|
82
114
|
channel: '#dev-ops-helm'
|
|
83
115
|
};
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
116
|
+
if (process.env.REFRESH_NPM_TOKEN_DEBUG) {
|
|
117
|
+
log({
|
|
118
|
+
slackURL,
|
|
119
|
+
slackData
|
|
120
|
+
}, '<==Slack skipped');
|
|
121
|
+
} else {
|
|
122
|
+
fetch(slackURL, {
|
|
123
|
+
method: 'POST',
|
|
124
|
+
body: JSON.stringify(slackData),
|
|
125
|
+
headers: {
|
|
126
|
+
'Content-Type': 'application/json'
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
91
130
|
if (npmrcRo.exists) {
|
|
92
131
|
log(_chalk.default.red('\nWARNING - the need for the ~/.npmrc.ro file has been eliminated - please remove'));
|
|
93
132
|
process.exit(1);
|
package/lib/web/unleash.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
var _execa = _interopRequireDefault(require("execa"));
|
|
5
|
+
var _simpleGit = _interopRequireDefault(require("simple-git"));
|
|
6
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
7
|
+
const git = new _simpleGit.default();
|
|
7
8
|
const getCurrentBranchName = async () => {
|
|
8
9
|
const branchInfo = await git.branch();
|
|
9
10
|
|
|
@@ -28,7 +29,7 @@ const isProtected = async () => {
|
|
|
28
29
|
};
|
|
29
30
|
const npmRunner = async script => {
|
|
30
31
|
try {
|
|
31
|
-
const results = await
|
|
32
|
+
const results = await (0, _execa.default)('npm', ['run', script], {
|
|
32
33
|
stdio: 'inherit'
|
|
33
34
|
});
|
|
34
35
|
return results;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leverege/build-tools",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.38.0-john.1",
|
|
4
4
|
"description": "A collection of build / support tools for Leverege developers",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -19,24 +19,24 @@
|
|
|
19
19
|
},
|
|
20
20
|
"bin": {
|
|
21
21
|
"build-tools": "src/build-tools.js",
|
|
22
|
-
"circleate": "src/circleate",
|
|
22
|
+
"circleate": "src/circleate.sh",
|
|
23
23
|
"decrypt-secrets": "src/decrypt-secrets",
|
|
24
24
|
"dirty-git": "src/dirty-git",
|
|
25
25
|
"dockreate": "src/dockreate",
|
|
26
26
|
"encrypt-secrets": "src/encrypt-secrets",
|
|
27
27
|
"firebaseDeploy": "src/firebaseDeploy.mjs",
|
|
28
28
|
"firebaseServe": "src/firebaseServe.mjs",
|
|
29
|
-
"getfbcfg": "src/getfbcfg.
|
|
30
|
-
"getjson": "src/getjson.
|
|
29
|
+
"getfbcfg": "src/getfbcfg.mjs",
|
|
30
|
+
"getjson": "src/getjson.mjs",
|
|
31
31
|
"git-tar": "src/git-tar",
|
|
32
32
|
"helmdn": "src/helmdn",
|
|
33
|
-
"helmup": "src/helmup",
|
|
34
|
-
"helminit": "src/helmup",
|
|
35
|
-
"helmwhat": "src/helmup",
|
|
36
|
-
"k8cryo": "src/k8cryo",
|
|
37
|
-
"k8scale": "src/k8scale",
|
|
38
|
-
"k8thaw": "src/k8cryo",
|
|
39
|
-
"k8x": "src/k8x",
|
|
33
|
+
"helmup": "src/helmup.sh",
|
|
34
|
+
"helminit": "src/helmup.sh",
|
|
35
|
+
"helmwhat": "src/helmup.sh",
|
|
36
|
+
"k8cryo": "src/k8cryo.sh",
|
|
37
|
+
"k8scale": "src/k8scale.sh",
|
|
38
|
+
"k8thaw": "src/k8cryo.sh",
|
|
39
|
+
"k8x": "src/k8x.sh",
|
|
40
40
|
"klog": "src/klog",
|
|
41
41
|
"npm-link": "src/npm-link",
|
|
42
42
|
"npm-unlink": "src/npm-unlink",
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"pkglint": "src/pkglint",
|
|
46
46
|
"prune-git": "src/prune-git",
|
|
47
47
|
"pull-git": "src/pull-git",
|
|
48
|
-
"push-my-chart": "src/push-my-chart",
|
|
48
|
+
"push-my-chart": "src/push-my-chart.mjs",
|
|
49
49
|
"refresh-npm-token": "src/refresh-npm-token.mjs",
|
|
50
50
|
"tag-release": "src/tag-release.mjs",
|
|
51
|
-
"unleash": "src/unleash.
|
|
51
|
+
"unleash": "src/unleash.mjs"
|
|
52
52
|
},
|
|
53
53
|
"author": "Leverege Devs",
|
|
54
54
|
"license": "SEE LICENSE IN LICENSE.md",
|
package/src/bash-funcs
CHANGED
|
@@ -5,6 +5,12 @@
|
|
|
5
5
|
# and can now be easily added to a script via bash sourcing:
|
|
6
6
|
# . `build-tools --bashfun`
|
|
7
7
|
|
|
8
|
+
# Typically /dev/null is used to redirect the noise but sometimes we need to
|
|
9
|
+
# see exactly what certain commands are complaining about. Running any of the
|
|
10
|
+
# build-tools with BUILD_TOOLS_DEBUG=1 will redirect the noise to stdout.
|
|
11
|
+
DEVNULL="/dev/null"
|
|
12
|
+
[ ! -z "BUILD_TOOLS_DEBUG" ] && DEVNULL="/dev/stdout" && printf "\n***BUILD_TOOLS_DEBUG DEVNULL=>$DEVNULL\n"
|
|
13
|
+
|
|
8
14
|
# Simple ANSI color coded string generator.
|
|
9
15
|
function color() {
|
|
10
16
|
local color=
|
|
@@ -121,13 +127,13 @@ function addHelmRepo() {
|
|
|
121
127
|
Adding helm repo => $(color g "$chart") from $(color g "$url")
|
|
122
128
|
|
|
123
129
|
REPOADD
|
|
124
|
-
helm repo add --force-update $chart $url &>
|
|
125
|
-
helm repo update &>
|
|
130
|
+
helm repo add --force-update $chart $url &> $DEVNULL
|
|
131
|
+
helm repo update &> $DEVNULL
|
|
126
132
|
}
|
|
127
133
|
|
|
128
134
|
function removeHelmRepo(){
|
|
129
135
|
[ ! -z "$SKIP_RM_HELM_REPO" ] && return
|
|
130
|
-
helm repo remove $1
|
|
136
|
+
helm repo remove $1 &> $DEVNULL
|
|
131
137
|
}
|
|
132
138
|
|
|
133
139
|
# initial use for logging helm activities
|
|
@@ -141,5 +147,5 @@ function postToSlack() {
|
|
|
141
147
|
|
|
142
148
|
curl -X POST -H 'Content-type: application/json' \
|
|
143
149
|
--data "{\"text\":\"$slackmsg\",\"channel\":\"$channel\"}" \
|
|
144
|
-
"$slackURL"
|
|
150
|
+
"$slackURL" &> $DEVNULL
|
|
145
151
|
}
|
package/src/dockreate
CHANGED
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
/**
|
|
19
19
|
* Get a command line switch parser.
|
|
20
20
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
import fs from 'fs'
|
|
22
|
+
import cliArgs from 'command-line-args'
|
|
23
|
+
import cliHelp from 'command-line-usage'
|
|
24
24
|
|
|
25
25
|
/* eslint-disable no-console */
|
|
26
26
|
const optionList = [ // Use optionList to tie into the Usage statements
|
|
@@ -4,7 +4,7 @@ showInstalling "Velero Backup System"
|
|
|
4
4
|
|
|
5
5
|
addHelmRepo vmware-tanzu https://vmware-tanzu.github.io/helm-charts
|
|
6
6
|
|
|
7
|
-
[ -z "$VELERO_CHART_VERSION" ] && VELERO_CHART_VERSION="
|
|
7
|
+
[ -z "$VELERO_CHART_VERSION" ] && VELERO_CHART_VERSION="5"
|
|
8
8
|
#
|
|
9
9
|
# Build the bucket, region and SA email variables and use --set to mod the
|
|
10
10
|
# chart values as opposed to using an OVH:<label> approach. This eliminates
|
package/src/{helmup → helmup.sh}
RENAMED
|
@@ -80,7 +80,7 @@ WORKLOAD_ID
|
|
|
80
80
|
|
|
81
81
|
# Verify the Kubernetes SA and create it if necessary
|
|
82
82
|
printf "\nChecking for the $NAMESPACE/$SVC_ACCT k8s SA\n"
|
|
83
|
-
kubectl get sa -n $NAMESPACE $SVC_ACCT
|
|
83
|
+
kubectl get sa -n $NAMESPACE $SVC_ACCT &> $DEVNULL
|
|
84
84
|
if [[ $? -eq 1 ]];
|
|
85
85
|
then
|
|
86
86
|
printf "Creating the k8s $SVC_ACCT SA in $NAMESPACE\n"
|
|
@@ -101,7 +101,7 @@ function generatePassword() {
|
|
|
101
101
|
|
|
102
102
|
function createNamespaceIfNeeded() {
|
|
103
103
|
# Check the namespace exists in kubernetes
|
|
104
|
-
kubectl get namespace $1 &>
|
|
104
|
+
kubectl get namespace $1 &> $DEVNULL
|
|
105
105
|
if [[ $? -eq 1 ]];
|
|
106
106
|
then
|
|
107
107
|
printf "\n*** Creating $1 namespace ***\n\n"
|
|
@@ -155,7 +155,7 @@ MISSING_HELMUP_PLUGIN
|
|
|
155
155
|
|
|
156
156
|
function errorIfMissingSecret() {
|
|
157
157
|
SECRET="$1"
|
|
158
|
-
kubectl get secret $SECRET &>
|
|
158
|
+
kubectl get secret $SECRET &> $DEVNULL
|
|
159
159
|
if [[ $? = 1 || SECRET = "" ]];
|
|
160
160
|
then
|
|
161
161
|
errorExit "missing secret `color y $SECRET` - did you `color g 'service-man --new-k8s'` ?"
|
|
@@ -176,9 +176,9 @@ function installStackdriverExporterEnvironment() {
|
|
|
176
176
|
|
|
177
177
|
# guarantee any previous remnants of the exporter are gone
|
|
178
178
|
printf "\n*** Removing the previous $SDEXP_SA installation...\n"
|
|
179
|
-
helm uninstall -n $SDEXP_NS $SDEXP_SA &>
|
|
180
|
-
kubectl delete serviceaccounts -n $SDEXP_NS $SDEXP_SA &>
|
|
181
|
-
gcloud --quiet iam service-accounts delete $SDEXP_EM &>
|
|
179
|
+
helm uninstall -n $SDEXP_NS $SDEXP_SA &> $DEVNULL
|
|
180
|
+
kubectl delete serviceaccounts -n $SDEXP_NS $SDEXP_SA &> $DEVNULL
|
|
181
|
+
gcloud --quiet iam service-accounts delete $SDEXP_EM &> $DEVNULL
|
|
182
182
|
|
|
183
183
|
# NOTE: The k8s SA != GCP SA - the former is created by the helm chart
|
|
184
184
|
# that installs the stackdriver-exporter, the latter is handled here in
|
|
@@ -188,13 +188,13 @@ function installStackdriverExporterEnvironment() {
|
|
|
188
188
|
printf "\n*** Creating GCP SA with $SDEXP_NS/viewer ***\n"
|
|
189
189
|
gcloud iam service-accounts create $SDEXP_SA \
|
|
190
190
|
--project "$GCP_PROJECT_ID" \
|
|
191
|
-
--display-name "Prometheus Stackdriver Exporter"
|
|
191
|
+
--display-name "Prometheus Stackdriver Exporter" &> $DEVNULL
|
|
192
192
|
warnOnError $? "the GCP SA $SDEXP_SA may already exist"
|
|
193
193
|
|
|
194
194
|
printf "\n*** Binding IAM role of $SDEXP_NS viewer to $SDEXP_SA in $GCP_PROJECT_ID\n"
|
|
195
195
|
gcloud projects add-iam-policy-binding "$GCP_PROJECT_ID" \
|
|
196
196
|
--role "roles/$SDEXP_NS.viewer" \
|
|
197
|
-
--member "serviceAccount:$SDEXP_EM"
|
|
197
|
+
--member "serviceAccount:$SDEXP_EM" &> $DEVNULL
|
|
198
198
|
sleep 2 # give the IAM binding a chance to complete before moving on
|
|
199
199
|
|
|
200
200
|
bindWorkloadIdentity $SDEXP_SA $SDEXP_NS
|
|
@@ -289,7 +289,7 @@ function installPreemptibleKiller() {
|
|
|
289
289
|
printf "\nBinding the IAM role to the $SVC_ACCT SA\n"
|
|
290
290
|
gcloud projects add-iam-policy-binding $GCP_PROJECT_ID \
|
|
291
291
|
--member=serviceAccount:${service_account_email} \
|
|
292
|
-
--role=projects/${GCP_PROJECT_ID}/roles/preemptibleKiller &>
|
|
292
|
+
--role=projects/${GCP_PROJECT_ID}/roles/preemptibleKiller &> $DEVNULL
|
|
293
293
|
warnOnError $? "Binding may have failed or it already exists"
|
|
294
294
|
|
|
295
295
|
bindWorkloadIdentity $SVC_ACCT $NAMESPACE
|
|
@@ -368,7 +368,7 @@ function installCertManagerSecret() {
|
|
|
368
368
|
createNamespaceIfNeeded cert-manager
|
|
369
369
|
|
|
370
370
|
local NSPACE="default"
|
|
371
|
-
kubectl get secret cloudflare --namespace $NSPACE
|
|
371
|
+
kubectl get secret cloudflare --namespace $NSPACE &> $DEVNULL
|
|
372
372
|
if [[ $? -eq 1 ]];
|
|
373
373
|
then
|
|
374
374
|
cat<<NEED_MANAGED_SECRET
|
|
@@ -399,13 +399,13 @@ function installVeleroEnvironment() {
|
|
|
399
399
|
gcloud config set project $GCP_PROJECT_ID
|
|
400
400
|
|
|
401
401
|
## The major chart version will determine the bucket suffix
|
|
402
|
-
[ -z "$VELERO_HELM_CHART" ] && VELERO_HELM_CHART="
|
|
402
|
+
[ -z "$VELERO_HELM_CHART" ] && VELERO_HELM_CHART="5"
|
|
403
403
|
|
|
404
404
|
## Create a bucket
|
|
405
405
|
BUCKET="$GCP_PROJECT_ID-velero-$VELERO_HELM_CHART"
|
|
406
406
|
GCE_REGION=`overwhelm -k GCE_REGION`
|
|
407
407
|
printf "\nCreating storage bucket `color g $BUCKET` in `color g $GCE_REGION`\n"
|
|
408
|
-
gsutil mb -l $GCE_REGION gs://$BUCKET/ &>
|
|
408
|
+
gsutil mb -l $GCE_REGION gs://$BUCKET/ &> $DEVNULL
|
|
409
409
|
warnOnError $? "Bucket failed to create or already exists - go check it\n"
|
|
410
410
|
|
|
411
411
|
## Create a service account
|
|
@@ -413,7 +413,7 @@ function installVeleroEnvironment() {
|
|
|
413
413
|
gcloud iam service-accounts create velero \
|
|
414
414
|
--project $GCP_PROJECT_ID \
|
|
415
415
|
--display-name "Velero service account" \
|
|
416
|
-
--description "Velero service account"
|
|
416
|
+
--description "Velero service account" &> $DEVNULL
|
|
417
417
|
if [ $? -eq 0 ];
|
|
418
418
|
then
|
|
419
419
|
# no error means a new SA was created - slight delay to let it update
|
|
@@ -446,7 +446,7 @@ function installVeleroEnvironment() {
|
|
|
446
446
|
gcloud iam roles create velero.server \
|
|
447
447
|
--project $GCP_PROJECT_ID \
|
|
448
448
|
--title "Velero Server" \
|
|
449
|
-
--permissions "$(IFS=","; echo "${ROLE_PERMISSIONS[*]}")"
|
|
449
|
+
--permissions "$(IFS=","; echo "${ROLE_PERMISSIONS[*]}")" &> $DEVNULL
|
|
450
450
|
if [ $? -ne 0 ];
|
|
451
451
|
then
|
|
452
452
|
# assume error is that role exists so try updating instead
|
|
@@ -454,7 +454,7 @@ function installVeleroEnvironment() {
|
|
|
454
454
|
gcloud iam roles update velero.server \
|
|
455
455
|
--project $GCP_PROJECT_ID \
|
|
456
456
|
--title "Velero Server" \
|
|
457
|
-
--permissions "$(IFS=","; echo "${ROLE_PERMISSIONS[*]}")"
|
|
457
|
+
--permissions "$(IFS=","; echo "${ROLE_PERMISSIONS[*]}")" &> $DEVNULL
|
|
458
458
|
fi
|
|
459
459
|
warnOnError $? "Failed to add roles to velero.server - perhaps they already exist?"
|
|
460
460
|
|
|
@@ -463,7 +463,7 @@ function installVeleroEnvironment() {
|
|
|
463
463
|
--project $GCP_PROJECT_ID \
|
|
464
464
|
--member serviceAccount:$SERVICE_ACCOUNT_EMAIL \
|
|
465
465
|
--condition 'None' \
|
|
466
|
-
--role projects/$GCP_PROJECT_ID/roles/velero.server
|
|
466
|
+
--role projects/$GCP_PROJECT_ID/roles/velero.server &> $DEVNULL
|
|
467
467
|
warnOnError $? "gcloud problem binding IAM policy"
|
|
468
468
|
|
|
469
469
|
printf "\nBinding workload identity IAM policy to the SA\n"
|
|
@@ -485,7 +485,7 @@ function installVeleroEnvironment() {
|
|
|
485
485
|
gsutil iam ch serviceAccount:$SERVICE_ACCOUNT_EMAIL:objectAdmin gs://$BUCKET
|
|
486
486
|
|
|
487
487
|
## Clean up from previous failed install
|
|
488
|
-
kubectl delete volumesnapshotlocation.velero.io -n velero gcp
|
|
488
|
+
kubectl delete volumesnapshotlocation.velero.io -n velero gcp &> $DEVNULL
|
|
489
489
|
}
|
|
490
490
|
|
|
491
491
|
# If a helmup.plugin file exists and is executable helmup assumes it is
|
|
@@ -522,7 +522,7 @@ function getServiceAndChartVersion() {
|
|
|
522
522
|
[ ! -z "$CHARTVER" ] && return # service and chart version from CLI
|
|
523
523
|
|
|
524
524
|
# force the move away from the old approach
|
|
525
|
-
LCL_CHART=`compgen -G $SERVICE/Chart-?*.?*.?*`
|
|
525
|
+
LCL_CHART=`compgen -G $SERVICE/Chart-?*.?*.?*` &> $DEVNULL
|
|
526
526
|
if [ ! -z "$LCL_CHART" ];
|
|
527
527
|
then
|
|
528
528
|
CHARTVER=${LCL_CHART#*/Chart-}
|
|
@@ -564,7 +564,7 @@ CHARTVER=
|
|
|
564
564
|
FROM_VERSIONS=
|
|
565
565
|
function doInstall() {
|
|
566
566
|
|
|
567
|
-
helm repo update &>
|
|
567
|
+
helm repo update &> $DEVNULL
|
|
568
568
|
|
|
569
569
|
for PARAM in "$@";
|
|
570
570
|
do
|
|
@@ -786,4 +786,4 @@ overwhelm
|
|
|
786
786
|
GCP_PROJECT_ID="$(getProjectIdFromK8sContext)"
|
|
787
787
|
|
|
788
788
|
doInstall $@
|
|
789
|
-
cd - &>
|
|
789
|
+
cd - &> $DEVNULL
|
package/src/overwhelm.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
//XXX console.log( `TOP=>[${process.cwd()}] PWD=[${process.env.PWD}]` )
|
|
3
|
+
// XXX console.log( `TOP=>[${process.cwd()}] PWD=[${process.env.PWD}]` )
|
|
4
4
|
/* eslint-disable no-console */
|
|
5
5
|
|
|
6
6
|
const path = require( 'node:path' )
|
|
7
|
+
const exec = require( 'node:child_process' ).execSync
|
|
8
|
+
const fs = require( 'node:fs' )
|
|
9
|
+
|
|
7
10
|
const chalk = require( 'chalk' )
|
|
8
11
|
const cliArgs = require( 'command-line-args' )
|
|
9
12
|
// const cliHelp = require( 'command-line-usage' )
|
|
10
13
|
const deepmerge = require( 'deepmerge' )
|
|
11
|
-
const exec = require( 'child_process' ).execSync
|
|
12
|
-
const fs = require( 'fs' )
|
|
13
14
|
const glob = require( 'glob' )
|
|
14
15
|
const parse = require( 'parse-gitignore' )
|
|
15
16
|
const ask = require( 'readline-sync' )
|
|
@@ -36,7 +37,7 @@ const gitTop = exec(
|
|
|
36
37
|
'git rev-parse --show-toplevel', { stdio : [ undefined ] }
|
|
37
38
|
).toString().trim()
|
|
38
39
|
let monoTop
|
|
39
|
-
if( fs.existsSync( `${gitTop}/packages` ) ) {
|
|
40
|
+
if ( fs.existsSync( `${gitTop}/packages` ) ) {
|
|
40
41
|
monoTop = path.basename( path.resolve() ) // process.env.PWD
|
|
41
42
|
console.log( `MONO=[${monoTop}]` )
|
|
42
43
|
}
|
|
@@ -97,8 +98,8 @@ if ( !cfgs ) {
|
|
|
97
98
|
}
|
|
98
99
|
|
|
99
100
|
// Check to see if we are deriving from another configuration.
|
|
100
|
-
if ( cfgs
|
|
101
|
-
const baseName = cfgs
|
|
101
|
+
if ( cfgs.PROJECT_BASE ) {
|
|
102
|
+
const baseName = cfgs.PROJECT_BASE
|
|
102
103
|
const tempCfgs = cfgs
|
|
103
104
|
cfgs = yaml[baseName]
|
|
104
105
|
Object.keys( tempCfgs ).forEach( ( key ) => { cfgs[key] = tempCfgs[key] } )
|
|
@@ -294,21 +295,21 @@ ahoy.forEach( ( dir ) => {
|
|
|
294
295
|
|
|
295
296
|
// we can also apply replaceables to any top level .ovh files to support top level config maps
|
|
296
297
|
glob.sync( '**/*.ovh' ).forEach( ( cfgmap ) => {
|
|
297
|
-
const target = cfgmap.replace(/.ovh$/,'')
|
|
298
|
+
const target = cfgmap.replace( /.ovh$/, '' )
|
|
298
299
|
let valuesOut = fs.readFileSync( cfgmap, { encoding : 'utf-8' } )
|
|
299
300
|
valuesOut = doReplacements( valuesOut, over )
|
|
300
301
|
fs.writeFileSync( target, valuesOut )
|
|
301
302
|
} )
|
|
302
303
|
|
|
303
|
-
if( args.genvals ) { process.exit( 0 ) }
|
|
304
|
+
if ( args.genvals ) { process.exit( 0 ) }
|
|
304
305
|
|
|
305
306
|
// Set the GCP context for safety!
|
|
306
307
|
const clusterName = over.CLUSTER_NAME
|
|
307
308
|
if ( over.PROJECT_NAME === 'minikube' ) {
|
|
308
|
-
process.exit(0)
|
|
309
|
+
process.exit( 0 )
|
|
309
310
|
}
|
|
310
311
|
const projectId = over.PROJECT_ID
|
|
311
|
-
let zone = over
|
|
312
|
+
let zone = over.GCE_REGION + ( over.GCE_ZONE ? `-${over.GCE_ZONE}` : '' )
|
|
312
313
|
|
|
313
314
|
if ( !clusterName ) {
|
|
314
315
|
console.log( chalk.yellow(
|
|
@@ -341,16 +342,6 @@ const currentCtx = kubeout.toString().trim()
|
|
|
341
342
|
let desiredCtx = `gke_${projectId}_${zone}_${clusterName}`
|
|
342
343
|
let cmd = `gcloud container clusters get-credentials ${clusterName} --zone ${zone} --project ${projectId}`
|
|
343
344
|
|
|
344
|
-
// Check if we are using AWS
|
|
345
|
-
if ( cfgs.CLOUD === 'aws' ) {
|
|
346
|
-
const awsAcctId = cfgs['AWS_ACCT_ID']
|
|
347
|
-
zone = over['AWS_REGION']
|
|
348
|
-
desiredCtx = `arn:aws:eks:${zone}:${awsAcctId}:cluster/${clusterName}`
|
|
349
|
-
cmd = `aws eks --region ${zone} update-kubeconfig --name ${clusterName}`
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
// TODO - FETCH AWS CLUSTER CREDENTIALS
|
|
353
|
-
|
|
354
345
|
const matchedCtx = ( currentCtx === desiredCtx )
|
|
355
346
|
|
|
356
347
|
if ( args.matchk8s ) {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import execa from 'execa'
|
|
4
|
+
import { lt as semverLt } from 'semver'
|
|
5
5
|
|
|
6
6
|
const pushItGood = async () => {
|
|
7
7
|
const version = await execa( 'helm', [ 'version', '--short' ] )
|
|
8
8
|
const pusher = ( semverLt( version.stdout, '3.7.0' ) ? 'push' : 'cm-push' )
|
|
9
9
|
|
|
10
10
|
try {
|
|
11
|
-
const museum = await execa
|
|
11
|
+
const museum = await execa( 'helm', [ pusher, 'helm', 'leverege' ] )
|
|
12
12
|
console.log( museum.stdout )
|
|
13
13
|
} catch ( ex ) {
|
|
14
14
|
console.log( ex.stderr )
|
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
/*
|
|
3
|
+
* refresh-npm-token will check the access time of the $HOME/.npmrc npm token
|
|
4
|
+
* file and if it is older than 24 hours then it will be updated to whatever
|
|
5
|
+
* value is currently in the NPM_DEVELOPER_SECRET on leverege-artifacts. It
|
|
6
|
+
* will also check to see if the deprecated $HOME/.npmrc.ro file exists and
|
|
7
|
+
* will suggest to the user to remove it. If either of the token files exist
|
|
8
|
+
* the first 6 and last four characters of the token will be extracted and
|
|
9
|
+
* reported via slack to allow DevOps operators to clean up old tokens in npm.
|
|
10
|
+
*
|
|
11
|
+
* For testing the Unix touch command may be used to modify the access access
|
|
12
|
+
* time of the npmrc token. The REFRESH_NPM_TOKEN_DEBUG env variable may also
|
|
13
|
+
* be set to enable debugging and disable the slack channel spam.
|
|
14
|
+
*
|
|
15
|
+
* touch -d 2023-08-20 ~/.npmrc; REFRESH_NPM_TOKEN_DEBUG=1 refresh-npm-token.mjs
|
|
16
|
+
*/
|
|
17
|
+
|
|
2
18
|
/* eslint-disable security/detect-non-literal-fs-filename */
|
|
3
19
|
import fs from 'node:fs'
|
|
4
20
|
import os from 'node:os'
|
|
@@ -6,11 +22,21 @@ import os from 'node:os'
|
|
|
6
22
|
import chalk from 'chalk'
|
|
7
23
|
import execa from 'execa' // we can't use $ until we upgrade to ESM execa
|
|
8
24
|
|
|
25
|
+
import { lt as semverLt } from 'semver'
|
|
26
|
+
|
|
27
|
+
if ( semverLt ( process.version, '18.0.0' ) ) {
|
|
28
|
+
console.log( chalk.red( '\n\n***ERROR: must be running at least node 18\n' ) )
|
|
29
|
+
process.exit( 1 )
|
|
30
|
+
}
|
|
31
|
+
|
|
9
32
|
// max age in seconds of the npmrc file before refresh
|
|
10
33
|
const refreshThreshold = 3600 * 24 // 1 day
|
|
11
34
|
|
|
12
35
|
// eslint-disable-next-line no-console
|
|
13
36
|
const log = console.log
|
|
37
|
+
const debug = ( obj, text ) => {
|
|
38
|
+
if ( process.env.REFRESH_NPM_TOKEN_DEBUG ) { log( obj, chalk.yellow( text ) ) }
|
|
39
|
+
}
|
|
14
40
|
|
|
15
41
|
const fetchToken = ( filename ) => {
|
|
16
42
|
const results = {
|
|
@@ -43,22 +69,24 @@ const fetchToken = ( filename ) => {
|
|
|
43
69
|
const npmrc = fetchToken( `${os.homedir()}/.npmrc` )
|
|
44
70
|
const npmrcRo = fetchToken( `${os.homedir()}/.npmrc.ro` )
|
|
45
71
|
|
|
46
|
-
|
|
72
|
+
debug( { npmrc, npmrcRo }, '<==Your current tokens' ) // debug
|
|
47
73
|
|
|
48
74
|
if ( npmrc.exists && npmrc.lastUpdated < refreshThreshold ) { process.exit( 0 ) }
|
|
49
75
|
|
|
50
76
|
// fetch the contents of the npmrc secret stored on leverege-registry
|
|
51
77
|
let npmrcSecret
|
|
78
|
+
const execaOpts = [
|
|
79
|
+
'secrets',
|
|
80
|
+
'versions',
|
|
81
|
+
'access',
|
|
82
|
+
'latest',
|
|
83
|
+
'--secret=NPM_DEVELOPER_NPMRC',
|
|
84
|
+
'--project=leverege-registry',
|
|
85
|
+
]
|
|
52
86
|
try {
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
'access',
|
|
57
|
-
'latest',
|
|
58
|
-
'--secret=NPM_DEVELOPER_NPMRC',
|
|
59
|
-
'--project=leverege-registry',
|
|
60
|
-
] )
|
|
61
|
-
npmrcSecret = stdout
|
|
87
|
+
const execaOut = await execa( 'gcloud', execaOpts )
|
|
88
|
+
npmrcSecret = execaOut.stdout
|
|
89
|
+
debug( { execaOut, execaOpts }, '<==exec info' )// debug
|
|
62
90
|
} catch ( err ) {
|
|
63
91
|
log( chalk.yellow( `\nFailed Command => [${err.escapedCommand}]\n\n` ), chalk.red( err.stderr ) )
|
|
64
92
|
process.exit( 1 )
|
|
@@ -85,14 +113,17 @@ const slackData = {
|
|
|
85
113
|
channel : '#dev-ops-helm',
|
|
86
114
|
}
|
|
87
115
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
116
|
+
if ( process.env.REFRESH_NPM_TOKEN_DEBUG ) {
|
|
117
|
+
log( { slackURL, slackData }, '<==Slack skipped' )
|
|
118
|
+
} else {
|
|
119
|
+
fetch( slackURL, {
|
|
120
|
+
method : 'POST',
|
|
121
|
+
body : JSON.stringify( slackData ),
|
|
122
|
+
headers : {
|
|
123
|
+
'Content-Type' : 'application/json',
|
|
124
|
+
},
|
|
125
|
+
} )
|
|
126
|
+
}
|
|
96
127
|
|
|
97
128
|
if ( npmrcRo.exists ) {
|
|
98
129
|
log( chalk.red( '\nWARNING - the need for the ~/.npmrc.ro file has been eliminated - please remove' ) )
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/src/{k8x → k8x.sh}
RENAMED
|
File without changes
|