@firestartr/cli 1.45.0-snapshot-11 → 1.45.0-snapshot-12

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.
Files changed (2) hide show
  1. package/build/index.js +45 -24
  2. package/package.json +1 -1
package/build/index.js CHANGED
@@ -262837,7 +262837,7 @@ const TFWorkspaceRefRegex = new RegExp(`\\$\\{\\{\\s*tfworkspace\\:(${regModuleN
262837
262837
  const SecretRefRegex = new RegExp(`\\$\\{\\{\\s*secret\\:(${regModuleName.source})\\.(${regModuleName.source})\\s*\\}\\}`, 'ig');
262838
262838
  const GroupRefRegex = new RegExp(`group\\:(${regModuleName.source})`, 'ig');
262839
262839
  const TFWorkspaceRefCR = new RegExp(`\\$\\{\\{\\s*references\\.(${regModuleName.source})\\s*\\}\\}`, 'i');
262840
- const GenericRefRegex = new RegExp(`user:${regModuleName.source}|group:${regModuleName.source}|system:${regModuleName.source}`, 'gm');
262840
+ const GenericRefRegex = new RegExp(`^["']?(user:${regModuleName.source}|group:${regModuleName.source}|system:${regModuleName.source})["']?$`, 'gm');
262841
262841
  const YAMLHeaderRegex = new RegExp(/^\s*(\w+:\s?)/);
262842
262842
  const YAMLListItemRegex = new RegExp(/^\s*(-\s)/);
262843
262843
  const YAMLInlineListRegex = new RegExp(/^\s*(\[.+\])/);
@@ -271648,7 +271648,6 @@ async function crawlWithExclusions(dir, filter, exec, excludedPaths = []) {
271648
271648
  }, exec);
271649
271649
  }
271650
271650
  catch (err) {
271651
- console.log(err);
271652
271651
  throw `Crawling with exclusions: ${dir}: ${err}`;
271653
271652
  }
271654
271653
  }
@@ -271674,7 +271673,6 @@ async function crawler_crawl(dir, filter, exec) {
271674
271673
  });
271675
271674
  }
271676
271675
  catch (err) {
271677
- console.log(err);
271678
271676
  throw `Crawling ${dir}: ${err}`;
271679
271677
  }
271680
271678
  }
@@ -271735,14 +271733,13 @@ async function crawlDirectory(dirEnt, exec) {
271735
271733
  for (const entry of entries) {
271736
271734
  const testDir = await isDir(entry);
271737
271735
  if (testDir) {
271738
- slurps.push(crawlDirectory(entry, exec));
271736
+ slurps.push(() => crawlDirectory(entry, exec));
271739
271737
  }
271740
271738
  else {
271741
- slurps.push(slurpFile(entry, exec));
271739
+ slurps.push(() => slurpFile(entry, exec));
271742
271740
  }
271743
271741
  }
271744
- return Promise.all(slurps).catch((err) => {
271745
- console.error(err);
271742
+ return Promise.all(slurps.map((f) => f())).catch((err) => {
271746
271743
  throw `crawlDirectory: ${err} on ${dirEnt}`;
271747
271744
  });
271748
271745
  }
@@ -274231,8 +274228,13 @@ async function loadClaims(claimsPath = config_getPath('claims')) {
274231
274228
  if (!('kind' in claim && 'name' in claim)) {
274232
274229
  throw new Error(`Invalid claim file ${entry}`);
274233
274230
  }
274234
- validateClaim(claim, base[`${claim.kind}Schema`]);
274235
- await optionalValidation(claim);
274231
+ try {
274232
+ validateClaim(claim, base[`${claim.kind}Schema`]);
274233
+ await optionalValidation(claim);
274234
+ }
274235
+ catch (err) {
274236
+ throw new Error(`Validating ${claim.kind + '-' + claim.name}: ${JSON.stringify(err, null, 2)}`);
274237
+ }
274236
274238
  if (result[`${claim.kind}-${claim.name}`]) {
274237
274239
  throw new Error(`Duplicate claim ${claim.kind}-${claim.name}`);
274238
274240
  }
@@ -279986,7 +279988,13 @@ async function runRenderer(globalsPath, initializersPath, claimsPath, crsPath, c
279986
279988
  if (claimRefs) {
279987
279989
  claimRefsList = claimRefs.replace(/\s/g, '').split(',');
279988
279990
  }
279989
- await renderer_render(catalogApp, firestartrApp, validateReferentialIntegrity === 'enabled' ? true : false, claimRefsList);
279991
+ try {
279992
+ await renderer_render(catalogApp, firestartrApp, validateReferentialIntegrity === 'enabled' ? true : false, claimRefsList);
279993
+ }
279994
+ catch (error) {
279995
+ console.log(`Rendering the system: \n ${error}`);
279996
+ process.exit(1);
279997
+ }
279990
279998
  catalogApp.synth();
279991
279999
  firestartrApp.synth();
279992
280000
  }
@@ -281748,6 +281756,7 @@ async function writePlanInGithubPR(prUrl, planText) {
281748
281756
  }
281749
281757
  async function addApplyCommitStatus(cr, state, targetURL = '', description = '', context = '') {
281750
281758
  try {
281759
+ await addCommitStatusToHeadCommit(cr.metadata.annotations['firestartr.dev/last-claim-pr'], state, targetURL, description, context);
281751
281760
  await addCommitStatusToPrMergeCommit(cr.metadata.annotations['firestartr.dev/last-state-pr'], state, targetURL, description, context);
281752
281761
  }
281753
281762
  catch (e) {
@@ -281789,6 +281798,12 @@ async function addCommitStatusToPrMergeCommit(prAnnotationValue, state, targetUR
281789
281798
  fDebug(`Adding commit status to ${prAnnotationValue} for owner ${owner}, repo ${repo} and SHA ${branchSha}`);
281790
281799
  await github_0.repo.addCommitStatus(state, branchSha, repo, owner, targetURL, description, context);
281791
281800
  }
281801
+ async function addCommitStatusToHeadCommit(prAnnotationValue, state, targetURL, description, context) {
281802
+ const { owner, repo, prNumber } = catalog_common.generic.getOwnerRepoPrNumberFromAnnotationValue(prAnnotationValue);
281803
+ const branchSha = await github_0.pulls.getPrLastCommitSHA(prNumber, repo, owner);
281804
+ fDebug(`Adding commit status to ${prAnnotationValue} for owner ${owner}, repo ${repo} and SHA ${branchSha}`);
281805
+ await github_0.repo.addCommitStatus(state, branchSha, repo, owner, targetURL, description, context);
281806
+ }
281792
281807
  async function getLastStatePrInfo(cr) {
281793
281808
  try {
281794
281809
  const prInfo = cr.metadata.annotations['firestartr.dev/last-state-pr'];
@@ -285051,7 +285066,8 @@ async function* doApply(item, op, handler) {
285051
285066
  }
285052
285067
  const deps = await handler.resolveReferences();
285053
285068
  cdktf_log('Item %s has the following dependencies: %O', item.metadata.name, deps);
285054
- if (item.metadata.annotations['firestartr.dev/last-state-pr'] || false) {
285069
+ if ((item.metadata.annotations['firestartr.dev/last-claim-pr'] || false) &&
285070
+ (item.metadata.annotations['firestartr.dev/last-state-pr'] || false)) {
285055
285071
  await addApplyCommitStatus(item, 'pending', catalog_common.generic.getPrLinkFromAnnotationValue(item.metadata.annotations['firestartr.dev/last-state-pr']), 'Performing apply operation...', `Terraform Apply ${item.metadata.name}`);
285056
285072
  }
285057
285073
  const applyOutput = await provisioner.runProvisioner({
@@ -285087,7 +285103,8 @@ async function* doApply(item, op, handler) {
285087
285103
  message: 'doApply',
285088
285104
  };
285089
285105
  await handler.writeTerraformOutputInTfResult(item, output);
285090
- if (item.metadata.annotations['firestartr.dev/last-state-pr'] || false) {
285106
+ if ((item.metadata.annotations['firestartr.dev/last-claim-pr'] || false) &&
285107
+ (item.metadata.annotations['firestartr.dev/last-state-pr'] || false)) {
285091
285108
  await addApplyCommitStatus(item, 'success', catalog_common.generic.getPrLinkFromAnnotationValue(item.metadata.annotations['firestartr.dev/last-state-pr']), 'Apply operation completed', `Terraform Apply ${item.metadata.name}`);
285092
285109
  }
285093
285110
  handler.success();
@@ -285123,7 +285140,8 @@ async function* doApply(item, op, handler) {
285123
285140
  status: 'False',
285124
285141
  message: error.toString(),
285125
285142
  };
285126
- if (item.metadata.annotations['firestartr.dev/last-state-pr'] || false) {
285143
+ if ((item.metadata.annotations['firestartr.dev/last-claim-pr'] || false) &&
285144
+ (item.metadata.annotations['firestartr.dev/last-state-pr'] || false)) {
285127
285145
  await addApplyCommitStatus(item, 'failure', catalog_common.generic.getPrLinkFromAnnotationValue(item.metadata.annotations['firestartr.dev/last-state-pr']), 'Apply operation failed', `Terraform Apply ${item.metadata.name}`);
285128
285146
  }
285129
285147
  handler.error();
@@ -286459,7 +286477,8 @@ async function* process_operation_doApply(item, op, handler) {
286459
286477
  const deps = await handler.resolveReferences();
286460
286478
  process_operation_log('Item %s has the following dependencies: %O', item.metadata.name, deps);
286461
286479
  const context = buildProvisionerContext(item, deps);
286462
- if (item.metadata.annotations['firestartr.dev/last-state-pr'] || false) {
286480
+ if ((item.metadata.annotations['firestartr.dev/last-claim-pr'] || false) &&
286481
+ (item.metadata.annotations['firestartr.dev/last-state-pr'] || false)) {
286463
286482
  await addApplyCommitStatus(item, 'pending', catalog_common.generic.getPrLinkFromAnnotationValue(item.metadata.annotations['firestartr.dev/last-state-pr']), 'Performing apply operation...', `Terraform Apply ${item.metadata.name}`);
286464
286483
  }
286465
286484
  const applyOutput = await runTerraformProvisioner(context, 'apply');
@@ -286494,7 +286513,8 @@ async function* process_operation_doApply(item, op, handler) {
286494
286513
  message: 'doApply',
286495
286514
  };
286496
286515
  await handler.writeTerraformOutputInTfResult(item, output);
286497
- if (item.metadata.annotations['firestartr.dev/last-state-pr'] || false) {
286516
+ if ((item.metadata.annotations['firestartr.dev/last-claim-pr'] || false) &&
286517
+ (item.metadata.annotations['firestartr.dev/last-state-pr'] || false)) {
286498
286518
  await addApplyCommitStatus(item, 'success', catalog_common.generic.getPrLinkFromAnnotationValue(item.metadata.annotations['firestartr.dev/last-state-pr']), 'Apply operation completed', `Terraform Apply ${item.metadata.name}`);
286499
286519
  }
286500
286520
  handler.success();
@@ -286524,7 +286544,8 @@ async function* process_operation_doApply(item, op, handler) {
286524
286544
  status: 'False',
286525
286545
  message: JSON.stringify(e),
286526
286546
  };
286527
- if (item.metadata.annotations['firestartr.dev/last-state-pr'] || false) {
286547
+ if ((item.metadata.annotations['firestartr.dev/last-claim-pr'] || false) &&
286548
+ (item.metadata.annotations['firestartr.dev/last-state-pr'] || false)) {
286528
286549
  await addApplyCommitStatus(item, 'failure', catalog_common.generic.getPrLinkFromAnnotationValue(item.metadata.annotations['firestartr.dev/last-state-pr']), 'Apply operation failed', `Terraform Apply ${item.metadata.name}`);
286529
286550
  }
286530
286551
  handler.error();
@@ -286767,27 +286788,27 @@ function getErrorOutputMessage(cr, key, ref) {
286767
286788
  return `
286768
286789
 
286769
286790
  ❌ No output ${key} found in secret '${ref.secret.metadata.name}' .
286770
-
286791
+
286771
286792
  ❗❕ Your terraform project has not the output '${key}' .
286772
-
286793
+
286773
286794
  Maybe you forgot to add it or your reference is wrong.
286774
-
286795
+
286775
286796
  🔗 Terraform project: ${cr.spec.module}
286776
-
286797
+
286777
286798
  🖹 Output example:
286778
-
286799
+
286779
286800
  ... your terraform code ...
286780
-
286801
+
286781
286802
  # missing output
286782
286803
  output '${key}' {
286783
286804
  value = <your_value>
286784
286805
  }
286785
-
286806
+
286786
286807
  `;
286787
286808
  }
286788
286809
  else if (cr.spec.source === 'Inline') {
286789
286810
  return `❗❕ Could not find output '${key}' in inline module:
286790
-
286811
+
286791
286812
  ${cr.spec.module}
286792
286813
  `;
286793
286814
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firestartr/cli",
3
- "version": "1.45.0-snapshot-11",
3
+ "version": "1.45.0-snapshot-12",
4
4
  "private": false,
5
5
  "description": "Commandline tool",
6
6
  "main": "build/main.js",