@leverege/build-tools 2.96.8 → 2.97.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/.vscode/launch.json +21 -1
- package/package.json +10 -10
- package/src/Utils.mjs +6 -1
- package/src/artifacts/Utils.mjs +5 -2
- package/src/build-cnpg-image.mjs +0 -1
- package/src/chart-compass.yaml +1 -1
- package/src/chart-to-registry.mjs +10 -1
- package/src/helm-charts/api-server/values-local.yaml +3 -0
- package/src/helm-charts/cnpg-db-psql-stack/cluster.yaml.ovh +37 -32
- package/src/helm-charts/cnpg-db-psql-stack/pooler.yaml +2 -0
- package/src/helm-charts/cnpg-db-recovery/cluster.yaml.ovh +1 -1
- package/src/helm-charts/cnpg-db-tsdb-basic/cluster.yaml.ovh +50 -46
- package/src/helm-charts/cnpg-db-tsdb-basic/pooler.yaml +2 -0
- package/src/helm-charts/cnpg-db-tsdb-dense/cluster.yaml.ovh +55 -47
- package/src/helm-charts/cnpg-db-tsdb-dense/pooler.yaml +2 -0
- package/src/helm-charts/cnpg-operator/helmup.bootstrap +8 -0
- package/src/helm-charts/cnpg-operator/helmup.plugin +29 -4
- package/src/helm-charts/db-curator/values-local.yaml +9 -1
- package/src/helm-charts/elasticsearch8/elasticsearch-local.yaml +54 -51
- package/src/helm-charts/emailer/values-local.yaml +4 -1
- package/src/helm-charts/messenger/values-local.yaml +1 -5
- package/src/helm-charts/pgbouncer/values-local.yaml +8 -3
- package/src/helm-charts/prom-operator/helmup.bootstrap +8 -5
- package/src/helm-charts/prom-operator/helmup.plugin +1 -1
- package/src/helm-charts/prom-operator/prometheus-stack.yaml.ovh +51 -11
- package/src/helm-charts/prom-operator/rules/elasticsearch-rules.yaml +1 -1
- package/src/helm-charts/prom-operator/rules/kubestate-rules.yaml +1 -1
- package/src/helm-charts/push-notifier/values-local.yaml +8 -0
- package/src/helm-charts/redis/values-local.yaml +2 -1
- package/src/helm-charts/traefik/values-local.yaml +1 -1
- package/src/helm-charts/transponder-dh/values-local.yaml +1 -0
- package/src/helm-charts/transponder-tsdb/values-local.yaml +1 -0
- package/src/helm-charts/velero/helmup.plugin +2 -2
- package/src/helm-charts/velero/values-local.yaml +17 -15
- package/src/helmdn.sh +1 -1
- package/src/helmup.sh +3 -3
- package/src/init-my-chart/Chartwright.mjs +69 -0
- package/src/init-my-chart/init-my-chart-v1.mjs +124 -0
- package/src/init-my-chart/init-my-chart.mjs +80 -0
- package/src/init-my-chart/leaf-chart-templates/Chart.yaml.hbs +10 -0
- package/src/init-my-chart/leaf-chart-templates/templates/configmap.yaml +1 -0
- package/src/init-my-chart/leaf-chart-templates/templates/deployment.yaml +1 -0
- package/src/init-my-chart/leaf-chart-templates/templates/hpa.yaml +1 -0
- package/src/init-my-chart/leaf-chart-templates/templates/pdb.yaml +1 -0
- package/src/init-my-chart/leaf-chart-templates/templates/service.yaml +1 -0
- package/src/init-my-chart/leaf-chart-templates/templates/serviceaccount.yaml +1 -0
- package/src/init-my-chart/leaf-chart-templates/templates/servicemonitor.yaml +1 -0
- package/src/init-my-chart/leaf-chart-templates/values.schema.json +623 -0
- package/src/init-my-chart/leaf-chart-templates/values.yaml.hbs +135 -0
- package/src/init-my-chart/legacy-helm-template/Chart.yaml +5 -0
- package/src/init-my-chart/legacy-helm-template/templates/NOTES.txt +5 -0
- package/src/init-my-chart/legacy-helm-template/templates/_helpers.tpl +135 -0
- package/src/init-my-chart/legacy-helm-template/templates/configmap.yaml +10 -0
- package/src/init-my-chart/legacy-helm-template/templates/deployment.yaml +125 -0
- package/src/init-my-chart/legacy-helm-template/templates/hpa.yaml +26 -0
- package/src/init-my-chart/legacy-helm-template/templates/ingressroute.yaml +18 -0
- package/src/init-my-chart/legacy-helm-template/templates/pdb.yaml +22 -0
- package/src/init-my-chart/legacy-helm-template/templates/service.yaml +15 -0
- package/src/init-my-chart/legacy-helm-template/templates/serviceaccount.yaml +13 -0
- package/src/init-my-chart/legacy-helm-template/templates/servicemonitor.yaml +23 -0
- package/src/init-my-chart/legacy-helm-template/values.yaml +152 -0
- package/src/testOauthLogic.mjs +12 -0
- 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/helm-charts/prom-operator/rules/awesome-base/elasticsearch-rules.yaml +0 -219
- package/src/helm-charts/prom-operator/rules/awesome-base/google-cadvisor.yaml +0 -108
- package/src/helm-charts/prom-operator/rules/awesome-base/kubestate-exporter.yaml +0 -394
- package/src/helm-charts/prom-operator/rules/awesome-base/prometheus-rules.yaml +0 -318
- package/src/helm-charts/prom-operator/rules/awesome-base/redis-rules.yaml +0 -142
- package/src/helm-charts/prom-operator/rules/awesome-base/traefik-rules.yaml +0 -43
- package/src/init-my-chart.mjs +0 -18
package/lib/server/overwhelm.js
DELETED
|
@@ -1,447 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// XXX console.log( `TOP=>[${process.cwd()}] PWD=[${process.env.PWD}]` )
|
|
4
|
-
/* eslint-disable no-console */
|
|
5
|
-
/* eslint-disable security/detect-non-literal-fs-filename */
|
|
6
|
-
"use strict";
|
|
7
|
-
|
|
8
|
-
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
9
|
-
var _nodeChild_process = require("node:child_process");
|
|
10
|
-
var _nodeFs = _interopRequireDefault(require("node:fs"));
|
|
11
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
12
|
-
var _commandLineArgs = _interopRequireDefault(require("command-line-args"));
|
|
13
|
-
var _deepmerge = _interopRequireDefault(require("deepmerge"));
|
|
14
|
-
var _glob = _interopRequireDefault(require("glob"));
|
|
15
|
-
var _parseGitignore = _interopRequireDefault(require("parse-gitignore"));
|
|
16
|
-
var _readlineSync = _interopRequireDefault(require("readline-sync"));
|
|
17
|
-
var _jsYaml = _interopRequireDefault(require("js-yaml"));
|
|
18
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
// const cliHelp = require( 'command-line-usage' )
|
|
20
|
-
const optionsDefinitions = [/* eslint-disable no-multi-spaces */
|
|
21
|
-
{
|
|
22
|
-
name: 'context',
|
|
23
|
-
alias: 'x',
|
|
24
|
-
type: String,
|
|
25
|
-
default: ''
|
|
26
|
-
}, {
|
|
27
|
-
name: 'section',
|
|
28
|
-
alias: 's',
|
|
29
|
-
type: String,
|
|
30
|
-
default: 'default'
|
|
31
|
-
}, {
|
|
32
|
-
name: 'key',
|
|
33
|
-
alias: 'k',
|
|
34
|
-
type: String
|
|
35
|
-
}, {
|
|
36
|
-
name: 'export',
|
|
37
|
-
alias: 'e',
|
|
38
|
-
type: Boolean,
|
|
39
|
-
default: false
|
|
40
|
-
}, {
|
|
41
|
-
name: 'continue',
|
|
42
|
-
alias: 'c',
|
|
43
|
-
type: Boolean,
|
|
44
|
-
default: false
|
|
45
|
-
}, {
|
|
46
|
-
name: 'checkctx',
|
|
47
|
-
alias: 't',
|
|
48
|
-
type: Boolean,
|
|
49
|
-
default: false
|
|
50
|
-
},
|
|
51
|
-
// checks overwhelm context
|
|
52
|
-
{
|
|
53
|
-
name: 'fetchctx',
|
|
54
|
-
alias: 'f',
|
|
55
|
-
type: Boolean,
|
|
56
|
-
default: false
|
|
57
|
-
},
|
|
58
|
-
// fetch and set k8s context
|
|
59
|
-
{
|
|
60
|
-
name: 'genvals',
|
|
61
|
-
alias: 'g',
|
|
62
|
-
type: Boolean,
|
|
63
|
-
default: false
|
|
64
|
-
},
|
|
65
|
-
// only generates values.yaml
|
|
66
|
-
{
|
|
67
|
-
name: 'matchk8s',
|
|
68
|
-
alias: 'm',
|
|
69
|
-
type: Boolean,
|
|
70
|
-
default: false
|
|
71
|
-
},
|
|
72
|
-
// checks k8s context
|
|
73
|
-
{
|
|
74
|
-
name: 'verbose',
|
|
75
|
-
alias: 'v',
|
|
76
|
-
type: Boolean,
|
|
77
|
-
default: false
|
|
78
|
-
}
|
|
79
|
-
/* eslint-enable no-multi-spaces */];
|
|
80
|
-
|
|
81
|
-
const args = (0, _commandLineArgs.default)(optionsDefinitions);
|
|
82
|
-
|
|
83
|
-
// See if we are in a monorepo, which changes some of the rules.
|
|
84
|
-
const gitTop = (0, _nodeChild_process.execSync)('git rev-parse --show-toplevel', {
|
|
85
|
-
stdio: [undefined]
|
|
86
|
-
}).toString().trim();
|
|
87
|
-
let monoTop;
|
|
88
|
-
if (_nodeFs.default.existsSync(`${gitTop}/packages`)) {
|
|
89
|
-
monoTop = _nodePath.default.basename(_nodePath.default.resolve()); // process.env.PWD
|
|
90
|
-
console.log(`MONO=[${monoTop}]`);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// The kubernetes context is equal to the git branch name.
|
|
94
|
-
const gitBranch = (0, _nodeChild_process.execSync)('git rev-parse --abbrev-ref HEAD', {
|
|
95
|
-
stdio: [undefined]
|
|
96
|
-
}).toString().trim();
|
|
97
|
-
const context = args.context || monoTop || gitBranch;
|
|
98
|
-
if (context === 'master') {
|
|
99
|
-
console.log('***ERROR: master context is forbidden; change to a different branch\n\n');
|
|
100
|
-
process.exit(1);
|
|
101
|
-
}
|
|
102
|
-
if (!_nodeFs.default.existsSync('overwhelm.yaml')) {
|
|
103
|
-
console.log(_chalk.default.red.bold(`
|
|
104
|
-
|
|
105
|
-
***ERROR overwhelm => missing the overwhelm.yaml file - this command expects
|
|
106
|
-
to execute from within a platform-k8s branch
|
|
107
|
-
`));
|
|
108
|
-
process.exit(1);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Load the default values and then overlay with the project specific yaml
|
|
112
|
-
// values. This supports the notion of this type of approach in the
|
|
113
|
-
// overwhelm yaml settings:
|
|
114
|
-
// default:
|
|
115
|
-
// GCE_MACHINE : "n1-standard-2"
|
|
116
|
-
//
|
|
117
|
-
// my-project:
|
|
118
|
-
// GCE_MACHINE : "n1-highcpu-8"
|
|
119
|
-
//
|
|
120
|
-
// fashion, but it is advised not to set a default region with this
|
|
121
|
-
// approach in order to keep us cognizant of exactly where a cluster is
|
|
122
|
-
// being formed.
|
|
123
|
-
//
|
|
124
|
-
const yaml = _jsYaml.default.load(_nodeFs.default.readFileSync('overwhelm.yaml', 'utf-8'));
|
|
125
|
-
const over = yaml.default;
|
|
126
|
-
if (process.env.OVERWHELM_DEBUG) {
|
|
127
|
-
console.log({
|
|
128
|
-
over,
|
|
129
|
-
yaml
|
|
130
|
-
}, '<==Contents of the over and yaml structs');
|
|
131
|
-
}
|
|
132
|
-
let cfgs = yaml[context];
|
|
133
|
-
|
|
134
|
-
// If we just need to check context return 0 if cfgs exists, else error.
|
|
135
|
-
if (args.checkctx) {
|
|
136
|
-
process.exit(!cfgs);
|
|
137
|
-
}
|
|
138
|
-
if (!cfgs) {
|
|
139
|
-
console.log(`***ERROR: Unknown context => [${context}]\n`);
|
|
140
|
-
console.log(' Known k8s contexts are:');
|
|
141
|
-
Object.keys(yaml).forEach(key => {
|
|
142
|
-
if (key !== 'default') {
|
|
143
|
-
console.log(` ${key}`);
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
console.log(`Add a section into overwhelm.yaml for ${context}\n\n`);
|
|
147
|
-
process.exit(1);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// Check to see if we are deriving from another configuration.
|
|
151
|
-
if (cfgs.PROJECT_BASE) {
|
|
152
|
-
const baseName = cfgs.PROJECT_BASE;
|
|
153
|
-
const tempCfgs = cfgs;
|
|
154
|
-
cfgs = yaml[baseName];
|
|
155
|
-
Object.keys(tempCfgs).forEach(key => {
|
|
156
|
-
cfgs[key] = tempCfgs[key];
|
|
157
|
-
});
|
|
158
|
-
console.log('PROJECT_BASE still under evaluation');
|
|
159
|
-
console.log('\n cfgs=', cfgs);
|
|
160
|
-
process.exit(1); // XXX HERE
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
Object.keys(cfgs).forEach(key => {
|
|
164
|
-
over[key] = cfgs[key] || over[key];
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
// Expand any variables that reference other variable settings. A perfect
|
|
168
|
-
// example of where this is useful is in the setting of a PROJECT_NAME and
|
|
169
|
-
// a PROJECT_ID. Most of the time these values are identical, which is why
|
|
170
|
-
// this setting exists in the default section:
|
|
171
|
-
// default:
|
|
172
|
-
// PROJECT_ID : ${PROJECT_NAME}
|
|
173
|
-
//
|
|
174
|
-
// However, in the case of projects like Siren Marine, this is the more
|
|
175
|
-
// likely setup due to legacy naming schemes:
|
|
176
|
-
// sire-marine:
|
|
177
|
-
// PROJECT_NAME : siren-marine
|
|
178
|
-
// PROJECT_ID : prod-rt-data
|
|
179
|
-
//
|
|
180
|
-
const varErrors = [];
|
|
181
|
-
Object.keys(over).forEach(key => {
|
|
182
|
-
if (!over[key]) return; // no value to work with - skip it
|
|
183
|
-
|
|
184
|
-
// Look for something in the form of "thing-${VAR1}-${VAR2}-${VARn}-stuff"
|
|
185
|
-
const matches = over[key].match(/\$\{\w+\}/g);
|
|
186
|
-
if (!matches) return;
|
|
187
|
-
matches.forEach(replaceThis => {
|
|
188
|
-
// The matched variable names will be in the form of ${VARNAME} so drop
|
|
189
|
-
// the ${} characters before using the VARNAME to map into the
|
|
190
|
-
// overwhelm map containing the desired replacement value.
|
|
191
|
-
const withThat = over[replaceThis.replace(/\W+/g, '')];
|
|
192
|
-
if (!withThat) {
|
|
193
|
-
varErrors.push(`${key} : ${over[key]}`);
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
// Store the replaced string back in the overwhelm value map.
|
|
197
|
-
over[key] = over[key].replace(replaceThis, withThat);
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
if (varErrors.length > 0) {
|
|
201
|
-
console.log('***ERROR: unkown variable reference(s) in overwhelm.yaml:\n');
|
|
202
|
-
varErrors.forEach(error => {
|
|
203
|
-
console.log(` ${error}`);
|
|
204
|
-
});
|
|
205
|
-
console.log('');
|
|
206
|
-
process.exit(1);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// Grab a list of the existing yaml templates.
|
|
210
|
-
const yams = _glob.default.sync('values-*.yaml');
|
|
211
|
-
|
|
212
|
-
// A function to apply the replacements to all of the matching yaml which
|
|
213
|
-
// will error out if it runs into an unknown OVH<tag>.
|
|
214
|
-
const doReplacements = (yamls, replacements) => {
|
|
215
|
-
let replYaml = yamls;
|
|
216
|
-
|
|
217
|
-
// wrap special chars with quotes if needed, like "#---incident-alerts---"
|
|
218
|
-
const quoteSpecials = raw => {
|
|
219
|
-
return /[#$?*]/g.test(raw) ? `"${raw}"` : raw;
|
|
220
|
-
};
|
|
221
|
-
Object.keys(replacements).forEach(repl => {
|
|
222
|
-
const replaceThis = new RegExp(`OVH:<${repl}>`, 'g');
|
|
223
|
-
const withThat = quoteSpecials(`${replacements[repl]}`);
|
|
224
|
-
replYaml = replYaml.replace(replaceThis, withThat);
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
// Verify all replaceables have been handled, or error out.
|
|
228
|
-
const missed = replYaml.match(/OVH:<(.*)>/g);
|
|
229
|
-
if (missed) {
|
|
230
|
-
console.log('\n***ERROR: missing replacements in overwhelm.yaml for these tags:\n');
|
|
231
|
-
missed.forEach(miss => {
|
|
232
|
-
console.log(` TAG: ${miss.match(/OVH:<(.*)>/)[1]}`);
|
|
233
|
-
});
|
|
234
|
-
console.log('');
|
|
235
|
-
process.exit(1);
|
|
236
|
-
}
|
|
237
|
-
return replYaml;
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
// Collect all of the yaml from the yams...
|
|
241
|
-
const buildYaml = (yamls, replacements) => {
|
|
242
|
-
const always = ['values-default.yaml'];
|
|
243
|
-
const values = [...always, ...yamls];
|
|
244
|
-
const loaded = [];
|
|
245
|
-
let allYamls = '';
|
|
246
|
-
values.forEach(yaml => {
|
|
247
|
-
if (!_nodeFs.default.existsSync(yaml)) {
|
|
248
|
-
console.log(`\n***ERROR: yaml file missing => ${yaml}\n`);
|
|
249
|
-
process.exit(1);
|
|
250
|
-
}
|
|
251
|
-
if (!loaded.includes(yaml)) {
|
|
252
|
-
allYamls += `\n# AHOY => ${yaml}\n\n`;
|
|
253
|
-
allYamls += _nodeFs.default.readFileSync(yaml, {
|
|
254
|
-
encoding: 'utf-8'
|
|
255
|
-
});
|
|
256
|
-
loaded.push(yaml);
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
// Now apply all of the replacements from the overwhelm file.
|
|
261
|
-
return doReplacements(allYamls, replacements);
|
|
262
|
-
};
|
|
263
|
-
|
|
264
|
-
// Call buildYaml to replace the OVH strings in the yaml files.
|
|
265
|
-
const values = buildYaml(yams, over);
|
|
266
|
-
|
|
267
|
-
// Check to see if someone is requesting a value from the yaml.
|
|
268
|
-
if (args.key) {
|
|
269
|
-
const section = args.section || 'default';
|
|
270
|
-
const keys = yaml[section];
|
|
271
|
-
if (args.verbose) {
|
|
272
|
-
console.log('replacements');
|
|
273
|
-
console.log(keys);
|
|
274
|
-
}
|
|
275
|
-
if (args.export) {
|
|
276
|
-
console.log(`export ${args.key}=${keys[args.key]}`);
|
|
277
|
-
} else {
|
|
278
|
-
console.log(keys[args.key]);
|
|
279
|
-
}
|
|
280
|
-
if (!args.continue) process.exit();
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
// Find all of the potential target dirs. Utilize .gitignore to ignore files
|
|
284
|
-
const gitignore = (0, _parseGitignore.default)(_nodeFs.default.readFileSync('.gitignore'));
|
|
285
|
-
const opt = {
|
|
286
|
-
ignore: gitignore.patterns
|
|
287
|
-
};
|
|
288
|
-
const ahoy = _glob.default.sync('*/', opt);
|
|
289
|
-
|
|
290
|
-
// .noahoy = skips generation of values.yaml but allows helmup to run
|
|
291
|
-
// .nohelm = overwhelm and helmup will skip the deployment entirely
|
|
292
|
-
ahoy.forEach(dir => {
|
|
293
|
-
if (_nodeFs.default.existsSync(`${dir}/.noahoy`)) {
|
|
294
|
-
!args.fetchctx && console.log(_chalk.default.yellow(`***WARNING: .noahoy detected, not regenerating ${dir}values.yaml`));
|
|
295
|
-
} else if (!_nodeFs.default.existsSync(`${dir}/.nohelm`)) {
|
|
296
|
-
args.verbose && console.log(`Generating values in ${dir}`); // eslint-disable-line no-unused-expressions
|
|
297
|
-
|
|
298
|
-
let valuesOut = []; // An accumulator for all of the output values.
|
|
299
|
-
|
|
300
|
-
// Add support for localized values for things like keel (or whatever)
|
|
301
|
-
const valuesLocal = `${dir}values-local.yaml`;
|
|
302
|
-
if (_nodeFs.default.existsSync(valuesLocal)) {
|
|
303
|
-
args.verbose && console.log(` Local values in ${valuesLocal}`); // eslint-disable-line no-unused-expressions
|
|
304
|
-
valuesOut += '\n# AHOY => values-local.yaml\n\n';
|
|
305
|
-
valuesOut += _nodeFs.default.readFileSync(valuesLocal, {
|
|
306
|
-
encoding: 'utf-8'
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
valuesOut += `\n${values}`;
|
|
310
|
-
|
|
311
|
-
// Augment the default service section of the YAML with settings that
|
|
312
|
-
// usually come from the top level overwhelm.yaml file.
|
|
313
|
-
//
|
|
314
|
-
const valuesAll = _jsYaml.default.load(valuesOut) || {};
|
|
315
|
-
const valuesSvc = {
|
|
316
|
-
service: {
|
|
317
|
-
project_id: 'OVH:<PROJECT_ID>',
|
|
318
|
-
project_name: 'OVH:<PROJECT_NAME>',
|
|
319
|
-
host: 'OVH:<HOST>',
|
|
320
|
-
ingress: 'OVH:<INGRESS>'
|
|
321
|
-
}
|
|
322
|
-
};
|
|
323
|
-
const valuesMerged = _jsYaml.default.dump((0, _deepmerge.default)(valuesSvc, valuesAll), {
|
|
324
|
-
quotingType: '"'
|
|
325
|
-
});
|
|
326
|
-
valuesOut = doReplacements(valuesMerged, over);
|
|
327
|
-
|
|
328
|
-
// DEPRECATED once siren and manheim are platform 4.0
|
|
329
|
-
// If we are going to override then we need to convert it to YAML and
|
|
330
|
-
// do a deepmerge to combine the values.
|
|
331
|
-
const valuesOverride = `${dir}/values-override.yaml`;
|
|
332
|
-
if (_nodeFs.default.existsSync(valuesOverride)) {
|
|
333
|
-
console.log(`===>Applying Overrides=> ${valuesOverride}`);
|
|
334
|
-
const overrides = _jsYaml.default.load(_nodeFs.default.readFileSync(valuesOverride, {
|
|
335
|
-
encofind: 'utf-8'
|
|
336
|
-
}));
|
|
337
|
-
const allValues = _jsYaml.default.load(valuesOut);
|
|
338
|
-
valuesOut = _jsYaml.default.dump((0, _deepmerge.default)(allValues, overrides), {
|
|
339
|
-
quotingType: '"'
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
// DEPRECATED
|
|
343
|
-
|
|
344
|
-
_nodeFs.default.writeFileSync(`${dir}/values.yaml`, valuesOut);
|
|
345
|
-
}
|
|
346
|
-
});
|
|
347
|
-
|
|
348
|
-
// we can also apply replaceables to any top level .ovh files to support top level config maps
|
|
349
|
-
_glob.default.sync('**/*.ovh').forEach(cfgmap => {
|
|
350
|
-
const target = cfgmap.replace(/.ovh$/, '');
|
|
351
|
-
let valuesOut = _nodeFs.default.readFileSync(cfgmap, {
|
|
352
|
-
encoding: 'utf-8'
|
|
353
|
-
});
|
|
354
|
-
valuesOut = doReplacements(valuesOut, over);
|
|
355
|
-
_nodeFs.default.writeFileSync(target, valuesOut);
|
|
356
|
-
});
|
|
357
|
-
if (args.genvals) {
|
|
358
|
-
process.exit(0);
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
// Set the GCP context for safety!
|
|
362
|
-
const clusterName = over.CLUSTER_NAME;
|
|
363
|
-
if (over.PROJECT_NAME === 'minikube') {
|
|
364
|
-
process.exit(0);
|
|
365
|
-
}
|
|
366
|
-
const projectId = over.PROJECT_ID;
|
|
367
|
-
const zone = over.GCE_REGION + (over.GCE_ZONE ? `-${over.GCE_ZONE}` : '');
|
|
368
|
-
if (!clusterName) {
|
|
369
|
-
console.log(_chalk.default.yellow(`
|
|
370
|
-
|
|
371
|
-
The overwhelm.yaml file in this branch is missing a CLUSTER_NAME setting,
|
|
372
|
-
which was added to support cluster names that do not match the project
|
|
373
|
-
name. Since the mismatch is rare, you can probably get by with simply
|
|
374
|
-
adding this line following PROJECT_NAME in the default section of
|
|
375
|
-
overwhelm.yaml:
|
|
376
|
-
|
|
377
|
-
${_chalk.default.bold.green('CLUSTER_NAME : \'${PROJECT_NAME}\'')}
|
|
378
|
-
|
|
379
|
-
However, if the CLUSTER_NAME is not the same as the PROJECT_NAME then go
|
|
380
|
-
ahead and add the CLUSTER_NAME setting to the ${_chalk.default.bold.green(projectId)} section of the
|
|
381
|
-
overwhelm.yaml file.
|
|
382
|
-
|
|
383
|
-
`));
|
|
384
|
-
process.exit(1);
|
|
385
|
-
}
|
|
386
|
-
let kubeout = '_no_current_context_';
|
|
387
|
-
try {
|
|
388
|
-
kubeout = (0, _nodeChild_process.execSync)('kubectl config current-context', {
|
|
389
|
-
stdio: [undefined]
|
|
390
|
-
});
|
|
391
|
-
} catch (err) {
|
|
392
|
-
// err && console.log( `Caught Error =>[${err}]` )
|
|
393
|
-
}
|
|
394
|
-
const currentCtx = kubeout.toString().trim();
|
|
395
|
-
const desiredCtx = `gke_${projectId}_${zone}_${clusterName}`;
|
|
396
|
-
const cmd = `gcloud container clusters get-credentials ${clusterName} --zone ${zone} --project ${projectId}`;
|
|
397
|
-
const matchedCtx = currentCtx === desiredCtx;
|
|
398
|
-
if (args.matchk8s) {
|
|
399
|
-
process.exit(matchedCtx ? 0 : 1);
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
// just fetch the context and exit if -f is specified
|
|
403
|
-
if (args.fetchctx) {
|
|
404
|
-
if (!matchedCtx) {
|
|
405
|
-
try {
|
|
406
|
-
(0, _nodeChild_process.execSync)(`${cmd}`, {
|
|
407
|
-
stdio: [undefined]
|
|
408
|
-
});
|
|
409
|
-
} catch (err) {
|
|
410
|
-
process.exit(61); // ECONNREFUSED
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
process.exit(0);
|
|
415
|
-
}
|
|
416
|
-
if (matchedCtx) {
|
|
417
|
-
console.log(`
|
|
418
|
-
|
|
419
|
-
Current context matches => ${_chalk.default.bold.green(currentCtx)}
|
|
420
|
-
|
|
421
|
-
`);
|
|
422
|
-
} else {
|
|
423
|
-
console.log(`
|
|
424
|
-
You are about to change your Kubernetes context to:
|
|
425
|
-
CLUSTER_NAME => ${_chalk.default.bold.green(clusterName)}
|
|
426
|
-
PROJECT_ID => ${_chalk.default.bold.green(projectId)}
|
|
427
|
-
REGION => ${_chalk.default.bold.green(zone)}
|
|
428
|
-
|
|
429
|
-
`);
|
|
430
|
-
}
|
|
431
|
-
const operation = matchedCtx ? 'refetch the credentials' : 'switch your context';
|
|
432
|
-
const ans = _readlineSync.default.question(`Enter "${_chalk.default.bold.green('yes')}" if you wish to ${operation} => `);
|
|
433
|
-
if (ans !== 'yes') {
|
|
434
|
-
if (matchedCtx) {
|
|
435
|
-
console.log(_chalk.default.bold.yellow('\n\nSkipping a refetch of your Kubernetes context and credentials\n\n'));
|
|
436
|
-
process.exit(0);
|
|
437
|
-
}
|
|
438
|
-
console.log(_chalk.default.bold.red('\n\nYour Kubernetes context and credentials do NOT match - this could be bad!\n\n'));
|
|
439
|
-
process.exit(1);
|
|
440
|
-
}
|
|
441
|
-
console.log(`\n\nExecuting: ${_chalk.default.bold.yellow(cmd)}\n\n`);
|
|
442
|
-
(0, _nodeChild_process.execSync)(`${cmd}`, (error, out) => {
|
|
443
|
-
if (error) {
|
|
444
|
-
console.log(`\n\n***ERROR ${error}\n\n`);
|
|
445
|
-
process.exit(1);
|
|
446
|
-
}
|
|
447
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
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); // eslint-disable-line no-console
|
|
13
|
-
} catch (ex) {
|
|
14
|
-
console.log(ex.stderr); // eslint-disable-line no-console
|
|
15
|
-
process.exit(1);
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
pushItGood();
|
|
@@ -1,135 +0,0 @@
|
|
|
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
|
-
|
|
18
|
-
/* eslint-disable security/detect-non-literal-fs-filename */
|
|
19
|
-
"use strict";
|
|
20
|
-
|
|
21
|
-
var _nodeFs = _interopRequireDefault(require("node:fs"));
|
|
22
|
-
var _nodeOs = _interopRequireDefault(require("node:os"));
|
|
23
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
24
|
-
var _execa = _interopRequireDefault(require("execa"));
|
|
25
|
-
var _semver = require("semver");
|
|
26
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
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')); // eslint-disable-line no-console
|
|
30
|
-
process.exit(1);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// max age in seconds of the npmrc file before refresh
|
|
34
|
-
const refreshThreshold = 3600 * 24; // 1 day
|
|
35
|
-
|
|
36
|
-
// eslint-disable-next-line no-console
|
|
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
|
-
};
|
|
43
|
-
const fetchToken = filename => {
|
|
44
|
-
const results = {
|
|
45
|
-
filename,
|
|
46
|
-
exists: false,
|
|
47
|
-
token: 'none',
|
|
48
|
-
lastUpdated: -1
|
|
49
|
-
};
|
|
50
|
-
try {
|
|
51
|
-
if (_nodeFs.default.existsSync(filename)) {
|
|
52
|
-
results.exists = true;
|
|
53
|
-
const stat = _nodeFs.default.statSync(filename);
|
|
54
|
-
results.lastUpdated = Math.trunc((Date.now() - stat.mtimeMs) / 1000);
|
|
55
|
-
// grab the current token for logging a redacted version
|
|
56
|
-
const currentNpmrc = _nodeFs.default.readFileSync(filename, 'utf8');
|
|
57
|
-
const found = currentNpmrc.match(/_authToken=(.*)\n/);
|
|
58
|
-
if (found) {
|
|
59
|
-
results.token = `${found[1].slice(0, 8)}......${found[1].slice(-4)}`;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
} catch (statErr) {
|
|
63
|
-
log({
|
|
64
|
-
statErr
|
|
65
|
-
}, `<==fs.statSync failed on file ${filename}`);
|
|
66
|
-
}
|
|
67
|
-
return results;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
// fetch the tokens - note the RO token is deprecated and may not exist
|
|
71
|
-
const npmrc = fetchToken(`${_nodeOs.default.homedir()}/.npmrc`);
|
|
72
|
-
const npmrcRo = fetchToken(`${_nodeOs.default.homedir()}/.npmrc.ro`);
|
|
73
|
-
debug({
|
|
74
|
-
npmrc,
|
|
75
|
-
npmrcRo
|
|
76
|
-
}, '<==Your current tokens'); // debug
|
|
77
|
-
|
|
78
|
-
if (npmrc.exists && npmrc.lastUpdated < refreshThreshold) {
|
|
79
|
-
process.exit(0);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// fetch the contents of the npmrc secret stored on leverege-registry
|
|
83
|
-
let npmrcSecret;
|
|
84
|
-
const execaOpts = ['secrets', 'versions', 'access', 'latest', '--secret=NPM_DEVELOPER_NPMRC', '--project=leverege-registry'];
|
|
85
|
-
try {
|
|
86
|
-
const execaOut = await (0, _execa.default)('gcloud', execaOpts);
|
|
87
|
-
npmrcSecret = execaOut.stdout;
|
|
88
|
-
debug({
|
|
89
|
-
execaOut,
|
|
90
|
-
execaOpts
|
|
91
|
-
}, '<==exec info'); // debug
|
|
92
|
-
} catch (err) {
|
|
93
|
-
log(_chalk.default.yellow(`\nFailed Command => [${err.escapedCommand}]\n\n`), _chalk.default.red(err.stderr));
|
|
94
|
-
process.exit(1);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// now update the user's npmrc file
|
|
98
|
-
log(_chalk.default.yellow('\n*** Refreshing your ~/.npmrc npm token file'));
|
|
99
|
-
try {
|
|
100
|
-
if (_nodeFs.default.existsSync(npmrc)) {
|
|
101
|
-
_nodeFs.default.copyFileSync(npmrc, `${npmrc}-BAK`); // make a backup for safety
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
_nodeFs.default.writeFileSync(npmrc.filename, npmrcSecret);
|
|
105
|
-
} catch (fileErr) {
|
|
106
|
-
log(fileErr, 'fs failed');
|
|
107
|
-
process.exit(1);
|
|
108
|
-
}
|
|
109
|
-
const now = new Date().toLocaleString();
|
|
110
|
-
const slackURL = 'https://hooks.slack.com/services/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';
|
|
111
|
-
const execaAct = await (0, _execa.default)('gcloud', ['config', 'get', 'account']);
|
|
112
|
-
const account = execaAct.stdout;
|
|
113
|
-
const slackData = {
|
|
114
|
-
// eslint-disable-next-line max-len
|
|
115
|
-
text: `--- npmrc refreshed by \`${account}\` at ${now}\n tokens RW [\`${npmrc.token}\`] RO [\`${npmrcRo.token}\`]`,
|
|
116
|
-
channel: '#dev-ops-helm'
|
|
117
|
-
};
|
|
118
|
-
if (process.env.REFRESH_NPM_TOKEN_DEBUG) {
|
|
119
|
-
log({
|
|
120
|
-
slackURL,
|
|
121
|
-
slackData
|
|
122
|
-
}, '<==Slack skipped');
|
|
123
|
-
} else {
|
|
124
|
-
fetch(slackURL, {
|
|
125
|
-
method: 'POST',
|
|
126
|
-
body: JSON.stringify(slackData),
|
|
127
|
-
headers: {
|
|
128
|
-
'Content-Type': 'application/json'
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
if (npmrcRo.exists) {
|
|
133
|
-
log(_chalk.default.red('\nWARNING - the need for the ~/.npmrc.ro file has been eliminated - please remove'));
|
|
134
|
-
process.exit(1);
|
|
135
|
-
}
|