@firestartr/cli 1.59.0-snapshot-15 → 1.59.0-snapshot-16

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 (28) hide show
  1. package/build/index.js +428 -74
  2. package/build/packages/cdk8s_renderer/src/claims/base/schemas/argodeploy.schema.d.ts +1 -0
  3. package/build/packages/cdk8s_renderer/src/claims/base/schemas/common-meta.schema.d.ts +46 -0
  4. package/build/packages/cdk8s_renderer/src/claims/base/schemas/component.schema.d.ts +1 -0
  5. package/build/packages/cdk8s_renderer/src/claims/base/schemas/group.schema.d.ts +1 -0
  6. package/build/packages/cdk8s_renderer/src/claims/base/schemas/index.d.ts +237 -0
  7. package/build/packages/cdk8s_renderer/src/claims/base/schemas/orgwebhook.schema.d.ts +1 -0
  8. package/build/packages/cdk8s_renderer/src/claims/base/schemas/secrets.schema.d.ts +1 -0
  9. package/build/packages/cdk8s_renderer/src/claims/base/schemas/tfworkspace.schema.d.ts +1 -0
  10. package/build/packages/cdk8s_renderer/src/claims/base/schemas/user.schema.d.ts +1 -0
  11. package/build/packages/cdk8s_renderer/src/claims/external-secrets/external-secrets.schema.d.ts +12 -0
  12. package/build/packages/cdk8s_renderer/src/claims/external-secrets/index.d.ts +12 -0
  13. package/build/packages/cdk8s_renderer/src/claims/github/component.schema.d.ts +136 -0
  14. package/build/packages/cdk8s_renderer/src/claims/github/group.schema.d.ts +11 -0
  15. package/build/packages/cdk8s_renderer/src/claims/github/index.d.ts +167 -0
  16. package/build/packages/cdk8s_renderer/src/claims/github/orgwebhook.schema.d.ts +9 -0
  17. package/build/packages/cdk8s_renderer/src/claims/github/user.schema.d.ts +11 -0
  18. package/build/packages/cdk8s_renderer/src/claims/tfworkspaces/index.d.ts +5 -0
  19. package/build/packages/cdk8s_renderer/src/claims/tfworkspaces/terraform.schema.d.ts +5 -0
  20. package/build/packages/importer/src/utils/nomicon.d.ts +1 -0
  21. package/build/packages/operator/src/definitions.d.ts +1 -0
  22. package/build/packages/operator/src/informer.d.ts +1 -0
  23. package/build/packages/terraform_provisioner/index.d.ts +2 -1
  24. package/build/packages/terraform_provisioner/src/process_handler.d.ts +7 -0
  25. package/build/packages/terraform_provisioner/src/project_tf.d.ts +5 -1
  26. package/build/packages/terraform_provisioner/src/project_tf_remote.d.ts +4 -0
  27. package/build/packages/terraform_provisioner/src/utils.d.ts +5 -4
  28. package/package.json +1 -1
package/build/index.js CHANGED
@@ -357922,6 +357922,42 @@ const external_node_child_process_namespaceObject = __WEBPACK_EXTERNAL_createReq
357922
357922
  },
357923
357923
  additionalProperties: false,
357924
357924
  },
357925
+ GithubRules: {
357926
+ $id: 'firestartr.dev://common/FirestartrGithubRules',
357927
+ type: 'object',
357928
+ properties: {
357929
+ path: { type: 'string' },
357930
+ owners: {
357931
+ type: 'array',
357932
+ items: {
357933
+ $ref: 'firestartr.dev://common/FirestartrOwnerRef',
357934
+ },
357935
+ },
357936
+ },
357937
+ required: ['path', 'owners'],
357938
+ additionalProperties: false,
357939
+ },
357940
+ GithubSync: {
357941
+ $id: 'firestartr.dev://common/FirestartrGithubSync',
357942
+ type: 'object',
357943
+ properties: {
357944
+ enabled: { type: 'boolean' },
357945
+ period: {
357946
+ type: 'string',
357947
+ pattern: '^[0-9]+[smhd]$',
357948
+ },
357949
+ policy: { type: 'string' },
357950
+ schedule: { type: 'string' },
357951
+ schedule_timezone: { type: 'string' },
357952
+ },
357953
+ additionalProperties: false,
357954
+ required: ['enabled'],
357955
+ },
357956
+ TfStateKey: {
357957
+ $id: 'firestartr.dev://common/TerraformStateKey',
357958
+ type: 'string',
357959
+ pattern: '^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12,}$',
357960
+ },
357925
357961
  },
357926
357962
  });
357927
357963
 
@@ -357957,6 +357993,7 @@ const external_node_child_process_namespaceObject = __WEBPACK_EXTERNAL_createReq
357957
357993
  $ref: 'firestartr.dev://github/GithubTeamClaim',
357958
357994
  },
357959
357995
  },
357996
+ additionalProperties: false,
357960
357997
  },
357961
357998
  },
357962
357999
  },
@@ -357988,6 +358025,7 @@ const external_node_child_process_namespaceObject = __WEBPACK_EXTERNAL_createReq
357988
358025
  $ref: 'firestartr.dev://github/GithubUserClaim',
357989
358026
  },
357990
358027
  },
358028
+ additionalProperties: false,
357991
358029
  },
357992
358030
  },
357993
358031
  },
@@ -358033,6 +358071,7 @@ const external_node_child_process_namespaceObject = __WEBPACK_EXTERNAL_createReq
358033
358071
  $ref: 'firestartr.dev://github/GithubComponentClaim',
358034
358072
  },
358035
358073
  },
358074
+ additionalProperties: false,
358036
358075
  },
358037
358076
  },
358038
358077
  required: ['owner'],
@@ -358122,6 +358161,7 @@ const external_node_child_process_namespaceObject = __WEBPACK_EXTERNAL_createReq
358122
358161
  $ref: 'firestartr.dev://terraform/TerraformProvider',
358123
358162
  },
358124
358163
  },
358164
+ additionalProperties: false,
358125
358165
  required: ['terraform'],
358126
358166
  },
358127
358167
  },
@@ -358159,6 +358199,7 @@ const external_node_child_process_namespaceObject = __WEBPACK_EXTERNAL_createReq
358159
358199
  $ref: 'firestartr.dev://argocd/ArgoCDProvider',
358160
358200
  },
358161
358201
  },
358202
+ additionalProperties: false,
358162
358203
  required: ['argocd'],
358163
358204
  },
358164
358205
  },
@@ -358195,6 +358236,7 @@ const external_node_child_process_namespaceObject = __WEBPACK_EXTERNAL_createReq
358195
358236
  $ref: 'firestartr.dev://secrets/ExternalSecretsProvider',
358196
358237
  },
358197
358238
  },
358239
+ additionalProperties: false,
358198
358240
  required: ['external_secrets'],
358199
358241
  },
358200
358242
  },
@@ -358234,6 +358276,7 @@ const external_node_child_process_namespaceObject = __WEBPACK_EXTERNAL_createReq
358234
358276
  $ref: 'firestartr.dev://github/GithubOrgWebhookClaim',
358235
358277
  },
358236
358278
  },
358279
+ additionalProperties: false,
358237
358280
  },
358238
358281
  },
358239
358282
  required: ['owner'],
@@ -358258,6 +358301,15 @@ const external_node_child_process_namespaceObject = __WEBPACK_EXTERNAL_createReq
358258
358301
  {
358259
358302
  type: 'object',
358260
358303
  properties: {
358304
+ name: {
358305
+ type: 'string',
358306
+ },
358307
+ tfStateKey: {
358308
+ $ref: 'firestartr.dev://common/TerraformStateKey',
358309
+ },
358310
+ sync: {
358311
+ $ref: 'firestartr.dev://common/FirestartrGithubSync',
358312
+ },
358261
358313
  privacy: {
358262
358314
  type: 'string',
358263
358315
  enum: ['closed', 'secret'],
@@ -358269,6 +358321,7 @@ const external_node_child_process_namespaceObject = __WEBPACK_EXTERNAL_createReq
358269
358321
  $ref: 'firestartr.dev://common/ClaimName',
358270
358322
  },
358271
358323
  },
358324
+ additionalProperties: false,
358272
358325
  required: ['org', 'privacy'],
358273
358326
  },
358274
358327
  ],
@@ -358293,6 +358346,15 @@ const external_node_child_process_namespaceObject = __WEBPACK_EXTERNAL_createReq
358293
358346
  {
358294
358347
  type: 'object',
358295
358348
  properties: {
358349
+ name: {
358350
+ type: 'string',
358351
+ },
358352
+ tfStateKey: {
358353
+ $ref: 'firestartr.dev://common/TerraformStateKey',
358354
+ },
358355
+ sync: {
358356
+ $ref: 'firestartr.dev://common/FirestartrGithubSync',
358357
+ },
358296
358358
  role: {
358297
358359
  type: 'string',
358298
358360
  enum: ['admin', 'member'],
@@ -358301,6 +358363,7 @@ const external_node_child_process_namespaceObject = __WEBPACK_EXTERNAL_createReq
358301
358363
  $ref: 'firestartr.dev://common/ClaimName',
358302
358364
  },
358303
358365
  },
358366
+ additionalProperties: false,
358304
358367
  required: ['org', 'role'],
358305
358368
  },
358306
358369
  ],
@@ -358331,14 +358394,125 @@ const external_node_child_process_namespaceObject = __WEBPACK_EXTERNAL_createReq
358331
358394
  type: 'string',
358332
358395
  description: 'The github repo name',
358333
358396
  },
358397
+ tfStateKey: {
358398
+ $ref: 'firestartr.dev://common/TerraformStateKey',
358399
+ },
358334
358400
  orgPermissions: {
358335
358401
  type: 'string',
358336
358402
  description: 'The level of org Permission',
358337
358403
  },
358404
+ sync: {
358405
+ $ref: 'firestartr.dev://common/FirestartrGithubSync',
358406
+ },
358407
+ technology: {
358408
+ type: 'object',
358409
+ properties: {
358410
+ stack: { type: 'string' },
358411
+ version: { type: 'string' },
358412
+ },
358413
+ additionalProperties: false,
358414
+ required: ['stack', 'version'],
358415
+ },
358416
+ defaultBranch: {
358417
+ type: 'string',
358418
+ },
358419
+ branchStrategy: {
358420
+ type: 'object',
358421
+ description: 'A branch strategy for a claim',
358422
+ properties: {
358423
+ name: {
358424
+ type: 'string',
358425
+ },
358426
+ defaultBranch: {
358427
+ type: 'string',
358428
+ },
358429
+ },
358430
+ additionalProperties: false,
358431
+ required: ['name'],
358432
+ },
358433
+ additionalBranches: {
358434
+ type: 'array',
358435
+ items: {
358436
+ type: 'object',
358437
+ properties: {
358438
+ name: { type: 'string' },
358439
+ orphan: { type: 'boolean' },
358440
+ },
358441
+ additionalProperties: false,
358442
+ required: ['name', 'orphan'],
358443
+ },
358444
+ },
358445
+ actions: {
358446
+ type: 'object',
358447
+ description: 'Actions configuration',
358448
+ properties: {
358449
+ oidc: {
358450
+ type: 'object',
358451
+ properties: {
358452
+ useDefault: { type: 'boolean' },
358453
+ includeClaimKeys: {
358454
+ type: 'array',
358455
+ items: { type: 'string' },
358456
+ },
358457
+ },
358458
+ additionalProperties: false,
358459
+ },
358460
+ },
358461
+ additionalProperties: false,
358462
+ required: ['oidc'],
358463
+ },
358338
358464
  archiveOnDestroy: {
358339
358465
  type: 'boolean',
358340
358466
  description: 'whether this repo should be archived when the claim is deleted',
358341
358467
  },
358468
+ allowMergeCommit: {
358469
+ type: 'boolean',
358470
+ },
358471
+ allowSquashMerge: {
358472
+ type: 'boolean',
358473
+ },
358474
+ allowRebaseMerge: {
358475
+ type: 'boolean',
358476
+ },
358477
+ allowAutoMerge: {
358478
+ type: 'boolean',
358479
+ },
358480
+ deleteBranchOnMerge: {
358481
+ type: 'boolean',
358482
+ },
358483
+ autoInit: {
358484
+ type: 'boolean',
358485
+ },
358486
+ allowUpdateBranch: {
358487
+ type: 'boolean',
358488
+ },
358489
+ hasIssues: {
358490
+ type: 'boolean',
358491
+ },
358492
+ hasWiki: {
358493
+ type: 'boolean',
358494
+ },
358495
+ pages: {
358496
+ type: 'object',
358497
+ properties: {
358498
+ cname: { type: 'string' },
358499
+ source: {
358500
+ type: 'object',
358501
+ properties: {
358502
+ branch: { type: 'string' },
358503
+ path: { type: 'string' },
358504
+ },
358505
+ additionalProperties: false,
358506
+ },
358507
+ },
358508
+ additionalProperties: false,
358509
+ },
358510
+ additionalRules: {
358511
+ type: 'array',
358512
+ items: {
358513
+ $ref: 'firestartr.dev://common/FirestartrGithubRules',
358514
+ },
358515
+ },
358342
358516
  visibility: {
358343
358517
  type: 'string',
358344
358518
  enum: ['private', 'public', 'internal'],
@@ -358367,8 +358541,14 @@ const external_node_child_process_namespaceObject = __WEBPACK_EXTERNAL_createReq
358367
358541
  pattern: '^[a-z0-9][a-z0-9-]*$',
358368
358542
  },
358369
358543
  },
358544
+ overrides: {
358545
+ type: 'object',
358546
+ properties: {},
358547
+ additionalProperties: true,
358548
+ },
358370
358549
  },
358371
- required: ['visibility', 'org'],
358550
+ additionalProperties: false,
358551
+ required: ['visibility', 'org', 'branchStrategy'],
358372
358552
  },
358373
358553
  ],
358374
358554
  },
@@ -358390,6 +358570,12 @@ const external_node_child_process_namespaceObject = __WEBPACK_EXTERNAL_createReq
358390
358570
  {
358391
358571
  type: 'object',
358392
358572
  properties: {
358573
+ name: {
358574
+ type: 'string',
358575
+ },
358576
+ tfStateKey: {
358577
+ $ref: 'firestartr.dev://common/TerraformStateKey',
358578
+ },
358393
358579
  orgName: {
358394
358580
  $ref: 'firestartr.dev://common/ClaimName',
358395
358581
  },
@@ -358420,9 +358606,11 @@ const external_node_child_process_namespaceObject = __WEBPACK_EXTERNAL_createReq
358420
358606
  },
358421
358607
  },
358422
358608
  },
358609
+ additionalProperties: false,
358423
358610
  required: ['url', 'contentType', 'events', 'secretRef'],
358424
358611
  },
358425
358612
  },
358613
+ additionalProperties: false,
358426
358614
  required: ['orgName', 'webhook'],
358427
358615
  },
358428
358616
  ],
@@ -358626,6 +358814,9 @@ const GithubSchemas = [
358626
358814
  name: {
358627
358815
  type: 'string',
358628
358816
  },
358817
+ tfStateKey: {
358818
+ $ref: 'firestartr.dev://common/TerraformStateKey',
358819
+ },
358629
358820
  source: {
358630
358821
  type: 'string',
358631
358822
  enum: ['remote', 'inline', 'Remote', 'Inline'],
@@ -358717,6 +358908,7 @@ const GithubSchemas = [
358717
358908
  additionalProperties: false,
358718
358909
  },
358719
358910
  },
358911
+ additionalProperties: false,
358720
358912
  required: ['values', 'context', 'source', 'name'],
358721
358913
  },
358722
358914
  ],
@@ -358849,6 +359041,7 @@ const ArgoCDSchemas = [argocd_schema];
358849
359041
  enum: ['SecretStore', 'ClusterSecretStore'],
358850
359042
  },
358851
359043
  },
359044
+ additionalProperties: false,
358852
359045
  required: ['name'],
358853
359046
  },
358854
359047
  ExternalSecretsSection: {
@@ -358884,6 +359077,9 @@ const ArgoCDSchemas = [argocd_schema];
358884
359077
  template: { type: 'object' },
358885
359078
  secretName: { type: 'string' },
358886
359079
  refreshInterval: { type: 'string' },
359080
+ updatePolicy: { type: 'string' },
359081
+ deletionPolicy: { type: 'string' },
359082
+ conversionStrategy: { type: 'string' },
358887
359083
  generator: {
358888
359084
  type: 'object',
358889
359085
  properties: {
@@ -358906,19 +359102,15 @@ const ArgoCDSchemas = [argocd_schema];
358906
359102
  'Grafana',
358907
359103
  ],
358908
359104
  },
358909
- apiVersion: {
358910
- type: 'string',
358911
- },
358912
- conversionStrategy: {
358913
- type: 'string',
358914
- },
358915
- outputKey: {
358916
- type: 'string',
358917
- },
359105
+ apiVersion: { type: 'string' },
359106
+ conversionStrategy: { type: 'string' },
359107
+ outputKey: { type: 'string' },
358918
359108
  },
359109
+ additionalProperties: false,
358919
359110
  required: ['name'],
358920
359111
  },
358921
359112
  },
359113
+ additionalProperties: false,
358922
359114
  required: ['secretName', 'generator'],
358923
359115
  },
358924
359116
  },
@@ -366185,6 +366377,8 @@ function walkArray(arr, symbolsToResolve, renderClaim) {
366185
366377
 
366186
366378
 
366187
366379
 
366380
+
366381
+
366188
366382
  /*
366189
366383
  * Function called when rendering from the importer class.
366190
366384
  *
@@ -366198,6 +366392,17 @@ function walkArray(arr, symbolsToResolve, renderClaim) {
366198
366392
  *
366199
366393
  */
366200
366394
  async function renderFromImports(rClaims, crs = {}, catalogOutputDir = '/tmp/.catalog', crOutputDir = '/tmp/.resources') {
366395
+ // Apply claim defaults (same as runRenderer path does via loadClaim/patchClaim)
366396
+ try {
366397
+ const defaults = loadClaimDefaults();
366398
+ for (const renderClaim of Object.values(rClaims)) {
366399
+ renderClaim.claim = loader_patchClaim(renderClaim.claim, defaults);
366400
+ validateClaim(renderClaim.claim);
366401
+ }
366402
+ }
366403
+ catch (e) {
366404
+ cdk8s_renderer_src_logger.warn(`Could not apply claim defaults: ${e.message}`);
366405
+ }
366201
366406
  // type: is the kind of the claim
366202
366407
  // value: is the imported-ref (the name in Github, can be with special characters, spaces, etc)
366203
366408
  const fSolver = (type, value) => {
@@ -366782,7 +366987,7 @@ class MemberGithubDecanter extends GithubDecanter {
366782
366987
  this.claim = {
366783
366988
  kind: this.claimKind,
366784
366989
  version: this.VERSION(),
366785
- name: this.data.memberDetails.login,
366990
+ name: this.data.memberDetails.login.toLowerCase(),
366786
366991
  profile: {
366787
366992
  displayName: this.data.memberDetails.login,
366788
366993
  email: this.data.memberDetails.email
@@ -366839,10 +367044,26 @@ MemberCollectionGithubDecanter.collectionKind = 'gh-members';
366839
367044
  applyCollectionMixins(MemberCollectionGithubDecanter);
366840
367045
  /* harmony default export */ const github_member_collection = (MemberCollectionGithubDecanter);
366841
367046
 
367047
+ ;// CONCATENATED MODULE: ../importer/src/utils/nomicon.ts
367048
+ function transformRepoName(repoName) {
367049
+ // Convert to lowercase
367050
+ let transformedName = repoName.toLowerCase();
367051
+ const specialCharsRegex = /[._]/g;
367052
+ if (specialCharsRegex.test(transformedName)) {
367053
+ transformedName = transformedName.replace(/[._]/g, '');
367054
+ // we add a random 2 letter suffix
367055
+ return (transformedName + '-imp-.' + Math.random().toString(36).substring(2, 4));
367056
+ }
367057
+ else {
367058
+ return transformedName;
367059
+ }
367060
+ }
367061
+
366842
367062
  ;// CONCATENATED MODULE: ../importer/src/decanter/gh/github_repo.ts
366843
367063
 
366844
367064
 
366845
367065
 
367066
+
366846
367067
  const TYPE_MAP = {
366847
367068
  User: 'user',
366848
367069
  Team: 'group',
@@ -366860,7 +367081,7 @@ class RepoGithubDecanter extends GithubDecanter {
366860
367081
  version: this.VERSION(),
366861
367082
  type: 'service',
366862
367083
  lifecycle: 'production',
366863
- name: this.data.repoDetails.name,
367084
+ name: transformRepoName(this.data.repoDetails.name),
366864
367085
  };
366865
367086
  }
366866
367087
  __decantProviders() {
@@ -366922,7 +367143,7 @@ class RepoGithubDecanter extends GithubDecanter {
366922
367143
  const outsideMaintainers = this.data.teamsAndMembers.outsideMembers
366923
367144
  .filter((member) => member.role === 'maintain')
366924
367145
  .map((member) => {
366925
- return `collaborator:${member.name}`;
367146
+ return `collaborator:${member.name.toLowerCase()}`;
366926
367147
  });
366927
367148
  const teamMaintainers = this.data.teamsAndMembers.teams
366928
367149
  .filter((team) => team.role === 'maintain')
@@ -366947,7 +367168,7 @@ class RepoGithubDecanter extends GithubDecanter {
366947
367168
  const outsideAdmins = this.data.teamsAndMembers.outsideMembers
366948
367169
  .filter((member) => member.role === 'admin')
366949
367170
  .map((member) => {
366950
- return `collaborator:${member.name}`;
367171
+ return `collaborator:${member.name.toLowerCase()}`;
366951
367172
  });
366952
367173
  const teamAdmins = this.data.teamsAndMembers.teams
366953
367174
  .filter((team) => team.role === 'admin')
@@ -366956,13 +367177,6 @@ class RepoGithubDecanter extends GithubDecanter {
366956
367177
  });
366957
367178
  const admins = directAdmins.concat(outsideAdmins).concat(teamAdmins);
366958
367179
  const overrides = {};
366959
- if (admins && admins.length > 0) {
366960
- this.__patchClaim({
366961
- op: 'add',
366962
- value: admins[0],
366963
- path: '/owner',
366964
- });
366965
- }
366966
367180
  if (admins && admins.length > 1) {
366967
367181
  overrides['additionalAdmins'] = [];
366968
367182
  for (let i = 1; i < admins.length; i++) {
@@ -366982,7 +367196,7 @@ class RepoGithubDecanter extends GithubDecanter {
366982
367196
  const outsideWriters = this.data.teamsAndMembers.outsideMembers
366983
367197
  .filter((member) => member.role === 'push')
366984
367198
  .map((member) => {
366985
- return `collaborator:${member.name}`;
367199
+ return `collaborator:${member.name.toLowerCase()}`;
366986
367200
  });
366987
367201
  const teamWriters = this.data.teamsAndMembers.teams
366988
367202
  .filter((team) => ['push', 'write'].includes(team.role))
@@ -367006,7 +367220,7 @@ class RepoGithubDecanter extends GithubDecanter {
367006
367220
  const outsideReaders = this.data.teamsAndMembers.outsideMembers
367007
367221
  .filter((member) => member.role === 'pull')
367008
367222
  .map((member) => {
367009
- return `collaborator:${member.name}`;
367223
+ return `collaborator:${member.name.toLowerCase()}`;
367010
367224
  });
367011
367225
  const teamReaders = this.data.teamsAndMembers.teams
367012
367226
  .filter((team) => ['pull', 'read'].includes(team.role))
@@ -367689,6 +367903,25 @@ function definitions_getPluralFromKind(kind) {
367689
367903
  const plural = Object.keys(kindPluralMap).find((key) => kindPluralMap[key] === kind);
367690
367904
  return plural;
367691
367905
  }
367906
+ const DAY_SECONDS = 24 * 60 * 60;
367907
+ const TIMEOUTS = {
367908
+ // expressed in seconds
367909
+ RENAMED: DAY_SECONDS,
367910
+ UPDATED: DAY_SECONDS,
367911
+ CREATED: DAY_SECONDS,
367912
+ RETRY: 120 * 60,
367913
+ MARKED_TO_DELETION: DAY_SECONDS,
367914
+ SYNC: DAY_SECONDS,
367915
+ NOTHING: 10,
367916
+ };
367917
+ function getTimeoutForOperation(operation) {
367918
+ if (operation in TIMEOUTS) {
367919
+ return TIMEOUTS[operation];
367920
+ }
367921
+ else {
367922
+ throw new Error(`getTimeoutForOperation: Unknown operation: ${operation}`);
367923
+ }
367924
+ }
367692
367925
 
367693
367926
  ;// CONCATENATED MODULE: ../operator/src/pr-annotation.ts
367694
367927
 
@@ -369200,6 +369433,19 @@ function enqueue(pluralKind, workItem, queue, compute, syncCtl, retryCtl) {
369200
369433
  itemPath: () => informer_itemPath(pluralKind, workItem.item),
369201
369434
  error: () => retryCtl.errorReconciling(informer_itemPath(pluralKind, workItem.item)),
369202
369435
  success: () => retryCtl.successReconciling(informer_itemPath(pluralKind, workItem.item)),
369436
+ recommendedTimeout: () => {
369437
+ const customTimeoutAnnotation = catalog_common.generic.getFirestartrAnnotation('test-custom-timeout');
369438
+ let customTimeout = null;
369439
+ if ('annotations' in workItem.item.metadata &&
369440
+ customTimeoutAnnotation in workItem.item.metadata.annotations &&
369441
+ !isNaN(parseInt(workItem.item.metadata.annotations[customTimeoutAnnotation]))) {
369442
+ customTimeout = parseInt(workItem.item.metadata.annotations[customTimeoutAnnotation]);
369443
+ }
369444
+ else {
369445
+ customTimeout = getTimeoutForOperation(workItem.operation);
369446
+ }
369447
+ return customTimeout;
369448
+ },
369203
369449
  needsBlocking: (item, operation) => {
369204
369450
  if (kindsWithDependants.indexOf(item.kind) === -1) {
369205
369451
  return false;
@@ -370052,16 +370298,6 @@ function getQueueMetrics() {
370052
370298
  // "FirestartrGithubRepositoryFeature": 1,
370053
370299
  // "FirestartrTerraformWorkspacePlan": 1,
370054
370300
  // }
370055
- const TIMEOUTS = {
370056
- // expressed in seconds
370057
- RENAMED: 30 * 60,
370058
- UPDATED: 60 * 60,
370059
- CREATED: 60 * 60,
370060
- RETRY: 60 * 60,
370061
- MARKED_TO_DELETION: 60 * 60,
370062
- SYNC: 60 * 60,
370063
- NOTHING: 10,
370064
- };
370065
370301
  let INIT = false;
370066
370302
  /**
370067
370303
  * Pushes a WorkItem to the queue
@@ -370099,27 +370335,12 @@ async function processItem_loop() {
370099
370335
  if (w) {
370100
370336
  const logMessage = `${new Date().toISOString()} : Processing OPERATION: ${w.operation} ITEM: ${w.item.kind}/${w.item.metadata.name}`;
370101
370337
  catalog_common.io.writeLogFile('process_item', logMessage);
370102
- const timeout = createTimeout(w);
370103
370338
  operator_src_logger.info(`The processor is currently handling a '${w.operation}' operation for item '${w.item.kind}/${w.item.metadata.name}' in namespace '${w.item.metadata.namespace}'. The current work status is '${w.workStatus}'.`);
370104
370339
  await runWorkItem(w);
370105
- clearTimeout(timeout);
370106
370340
  }
370107
370341
  await processItem_wait();
370108
370342
  }
370109
370343
  }
370110
- /**
370111
- * Creates a timeout for a workItem
370112
- *
370113
- *
370114
- **/
370115
- function createTimeout(w) {
370116
- return setTimeout(() => {
370117
- //throw new Error('Timeout on workitem ' + w);
370118
- console.error('Timeout on workitem %O', w);
370119
- operator_src_logger.error(`The processor timed out while handling a '${w.operation}' operation for item '${w.item.kind}/${w.item.metadata.name}' in namespace '${w.item.metadata.namespace}'. The current work status is '${w.workStatus}'.`);
370120
- process.exit(1);
370121
- }, TIMEOUTS[w.operation] * 1000);
370122
- }
370123
370344
  /**
370124
370345
  * Sorts the queue based on the operation type
370125
370346
  * @param {WorkItem[]} queue - store of WorkItems
@@ -373108,11 +373329,82 @@ class TFPlanItemVersion extends TFPlanItem {
373108
373329
 
373109
373330
  /* harmony default export */ const terraform_provisioner_src_logger = (catalog_common.logger);
373110
373331
 
373332
+ ;// CONCATENATED MODULE: ../terraform_provisioner/src/process_handler.ts
373333
+
373334
+ const GRACE_PERIOD = 60 * 2; // 2 min
373335
+ const HARD_RESET_PERIOD = 10; // 10 sec
373336
+ function processHandler(processToHandle, ctl, onTimedOut) {
373337
+ let gracefulResetId;
373338
+ let hardResetId;
373339
+ let callerNotified = false;
373340
+ let timedOut = false;
373341
+ const safeKill = (signal) => {
373342
+ try {
373343
+ const sent = processToHandle.kill(signal);
373344
+ if (!sent) {
373345
+ throw new Error(`Failed to send signal ${signal} to the process`);
373346
+ }
373347
+ }
373348
+ catch (error) {
373349
+ terraform_provisioner_src_logger.error(`FATAL: timeout signal ${signal} could not be delivered to the process: ${error}`);
373350
+ if (!callerNotified) {
373351
+ ctl.processKilled(false);
373352
+ callerNotified = true;
373353
+ }
373354
+ }
373355
+ };
373356
+ const terminateId = setTimeout(() => {
373357
+ // we take control of the process
373358
+ onTimedOut();
373359
+ timedOut = true;
373360
+ // send sigInt
373361
+ terraform_provisioner_src_logger.error(`Terraform process has not exited after initial timeout of ${ctl.hardTimeout} seconds, sending SIGINT...`);
373362
+ safeKill('SIGINT');
373363
+ // grace period
373364
+ gracefulResetId = setTimeout(() => {
373365
+ terraform_provisioner_src_logger.error(`Terraform process has not exited after SIGINT grace period of ${GRACE_PERIOD} seconds (total elapsed ~${ctl.hardTimeout + GRACE_PERIOD} seconds), sending SIGTERM...`);
373366
+ safeKill('SIGTERM');
373367
+ // hard reset period
373368
+ hardResetId = setTimeout(() => {
373369
+ terraform_provisioner_src_logger.error(`Terraform process has not exited after SIGTERM hard reset period of ${HARD_RESET_PERIOD} seconds (total elapsed ~${ctl.hardTimeout + GRACE_PERIOD + HARD_RESET_PERIOD} seconds), sending SIGKILL...`);
373370
+ safeKill('SIGKILL');
373371
+ setTimeout(() => {
373372
+ // we send if the process was killed or not to the caller
373373
+ if (!callerNotified) {
373374
+ ctl.processKilled(processToHandle.killed);
373375
+ callerNotified = true;
373376
+ }
373377
+ }, 10 * 1000);
373378
+ }, HARD_RESET_PERIOD * 1000);
373379
+ }, GRACE_PERIOD * 1000);
373380
+ }, ctl.hardTimeout * 1000);
373381
+ processToHandle.on('exit', () => {
373382
+ // the process has exited
373383
+ // let's clear all the timeouts
373384
+ if (terminateId) {
373385
+ clearTimeout(terminateId);
373386
+ }
373387
+ if (gracefulResetId) {
373388
+ clearTimeout(gracefulResetId);
373389
+ }
373390
+ if (hardResetId) {
373391
+ clearTimeout(hardResetId);
373392
+ }
373393
+ // we inform the caller
373394
+ // if the process exited and the timeout control has kicked-off
373395
+ if (!callerNotified && timedOut) {
373396
+ ctl.processKilled(true);
373397
+ callerNotified = true;
373398
+ }
373399
+ });
373400
+ }
373401
+
373111
373402
  ;// CONCATENATED MODULE: ../terraform_provisioner/src/utils.ts
373112
373403
 
373113
373404
 
373114
373405
 
373115
373406
 
373407
+
373116
373408
  async function utils_validate(path, secrets) {
373117
373409
  return await tfExec(path, ['validate'], secrets);
373118
373410
  }
@@ -373122,28 +373414,28 @@ async function init(path, secrets, stream) {
373122
373414
  async function initFromModule(path, source, secrets, stream) {
373123
373415
  return tfExec(path, ['init', `-from-module=${source}`], secrets, [], stream);
373124
373416
  }
373125
- async function plan(path, secrets, format, args = ['plan'], stream) {
373417
+ async function plan(path, secrets, format, args = ['plan'], stream, ctl) {
373126
373418
  terraform_provisioner_src_logger.info(`Running terraform plan with ${format} in path ${path}`);
373127
- const plan = await tfExec(path, args.concat(format === 'json' ? ['-json'] : []), secrets, ['-input=false'], stream);
373419
+ const plan = await tfExec(path, args.concat(format === 'json' ? ['-json'] : []), secrets, ['-input=false'], stream, ctl);
373128
373420
  if (format === 'json') {
373129
373421
  const tfPlan = planGet(plan);
373130
373422
  return tfPlan;
373131
373423
  }
373132
373424
  return plan;
373133
373425
  }
373134
- async function apply(path, secrets, stream) {
373426
+ async function apply(path, secrets, stream, ctl) {
373135
373427
  terraform_provisioner_src_logger.debug(`Running terraform apply in path ${path}`);
373136
- return await tfExec(path, ['apply', '-auto-approve'], secrets, ['-input=false'], stream);
373428
+ return await tfExec(path, ['apply', '-auto-approve'], secrets, ['-input=false'], stream, ctl);
373137
373429
  }
373138
- async function destroy(path, secrets, stream) {
373430
+ async function destroy(path, secrets, stream, ctl) {
373139
373431
  terraform_provisioner_src_logger.debug(`Running terraform destroy in path ${path}`);
373140
- return await tfExec(path, ['destroy', '-auto-approve'], secrets, ['-input=false'], stream);
373432
+ return await tfExec(path, ['destroy', '-auto-approve'], secrets, ['-input=false'], stream, ctl);
373141
373433
  }
373142
373434
  async function output(path, secrets) {
373143
373435
  terraform_provisioner_src_logger.debug(`Running terraform output in path ${path}`);
373144
373436
  return await tfExec(path, ['output', '-json'], secrets, []);
373145
373437
  }
373146
- async function tfExec(path, args, secrets, extraArgs = ['-input=false'], stream) {
373438
+ async function tfExec(path, args, secrets, extraArgs = ['-input=false'], stream, ctl) {
373147
373439
  return new Promise((ok, ko) => {
373148
373440
  const tfProcess = (0,external_child_process_.spawn)('tofu', args.concat(extraArgs), {
373149
373441
  cwd: path,
@@ -373153,6 +373445,7 @@ async function tfExec(path, args, secrets, extraArgs = ['-input=false'], stream)
373153
373445
  let flagStdoutEnd = false;
373154
373446
  let flagStderrEnd = false;
373155
373447
  let outputErrors = '';
373448
+ let processTimeout = false;
373156
373449
  tfProcess.stdout.on('data', (log) => {
373157
373450
  const line = catalog_common.io.stripAnsi(log.toString());
373158
373451
  output += line;
@@ -373173,12 +373466,21 @@ async function tfExec(path, args, secrets, extraArgs = ['-input=false'], stream)
373173
373466
  });
373174
373467
  tfProcess.on('exit', async (code) => {
373175
373468
  let retryCount = 0;
373176
- while ((!flagStdoutEnd && !flagStderrEnd) || retryCount < 10) {
373469
+ while (!flagStdoutEnd && !flagStderrEnd && retryCount < 10) {
373177
373470
  retryCount++;
373178
373471
  await catalog_common.generic.sleep(500);
373179
373472
  }
373473
+ // this process has been killed/terminated
373474
+ // by timeout (not in our control)
373475
+ if (processTimeout) {
373476
+ terraform_provisioner_src_logger.error(`Terraform output ${path}: ${[output, outputErrors].join('')}`);
373477
+ ko(catalog_common.generic.buildCommandExecutionError([output, outputErrors, '\n<PROCESS TIMEOUT>'].join(''), catalog_common.generic.normalizeExitCode(code), args.concat(extraArgs), {
373478
+ errorName: 'TerraformCommandError',
373479
+ label: 'Terraform command',
373480
+ }));
373481
+ return;
373482
+ }
373180
373483
  if (code !== 0) {
373181
- terraform_provisioner_src_logger.error(`Terraform output ${path}: ${output + outputErrors}`);
373182
373484
  terraform_provisioner_src_logger.error(`Terraform output ${path}: ${[output, outputErrors].join('')}`);
373183
373485
  ko(catalog_common.generic.buildCommandExecutionError([output, outputErrors].join(''), catalog_common.generic.normalizeExitCode(code), args.concat(extraArgs), {
373184
373486
  errorName: 'TerraformCommandError',
@@ -373190,6 +373492,13 @@ async function tfExec(path, args, secrets, extraArgs = ['-input=false'], stream)
373190
373492
  ok(output);
373191
373493
  }
373192
373494
  });
373495
+ if (ctl) {
373496
+ void processHandler(tfProcess, ctl, () => {
373497
+ // callback to be called by the process handler
373498
+ // we set on our flag to avoid sending our own messages
373499
+ processTimeout = true;
373500
+ });
373501
+ }
373193
373502
  });
373194
373503
  }
373195
373504
  async function configureGit(ghToken) {
@@ -373678,6 +373987,15 @@ class project_tf_TFProjectManager {
373678
373987
  }
373679
373988
  this.secrets = ctx.secrets;
373680
373989
  }
373990
+ set ctl(ctl) {
373991
+ this._ctl = ctl;
373992
+ }
373993
+ get ctl() {
373994
+ return this._ctl;
373995
+ }
373996
+ getOutput() {
373997
+ return this.tfOutput;
373998
+ }
373681
373999
  setStreamCallbacks(fnData, fnEnd, reopen = true) {
373682
374000
  if (reopen || !this.stream)
373683
374001
  this.stream = new external_stream_.PassThrough();
@@ -373686,9 +374004,6 @@ class project_tf_TFProjectManager {
373686
374004
  });
373687
374005
  this.stream.on('end', fnEnd);
373688
374006
  }
373689
- getOutput() {
373690
- return this.tfOutput;
373691
- }
373692
374007
  async build() {
373693
374008
  await this.mainTfWriter.render();
373694
374009
  this.mainTfWriter.writeToTerraformProject(external_path_.join(this.projectPath, 'firestartr-main.tf'));
@@ -373715,7 +374030,7 @@ class project_tf_TFProjectManager {
373715
374030
  await this.__init();
373716
374031
  if (format === 'json')
373717
374032
  this.tfOutput = null;
373718
- this.tfOutput = await plan(this.projectPath, this.secrets, format, ['plan'], this.stream);
374033
+ this.tfOutput = await plan(this.projectPath, this.secrets, format, ['plan'], this.stream, this.ctl);
373719
374034
  if (this.stream)
373720
374035
  this.stream.end();
373721
374036
  }
@@ -373723,17 +374038,17 @@ class project_tf_TFProjectManager {
373723
374038
  await this.__init();
373724
374039
  if (format === 'json')
373725
374040
  this.tfOutput = null;
373726
- this.tfOutput = await plan(this.projectPath, this.secrets, format, ['plan', '-destroy'], this.stream);
374041
+ this.tfOutput = await plan(this.projectPath, this.secrets, format, ['plan', '-destroy'], this.stream, this.ctl);
373727
374042
  }
373728
374043
  async apply() {
373729
374044
  await this.__init();
373730
- this.tfOutput += await apply(this.projectPath, this.secrets, this.stream);
374045
+ this.tfOutput += await apply(this.projectPath, this.secrets, this.stream, this.ctl);
373731
374046
  if (this.stream)
373732
374047
  this.stream.end();
373733
374048
  }
373734
374049
  async destroy() {
373735
374050
  await this.__init();
373736
- this.tfOutput += await destroy(this.projectPath, this.secrets, this.stream);
374051
+ this.tfOutput += await destroy(this.projectPath, this.secrets, this.stream, this.ctl);
373737
374052
  if (this.stream)
373738
374053
  this.stream.end();
373739
374054
  }
@@ -373845,6 +374160,12 @@ class TFProjectManagerRemote {
373845
374160
  }
373846
374161
  this.tfVarsJsonWriter = new WriterTfVarsJson(ctx.values, ctx.references);
373847
374162
  }
374163
+ set ctl(ctl) {
374164
+ this._ctl = ctl;
374165
+ }
374166
+ get ctl() {
374167
+ return this._ctl;
374168
+ }
373848
374169
  getOutput() {
373849
374170
  return this.tfOutput;
373850
374171
  }
@@ -373893,23 +374214,23 @@ insteadOf = https://github.com`);
373893
374214
  async plan(format) {
373894
374215
  await this.__init();
373895
374216
  if (format === 'json') {
373896
- this.tfOutput = await plan(this.projectPath, this.secrets, format, ['plan'], this.stream);
374217
+ this.tfOutput = await plan(this.projectPath, this.secrets, format, ['plan'], this.stream, this.ctl);
373897
374218
  }
373898
374219
  else {
373899
- this.tfOutput += await plan(this.projectPath, this.secrets, format, ['plan'], this.stream);
374220
+ this.tfOutput += await plan(this.projectPath, this.secrets, format, ['plan'], this.stream, this.ctl);
373900
374221
  }
373901
374222
  if (this.stream)
373902
374223
  this.stream.end();
373903
374224
  }
373904
374225
  async apply() {
373905
374226
  await this.__init();
373906
- this.tfOutput += await apply(this.projectPath, this.secrets, this.stream);
374227
+ this.tfOutput += await apply(this.projectPath, this.secrets, this.stream, this.ctl);
373907
374228
  if (this.stream)
373908
374229
  this.stream.end();
373909
374230
  }
373910
374231
  async destroy() {
373911
374232
  await this.__init();
373912
- this.tfOutput += await destroy(this.projectPath, this.secrets, this.stream);
374233
+ this.tfOutput += await destroy(this.projectPath, this.secrets, this.stream, this.ctl);
373913
374234
  if (this.stream)
373914
374235
  this.stream.end();
373915
374236
  }
@@ -373958,7 +374279,7 @@ async function run() {
373958
374279
  await execCommand(command, tfProject);
373959
374280
  }
373960
374281
  // Programatic API
373961
- async function runTerraformProvisioner(context, command = 'init', streaming) {
374282
+ async function runTerraformProvisioner(context, command = 'init', streaming, ctl) {
373962
374283
  terraform_provisioner_src_logger.info(`Running command ${command} on a ${context.type} project`);
373963
374284
  validateContext(context);
373964
374285
  let tfProject = {};
@@ -373971,6 +374292,9 @@ async function runTerraformProvisioner(context, command = 'init', streaming) {
373971
374292
  if (streaming) {
373972
374293
  tfProject.setStreamCallbacks(streaming.fnData, streaming.fnEnd);
373973
374294
  }
374295
+ if (ctl) {
374296
+ tfProject.ctl = ctl;
374297
+ }
373974
374298
  const output = await execCommand(command, tfProject);
373975
374299
  return output;
373976
374300
  }
@@ -374215,7 +374539,17 @@ async function* doPlanJSONFormat(item, op, handler, setResult = function (_r) {
374215
374539
  if (item.metadata.annotations['firestartr.dev/last-state-pr'] || false) {
374216
374540
  await addPlanStatusCheck(item.metadata.annotations['firestartr.dev/last-state-pr'], 'Terraform plan in progress...');
374217
374541
  }
374218
- const tfPlan = await runTerraformProvisioner(context, planType);
374542
+ const tfPlan = await runTerraformProvisioner(context, planType, null, {
374543
+ hardTimeout: handler.recommendedTimeout(),
374544
+ processKilled: (killed) => {
374545
+ if (killed) {
374546
+ operator_src_logger.error(`The Terraform process for item '${item.kind}/${item.metadata.name}' was killed due to a timeout.`);
374547
+ }
374548
+ else {
374549
+ operator_src_logger.error(`PANIC!!: The Terraform process for item '${item.kind}/${item.metadata.name}' could not be killed`);
374550
+ }
374551
+ },
374552
+ });
374219
374553
  if (tfPlan.summary.hasChanges()) {
374220
374554
  yield {
374221
374555
  item,
@@ -374502,7 +374836,17 @@ async function* process_operation_markedToDeletion(item, op, handler) {
374502
374836
  }
374503
374837
  const deps = await handler.resolveReferences();
374504
374838
  const context = buildProvisionerContext(item, deps);
374505
- const destroyOutput = await runTerraformProvisioner(context, 'destroy');
374839
+ const destroyOutput = await runTerraformProvisioner(context, 'destroy', null, {
374840
+ hardTimeout: handler.recommendedTimeout(),
374841
+ processKilled: (killed) => {
374842
+ if (killed) {
374843
+ operator_src_logger.error(`The Terraform process for item '${item.kind}/${item.metadata.name}' was killed due to a timeout.`);
374844
+ }
374845
+ else {
374846
+ operator_src_logger.error(`PANIC!!: The Terraform process for item '${item.kind}/${item.metadata.name}' could not be killed`);
374847
+ }
374848
+ },
374849
+ });
374506
374850
  yield {
374507
374851
  item,
374508
374852
  reason: op,
@@ -374613,7 +374957,17 @@ async function* process_operation_doApply(item, op, handler) {
374613
374957
  const deps = await handler.resolveReferences();
374614
374958
  operator_src_logger.info(`The Terraform processor is applying and assessing dependencies for item '${item.kind}/${item.metadata.name}' with dependencies: '${deps}'.`);
374615
374959
  const context = buildProvisionerContext(item, deps);
374616
- const applyOutput = await runTerraformProvisioner(context, 'apply', checkRunCtl);
374960
+ const applyOutput = await runTerraformProvisioner(context, 'apply', checkRunCtl, {
374961
+ hardTimeout: handler.recommendedTimeout(),
374962
+ processKilled: (killed) => {
374963
+ if (killed) {
374964
+ operator_src_logger.error(`The Terraform process for item '${item.kind}/${item.metadata.name}' was killed due to a timeout.`);
374965
+ }
374966
+ else {
374967
+ operator_src_logger.error(`PANIC!!: The Terraform process for item '${item.kind}/${item.metadata.name}' could not be killed`);
374968
+ }
374969
+ },
374970
+ });
374617
374971
  const terraformOutputJson = await runTerraformProvisioner(context, 'output');
374618
374972
  if (!terraformOutputJson) {
374619
374973
  throw new Error(`Terraform output is empty for ${item.kind}/${item.metadata.name}`);
@@ -376752,9 +377106,9 @@ const crs_analyzerSubcommand = {
376752
377106
  };
376753
377107
 
376754
377108
  ;// CONCATENATED MODULE: ./package.json
376755
- const package_namespaceObject = JSON.parse('{"i8":"1.59.0-snapshot-15"}');
377109
+ const package_namespaceObject = JSON.parse('{"i8":"1.59.0-snapshot-16"}');
376756
377110
  ;// CONCATENATED MODULE: ../../package.json
376757
- const package_namespaceObject_1 = {"i8":"1.58.0"};
377111
+ const package_namespaceObject_1 = {"i8":"1.59.3"};
376758
377112
  ;// CONCATENATED MODULE: ./src/subcommands/index.ts
376759
377113
 
376760
377114