@firestartr/cli 1.53.0-snapshot-13 → 1.54.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
@@ -359560,6 +359560,7 @@ var ajv_default = /*#__PURE__*/__nccwpck_require__.n(dist_ajv);
359560
359560
 
359561
359561
 
359562
359562
 
359563
+
359563
359564
  function validate_validate(featurePath) {
359564
359565
  __validateDirStructure(featurePath);
359565
359566
  const configData = __validateFeatureConfig(featurePath);
@@ -359574,6 +359575,17 @@ function __validateDirStructure(featurePath) {
359574
359575
  if (!isFile(external_path_.join(featurePath, 'config.yaml'))) {
359575
359576
  throw `Feature: ${featurePath}/config.yaml not found or not a file`;
359576
359577
  }
359578
+ if (!isDirectory(external_path_.join(featurePath, 'templates/docs'))) {
359579
+ throw `Feature: ${featurePath}templates/docs not a directory`;
359580
+ }
359581
+ if (!__validateDocsHasReadmes(featurePath)) {
359582
+ throw `Feature: ${featurePath}: should have at least one .md file in the templates/docs`;
359583
+ }
359584
+ }
359585
+ function __validateDocsHasReadmes(featurePath) {
359586
+ const dirEntries = external_fs_default().readdirSync(external_path_.join(featurePath, 'templates/docs'));
359587
+ return (dirEntries.some((entryFile) => !isDirectory(external_path_.join(featurePath, '/templates/docs', entryFile)) &&
359588
+ entryFile.endsWith('.md')) !== undefined);
359577
359589
  }
359578
359590
  function __validateFeatureConfig(featurePath) {
359579
359591
  try {
@@ -360629,6 +360641,7 @@ function buildExpectedOutput(config, renderDir) {
360629
360641
  localPath: external_node_path_.join(renderDir, f.dest),
360630
360642
  repoPath: f.dest,
360631
360643
  userManaged: f.user_managed,
360644
+ targetBranch: f.target_branch ?? '',
360632
360645
  }));
360633
360646
  return {
360634
360647
  files,
@@ -371256,6 +371269,7 @@ async function* markedToDeletion(item, op, handler) {
371256
371269
  // here we store the current callbacks that
371257
371270
  // are being used (synth|tf-apply...)
371258
371271
  let checkRunCtl;
371272
+ let error = false;
371259
371273
  try {
371260
371274
  void cleanTerraformState();
371261
371275
  const type = 'DELETING';
@@ -371330,13 +371344,7 @@ async function* markedToDeletion(item, op, handler) {
371330
371344
  void handler.success();
371331
371345
  }
371332
371346
  catch (e) {
371333
- yield {
371334
- item,
371335
- reason: op,
371336
- type: 'ERROR',
371337
- status: 'True',
371338
- message: DESTROY_DEFAULT_ERROR_MESSAGE,
371339
- };
371347
+ error = true;
371340
371348
  // if there is a current checkRun working
371341
371349
  // we close it with an error
371342
371350
  if (checkRunCtl)
@@ -371344,6 +371352,17 @@ async function* markedToDeletion(item, op, handler) {
371344
371352
  await handler.writeTerraformOutputInTfResult(item, e);
371345
371353
  void handler.error();
371346
371354
  }
371355
+ finally {
371356
+ if (error) {
371357
+ yield {
371358
+ item,
371359
+ reason: op,
371360
+ type: 'ERROR',
371361
+ status: 'True',
371362
+ message: DESTROY_DEFAULT_ERROR_MESSAGE,
371363
+ };
371364
+ }
371365
+ }
371347
371366
  }
371348
371367
  async function* nothing(item, op, handler) {
371349
371368
  yield {
@@ -371363,6 +371382,7 @@ async function* doApply(item, op, handler) {
371363
371382
  // here we store the current callbacks that
371364
371383
  // are being used (synth|tf-apply...)
371365
371384
  let checkRunCtl;
371385
+ let error = false;
371366
371386
  try {
371367
371387
  cleanTerraformState();
371368
371388
  yield {
@@ -371469,43 +371489,48 @@ async function* doApply(item, op, handler) {
371469
371489
  handler.success();
371470
371490
  }
371471
371491
  catch (e) {
371472
- let error;
371492
+ error = true;
371493
+ let errorMsg;
371473
371494
  if (typeof e === 'object' && 'output' in e) {
371474
- error = e.output;
371495
+ errorMsg = e.output;
371475
371496
  }
371476
371497
  else {
371477
- error = e;
371498
+ errorMsg = e;
371478
371499
  }
371479
- await tryPublishApply(item, error, item.kind);
371500
+ await tryPublishApply(item, errorMsg, item.kind);
371480
371501
  // if there is a current checkRun working
371481
371502
  // we close it with an error
371482
371503
  if (checkRunCtl)
371483
- checkRunCtl.fnOnError(error);
371484
- operator_src_logger.error(`Error applying item ${item.metadata.name}: ${error}`);
371485
- yield {
371486
- item,
371487
- reason: op,
371488
- type: 'ERROR',
371489
- status: 'True',
371490
- message: APPLY_DEFAULT_ERROR_MESSAGE,
371491
- };
371492
- yield {
371493
- item,
371494
- reason: op,
371495
- type: 'PROVISIONED',
371496
- status: 'False',
371497
- message: APPLY_DEFAULT_ERROR_MESSAGE,
371498
- };
371499
- yield {
371500
- item,
371501
- reason: op,
371502
- type: 'PROVISIONING',
371503
- status: 'False',
371504
- message: APPLY_DEFAULT_ERROR_MESSAGE,
371505
- };
371504
+ checkRunCtl.fnOnError(errorMsg);
371505
+ operator_src_logger.error(`Error applying item ${item.metadata.name}: ${errorMsg}`);
371506
371506
  handler.error();
371507
+ if (errorMsg) {
371508
+ await handler.writeTerraformOutputInTfResult(item, errorMsg);
371509
+ }
371510
+ }
371511
+ finally {
371507
371512
  if (error) {
371508
- await handler.writeTerraformOutputInTfResult(item, error);
371513
+ yield {
371514
+ item,
371515
+ reason: op,
371516
+ type: 'ERROR',
371517
+ status: 'True',
371518
+ message: APPLY_DEFAULT_ERROR_MESSAGE,
371519
+ };
371520
+ yield {
371521
+ item,
371522
+ reason: op,
371523
+ type: 'PROVISIONED',
371524
+ status: 'False',
371525
+ message: APPLY_DEFAULT_ERROR_MESSAGE,
371526
+ };
371527
+ yield {
371528
+ item,
371529
+ reason: op,
371530
+ type: 'PROVISIONING',
371531
+ status: 'False',
371532
+ message: APPLY_DEFAULT_ERROR_MESSAGE,
371533
+ };
371509
371534
  }
371510
371535
  }
371511
371536
  }
@@ -372598,6 +372623,7 @@ async function* process_operation_observe(item, op, handler) {
372598
372623
  }
372599
372624
  }
372600
372625
  async function* doPlanJSONFormat(item, op, handler) {
372626
+ let error = false;
372601
372627
  try {
372602
372628
  yield {
372603
372629
  item,
@@ -372683,36 +372709,9 @@ async function* doPlanJSONFormat(item, op, handler) {
372683
372709
  }
372684
372710
  }
372685
372711
  catch (e) {
372712
+ error = true;
372686
372713
  console.error(e);
372687
372714
  operator_src_logger.error(`The Terraform processor encountered an error while observing the plan for item '${item.kind}/${item.metadata.name}': '${e}'.`);
372688
- yield {
372689
- item,
372690
- reason: op,
372691
- type: 'PROVISIONED',
372692
- status: 'False',
372693
- message: PLAN_DEFAULT_ERROR_MESSAGE,
372694
- };
372695
- yield {
372696
- item,
372697
- reason: op,
372698
- type: 'PLANNING',
372699
- status: 'False',
372700
- message: PLAN_DEFAULT_ERROR_MESSAGE,
372701
- };
372702
- yield {
372703
- item,
372704
- reason: op,
372705
- type: 'OUT_OF_SYNC',
372706
- status: 'False',
372707
- message: PLAN_DEFAULT_ERROR_MESSAGE,
372708
- };
372709
- yield {
372710
- item,
372711
- reason: op,
372712
- type: 'ERROR',
372713
- status: 'True',
372714
- message: PLAN_DEFAULT_ERROR_MESSAGE,
372715
- };
372716
372715
  const summaryText = tryCreateErrorSummary('Terraform Plan failed', e);
372717
372716
  if (item.metadata.annotations['firestartr.dev/last-state-pr'] || false) {
372718
372717
  await addPlanStatusCheck(item.metadata.annotations['firestartr.dev/last-state-pr'], summaryText, 'completed', true);
@@ -372722,6 +372721,38 @@ async function* doPlanJSONFormat(item, op, handler) {
372722
372721
  await handler.writeTerraformOutputInTfResult(item, e);
372723
372722
  }
372724
372723
  }
372724
+ finally {
372725
+ if (error) {
372726
+ yield {
372727
+ item,
372728
+ reason: op,
372729
+ type: 'PROVISIONED',
372730
+ status: 'False',
372731
+ message: PLAN_DEFAULT_ERROR_MESSAGE,
372732
+ };
372733
+ yield {
372734
+ item,
372735
+ reason: op,
372736
+ type: 'PLANNING',
372737
+ status: 'False',
372738
+ message: PLAN_DEFAULT_ERROR_MESSAGE,
372739
+ };
372740
+ yield {
372741
+ item,
372742
+ reason: op,
372743
+ type: 'OUT_OF_SYNC',
372744
+ status: 'False',
372745
+ message: PLAN_DEFAULT_ERROR_MESSAGE,
372746
+ };
372747
+ yield {
372748
+ item,
372749
+ reason: op,
372750
+ type: 'ERROR',
372751
+ status: 'True',
372752
+ message: PLAN_DEFAULT_ERROR_MESSAGE,
372753
+ };
372754
+ }
372755
+ }
372725
372756
  }
372726
372757
  async function* process_operation_created(item, op, handler) {
372727
372758
  for await (const transition of process_operation_doApply(item, op, handler)) {
@@ -372797,6 +372828,7 @@ async function* process_operation_sync(item, op, handler, syncPolicy, generalPol
372797
372828
  };
372798
372829
  }
372799
372830
  async function* process_operation_markedToDeletion(item, op, handler) {
372831
+ let error = false;
372800
372832
  try {
372801
372833
  const type = 'DELETING';
372802
372834
  yield {
@@ -372877,19 +372909,24 @@ async function* process_operation_markedToDeletion(item, op, handler) {
372877
372909
  void handler.success();
372878
372910
  }
372879
372911
  catch (e) {
372880
- yield {
372881
- item,
372882
- reason: op,
372883
- type: 'ERROR',
372884
- status: 'True',
372885
- message: DESTROY_DEFAULT_ERROR_MESSAGE,
372886
- };
372912
+ error = true;
372887
372913
  await handler.writeTerraformOutputInTfResult(item, e);
372888
372914
  if (item.metadata.annotations['firestartr.dev/last-state-pr'] || false) {
372889
372915
  await addDestroyCommitStatus(item, 'failure', 'Destroy operation failed', `Terraform Destroy ${item.metadata.name}`);
372890
372916
  }
372891
372917
  void handler.error();
372892
372918
  }
372919
+ finally {
372920
+ if (error) {
372921
+ yield {
372922
+ item,
372923
+ reason: op,
372924
+ type: 'ERROR',
372925
+ status: 'True',
372926
+ message: DESTROY_DEFAULT_ERROR_MESSAGE,
372927
+ };
372928
+ }
372929
+ }
372893
372930
  }
372894
372931
  async function* process_operation_nothing(item, op, handler) {
372895
372932
  yield {
@@ -372908,6 +372945,7 @@ async function* process_operation_nothing(item, op, handler) {
372908
372945
  */
372909
372946
  async function* process_operation_doApply(item, op, handler) {
372910
372947
  const checkRunCtl = await TFCheckRun('apply', item);
372948
+ let error = false;
372911
372949
  try {
372912
372950
  yield {
372913
372951
  item,
@@ -372991,36 +373029,41 @@ async function* process_operation_doApply(item, op, handler) {
372991
373029
  handler.success();
372992
373030
  }
372993
373031
  catch (e) {
373032
+ error = true;
372994
373033
  checkRunCtl.fnOnError(e);
372995
373034
  console.error(e);
372996
373035
  await tryPublishApply(item, e, 'TFWorkspace');
372997
373036
  operator_src_logger.error(`The Terraform processor encountered an error during operation '${op}' for item '${item.kind}/${item.metadata.name}': '${e}'.`);
372998
- yield {
372999
- item,
373000
- reason: op,
373001
- type: 'ERROR',
373002
- status: 'True',
373003
- message: APPLY_DEFAULT_ERROR_MESSAGE,
373004
- };
373005
- yield {
373006
- item,
373007
- reason: op,
373008
- type: 'PROVISIONED',
373009
- status: 'False',
373010
- message: APPLY_DEFAULT_ERROR_MESSAGE,
373011
- };
373012
- yield {
373013
- item,
373014
- reason: op,
373015
- type: 'PROVISIONING',
373016
- status: 'False',
373017
- message: APPLY_DEFAULT_ERROR_MESSAGE,
373018
- };
373019
373037
  handler.error();
373020
373038
  if (e) {
373021
373039
  await handler.writeTerraformOutputInTfResult(item, e);
373022
373040
  }
373023
373041
  }
373042
+ finally {
373043
+ if (error) {
373044
+ yield {
373045
+ item,
373046
+ reason: op,
373047
+ type: 'ERROR',
373048
+ status: 'True',
373049
+ message: APPLY_DEFAULT_ERROR_MESSAGE,
373050
+ };
373051
+ yield {
373052
+ item,
373053
+ reason: op,
373054
+ type: 'PROVISIONED',
373055
+ status: 'False',
373056
+ message: APPLY_DEFAULT_ERROR_MESSAGE,
373057
+ };
373058
+ yield {
373059
+ item,
373060
+ reason: op,
373061
+ type: 'PROVISIONING',
373062
+ status: 'False',
373063
+ message: APPLY_DEFAULT_ERROR_MESSAGE,
373064
+ };
373065
+ }
373066
+ }
373024
373067
  }
373025
373068
  async function* errorPolicyNotAllowsOp(item, op, handler, msg) {
373026
373069
  const reason = 'POLICY CONFLICT';
@@ -373422,6 +373465,7 @@ async function* processOperationPlan_plan(item, op, handler, format = 'plain-tex
373422
373465
  }
373423
373466
  }
373424
373467
  async function* doPlanPlainTextFormat(item, op, handler, action) {
373468
+ let error = false;
373425
373469
  try {
373426
373470
  yield {
373427
373471
  item,
@@ -373481,32 +373525,12 @@ async function* doPlanPlainTextFormat(item, op, handler, action) {
373481
373525
  }
373482
373526
  }
373483
373527
  catch (e) {
373528
+ error = true;
373484
373529
  const { prNumber, repo, org } = extractPrInfo(item, 'firestartr.dev/pull-request-plan');
373485
373530
  await publishPlan(item, JSON.stringify(e), prNumber, repo, org);
373486
373531
  operator_src_logger.error('TFWORKSPACE_PROCESSOR_PLAN_OBSERVING_ERROR', {
373487
373532
  metadata: { item, error: e },
373488
373533
  });
373489
- yield {
373490
- item,
373491
- reason: op,
373492
- type: 'PROVISIONED',
373493
- status: 'False',
373494
- message: PLAN_DEFAULT_ERROR_MESSAGE,
373495
- };
373496
- yield {
373497
- item,
373498
- reason: op,
373499
- type: 'PLANNING',
373500
- status: 'False',
373501
- message: PLAN_DEFAULT_ERROR_MESSAGE,
373502
- };
373503
- yield {
373504
- item,
373505
- reason: op,
373506
- type: 'ERROR',
373507
- status: 'True',
373508
- message: PLAN_DEFAULT_ERROR_MESSAGE,
373509
- };
373510
373534
  const summaryText = tryCreateErrorSummary('Terraform Plan failed', e);
373511
373535
  if (item.metadata.annotations['firestartr.dev/last-state-pr'] || false) {
373512
373536
  await addPlanStatusCheck(item.metadata.annotations['firestartr.dev/last-state-pr'], summaryText, 'completed', true);
@@ -373516,8 +373540,34 @@ async function* doPlanPlainTextFormat(item, op, handler, action) {
373516
373540
  await handler.writeTerraformOutputInTfResult(item, e);
373517
373541
  }
373518
373542
  }
373543
+ finally {
373544
+ if (error) {
373545
+ yield {
373546
+ item,
373547
+ reason: op,
373548
+ type: 'PROVISIONED',
373549
+ status: 'False',
373550
+ message: PLAN_DEFAULT_ERROR_MESSAGE,
373551
+ };
373552
+ yield {
373553
+ item,
373554
+ reason: op,
373555
+ type: 'PLANNING',
373556
+ status: 'False',
373557
+ message: PLAN_DEFAULT_ERROR_MESSAGE,
373558
+ };
373559
+ yield {
373560
+ item,
373561
+ reason: op,
373562
+ type: 'ERROR',
373563
+ status: 'True',
373564
+ message: PLAN_DEFAULT_ERROR_MESSAGE,
373565
+ };
373566
+ }
373567
+ }
373519
373568
  }
373520
373569
  async function* processOperationPlan_doPlanJSONFormat(item, op, handler, action) {
373570
+ let error = false;
373521
373571
  try {
373522
373572
  yield {
373523
373573
  item,
@@ -373600,43 +373650,48 @@ async function* processOperationPlan_doPlanJSONFormat(item, op, handler, action)
373600
373650
  }
373601
373651
  }
373602
373652
  catch (e) {
373653
+ error = true;
373603
373654
  console.error(e);
373604
373655
  operator_src_logger.error('TFWORKSPACE_PROCESSOR_PLAN_DO_PLAN_ERROR', {
373605
373656
  metadata: { item, error: e },
373606
373657
  });
373607
- yield {
373608
- item,
373609
- reason: op,
373610
- type: 'PROVISIONED',
373611
- status: 'False',
373612
- message: PLAN_DEFAULT_ERROR_MESSAGE,
373613
- };
373614
- yield {
373615
- item,
373616
- reason: op,
373617
- type: 'PLANNING',
373618
- status: 'False',
373619
- message: PLAN_DEFAULT_ERROR_MESSAGE,
373620
- };
373621
- yield {
373622
- item,
373623
- reason: op,
373624
- type: 'OUT_OF_SYNC',
373625
- status: 'False',
373626
- message: PLAN_DEFAULT_ERROR_MESSAGE,
373627
- };
373628
- yield {
373629
- item,
373630
- reason: op,
373631
- type: 'ERROR',
373632
- status: 'True',
373633
- message: PLAN_DEFAULT_ERROR_MESSAGE,
373634
- };
373635
373658
  void handler.error();
373636
373659
  if (e) {
373637
373660
  await handler.writeTerraformOutputInTfResult(item, e);
373638
373661
  }
373639
373662
  }
373663
+ finally {
373664
+ if (error) {
373665
+ yield {
373666
+ item,
373667
+ reason: op,
373668
+ type: 'PROVISIONED',
373669
+ status: 'False',
373670
+ message: PLAN_DEFAULT_ERROR_MESSAGE,
373671
+ };
373672
+ yield {
373673
+ item,
373674
+ reason: op,
373675
+ type: 'PLANNING',
373676
+ status: 'False',
373677
+ message: PLAN_DEFAULT_ERROR_MESSAGE,
373678
+ };
373679
+ yield {
373680
+ item,
373681
+ reason: op,
373682
+ type: 'OUT_OF_SYNC',
373683
+ status: 'False',
373684
+ message: PLAN_DEFAULT_ERROR_MESSAGE,
373685
+ };
373686
+ yield {
373687
+ item,
373688
+ reason: op,
373689
+ type: 'ERROR',
373690
+ status: 'True',
373691
+ message: PLAN_DEFAULT_ERROR_MESSAGE,
373692
+ };
373693
+ }
373694
+ }
373640
373695
  }
373641
373696
  /**
373642
373697
  * @description Adapts the CR to the format expected by the terraform provisioner
@@ -5,6 +5,7 @@ export interface ConfigFile {
5
5
  dest: string;
6
6
  src: string;
7
7
  user_managed: boolean;
8
+ target_branch: string;
8
9
  }
9
10
  export interface FeatureConfig {
10
11
  files?: ConfigFile[];
@@ -14,6 +15,7 @@ export interface ExpectedFile {
14
15
  localPath: string;
15
16
  repoPath: string;
16
17
  userManaged: boolean;
18
+ targetBranch: string;
17
19
  }
18
20
  export interface ExpectedOutput {
19
21
  files: ExpectedFile[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firestartr/cli",
3
- "version": "1.53.0-snapshot-13",
3
+ "version": "1.54.0-snapshot-0",
4
4
  "private": false,
5
5
  "description": "Commandline tool",
6
6
  "main": "build/main.js",