@firestartr/cli 1.45.0-snapshot-17 → 1.46.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 +157 -89
- package/build/packages/cdk8s_renderer/src/claims/base/schemas/component.schema.d.ts +6 -0
- package/build/packages/cdk8s_renderer/src/claims/base/schemas/index.d.ts +6 -0
- package/build/packages/cdk8s_renderer/src/loader/lazy_loader.d.ts +1 -0
- package/build/packages/cdk8s_renderer/src/loader/loader.d.ts +1 -1
- package/build/packages/cdk8s_renderer/src/renderer/renderer.d.ts +1 -1
- package/build/packages/cdk8s_renderer/src/utils/claimUtils.d.ts +3 -0
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -270521,7 +270521,7 @@ function helperCTX(patch) {
|
|
|
270521
270521
|
|
|
270522
270522
|
|
|
270523
270523
|
|
|
270524
|
-
class
|
|
270524
|
+
class uuid_UUIDInitializer extends InitializerPatches {
|
|
270525
270525
|
constructor() {
|
|
270526
270526
|
super(...arguments);
|
|
270527
270527
|
this.applicableProviders = ['github', 'terraform'];
|
|
@@ -270530,9 +270530,9 @@ class UUIDInitializer extends InitializerPatches {
|
|
|
270530
270530
|
return true;
|
|
270531
270531
|
}
|
|
270532
270532
|
async __patches(claim, previousCR) {
|
|
270533
|
-
if (
|
|
270533
|
+
if (uuid_UUIDInitializer.applicableKinds.indexOf(claim.kind) === -1) {
|
|
270534
270534
|
throw new InitializerError(`${claim.name} is of kind ${claim.kind}, which is not allowed. ` +
|
|
270535
|
-
`Allowed kinds: ${
|
|
270535
|
+
`Allowed kinds: ${uuid_UUIDInitializer.applicableKinds}`);
|
|
270536
270536
|
}
|
|
270537
270537
|
const uuid = false;
|
|
270538
270538
|
const fBuildWriteConnectionSecretToRef = (cr, crKind) => {
|
|
@@ -270569,7 +270569,7 @@ class UUIDInitializer extends InitializerPatches {
|
|
|
270569
270569
|
];
|
|
270570
270570
|
}
|
|
270571
270571
|
}
|
|
270572
|
-
|
|
270572
|
+
uuid_UUIDInitializer.applicableKinds = [
|
|
270573
270573
|
'GroupClaim',
|
|
270574
270574
|
'UserClaim',
|
|
270575
270575
|
'ComponentClaim',
|
|
@@ -270640,7 +270640,7 @@ class NormalizerError extends Error {
|
|
|
270640
270640
|
|
|
270641
270641
|
|
|
270642
270642
|
|
|
270643
|
-
class
|
|
270643
|
+
class name_NameNormalizer extends Normalizer {
|
|
270644
270644
|
constructor() {
|
|
270645
270645
|
super(...arguments);
|
|
270646
270646
|
this.applicableProviders = ['all'];
|
|
@@ -271061,7 +271061,7 @@ class GlobalDefault extends DefaultSection {
|
|
|
271061
271061
|
* - __getDesiredPatches(): a list of fast-json-patch patches
|
|
271062
271062
|
*
|
|
271063
271063
|
*/
|
|
271064
|
-
class
|
|
271064
|
+
class initializer_InitializerDefault extends DefaultSection {
|
|
271065
271065
|
constructor(data) {
|
|
271066
271066
|
super();
|
|
271067
271067
|
this.applicableProviders = ['github'];
|
|
@@ -271124,7 +271124,7 @@ class InitializerDefault extends DefaultSection {
|
|
|
271124
271124
|
;// CONCATENATED MODULE: ../cdk8s_renderer/src/initializers/claimRef.ts
|
|
271125
271125
|
|
|
271126
271126
|
|
|
271127
|
-
class
|
|
271127
|
+
class claimRef_InitializerClaimRef extends InitializerPatches {
|
|
271128
271128
|
constructor() {
|
|
271129
271129
|
super(...arguments);
|
|
271130
271130
|
this.applicableProviders = ['github', 'terraform'];
|
|
@@ -271155,7 +271155,7 @@ class InitializerClaimRef extends InitializerPatches {
|
|
|
271155
271155
|
];
|
|
271156
271156
|
}
|
|
271157
271157
|
}
|
|
271158
|
-
|
|
271158
|
+
claimRef_InitializerClaimRef.applicableKinds = [
|
|
271159
271159
|
'GroupClaim',
|
|
271160
271160
|
'UserClaim',
|
|
271161
271161
|
'ComponentClaim',
|
|
@@ -271475,7 +271475,7 @@ function setPath(pathName, pathValue) {
|
|
|
271475
271475
|
__PATH_VARIABLES[pathName] = pathValue;
|
|
271476
271476
|
}
|
|
271477
271477
|
let renamesEnabled = false;
|
|
271478
|
-
function
|
|
271478
|
+
function config_getRenamesEnabled() {
|
|
271479
271479
|
return renamesEnabled;
|
|
271480
271480
|
}
|
|
271481
271481
|
function setRenamesEnabled(enabled) {
|
|
@@ -271502,10 +271502,10 @@ class ConfigError extends Error {
|
|
|
271502
271502
|
super(`${errorType}: ${message}`);
|
|
271503
271503
|
}
|
|
271504
271504
|
}
|
|
271505
|
-
function getSelectedKindClaimCrMap(provider =
|
|
271505
|
+
function getSelectedKindClaimCrMap(provider = config_getConfiguredProvider().toString()) {
|
|
271506
271506
|
return PROVIDER_CLAIM_CR_MAP[provider.toString()];
|
|
271507
271507
|
}
|
|
271508
|
-
function
|
|
271508
|
+
function config_getConfiguredProvider() {
|
|
271509
271509
|
if (!configuredProvider)
|
|
271510
271510
|
throw new ConfigError('Provider config error', 'No provider configured, please call configureProvider()');
|
|
271511
271511
|
return configuredProvider;
|
|
@@ -272285,18 +272285,18 @@ PolicyInitializer.applicableKinds = ['TFWorkspaceClaim'];
|
|
|
272285
272285
|
|
|
272286
272286
|
|
|
272287
272287
|
const INITIALIZERS = [
|
|
272288
|
-
|
|
272289
|
-
|
|
272288
|
+
uuid_UUIDInitializer,
|
|
272289
|
+
claimRef_InitializerClaimRef,
|
|
272290
272290
|
BackstageInitializer,
|
|
272291
272291
|
PolicyInitializer,
|
|
272292
272292
|
SyncerInitializer,
|
|
272293
272293
|
];
|
|
272294
272294
|
const INITIALIZERS_BY_FILE_NAME = {
|
|
272295
272295
|
[TechnologyInitializer.FILE_NAME()]: TechnologyInitializer,
|
|
272296
|
-
defaults_github_repository:
|
|
272297
|
-
defaults_github_membership:
|
|
272298
|
-
defaults_github_group:
|
|
272299
|
-
defaults_github_orgwebhook:
|
|
272296
|
+
defaults_github_repository: initializer_InitializerDefault,
|
|
272297
|
+
defaults_github_membership: initializer_InitializerDefault,
|
|
272298
|
+
defaults_github_group: initializer_InitializerDefault,
|
|
272299
|
+
defaults_github_orgwebhook: initializer_InitializerDefault,
|
|
272300
272300
|
};
|
|
272301
272301
|
const SCHEMAS_BY_INITIALIZER_NAME = {
|
|
272302
272302
|
[TechnologyInitializer.FILE_NAME()]: technologies,
|
|
@@ -272547,6 +272547,10 @@ class FirestartrAllClaim {
|
|
|
272547
272547
|
type: 'string',
|
|
272548
272548
|
pattern: '^system:.+$',
|
|
272549
272549
|
},
|
|
272550
|
+
owner: {
|
|
272551
|
+
type: 'string',
|
|
272552
|
+
pattern: '^[^:]+:[^:]+$',
|
|
272553
|
+
},
|
|
272550
272554
|
providers: {
|
|
272551
272555
|
type: 'object',
|
|
272552
272556
|
properties: {
|
|
@@ -272556,6 +272560,7 @@ class FirestartrAllClaim {
|
|
|
272556
272560
|
},
|
|
272557
272561
|
},
|
|
272558
272562
|
},
|
|
272563
|
+
required: ['owner'],
|
|
272559
272564
|
additionalProperties: true,
|
|
272560
272565
|
},
|
|
272561
272566
|
],
|
|
@@ -273652,7 +273657,7 @@ function validatek8sLimits(moduleContent) {
|
|
|
273652
273657
|
|
|
273653
273658
|
|
|
273654
273659
|
const NORMALIZERS = [
|
|
273655
|
-
|
|
273660
|
+
name_NameNormalizer,
|
|
273656
273661
|
RefValuesNormalizer,
|
|
273657
273662
|
TFWorkspaceNormalizer,
|
|
273658
273663
|
RevisionNormalizer,
|
|
@@ -273925,9 +273930,14 @@ async function loadClaim(claimRef, org, defaults = loadClaimDefaults(), patchCla
|
|
|
273925
273930
|
}
|
|
273926
273931
|
return result;
|
|
273927
273932
|
}
|
|
273928
|
-
|
|
273929
|
-
|
|
273930
|
-
|
|
273933
|
+
let LoadedClaims = {};
|
|
273934
|
+
let VisitedClaims = {};
|
|
273935
|
+
let DuplicatedClaims = {};
|
|
273936
|
+
function resetLazyLoader() {
|
|
273937
|
+
LoadedClaims = {};
|
|
273938
|
+
VisitedClaims = {};
|
|
273939
|
+
DuplicatedClaims = {};
|
|
273940
|
+
}
|
|
273931
273941
|
async function lazyGetClaim(kind, name, org, cwd) {
|
|
273932
273942
|
const indice = `${kind}-${name}`;
|
|
273933
273943
|
lazy_loader_log(`Lazy loading ${kind}-${name} with index ${indice}`);
|
|
@@ -273951,6 +273961,7 @@ async function getClaimsByName(name, cwd = '.') {
|
|
|
273951
273961
|
const handler = (0,external_node_child_process_namespaceObject.spawn)('grep', ['-r', '-l', '--include=*', '-E', `name: "?${name}"?`, '.'], {
|
|
273952
273962
|
cwd: cwd,
|
|
273953
273963
|
});
|
|
273964
|
+
lazy_loader_log(`Running ${['grep', '-r', '-l', '--include', '-E', 'name: "' + name + '"?', '.'].join(' ')}`);
|
|
273954
273965
|
const entradas = [];
|
|
273955
273966
|
const chunks = [];
|
|
273956
273967
|
handler.stdout.on('data', (data) => {
|
|
@@ -274008,13 +274019,13 @@ async function loadRawClaim(entry) {
|
|
|
274008
274019
|
async function setVirtualClaimAdditionalData(renderedData, claim, claimRef) {
|
|
274009
274020
|
const virtualClaim = getVirtualClaim(claim.kind, claim.name);
|
|
274010
274021
|
renderedData[claimRef]['initializers'] = [
|
|
274011
|
-
new
|
|
274012
|
-
new
|
|
274013
|
-
new
|
|
274022
|
+
new uuid_UUIDInitializer(claim),
|
|
274023
|
+
new claimRef_InitializerClaimRef(),
|
|
274024
|
+
new initializer_InitializerDefault(virtualClaim.getDefaultConfig()),
|
|
274014
274025
|
];
|
|
274015
274026
|
renderedData[claimRef]['globals'] = [];
|
|
274016
274027
|
renderedData[claimRef]['overrides'] = [];
|
|
274017
|
-
renderedData[claimRef]['normalizers'] = [new
|
|
274028
|
+
renderedData[claimRef]['normalizers'] = [new name_NameNormalizer()];
|
|
274018
274029
|
return renderedData;
|
|
274019
274030
|
}
|
|
274020
274031
|
async function setNonVirtualClaimAdditionalData(renderedData, claim, claimRef, loadInitializers, loadGlobals, loadOverrides, loadNormalizers) {
|
|
@@ -274217,19 +274228,19 @@ async function loadInitializers(claim, initializersPath = config_getPath('initia
|
|
|
274217
274228
|
* · The claim's applicable initializers, globals and overrides
|
|
274218
274229
|
*
|
|
274219
274230
|
*/
|
|
274220
|
-
async function loadClaims(claimsPath =
|
|
274231
|
+
async function loadClaims(claimsPath = getPath('claims')) {
|
|
274221
274232
|
const result = {};
|
|
274222
274233
|
const defaultsClaims = loadClaimDefaults();
|
|
274223
|
-
await
|
|
274234
|
+
await crawl(claimsPath, (entry) => {
|
|
274224
274235
|
return isYamlFile.test(entry);
|
|
274225
274236
|
}, async (entry, data) => {
|
|
274226
|
-
const claim = loader_patchClaim(
|
|
274237
|
+
const claim = loader_patchClaim(common.io.fromYaml(data), defaultsClaims);
|
|
274227
274238
|
if (!('kind' in claim && 'name' in claim)) {
|
|
274228
274239
|
throw new Error(`Invalid claim file ${entry}`);
|
|
274229
274240
|
}
|
|
274230
274241
|
try {
|
|
274231
|
-
validateClaim(claim,
|
|
274232
|
-
await optionalValidation(claim);
|
|
274242
|
+
ClaimValidation.validateClaim(claim, claims[`${claim.kind}Schema`]);
|
|
274243
|
+
await ClaimValidation.optionalValidation(claim);
|
|
274233
274244
|
}
|
|
274234
274245
|
catch (err) {
|
|
274235
274246
|
throw new Error(`Validating ${claim.kind + '-' + claim.name}: ${JSON.stringify(err, null, 2)}`);
|
|
@@ -274326,7 +274337,7 @@ async function loadRenames(claims, crs) {
|
|
|
274326
274337
|
if (!anyCr?.metadata?.annotations)
|
|
274327
274338
|
continue;
|
|
274328
274339
|
// if the annotation is a claimRef
|
|
274329
|
-
const annotationName =
|
|
274340
|
+
const annotationName = common.generic.getFirestartrAnnotation('claim-ref');
|
|
274330
274341
|
const annotations = anyCr?.metadata?.annotations || {};
|
|
274331
274342
|
if (annotationName in annotations) {
|
|
274332
274343
|
const claimRef = anyCr.metadata.annotations[annotationName];
|
|
@@ -274408,7 +274419,7 @@ async function loadClaimsList(claimRefList, claimsPath = config_getPath('claims'
|
|
|
274408
274419
|
crs: {},
|
|
274409
274420
|
};
|
|
274410
274421
|
const defaults = loadClaimDefaults();
|
|
274411
|
-
for (const claimRef of claimRefList) {
|
|
274422
|
+
for await (const claimRef of claimRefList) {
|
|
274412
274423
|
const renderedClaimData = await loadClaim(claimRef, getOrg(), defaults, loader_patchClaim, loadInitializers, loadGlobals, loadOverrides, loadNormalizers, claimsPath);
|
|
274413
274424
|
data.renderClaims = lodash_default().merge(data.renderClaims, renderedClaimData);
|
|
274414
274425
|
}
|
|
@@ -274530,8 +274541,8 @@ Check the following Claims to ensure that the tfStateKey is unique:
|
|
|
274530
274541
|
*/
|
|
274531
274542
|
function validateReferencesInCR(cr, crs) {
|
|
274532
274543
|
if (isCatalogEntity(cr)) {
|
|
274533
|
-
if (
|
|
274534
|
-
validateCatalogEntities(cr, crs);
|
|
274544
|
+
if (config_getConfiguredProvider() === AllowedProviders.catalog) {
|
|
274545
|
+
//validateCatalogEntities(cr, crs);
|
|
274535
274546
|
//console.log(`Skip validation ${cr.name}`);
|
|
274536
274547
|
}
|
|
274537
274548
|
}
|
|
@@ -274592,8 +274603,8 @@ function validateNonCatalogEntities(cr, crs) {
|
|
|
274592
274603
|
*/
|
|
274593
274604
|
function validateCatalogEntities(cr, crs) {
|
|
274594
274605
|
for (const rel of WELL_KNOWN_RELATIONS_CATALOG[cr.kind]) {
|
|
274595
|
-
if (
|
|
274596
|
-
const refObject =
|
|
274606
|
+
if (_.has(cr, rel)) {
|
|
274607
|
+
const refObject = _.get(cr, rel);
|
|
274597
274608
|
const catalogEntityName = extractNameCatalogEntity(cr);
|
|
274598
274609
|
if (!Array.isArray(refObject)) {
|
|
274599
274610
|
const propertyRef = createCatalogEntityPropertyRef(refObject);
|
|
@@ -276131,6 +276142,10 @@ const KINDS_CR_MAP = {
|
|
|
276131
276142
|
};
|
|
276132
276143
|
|
|
276133
276144
|
|
|
276145
|
+
|
|
276146
|
+
|
|
276147
|
+
|
|
276148
|
+
const claimUtils_log = src_default()('firestartr:utils:path-resolver');
|
|
276134
276149
|
function resolveStringReference(reference) {
|
|
276135
276150
|
const referenceElements = reference.split(':');
|
|
276136
276151
|
const actualKind = KINDS_CR_MAP[referenceElements[0]];
|
|
@@ -276139,6 +276154,11 @@ function resolveStringReference(reference) {
|
|
|
276139
276154
|
name: referenceElements[1],
|
|
276140
276155
|
};
|
|
276141
276156
|
}
|
|
276157
|
+
async function* claimsRefListAsGenerator(refs) {
|
|
276158
|
+
for (const ref of refs) {
|
|
276159
|
+
yield ref;
|
|
276160
|
+
}
|
|
276161
|
+
}
|
|
276142
276162
|
// Given a fileList "<file1>,<file2>....<fileN>"
|
|
276143
276163
|
// It parses the files an returns a list of references
|
|
276144
276164
|
// in the form of <kind>-<name>
|
|
@@ -276147,8 +276167,8 @@ function resolveClaimFilesList(claimRefsList) {
|
|
|
276147
276167
|
const refList = [];
|
|
276148
276168
|
for (const file of fileList) {
|
|
276149
276169
|
try {
|
|
276150
|
-
const data =
|
|
276151
|
-
const claim =
|
|
276170
|
+
const data = fs.readFileSync(file, 'utf-8');
|
|
276171
|
+
const claim = common.io.fromYaml(data);
|
|
276152
276172
|
if (!('kind' in claim && 'name' in claim)) {
|
|
276153
276173
|
throw 'Invalid claim file, has not kind and/or name';
|
|
276154
276174
|
}
|
|
@@ -276163,6 +276183,65 @@ function resolveClaimFilesList(claimRefsList) {
|
|
|
276163
276183
|
}
|
|
276164
276184
|
return refList;
|
|
276165
276185
|
}
|
|
276186
|
+
// This function receives an array of entries (dirs or files)
|
|
276187
|
+
// it returns a generator able to be used in a loop
|
|
276188
|
+
// under the form: for await (const claimRef of resolveClaimRefsGenerator){}
|
|
276189
|
+
// If dirs are passed, it resolves them recursively
|
|
276190
|
+
async function* resolveClaimEntries(claimRefsList) {
|
|
276191
|
+
claimUtils_log(`Resolving ${claimRefsList.join(',')}`);
|
|
276192
|
+
for (const claimEntry of claimRefsList) {
|
|
276193
|
+
try {
|
|
276194
|
+
const claimEntryStats = await (0,promises_namespaceObject.stat)(claimEntry);
|
|
276195
|
+
if (claimEntryStats.isDirectory()) {
|
|
276196
|
+
yield* resolveDirEntries(claimEntry);
|
|
276197
|
+
}
|
|
276198
|
+
else if (claimEntryStats.isFile()) {
|
|
276199
|
+
claimUtils_log(`Sending entry ${resolveClaimFileRef(claimEntry)} (${claimEntry})`);
|
|
276200
|
+
yield resolveClaimFileRef(claimEntry);
|
|
276201
|
+
}
|
|
276202
|
+
}
|
|
276203
|
+
catch (err) {
|
|
276204
|
+
throw `Error processing: ${claimEntry}: ${err}`;
|
|
276205
|
+
}
|
|
276206
|
+
}
|
|
276207
|
+
}
|
|
276208
|
+
// this function recursively searches for files
|
|
276209
|
+
// it returns a generator that yields claimRefs
|
|
276210
|
+
async function* resolveDirEntries(dir) {
|
|
276211
|
+
let entries = [];
|
|
276212
|
+
try {
|
|
276213
|
+
entries = await (0,promises_namespaceObject.readdir)(dir, { withFileTypes: true });
|
|
276214
|
+
}
|
|
276215
|
+
catch (err) {
|
|
276216
|
+
throw `Reading dir: ${dir}: ${err}`;
|
|
276217
|
+
}
|
|
276218
|
+
for (const entry of entries) {
|
|
276219
|
+
const fullPath = external_path_default().join(dir, entry.name);
|
|
276220
|
+
if (entry.isDirectory(fullPath)) {
|
|
276221
|
+
yield* resolveDirEntries(fullPath);
|
|
276222
|
+
}
|
|
276223
|
+
else if (entry.isFile(fullPath) && entry.name.match(/\.yaml$|\.yml$/)) {
|
|
276224
|
+
claimUtils_log(`Sending entry ${resolveClaimFileRef(fullPath)} (${fullPath})`);
|
|
276225
|
+
yield resolveClaimFileRef(fullPath);
|
|
276226
|
+
}
|
|
276227
|
+
}
|
|
276228
|
+
}
|
|
276229
|
+
function resolveClaimFileRef(claimFile) {
|
|
276230
|
+
try {
|
|
276231
|
+
const data = external_fs_default().readFileSync(claimFile, 'utf-8');
|
|
276232
|
+
const claim = catalog_common.io.fromYaml(data);
|
|
276233
|
+
if (!('kind' in claim && 'name' in claim)) {
|
|
276234
|
+
throw 'Invalid claim file has not kind and/or name';
|
|
276235
|
+
}
|
|
276236
|
+
else {
|
|
276237
|
+
const claimRef = `${claim.kind}-${claim.name}`;
|
|
276238
|
+
return claimRef;
|
|
276239
|
+
}
|
|
276240
|
+
}
|
|
276241
|
+
catch (err) {
|
|
276242
|
+
throw `Error: file ${claimFile}: ${err}`;
|
|
276243
|
+
}
|
|
276244
|
+
}
|
|
276166
276245
|
|
|
276167
276246
|
;// CONCATENATED MODULE: ../cdk8s_renderer/imports/firestartr.dev.ts
|
|
276168
276247
|
// generated by cdk8s
|
|
@@ -279522,7 +279601,7 @@ async function renderClaims(catalogScope, firestartrScope, data) {
|
|
|
279522
279601
|
for (const renderClaims of sortedKinds) {
|
|
279523
279602
|
for (const claimKey of Object.keys(renderClaims)) {
|
|
279524
279603
|
const claim = renderClaims[claimKey].claim;
|
|
279525
|
-
const configuredProvider =
|
|
279604
|
+
const configuredProvider = config_getConfiguredProvider().toString();
|
|
279526
279605
|
let providers = Object.keys(claim.providers);
|
|
279527
279606
|
if (configuredProvider !== AllowedProviders.all.toString()) {
|
|
279528
279607
|
providers = providers.filter((provider) => provider === configuredProvider);
|
|
@@ -279571,7 +279650,7 @@ async function renderClaim(catalogScope, firestartrScope, claim, patches, previo
|
|
|
279571
279650
|
}
|
|
279572
279651
|
const renderPatches = patches.filter((patch) => !patch.isPostPatch);
|
|
279573
279652
|
const postPatches = patches.filter((patch) => patch.isPostPatch);
|
|
279574
|
-
const provider =
|
|
279653
|
+
const provider = config_getConfiguredProvider();
|
|
279575
279654
|
const loadGithub = (provider === AllowedProviders.all ||
|
|
279576
279655
|
provider === AllowedProviders.catalog ||
|
|
279577
279656
|
provider === AllowedProviders.github) &&
|
|
@@ -279701,14 +279780,8 @@ async function renderClaim(catalogScope, firestartrScope, claim, patches, previo
|
|
|
279701
279780
|
* rendered firestartr-all group
|
|
279702
279781
|
*
|
|
279703
279782
|
*/
|
|
279704
|
-
async function renderer_render(catalogScope, firestartrScope, activateReferentialIntegrityValidation = true, claimList
|
|
279705
|
-
|
|
279706
|
-
if (claimList.length > 0) {
|
|
279707
|
-
data = await loadClaimsList(claimList);
|
|
279708
|
-
}
|
|
279709
|
-
else {
|
|
279710
|
-
data = await loadAll();
|
|
279711
|
-
}
|
|
279783
|
+
async function renderer_render(catalogScope, firestartrScope, activateReferentialIntegrityValidation = true, claimList) {
|
|
279784
|
+
const data = await loadClaimsList(claimList);
|
|
279712
279785
|
const result = await renderClaims(catalogScope, firestartrScope, data);
|
|
279713
279786
|
if (activateReferentialIntegrityValidation) {
|
|
279714
279787
|
validateReferentialIntegrity(result);
|
|
@@ -279726,6 +279799,8 @@ async function renderer_render(catalogScope, firestartrScope, activateReferentia
|
|
|
279726
279799
|
|
|
279727
279800
|
|
|
279728
279801
|
|
|
279802
|
+
|
|
279803
|
+
|
|
279729
279804
|
const MAIN_BRANCH_OUTPUT_DIR = '/tmp/resources_from_main_branch';
|
|
279730
279805
|
const PR_BRANCH_OUTPUT_DIR = '/tmp/resources_from_pr_branch';
|
|
279731
279806
|
/**
|
|
@@ -279774,9 +279849,10 @@ async function getAffectedRepositories(claimPathFromMain, claimPathFromPR, wetRe
|
|
|
279774
279849
|
yamlOutputType: lib.YamlOutputType.FILE_PER_RESOURCE,
|
|
279775
279850
|
});
|
|
279776
279851
|
// Render the main branch
|
|
279777
|
-
const renderFromMainBranch = await renderer_render(mainBranchCatalogApp, mainBranchFirestartrApp);
|
|
279852
|
+
const renderFromMainBranch = await renderer_render(mainBranchCatalogApp, mainBranchFirestartrApp, true, await resolveClaimEntries([claimPathFromMain]));
|
|
279778
279853
|
mainBranchFirestartrApp.synth();
|
|
279779
279854
|
emptyRenderedClaims();
|
|
279855
|
+
resetLazyLoader();
|
|
279780
279856
|
// Change the claims path to the PR branch
|
|
279781
279857
|
setPath('claims', claimPathFromPR);
|
|
279782
279858
|
const app2 = new lib.App({
|
|
@@ -279785,7 +279861,7 @@ async function getAffectedRepositories(claimPathFromMain, claimPathFromPR, wetRe
|
|
|
279785
279861
|
yamlOutputType: lib.YamlOutputType.FILE_PER_RESOURCE,
|
|
279786
279862
|
});
|
|
279787
279863
|
// Render the PR branch
|
|
279788
|
-
const renderFromPRBranch = await renderer_render(new lib.App(), app2);
|
|
279864
|
+
const renderFromPRBranch = await renderer_render(new lib.App(), app2, true, await resolveClaimEntries([claimPathFromPR]));
|
|
279789
279865
|
app2.synth();
|
|
279790
279866
|
// Iterate over the resources from the main branch
|
|
279791
279867
|
for (const key of Object.keys(renderFromMainBranch)) {
|
|
@@ -279886,7 +279962,7 @@ async function runComparer(claimPathFromMain, claimPathFromPR, claimsDefaultsPat
|
|
|
279886
279962
|
const renderer_log = src_default()('firestartr:operator:cmd:tfworkspaces-renderer');
|
|
279887
279963
|
async function renderTfWorkspace(claim, firestartrId, resolveRef, namespace) {
|
|
279888
279964
|
const app = new lib.App();
|
|
279889
|
-
const initializers = [new
|
|
279965
|
+
const initializers = [new uuid_UUIDInitializer(), new claimRef_InitializerClaimRef()];
|
|
279890
279966
|
const previousCR = await resolveRef('TFWorkspace', claim.name, namespace);
|
|
279891
279967
|
if (previousCR) {
|
|
279892
279968
|
renderer_log(`💊 Previous CR found for ${claim.name} in ${namespace} with tfStateKey ${previousCR.spec.firestartr.tfStateKey}`);
|
|
@@ -279896,7 +279972,7 @@ async function renderTfWorkspace(claim, firestartrId, resolveRef, namespace) {
|
|
|
279896
279972
|
}
|
|
279897
279973
|
const refValuesNormalizer = new RefValuesNormalizer();
|
|
279898
279974
|
refValuesNormalizer.rsClaimRef = (kind, name) => resolveRef(kind, name, namespace);
|
|
279899
|
-
const normalizers = [refValuesNormalizer, new
|
|
279975
|
+
const normalizers = [refValuesNormalizer, new name_NameNormalizer()];
|
|
279900
279976
|
let totalPatches = [];
|
|
279901
279977
|
for (const normalizer of normalizers) {
|
|
279902
279978
|
const patches = await normalizer.patches(claim, previousCR);
|
|
@@ -280038,12 +280114,17 @@ async function runRenderer(globalsPath, initializersPath, claimsPath, crsPath, c
|
|
|
280038
280114
|
outputFileExtension: '.yaml',
|
|
280039
280115
|
yamlOutputType: lib.YamlOutputType.FILE_PER_RESOURCE,
|
|
280040
280116
|
});
|
|
280041
|
-
let claimRefsList =
|
|
280117
|
+
let claimRefsList = null;
|
|
280042
280118
|
if (claimRefs) {
|
|
280043
|
-
claimRefsList = claimRefs.replace(/\s/g, '').split(',');
|
|
280119
|
+
claimRefsList = await claimsRefListAsGenerator(claimRefs.replace(/\s/g, '').split(','));
|
|
280044
280120
|
}
|
|
280045
280121
|
else if (claimFilesList) {
|
|
280046
|
-
claimRefsList =
|
|
280122
|
+
claimRefsList = await resolveClaimEntries(claimFilesList.replace(/\s/g, '').split(','));
|
|
280123
|
+
}
|
|
280124
|
+
else {
|
|
280125
|
+
// in case nothing is passed
|
|
280126
|
+
// the system takes everything defined in the claims path
|
|
280127
|
+
claimRefsList = await resolveClaimEntries([claimsPath]);
|
|
280047
280128
|
}
|
|
280048
280129
|
try {
|
|
280049
280130
|
await renderer_render(catalogApp, firestartrApp, validateReferentialIntegrity === 'enabled' ? true : false, claimRefsList);
|
|
@@ -280124,10 +280205,10 @@ class Decanter {
|
|
|
280124
280205
|
this.data = data;
|
|
280125
280206
|
}
|
|
280126
280207
|
async __adaptInitializerTfStateKey() {
|
|
280127
|
-
return new
|
|
280208
|
+
return new uuid_UUIDInitializer();
|
|
280128
280209
|
}
|
|
280129
280210
|
async __adaptInitializerClaimRef() {
|
|
280130
|
-
return new
|
|
280211
|
+
return new claimRef_InitializerClaimRef();
|
|
280131
280212
|
}
|
|
280132
280213
|
async __adaptInitializerImport() {
|
|
280133
280214
|
return new ImportInitializer();
|
|
@@ -280211,7 +280292,7 @@ class Decanter {
|
|
|
280211
280292
|
initializers,
|
|
280212
280293
|
globals: [],
|
|
280213
280294
|
overrides,
|
|
280214
|
-
normalizers: [new
|
|
280295
|
+
normalizers: [new name_NameNormalizer()],
|
|
280215
280296
|
},
|
|
280216
280297
|
};
|
|
280217
280298
|
return adapted;
|
|
@@ -280242,7 +280323,7 @@ class GithubDecanter extends decanter_base {
|
|
|
280242
280323
|
this.org = org;
|
|
280243
280324
|
}
|
|
280244
280325
|
__adaptClaimRef() {
|
|
280245
|
-
return new
|
|
280326
|
+
return new claimRef_InitializerClaimRef();
|
|
280246
280327
|
}
|
|
280247
280328
|
}
|
|
280248
280329
|
|
|
@@ -280327,7 +280408,7 @@ class GroupGithubDecanter extends GithubDecanter {
|
|
|
280327
280408
|
},
|
|
280328
280409
|
},
|
|
280329
280410
|
};
|
|
280330
|
-
return new
|
|
280411
|
+
return new initializer_InitializerDefault(adapterBase);
|
|
280331
280412
|
}
|
|
280332
280413
|
__validateKind(cr) {
|
|
280333
280414
|
return true;
|
|
@@ -280482,7 +280563,7 @@ class MemberGithubDecanter extends GithubDecanter {
|
|
|
280482
280563
|
},
|
|
280483
280564
|
},
|
|
280484
280565
|
};
|
|
280485
|
-
return new
|
|
280566
|
+
return new initializer_InitializerDefault(adapterBase);
|
|
280486
280567
|
}
|
|
280487
280568
|
}
|
|
280488
280569
|
|
|
@@ -280821,7 +280902,7 @@ class RepoGithubDecanter extends GithubDecanter {
|
|
|
280821
280902
|
},
|
|
280822
280903
|
},
|
|
280823
280904
|
};
|
|
280824
|
-
return new
|
|
280905
|
+
return new initializer_InitializerDefault(adapterBase);
|
|
280825
280906
|
}
|
|
280826
280907
|
async __adaptOverriderRepo(_claim) {
|
|
280827
280908
|
return new GithubRepositoryOverrider();
|
|
@@ -281813,7 +281894,6 @@ async function writePlanInGithubPR(prUrl, planText) {
|
|
|
281813
281894
|
}
|
|
281814
281895
|
async function addApplyCommitStatus(cr, state, targetURL = '', description = '', context = '') {
|
|
281815
281896
|
try {
|
|
281816
|
-
await addCommitStatusToHeadCommit(cr.metadata.annotations['firestartr.dev/last-claim-pr'], state, targetURL, description, context);
|
|
281817
281897
|
await addCommitStatusToPrMergeCommit(cr.metadata.annotations['firestartr.dev/last-state-pr'], state, targetURL, description, context);
|
|
281818
281898
|
}
|
|
281819
281899
|
catch (e) {
|
|
@@ -281855,12 +281935,6 @@ async function addCommitStatusToPrMergeCommit(prAnnotationValue, state, targetUR
|
|
|
281855
281935
|
fDebug(`Adding commit status to ${prAnnotationValue} for owner ${owner}, repo ${repo} and SHA ${branchSha}`);
|
|
281856
281936
|
await github_0.repo.addCommitStatus(state, branchSha, repo, owner, targetURL, description, context);
|
|
281857
281937
|
}
|
|
281858
|
-
async function addCommitStatusToHeadCommit(prAnnotationValue, state, targetURL, description, context) {
|
|
281859
|
-
const { owner, repo, prNumber } = catalog_common.generic.getOwnerRepoPrNumberFromAnnotationValue(prAnnotationValue);
|
|
281860
|
-
const branchSha = await github_0.pulls.getPrLastCommitSHA(prNumber, repo, owner);
|
|
281861
|
-
fDebug(`Adding commit status to ${prAnnotationValue} for owner ${owner}, repo ${repo} and SHA ${branchSha}`);
|
|
281862
|
-
await github_0.repo.addCommitStatus(state, branchSha, repo, owner, targetURL, description, context);
|
|
281863
|
-
}
|
|
281864
281938
|
async function getLastStatePrInfo(cr) {
|
|
281865
281939
|
try {
|
|
281866
281940
|
const prInfo = cr.metadata.annotations['firestartr.dev/last-state-pr'];
|
|
@@ -285123,8 +285197,7 @@ async function* doApply(item, op, handler) {
|
|
|
285123
285197
|
}
|
|
285124
285198
|
const deps = await handler.resolveReferences();
|
|
285125
285199
|
cdktf_log('Item %s has the following dependencies: %O', item.metadata.name, deps);
|
|
285126
|
-
if (
|
|
285127
|
-
(item.metadata.annotations['firestartr.dev/last-state-pr'] || false)) {
|
|
285200
|
+
if (item.metadata.annotations['firestartr.dev/last-state-pr'] || false) {
|
|
285128
285201
|
await addApplyCommitStatus(item, 'pending', catalog_common.generic.getPrLinkFromAnnotationValue(item.metadata.annotations['firestartr.dev/last-state-pr']), 'Performing apply operation...', `Terraform Apply ${item.metadata.name}`);
|
|
285129
285202
|
}
|
|
285130
285203
|
const applyOutput = await provisioner.runProvisioner({
|
|
@@ -285160,8 +285233,7 @@ async function* doApply(item, op, handler) {
|
|
|
285160
285233
|
message: 'doApply',
|
|
285161
285234
|
};
|
|
285162
285235
|
await handler.writeTerraformOutputInTfResult(item, output);
|
|
285163
|
-
if (
|
|
285164
|
-
(item.metadata.annotations['firestartr.dev/last-state-pr'] || false)) {
|
|
285236
|
+
if (item.metadata.annotations['firestartr.dev/last-state-pr'] || false) {
|
|
285165
285237
|
await addApplyCommitStatus(item, 'success', catalog_common.generic.getPrLinkFromAnnotationValue(item.metadata.annotations['firestartr.dev/last-state-pr']), 'Apply operation completed', `Terraform Apply ${item.metadata.name}`);
|
|
285166
285238
|
}
|
|
285167
285239
|
handler.success();
|
|
@@ -285197,8 +285269,7 @@ async function* doApply(item, op, handler) {
|
|
|
285197
285269
|
status: 'False',
|
|
285198
285270
|
message: error.toString(),
|
|
285199
285271
|
};
|
|
285200
|
-
if (
|
|
285201
|
-
(item.metadata.annotations['firestartr.dev/last-state-pr'] || false)) {
|
|
285272
|
+
if (item.metadata.annotations['firestartr.dev/last-state-pr'] || false) {
|
|
285202
285273
|
await addApplyCommitStatus(item, 'failure', catalog_common.generic.getPrLinkFromAnnotationValue(item.metadata.annotations['firestartr.dev/last-state-pr']), 'Apply operation failed', `Terraform Apply ${item.metadata.name}`);
|
|
285203
285274
|
}
|
|
285204
285275
|
handler.error();
|
|
@@ -286534,8 +286605,7 @@ async function* process_operation_doApply(item, op, handler) {
|
|
|
286534
286605
|
const deps = await handler.resolveReferences();
|
|
286535
286606
|
process_operation_log('Item %s has the following dependencies: %O', item.metadata.name, deps);
|
|
286536
286607
|
const context = buildProvisionerContext(item, deps);
|
|
286537
|
-
if (
|
|
286538
|
-
(item.metadata.annotations['firestartr.dev/last-state-pr'] || false)) {
|
|
286608
|
+
if (item.metadata.annotations['firestartr.dev/last-state-pr'] || false) {
|
|
286539
286609
|
await addApplyCommitStatus(item, 'pending', catalog_common.generic.getPrLinkFromAnnotationValue(item.metadata.annotations['firestartr.dev/last-state-pr']), 'Performing apply operation...', `Terraform Apply ${item.metadata.name}`);
|
|
286540
286610
|
}
|
|
286541
286611
|
const applyOutput = await runTerraformProvisioner(context, 'apply');
|
|
@@ -286570,8 +286640,7 @@ async function* process_operation_doApply(item, op, handler) {
|
|
|
286570
286640
|
message: 'doApply',
|
|
286571
286641
|
};
|
|
286572
286642
|
await handler.writeTerraformOutputInTfResult(item, output);
|
|
286573
|
-
if (
|
|
286574
|
-
(item.metadata.annotations['firestartr.dev/last-state-pr'] || false)) {
|
|
286643
|
+
if (item.metadata.annotations['firestartr.dev/last-state-pr'] || false) {
|
|
286575
286644
|
await addApplyCommitStatus(item, 'success', catalog_common.generic.getPrLinkFromAnnotationValue(item.metadata.annotations['firestartr.dev/last-state-pr']), 'Apply operation completed', `Terraform Apply ${item.metadata.name}`);
|
|
286576
286645
|
}
|
|
286577
286646
|
handler.success();
|
|
@@ -286601,8 +286670,7 @@ async function* process_operation_doApply(item, op, handler) {
|
|
|
286601
286670
|
status: 'False',
|
|
286602
286671
|
message: JSON.stringify(e),
|
|
286603
286672
|
};
|
|
286604
|
-
if (
|
|
286605
|
-
(item.metadata.annotations['firestartr.dev/last-state-pr'] || false)) {
|
|
286673
|
+
if (item.metadata.annotations['firestartr.dev/last-state-pr'] || false) {
|
|
286606
286674
|
await addApplyCommitStatus(item, 'failure', catalog_common.generic.getPrLinkFromAnnotationValue(item.metadata.annotations['firestartr.dev/last-state-pr']), 'Apply operation failed', `Terraform Apply ${item.metadata.name}`);
|
|
286607
286675
|
}
|
|
286608
286676
|
handler.error();
|
|
@@ -286845,27 +286913,27 @@ function getErrorOutputMessage(cr, key, ref) {
|
|
|
286845
286913
|
return `
|
|
286846
286914
|
|
|
286847
286915
|
❌ No output ${key} found in secret '${ref.secret.metadata.name}' .
|
|
286848
|
-
|
|
286916
|
+
|
|
286849
286917
|
❗❕ Your terraform project has not the output '${key}' .
|
|
286850
|
-
|
|
286918
|
+
|
|
286851
286919
|
Maybe you forgot to add it or your reference is wrong.
|
|
286852
|
-
|
|
286920
|
+
|
|
286853
286921
|
🔗 Terraform project: ${cr.spec.module}
|
|
286854
|
-
|
|
286922
|
+
|
|
286855
286923
|
🖹 Output example:
|
|
286856
|
-
|
|
286924
|
+
|
|
286857
286925
|
... your terraform code ...
|
|
286858
|
-
|
|
286926
|
+
|
|
286859
286927
|
# missing output
|
|
286860
286928
|
output '${key}' {
|
|
286861
286929
|
value = <your_value>
|
|
286862
286930
|
}
|
|
286863
|
-
|
|
286931
|
+
|
|
286864
286932
|
`;
|
|
286865
286933
|
}
|
|
286866
286934
|
else if (cr.spec.source === 'Inline') {
|
|
286867
286935
|
return `❗❕ Could not find output '${key}' in inline module:
|
|
286868
|
-
|
|
286936
|
+
|
|
286869
286937
|
${cr.spec.module}
|
|
286870
286938
|
`;
|
|
286871
286939
|
}
|
|
@@ -10,6 +10,7 @@ declare const _default: {
|
|
|
10
10
|
$ref: string;
|
|
11
11
|
type?: undefined;
|
|
12
12
|
properties?: undefined;
|
|
13
|
+
required?: undefined;
|
|
13
14
|
additionalProperties?: undefined;
|
|
14
15
|
} | {
|
|
15
16
|
type: string;
|
|
@@ -18,6 +19,10 @@ declare const _default: {
|
|
|
18
19
|
type: string;
|
|
19
20
|
pattern: string;
|
|
20
21
|
};
|
|
22
|
+
owner: {
|
|
23
|
+
type: string;
|
|
24
|
+
pattern: string;
|
|
25
|
+
};
|
|
21
26
|
providers: {
|
|
22
27
|
type: string;
|
|
23
28
|
properties: {
|
|
@@ -27,6 +32,7 @@ declare const _default: {
|
|
|
27
32
|
};
|
|
28
33
|
};
|
|
29
34
|
};
|
|
35
|
+
required: string[];
|
|
30
36
|
additionalProperties: boolean;
|
|
31
37
|
$ref?: undefined;
|
|
32
38
|
})[];
|
|
@@ -142,6 +142,7 @@ declare const schemas: {
|
|
|
142
142
|
$ref: string;
|
|
143
143
|
type?: undefined;
|
|
144
144
|
properties?: undefined;
|
|
145
|
+
required?: undefined;
|
|
145
146
|
additionalProperties?: undefined;
|
|
146
147
|
} | {
|
|
147
148
|
type: string;
|
|
@@ -150,6 +151,10 @@ declare const schemas: {
|
|
|
150
151
|
type: string;
|
|
151
152
|
pattern: string;
|
|
152
153
|
};
|
|
154
|
+
owner: {
|
|
155
|
+
type: string;
|
|
156
|
+
pattern: string;
|
|
157
|
+
};
|
|
153
158
|
providers: {
|
|
154
159
|
type: string;
|
|
155
160
|
properties: {
|
|
@@ -159,6 +164,7 @@ declare const schemas: {
|
|
|
159
164
|
};
|
|
160
165
|
};
|
|
161
166
|
};
|
|
167
|
+
required: string[];
|
|
162
168
|
additionalProperties: boolean;
|
|
163
169
|
$ref?: undefined;
|
|
164
170
|
})[];
|
|
@@ -3,3 +3,4 @@ import { GlobalSection } from '../globals/base';
|
|
|
3
3
|
import { OverriderPatches } from '../overriders/base';
|
|
4
4
|
import { Normalizer } from '../normalizers/base';
|
|
5
5
|
export declare function loadClaim(claimRef: string, org: string, defaults: any, patchClaim: (claim: any, defaults: any) => any, loadInitializers: (claim: any) => Promise<InitializerPatches[]>, loadGlobals: (claim: any) => Promise<GlobalSection[]>, loadOverrides: (claim: any) => OverriderPatches[], loadNormalizers: (claim: any, path: string) => Promise<Normalizer[]>, cwd?: string, existingRefs?: any): Promise<any>;
|
|
6
|
+
export declare function resetLazyLoader(): void;
|
|
@@ -39,7 +39,7 @@ export declare function loadAll(): Promise<{
|
|
|
39
39
|
crs: any;
|
|
40
40
|
renames?: IRenameResult[];
|
|
41
41
|
}>;
|
|
42
|
-
export declare function loadClaimsList(claimRefList: string
|
|
42
|
+
export declare function loadClaimsList(claimRefList: AsyncGenerator<string, void, unknown>, claimsPath?: string): Promise<{
|
|
43
43
|
renderClaims: RenderClaims;
|
|
44
44
|
crs: any;
|
|
45
45
|
renames?: IRenameResult[];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Construct } from 'constructs';
|
|
2
2
|
import { RenderedCrMap } from './types';
|
|
3
|
-
export declare function render(catalogScope: Construct, firestartrScope: Construct, activateReferentialIntegrityValidation
|
|
3
|
+
export declare function render(catalogScope: Construct, firestartrScope: Construct, activateReferentialIntegrityValidation: boolean, claimList: AsyncGenerator<string, void, unknown>): Promise<RenderedCrMap>;
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
export declare function resolveStringReference(reference: string): any;
|
|
2
|
+
export declare function claimsRefListAsGenerator(refs: string[]): AsyncGenerator<string, void, unknown>;
|
|
2
3
|
export declare function resolveClaimFilesList(claimRefsList: string): string[];
|
|
4
|
+
export declare function resolveClaimEntries(claimRefsList: string[]): AsyncGenerator<string, void, unknown>;
|
|
5
|
+
export declare function resolveClaimFileRef(claimFile: string): string;
|