@firestartr/cli 1.53.0-snapshot-13 → 1.53.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.
Files changed (2) hide show
  1. package/build/index.js +182 -140
  2. package/package.json +1 -1
package/build/index.js CHANGED
@@ -371256,6 +371256,7 @@ async function* markedToDeletion(item, op, handler) {
371256
371256
  // here we store the current callbacks that
371257
371257
  // are being used (synth|tf-apply...)
371258
371258
  let checkRunCtl;
371259
+ let error = false;
371259
371260
  try {
371260
371261
  void cleanTerraformState();
371261
371262
  const type = 'DELETING';
@@ -371330,13 +371331,7 @@ async function* markedToDeletion(item, op, handler) {
371330
371331
  void handler.success();
371331
371332
  }
371332
371333
  catch (e) {
371333
- yield {
371334
- item,
371335
- reason: op,
371336
- type: 'ERROR',
371337
- status: 'True',
371338
- message: DESTROY_DEFAULT_ERROR_MESSAGE,
371339
- };
371334
+ error = true;
371340
371335
  // if there is a current checkRun working
371341
371336
  // we close it with an error
371342
371337
  if (checkRunCtl)
@@ -371344,6 +371339,17 @@ async function* markedToDeletion(item, op, handler) {
371344
371339
  await handler.writeTerraformOutputInTfResult(item, e);
371345
371340
  void handler.error();
371346
371341
  }
371342
+ finally {
371343
+ if (error) {
371344
+ yield {
371345
+ item,
371346
+ reason: op,
371347
+ type: 'ERROR',
371348
+ status: 'True',
371349
+ message: DESTROY_DEFAULT_ERROR_MESSAGE,
371350
+ };
371351
+ }
371352
+ }
371347
371353
  }
371348
371354
  async function* nothing(item, op, handler) {
371349
371355
  yield {
@@ -371363,6 +371369,7 @@ async function* doApply(item, op, handler) {
371363
371369
  // here we store the current callbacks that
371364
371370
  // are being used (synth|tf-apply...)
371365
371371
  let checkRunCtl;
371372
+ let error = false;
371366
371373
  try {
371367
371374
  cleanTerraformState();
371368
371375
  yield {
@@ -371469,43 +371476,48 @@ async function* doApply(item, op, handler) {
371469
371476
  handler.success();
371470
371477
  }
371471
371478
  catch (e) {
371472
- let error;
371479
+ error = true;
371480
+ let errorMsg;
371473
371481
  if (typeof e === 'object' && 'output' in e) {
371474
- error = e.output;
371482
+ errorMsg = e.output;
371475
371483
  }
371476
371484
  else {
371477
- error = e;
371485
+ errorMsg = e;
371478
371486
  }
371479
- await tryPublishApply(item, error, item.kind);
371487
+ await tryPublishApply(item, errorMsg, item.kind);
371480
371488
  // if there is a current checkRun working
371481
371489
  // we close it with an error
371482
371490
  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
- };
371491
+ checkRunCtl.fnOnError(errorMsg);
371492
+ operator_src_logger.error(`Error applying item ${item.metadata.name}: ${errorMsg}`);
371506
371493
  handler.error();
371494
+ if (errorMsg) {
371495
+ await handler.writeTerraformOutputInTfResult(item, errorMsg);
371496
+ }
371497
+ }
371498
+ finally {
371507
371499
  if (error) {
371508
- await handler.writeTerraformOutputInTfResult(item, error);
371500
+ yield {
371501
+ item,
371502
+ reason: op,
371503
+ type: 'ERROR',
371504
+ status: 'True',
371505
+ message: APPLY_DEFAULT_ERROR_MESSAGE,
371506
+ };
371507
+ yield {
371508
+ item,
371509
+ reason: op,
371510
+ type: 'PROVISIONED',
371511
+ status: 'False',
371512
+ message: APPLY_DEFAULT_ERROR_MESSAGE,
371513
+ };
371514
+ yield {
371515
+ item,
371516
+ reason: op,
371517
+ type: 'PROVISIONING',
371518
+ status: 'False',
371519
+ message: APPLY_DEFAULT_ERROR_MESSAGE,
371520
+ };
371509
371521
  }
371510
371522
  }
371511
371523
  }
@@ -372598,6 +372610,7 @@ async function* process_operation_observe(item, op, handler) {
372598
372610
  }
372599
372611
  }
372600
372612
  async function* doPlanJSONFormat(item, op, handler) {
372613
+ let error = false;
372601
372614
  try {
372602
372615
  yield {
372603
372616
  item,
@@ -372683,36 +372696,9 @@ async function* doPlanJSONFormat(item, op, handler) {
372683
372696
  }
372684
372697
  }
372685
372698
  catch (e) {
372699
+ error = true;
372686
372700
  console.error(e);
372687
372701
  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
372702
  const summaryText = tryCreateErrorSummary('Terraform Plan failed', e);
372717
372703
  if (item.metadata.annotations['firestartr.dev/last-state-pr'] || false) {
372718
372704
  await addPlanStatusCheck(item.metadata.annotations['firestartr.dev/last-state-pr'], summaryText, 'completed', true);
@@ -372722,6 +372708,38 @@ async function* doPlanJSONFormat(item, op, handler) {
372722
372708
  await handler.writeTerraformOutputInTfResult(item, e);
372723
372709
  }
372724
372710
  }
372711
+ finally {
372712
+ if (error) {
372713
+ yield {
372714
+ item,
372715
+ reason: op,
372716
+ type: 'PROVISIONED',
372717
+ status: 'False',
372718
+ message: PLAN_DEFAULT_ERROR_MESSAGE,
372719
+ };
372720
+ yield {
372721
+ item,
372722
+ reason: op,
372723
+ type: 'PLANNING',
372724
+ status: 'False',
372725
+ message: PLAN_DEFAULT_ERROR_MESSAGE,
372726
+ };
372727
+ yield {
372728
+ item,
372729
+ reason: op,
372730
+ type: 'OUT_OF_SYNC',
372731
+ status: 'False',
372732
+ message: PLAN_DEFAULT_ERROR_MESSAGE,
372733
+ };
372734
+ yield {
372735
+ item,
372736
+ reason: op,
372737
+ type: 'ERROR',
372738
+ status: 'True',
372739
+ message: PLAN_DEFAULT_ERROR_MESSAGE,
372740
+ };
372741
+ }
372742
+ }
372725
372743
  }
372726
372744
  async function* process_operation_created(item, op, handler) {
372727
372745
  for await (const transition of process_operation_doApply(item, op, handler)) {
@@ -372797,6 +372815,7 @@ async function* process_operation_sync(item, op, handler, syncPolicy, generalPol
372797
372815
  };
372798
372816
  }
372799
372817
  async function* process_operation_markedToDeletion(item, op, handler) {
372818
+ let error = false;
372800
372819
  try {
372801
372820
  const type = 'DELETING';
372802
372821
  yield {
@@ -372877,19 +372896,24 @@ async function* process_operation_markedToDeletion(item, op, handler) {
372877
372896
  void handler.success();
372878
372897
  }
372879
372898
  catch (e) {
372880
- yield {
372881
- item,
372882
- reason: op,
372883
- type: 'ERROR',
372884
- status: 'True',
372885
- message: DESTROY_DEFAULT_ERROR_MESSAGE,
372886
- };
372899
+ error = true;
372887
372900
  await handler.writeTerraformOutputInTfResult(item, e);
372888
372901
  if (item.metadata.annotations['firestartr.dev/last-state-pr'] || false) {
372889
372902
  await addDestroyCommitStatus(item, 'failure', 'Destroy operation failed', `Terraform Destroy ${item.metadata.name}`);
372890
372903
  }
372891
372904
  void handler.error();
372892
372905
  }
372906
+ finally {
372907
+ if (error) {
372908
+ yield {
372909
+ item,
372910
+ reason: op,
372911
+ type: 'ERROR',
372912
+ status: 'True',
372913
+ message: DESTROY_DEFAULT_ERROR_MESSAGE,
372914
+ };
372915
+ }
372916
+ }
372893
372917
  }
372894
372918
  async function* process_operation_nothing(item, op, handler) {
372895
372919
  yield {
@@ -372908,6 +372932,7 @@ async function* process_operation_nothing(item, op, handler) {
372908
372932
  */
372909
372933
  async function* process_operation_doApply(item, op, handler) {
372910
372934
  const checkRunCtl = await TFCheckRun('apply', item);
372935
+ let error = false;
372911
372936
  try {
372912
372937
  yield {
372913
372938
  item,
@@ -372991,36 +373016,41 @@ async function* process_operation_doApply(item, op, handler) {
372991
373016
  handler.success();
372992
373017
  }
372993
373018
  catch (e) {
373019
+ error = true;
372994
373020
  checkRunCtl.fnOnError(e);
372995
373021
  console.error(e);
372996
373022
  await tryPublishApply(item, e, 'TFWorkspace');
372997
373023
  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
373024
  handler.error();
373020
373025
  if (e) {
373021
373026
  await handler.writeTerraformOutputInTfResult(item, e);
373022
373027
  }
373023
373028
  }
373029
+ finally {
373030
+ if (error) {
373031
+ yield {
373032
+ item,
373033
+ reason: op,
373034
+ type: 'ERROR',
373035
+ status: 'True',
373036
+ message: APPLY_DEFAULT_ERROR_MESSAGE,
373037
+ };
373038
+ yield {
373039
+ item,
373040
+ reason: op,
373041
+ type: 'PROVISIONED',
373042
+ status: 'False',
373043
+ message: APPLY_DEFAULT_ERROR_MESSAGE,
373044
+ };
373045
+ yield {
373046
+ item,
373047
+ reason: op,
373048
+ type: 'PROVISIONING',
373049
+ status: 'False',
373050
+ message: APPLY_DEFAULT_ERROR_MESSAGE,
373051
+ };
373052
+ }
373053
+ }
373024
373054
  }
373025
373055
  async function* errorPolicyNotAllowsOp(item, op, handler, msg) {
373026
373056
  const reason = 'POLICY CONFLICT';
@@ -373422,6 +373452,7 @@ async function* processOperationPlan_plan(item, op, handler, format = 'plain-tex
373422
373452
  }
373423
373453
  }
373424
373454
  async function* doPlanPlainTextFormat(item, op, handler, action) {
373455
+ let error = false;
373425
373456
  try {
373426
373457
  yield {
373427
373458
  item,
@@ -373481,32 +373512,12 @@ async function* doPlanPlainTextFormat(item, op, handler, action) {
373481
373512
  }
373482
373513
  }
373483
373514
  catch (e) {
373515
+ error = true;
373484
373516
  const { prNumber, repo, org } = extractPrInfo(item, 'firestartr.dev/pull-request-plan');
373485
373517
  await publishPlan(item, JSON.stringify(e), prNumber, repo, org);
373486
373518
  operator_src_logger.error('TFWORKSPACE_PROCESSOR_PLAN_OBSERVING_ERROR', {
373487
373519
  metadata: { item, error: e },
373488
373520
  });
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
373521
  const summaryText = tryCreateErrorSummary('Terraform Plan failed', e);
373511
373522
  if (item.metadata.annotations['firestartr.dev/last-state-pr'] || false) {
373512
373523
  await addPlanStatusCheck(item.metadata.annotations['firestartr.dev/last-state-pr'], summaryText, 'completed', true);
@@ -373516,8 +373527,34 @@ async function* doPlanPlainTextFormat(item, op, handler, action) {
373516
373527
  await handler.writeTerraformOutputInTfResult(item, e);
373517
373528
  }
373518
373529
  }
373530
+ finally {
373531
+ if (error) {
373532
+ yield {
373533
+ item,
373534
+ reason: op,
373535
+ type: 'PROVISIONED',
373536
+ status: 'False',
373537
+ message: PLAN_DEFAULT_ERROR_MESSAGE,
373538
+ };
373539
+ yield {
373540
+ item,
373541
+ reason: op,
373542
+ type: 'PLANNING',
373543
+ status: 'False',
373544
+ message: PLAN_DEFAULT_ERROR_MESSAGE,
373545
+ };
373546
+ yield {
373547
+ item,
373548
+ reason: op,
373549
+ type: 'ERROR',
373550
+ status: 'True',
373551
+ message: PLAN_DEFAULT_ERROR_MESSAGE,
373552
+ };
373553
+ }
373554
+ }
373519
373555
  }
373520
373556
  async function* processOperationPlan_doPlanJSONFormat(item, op, handler, action) {
373557
+ let error = false;
373521
373558
  try {
373522
373559
  yield {
373523
373560
  item,
@@ -373600,43 +373637,48 @@ async function* processOperationPlan_doPlanJSONFormat(item, op, handler, action)
373600
373637
  }
373601
373638
  }
373602
373639
  catch (e) {
373640
+ error = true;
373603
373641
  console.error(e);
373604
373642
  operator_src_logger.error('TFWORKSPACE_PROCESSOR_PLAN_DO_PLAN_ERROR', {
373605
373643
  metadata: { item, error: e },
373606
373644
  });
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
373645
  void handler.error();
373636
373646
  if (e) {
373637
373647
  await handler.writeTerraformOutputInTfResult(item, e);
373638
373648
  }
373639
373649
  }
373650
+ finally {
373651
+ if (error) {
373652
+ yield {
373653
+ item,
373654
+ reason: op,
373655
+ type: 'PROVISIONED',
373656
+ status: 'False',
373657
+ message: PLAN_DEFAULT_ERROR_MESSAGE,
373658
+ };
373659
+ yield {
373660
+ item,
373661
+ reason: op,
373662
+ type: 'PLANNING',
373663
+ status: 'False',
373664
+ message: PLAN_DEFAULT_ERROR_MESSAGE,
373665
+ };
373666
+ yield {
373667
+ item,
373668
+ reason: op,
373669
+ type: 'OUT_OF_SYNC',
373670
+ status: 'False',
373671
+ message: PLAN_DEFAULT_ERROR_MESSAGE,
373672
+ };
373673
+ yield {
373674
+ item,
373675
+ reason: op,
373676
+ type: 'ERROR',
373677
+ status: 'True',
373678
+ message: PLAN_DEFAULT_ERROR_MESSAGE,
373679
+ };
373680
+ }
373681
+ }
373640
373682
  }
373641
373683
  /**
373642
373684
  * @description Adapts the CR to the format expected by the terraform provisioner
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.53.0",
4
4
  "private": false,
5
5
  "description": "Commandline tool",
6
6
  "main": "build/main.js",