@firestartr/cli 1.47.0 → 1.48.0-snapshot-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/build/index.js
CHANGED
|
@@ -300247,11 +300247,17 @@ class TFWorkspaceNormalizer extends Normalizer {
|
|
|
300247
300247
|
}
|
|
300248
300248
|
async function normalizeModuleContent(tfRootModulePath) {
|
|
300249
300249
|
let content = '';
|
|
300250
|
+
const files = {};
|
|
300250
300251
|
await crawl(tfRootModulePath, (entry) => {
|
|
300251
300252
|
return entry.endsWith('.tf');
|
|
300252
300253
|
}, (entry, data) => {
|
|
300254
|
+
files[entry] = data;
|
|
300255
|
+
});
|
|
300256
|
+
Object.keys(files)
|
|
300257
|
+
.sort()
|
|
300258
|
+
.forEach((entry) => {
|
|
300253
300259
|
content += `# ${external_path_.basename(entry)}
|
|
300254
|
-
${
|
|
300260
|
+
${files[entry]}
|
|
300255
300261
|
`;
|
|
300256
300262
|
});
|
|
300257
300263
|
return content;
|
|
@@ -303205,6 +303211,210 @@ function renderContent(template, ctx) {
|
|
|
303205
303211
|
return mustache_mustache.render(template, ctx, {}, ['{{|', '|}}']);
|
|
303206
303212
|
}
|
|
303207
303213
|
|
|
303214
|
+
// EXTERNAL MODULE: external "node:fs"
|
|
303215
|
+
var external_node_fs_ = __nccwpck_require__(87561);
|
|
303216
|
+
// EXTERNAL MODULE: external "node:path"
|
|
303217
|
+
var external_node_path_ = __nccwpck_require__(49411);
|
|
303218
|
+
;// CONCATENATED MODULE: external "node:os"
|
|
303219
|
+
const external_node_os_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:os");
|
|
303220
|
+
;// CONCATENATED MODULE: ../features_renderer/src/auxiliar.ts
|
|
303221
|
+
// src/auxiliar.ts
|
|
303222
|
+
|
|
303223
|
+
|
|
303224
|
+
|
|
303225
|
+
|
|
303226
|
+
|
|
303227
|
+
|
|
303228
|
+
|
|
303229
|
+
const renderTestsSchema = {
|
|
303230
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
303231
|
+
type: 'object',
|
|
303232
|
+
additionalProperties: false,
|
|
303233
|
+
required: ['tests'],
|
|
303234
|
+
properties: {
|
|
303235
|
+
tests: {
|
|
303236
|
+
type: 'array',
|
|
303237
|
+
minItems: 1,
|
|
303238
|
+
items: {
|
|
303239
|
+
type: 'object',
|
|
303240
|
+
additionalProperties: false,
|
|
303241
|
+
required: ['name', 'cr'],
|
|
303242
|
+
properties: {
|
|
303243
|
+
name: { type: 'string', minLength: 1 },
|
|
303244
|
+
cr: { type: 'string', minLength: 1 },
|
|
303245
|
+
args: { type: 'object' },
|
|
303246
|
+
},
|
|
303247
|
+
},
|
|
303248
|
+
},
|
|
303249
|
+
},
|
|
303250
|
+
};
|
|
303251
|
+
const YAML_FILE_REGEX = /\.[yY]a?ml$/;
|
|
303252
|
+
/* ---------- Core helpers ---------- */
|
|
303253
|
+
function formatAjvErrors(errors) {
|
|
303254
|
+
if (!errors || errors.length === 0)
|
|
303255
|
+
return 'Unknown schema error';
|
|
303256
|
+
return errors
|
|
303257
|
+
.map((e) => {
|
|
303258
|
+
const where = e.instancePath && e.instancePath.length ? e.instancePath : '/';
|
|
303259
|
+
const msg = e.message ?? 'validation error';
|
|
303260
|
+
return `- ${where} ${msg}`;
|
|
303261
|
+
})
|
|
303262
|
+
.join('\n');
|
|
303263
|
+
}
|
|
303264
|
+
function ensureUniqueTestNames(doc) {
|
|
303265
|
+
const seen = new Set();
|
|
303266
|
+
for (const t of doc.tests) {
|
|
303267
|
+
if (seen.has(t.name)) {
|
|
303268
|
+
throw new Error(`Duplicate test name "${t.name}" in render_tests.yaml`);
|
|
303269
|
+
}
|
|
303270
|
+
seen.add(t.name);
|
|
303271
|
+
}
|
|
303272
|
+
}
|
|
303273
|
+
function loadAndValidateRenderTests(featurePath) {
|
|
303274
|
+
const file = external_node_path_.join(featurePath, 'render_tests.yaml');
|
|
303275
|
+
if (!external_node_fs_.existsSync(file)) {
|
|
303276
|
+
throw new Error(`render_tests.yaml is required but not found at ${file}`);
|
|
303277
|
+
}
|
|
303278
|
+
const raw = loadYaml(file);
|
|
303279
|
+
const ajv = new (ajv_default())({ allErrors: true, strict: true });
|
|
303280
|
+
const validate = ajv.compile(renderTestsSchema);
|
|
303281
|
+
const ok = validate(raw);
|
|
303282
|
+
if (!ok) {
|
|
303283
|
+
throw new Error(`render_tests.yaml schema validation failed:\n${formatAjvErrors(validate.errors ?? [])}`);
|
|
303284
|
+
}
|
|
303285
|
+
const doc = raw;
|
|
303286
|
+
ensureUniqueTestNames(doc);
|
|
303287
|
+
return doc;
|
|
303288
|
+
}
|
|
303289
|
+
function resolveCrPath(featurePath, crRelPath) {
|
|
303290
|
+
if (external_node_path_.isAbsolute(crRelPath)) {
|
|
303291
|
+
throw new Error(`CR path must be relative to the feature root, got absolute: ${crRelPath}`);
|
|
303292
|
+
}
|
|
303293
|
+
const resolved = external_node_path_.resolve(featurePath, crRelPath);
|
|
303294
|
+
if (!external_node_fs_.existsSync(resolved)) {
|
|
303295
|
+
throw new Error(`CR file not found (resolved from "${crRelPath}"): ${resolved}`);
|
|
303296
|
+
}
|
|
303297
|
+
return resolved;
|
|
303298
|
+
}
|
|
303299
|
+
function listYamlFiles(dir) {
|
|
303300
|
+
if (!fs.existsSync(dir))
|
|
303301
|
+
return [];
|
|
303302
|
+
let entries;
|
|
303303
|
+
try {
|
|
303304
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
303305
|
+
}
|
|
303306
|
+
catch (e) {
|
|
303307
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
303308
|
+
throw new Error(`Failed to read directory "${dir}": ${msg}`);
|
|
303309
|
+
}
|
|
303310
|
+
return entries
|
|
303311
|
+
.filter((e) => e.isFile() && YAML_FILE_REGEX.test(e.name))
|
|
303312
|
+
.map((e) => path.join(dir, e.name));
|
|
303313
|
+
}
|
|
303314
|
+
function loadYaml(file) {
|
|
303315
|
+
try {
|
|
303316
|
+
const configDataRaw = common_slurpFile(external_node_path_.join(file));
|
|
303317
|
+
return catalog_common.io.fromYaml(configDataRaw);
|
|
303318
|
+
}
|
|
303319
|
+
catch (e) {
|
|
303320
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
303321
|
+
throw new Error(`Failed to parse YAML "${file}": ${msg}`);
|
|
303322
|
+
}
|
|
303323
|
+
}
|
|
303324
|
+
function ensureSafeTmpName(name) {
|
|
303325
|
+
if (typeof name !== 'string' || !name.trim()) {
|
|
303326
|
+
throw new Error('Test "name" must be a non-empty string');
|
|
303327
|
+
}
|
|
303328
|
+
if (name.length > 128) {
|
|
303329
|
+
throw new Error('Test "name" is too long (max 128 characters)');
|
|
303330
|
+
}
|
|
303331
|
+
if (external_node_path_.isAbsolute(name)) {
|
|
303332
|
+
throw new Error(`Test "name" must be relative, got absolute: "${name}"`);
|
|
303333
|
+
}
|
|
303334
|
+
if (name.includes('..')) {
|
|
303335
|
+
throw new Error('Test "name" must not contain ".."');
|
|
303336
|
+
}
|
|
303337
|
+
if (/[/\\]/.test(name)) {
|
|
303338
|
+
throw new Error('Test "name" must not contain path separators (/ or \\)');
|
|
303339
|
+
}
|
|
303340
|
+
if (!/^[A-Za-z0-9._-]+$/.test(name)) {
|
|
303341
|
+
throw new Error('Test "name" may only contain letters, numbers, ".", "_", or "-"');
|
|
303342
|
+
}
|
|
303343
|
+
}
|
|
303344
|
+
async function mkNamedTmp(name) {
|
|
303345
|
+
ensureSafeTmpName(name);
|
|
303346
|
+
const dir = external_node_path_.join(external_node_os_namespaceObject.tmpdir(), name);
|
|
303347
|
+
await promises_namespaceObject.rm(dir, { recursive: true, force: true });
|
|
303348
|
+
await promises_namespaceObject.mkdir(dir, { recursive: true });
|
|
303349
|
+
return dir;
|
|
303350
|
+
}
|
|
303351
|
+
async function mkTmp(prefix = 'feature-render-') {
|
|
303352
|
+
return await fsp.mkdtemp(path.join(os.tmpdir(), prefix));
|
|
303353
|
+
}
|
|
303354
|
+
function buildExpectedOutput(config, renderDir) {
|
|
303355
|
+
const files = (config.files || []).map((f) => ({
|
|
303356
|
+
localPath: external_node_path_.join(renderDir, f.dest),
|
|
303357
|
+
repoPath: f.src,
|
|
303358
|
+
userManaged: f.user_managed,
|
|
303359
|
+
}));
|
|
303360
|
+
return {
|
|
303361
|
+
files,
|
|
303362
|
+
patches: config.patches || [],
|
|
303363
|
+
};
|
|
303364
|
+
}
|
|
303365
|
+
/* ---------- Context-style API for a render temp dir ---------- */
|
|
303366
|
+
async function createRenderContext(prefix = 'feature-render-') {
|
|
303367
|
+
const dir = await mkTmp(prefix);
|
|
303368
|
+
const join = (...p) => path.join(dir, ...p);
|
|
303369
|
+
return {
|
|
303370
|
+
getContextPath: () => dir,
|
|
303371
|
+
join,
|
|
303372
|
+
getFile: async (relPath, { yaml: asYaml = false, json: asJson = false, } = {}) => {
|
|
303373
|
+
const data = await fsp.readFile(join(relPath), 'utf8');
|
|
303374
|
+
if (asYaml)
|
|
303375
|
+
return common.io.fromYaml(data);
|
|
303376
|
+
if (asJson)
|
|
303377
|
+
return JSON.parse(data);
|
|
303378
|
+
return data;
|
|
303379
|
+
},
|
|
303380
|
+
getFilePath: (relPath) => join(relPath),
|
|
303381
|
+
setFile: async (relPath, contents) => {
|
|
303382
|
+
await fsp.mkdir(path.dirname(join(relPath)), { recursive: true });
|
|
303383
|
+
await fsp.writeFile(join(relPath), contents);
|
|
303384
|
+
},
|
|
303385
|
+
exists: async (relPath) => {
|
|
303386
|
+
try {
|
|
303387
|
+
await fsp.access(join(relPath));
|
|
303388
|
+
return true;
|
|
303389
|
+
}
|
|
303390
|
+
catch {
|
|
303391
|
+
return false;
|
|
303392
|
+
}
|
|
303393
|
+
},
|
|
303394
|
+
getOutputJson: async () => {
|
|
303395
|
+
const p = join('output.json');
|
|
303396
|
+
const raw = await fsp.readFile(p, 'utf8');
|
|
303397
|
+
return JSON.parse(raw);
|
|
303398
|
+
},
|
|
303399
|
+
list: async (relPath = '.') => {
|
|
303400
|
+
const entries = await fsp.readdir(join(relPath), {
|
|
303401
|
+
withFileTypes: true,
|
|
303402
|
+
});
|
|
303403
|
+
return entries.map((e) => ({ name: e.name, isDir: e.isDirectory() }));
|
|
303404
|
+
},
|
|
303405
|
+
remove: async () => {
|
|
303406
|
+
await fsp.rm(dir, { recursive: true, force: true });
|
|
303407
|
+
},
|
|
303408
|
+
};
|
|
303409
|
+
}
|
|
303410
|
+
/* harmony default export */ const auxiliar = ({
|
|
303411
|
+
mkNamedTmp,
|
|
303412
|
+
loadYaml,
|
|
303413
|
+
buildExpectedOutput,
|
|
303414
|
+
loadAndValidateRenderTests,
|
|
303415
|
+
resolveCrPath,
|
|
303416
|
+
});
|
|
303417
|
+
|
|
303208
303418
|
;// CONCATENATED MODULE: ../features_renderer/src/update_file.ts
|
|
303209
303419
|
|
|
303210
303420
|
|
|
@@ -303216,10 +303426,12 @@ function updateFileContent(featureRenderPath, filePath, content) {
|
|
|
303216
303426
|
|
|
303217
303427
|
|
|
303218
303428
|
|
|
303429
|
+
|
|
303219
303430
|
/* harmony default export */ const features_renderer = ({
|
|
303220
303431
|
validate: validate_validate,
|
|
303221
303432
|
render: render,
|
|
303222
303433
|
updateFileContent: updateFileContent,
|
|
303434
|
+
auxiliar: auxiliar,
|
|
303223
303435
|
});
|
|
303224
303436
|
|
|
303225
303437
|
;// CONCATENATED MODULE: ../features_preparer/src/renderer.ts
|
|
@@ -315600,27 +315812,28 @@ var sdk_metrics_build_src = __nccwpck_require__(84016);
|
|
|
315600
315812
|
;// CONCATENATED MODULE: ../operator/src/metrics/CRStates.ts
|
|
315601
315813
|
|
|
315602
315814
|
|
|
315815
|
+
|
|
315603
315816
|
const INTERVAL_IN_SEGS = 60;
|
|
315604
315817
|
class CRStateMetrics {
|
|
315605
315818
|
constructor(kind, namespace, meter) {
|
|
315606
315819
|
this.kind = kind;
|
|
315607
|
-
this.provisionedGauge = meter.createGauge(
|
|
315608
|
-
description:
|
|
315820
|
+
this.provisionedGauge = meter.createGauge('firestartr_provisioned_total', {
|
|
315821
|
+
description: 'Total number of CRs in PROVISIONED state',
|
|
315609
315822
|
});
|
|
315610
|
-
this.provisioningGauge = meter.createGauge(
|
|
315611
|
-
description:
|
|
315823
|
+
this.provisioningGauge = meter.createGauge('firestartr_provisioning_total', {
|
|
315824
|
+
description: 'Total number of CRs in PROVISIONING state',
|
|
315612
315825
|
});
|
|
315613
|
-
this.outOfSyncGauge = meter.createGauge(
|
|
315614
|
-
description:
|
|
315826
|
+
this.outOfSyncGauge = meter.createGauge('firestartr_out_of_sync_total', {
|
|
315827
|
+
description: 'Total number of CRs in OUT_OF_SYNC state',
|
|
315615
315828
|
});
|
|
315616
|
-
this.errorGauge = meter.createGauge(
|
|
315617
|
-
description:
|
|
315829
|
+
this.errorGauge = meter.createGauge('firestartr_error_total', {
|
|
315830
|
+
description: 'Total number of CRs in ERROR state',
|
|
315618
315831
|
});
|
|
315619
|
-
this.planningGauge = meter.createGauge(
|
|
315620
|
-
description:
|
|
315832
|
+
this.planningGauge = meter.createGauge('firestartr_planning_total', {
|
|
315833
|
+
description: 'Total number of CRs in PLANNING state',
|
|
315621
315834
|
});
|
|
315622
|
-
this.deletedGauge = meter.createGauge(
|
|
315623
|
-
description:
|
|
315835
|
+
this.deletedGauge = meter.createGauge('firestartr_deleted_total', {
|
|
315836
|
+
description: 'Total number of CRs in DELETED state',
|
|
315624
315837
|
});
|
|
315625
315838
|
this.namespace = namespace;
|
|
315626
315839
|
}
|
|
@@ -315677,19 +315890,33 @@ class CRStateMetrics {
|
|
|
315677
315890
|
}
|
|
315678
315891
|
this.provisionedGauge.record(provisionedCount, {
|
|
315679
315892
|
namespace: this.namespace,
|
|
315893
|
+
kind: this.kind,
|
|
315680
315894
|
});
|
|
315681
315895
|
this.provisioningGauge.record(provisioningCount, {
|
|
315682
315896
|
namespace: this.namespace,
|
|
315897
|
+
kind: this.kind,
|
|
315898
|
+
});
|
|
315899
|
+
this.planningGauge.record(planningCount, {
|
|
315900
|
+
namespace: this.namespace,
|
|
315901
|
+
kind: this.kind,
|
|
315902
|
+
});
|
|
315903
|
+
this.deletedGauge.record(deletedCount, {
|
|
315904
|
+
namespace: this.namespace,
|
|
315905
|
+
kind: this.kind,
|
|
315906
|
+
});
|
|
315907
|
+
this.outOfSyncGauge.record(outOfSyncCount, {
|
|
315908
|
+
namespace: this.namespace,
|
|
315909
|
+
kind: this.kind,
|
|
315910
|
+
});
|
|
315911
|
+
this.errorGauge.record(errorCount, {
|
|
315912
|
+
namespace: this.namespace,
|
|
315913
|
+
kind: this.kind,
|
|
315683
315914
|
});
|
|
315684
|
-
this.planningGauge.record(planningCount, { namespace: this.namespace });
|
|
315685
|
-
this.deletedGauge.record(deletedCount, { namespace: this.namespace });
|
|
315686
|
-
this.outOfSyncGauge.record(outOfSyncCount, { namespace: this.namespace });
|
|
315687
|
-
this.errorGauge.record(errorCount, { namespace: this.namespace });
|
|
315688
315915
|
}
|
|
315689
315916
|
catch (err) {
|
|
315690
|
-
console.log(err);
|
|
315917
|
+
console.log(`CRStateMetrics: update ${err}`);
|
|
315691
315918
|
this.onUpdate = false;
|
|
315692
|
-
|
|
315919
|
+
src_logger.error('CR_METRICS_UPDATE', { error: err });
|
|
315693
315920
|
}
|
|
315694
315921
|
this.onUpdate = false;
|
|
315695
315922
|
}
|
|
@@ -5,5 +5,12 @@ declare const _default: {
|
|
|
5
5
|
validate: typeof validate;
|
|
6
6
|
render: typeof render;
|
|
7
7
|
updateFileContent: typeof updateFileContent;
|
|
8
|
+
auxiliar: {
|
|
9
|
+
mkNamedTmp: (name: string) => Promise<string>;
|
|
10
|
+
loadYaml: <T = unknown>(file: string) => T;
|
|
11
|
+
buildExpectedOutput: (config: import("./src/auxiliar").FeatureConfig, renderDir: string) => import("./src/auxiliar").ExpectedOutput;
|
|
12
|
+
loadAndValidateRenderTests: (featurePath: string) => import("./src/auxiliar").RenderTestsFile;
|
|
13
|
+
resolveCrPath: (featurePath: string, crRelPath: string) => string;
|
|
14
|
+
};
|
|
8
15
|
};
|
|
9
16
|
export default _default;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
export interface ConfigFile {
|
|
5
|
+
dest: string;
|
|
6
|
+
src: string;
|
|
7
|
+
user_managed: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface FeatureConfig {
|
|
10
|
+
files?: ConfigFile[];
|
|
11
|
+
patches?: unknown[];
|
|
12
|
+
}
|
|
13
|
+
export interface ExpectedFile {
|
|
14
|
+
localPath: string;
|
|
15
|
+
repoPath: string;
|
|
16
|
+
userManaged: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface ExpectedOutput {
|
|
19
|
+
files: ExpectedFile[];
|
|
20
|
+
patches: unknown[];
|
|
21
|
+
}
|
|
22
|
+
export interface RenderTest {
|
|
23
|
+
name: string;
|
|
24
|
+
cr: string;
|
|
25
|
+
args?: Record<string, unknown>;
|
|
26
|
+
}
|
|
27
|
+
export interface RenderTestsFile {
|
|
28
|
+
tests: RenderTest[];
|
|
29
|
+
}
|
|
30
|
+
export interface RenderContext {
|
|
31
|
+
/** Absolute path to the temp dir */
|
|
32
|
+
getContextPath: () => string;
|
|
33
|
+
/** Join a relative path inside the temp dir */
|
|
34
|
+
join: (...p: string[]) => string;
|
|
35
|
+
/** Read a file (raw / JSON / YAML) from the temp dir */
|
|
36
|
+
getFile: <T = unknown>(relPath: string, opts?: {
|
|
37
|
+
yaml?: boolean;
|
|
38
|
+
json?: boolean;
|
|
39
|
+
}) => Promise<T | string>;
|
|
40
|
+
/** Absolute path of a file in the temp dir (no existence check) */
|
|
41
|
+
getFilePath: (relPath: string) => string;
|
|
42
|
+
/** Write a file (ensures parent dirs) */
|
|
43
|
+
setFile: (relPath: string, contents: string | Buffer | NodeJS.ArrayBufferView) => Promise<void>;
|
|
44
|
+
/** Whether a path exists in the temp dir */
|
|
45
|
+
exists: (relPath: string) => Promise<boolean>;
|
|
46
|
+
/** Convenience: read output.json from the temp dir */
|
|
47
|
+
getOutputJson: <T = unknown>() => Promise<T>;
|
|
48
|
+
/** List entries (name + isDir) in a subdirectory */
|
|
49
|
+
list: (relPath?: string) => Promise<Array<{
|
|
50
|
+
name: string;
|
|
51
|
+
isDir: boolean;
|
|
52
|
+
}>>;
|
|
53
|
+
/** Optional cleanup */
|
|
54
|
+
remove: () => Promise<void>;
|
|
55
|
+
}
|
|
56
|
+
declare function loadAndValidateRenderTests(featurePath: string): RenderTestsFile;
|
|
57
|
+
declare function resolveCrPath(featurePath: string, crRelPath: string): string;
|
|
58
|
+
export declare function listYamlFiles(dir: string): string[];
|
|
59
|
+
declare function loadYaml<T = unknown>(file: string): T;
|
|
60
|
+
export declare function ensureSafeTmpName(name: string): void;
|
|
61
|
+
declare function mkNamedTmp(name: string): Promise<string>;
|
|
62
|
+
export declare function mkTmp(prefix?: string): Promise<string>;
|
|
63
|
+
declare function buildExpectedOutput(config: FeatureConfig, renderDir: string): ExpectedOutput;
|
|
64
|
+
export declare function createRenderContext(prefix?: string): Promise<RenderContext>;
|
|
65
|
+
declare const _default: {
|
|
66
|
+
mkNamedTmp: typeof mkNamedTmp;
|
|
67
|
+
loadYaml: typeof loadYaml;
|
|
68
|
+
buildExpectedOutput: typeof buildExpectedOutput;
|
|
69
|
+
loadAndValidateRenderTests: typeof loadAndValidateRenderTests;
|
|
70
|
+
resolveCrPath: typeof resolveCrPath;
|
|
71
|
+
};
|
|
72
|
+
export default _default;
|