@firestartr/cli 2.1.0-snapshot-1 → 2.1.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 +21 -50
  2. package/package.json +1 -1
package/build/index.js CHANGED
@@ -356187,39 +356187,33 @@ function createCRrefFrom(claimRef, needsSecret) {
356187
356187
  * @returns string
356188
356188
  */
356189
356189
  function createCodeOwnersData(claim, additionalRules) {
356190
- const paddedAsterisk = '*'.padEnd(25);
356191
- // we avoid generating the same line twice (idempotency)
356192
- const redactedLines = [];
356193
- const concatLine = function (messageFinal, line) {
356194
- if (redactedLines.includes(line)) {
356195
- return messageFinal;
356190
+ const rulesMap = new Map();
356191
+ const addOwnerToPath = (path, owner) => {
356192
+ const owners = rulesMap.get(path) ?? [];
356193
+ if (!owners.includes(owner)) {
356194
+ owners.push(owner);
356196
356195
  }
356197
- else {
356198
- redactedLines.push(line);
356199
- messageFinal += line;
356200
- }
356201
- return messageFinal;
356196
+ rulesMap.set(path, owners);
356202
356197
  };
356203
356198
  let message = `# This file was generated by firestartr.
356204
356199
  # WARNING: Please don't edit this file directly in the repository
356205
356200
  # Go to gitops repository to modify it!`;
356206
356201
  if (claim.owner) {
356207
- message = concatLine(message, `\n${paddedAsterisk}${resolveCodeownersRef(claim.owner, claim.providers.github.org)}`);
356202
+ addOwnerToPath('*', resolveCodeownersRef(claim.owner, claim.providers.github.org));
356208
356203
  }
356209
356204
  if (claim.platformOwner) {
356210
- message = concatLine(message, `\n${'/.github/'.padEnd(25)}${resolveCodeownersRef(claim.platformOwner, claim.providers.github.org)}`);
356205
+ addOwnerToPath('/.github/', resolveCodeownersRef(claim.platformOwner, claim.providers.github.org));
356211
356206
  }
356212
356207
  if (additionalRules) {
356213
356208
  for (const rule of additionalRules) {
356214
- let line = `\n${rule.path.padEnd(25)}`;
356215
356209
  for (const owner of rule.owners) {
356216
- line += `${resolveCodeownersRef(owner, claim.providers.github.org)} `;
356210
+ addOwnerToPath(rule.path, resolveCodeownersRef(owner, claim.providers.github.org));
356217
356211
  }
356218
- message = concatLine(message, line);
356219
- // Remove trailing <space> from the previous loop
356220
- message = message.substring(0, message.length - 1);
356221
356212
  }
356222
356213
  }
356214
+ for (const [path, owners] of rulesMap.entries()) {
356215
+ message += `\n${path.padEnd(25)} ${owners.join(' ')}`;
356216
+ }
356223
356217
  return message;
356224
356218
  }
356225
356219
  function resolveCodeownersRef(ref, org) {
@@ -371115,6 +371109,7 @@ function processHandler(processToHandle, ctl, onTimedOut) {
371115
371109
 
371116
371110
 
371117
371111
 
371112
+ const TOFU_LOCK_TIMEOUT = '-lock-timeout=60s';
371118
371113
  async function utils_validate(path, secrets) {
371119
371114
  return await tfExec(path, ['validate'], secrets);
371120
371115
  }
@@ -371135,7 +371130,7 @@ async function plan(path, secrets, format, args = ['plan'], stream, ctl) {
371135
371130
  }
371136
371131
  async function apply(path, secrets, stream, ctl) {
371137
371132
  terraform_provisioner_src_logger.debug(`Running terraform apply in path ${path}`);
371138
- return await tfExec(path, ['apply', '-auto-approve'], secrets, ['-input=false'], stream, ctl);
371133
+ return await tfExec(path, ['apply', '-auto-approve', TOFU_LOCK_TIMEOUT], secrets, ['-input=false'], stream, ctl);
371139
371134
  }
371140
371135
  async function customCommand(path, secrets, args, stream) {
371141
371136
  terraform_provisioner_src_logger.debug(`Running terraform customCommand in path ${path} ${args.join(',')}`);
@@ -371143,7 +371138,7 @@ async function customCommand(path, secrets, args, stream) {
371143
371138
  }
371144
371139
  async function destroy(path, secrets, stream, ctl) {
371145
371140
  terraform_provisioner_src_logger.debug(`Running terraform destroy in path ${path}`);
371146
- return await tfExec(path, ['destroy', '-auto-approve'], secrets, ['-input=false'], stream, ctl);
371141
+ return await tfExec(path, ['destroy', '-auto-approve', TOFU_LOCK_TIMEOUT], secrets, ['-input=false'], stream, ctl);
371147
371142
  }
371148
371143
  async function output(path, secrets) {
371149
371144
  terraform_provisioner_src_logger.debug(`Running terraform output in path ${path}`);
@@ -375297,47 +375292,23 @@ async function endDebug(entity) {
375297
375292
 
375298
375293
 
375299
375294
  const tp_bridge_TF_PROJECTS_PATH = '/tmp/gh-workspaces';
375300
- const STATE_LOCK_RETRY_ATTEMPTS = 3;
375301
- const STATE_LOCK_RETRY_DELAY_MS = 5000;
375302
- function isStateLockError(error) {
375303
- const message = String(error);
375304
- return (message.includes('Error acquiring the state lock') ||
375305
- message.includes('already locked by another tofu client'));
375306
- }
375307
- async function tp_bridge_sleep(ms) {
375308
- await new Promise((resolve) => setTimeout(resolve, ms));
375309
- }
375310
- async function runTerraformProvisionerWithLockRetry(entity, command, streaming, customArgs, ctl) {
375311
- for (let attempt = 1;; attempt++) {
375312
- try {
375313
- return await runTerraformProvisioner(tp_bridge_buildContext(entity), command, streaming, customArgs, ctl);
375314
- }
375315
- catch (error) {
375316
- if (!isStateLockError(error) || attempt >= STATE_LOCK_RETRY_ATTEMPTS) {
375317
- throw error;
375318
- }
375319
- gh_provisioner_src_logger.warn(`State lock detected for ${entity.k8sId} while running '${command}'. Retrying in ${STATE_LOCK_RETRY_DELAY_MS}ms (attempt ${attempt + 1}/${STATE_LOCK_RETRY_ATTEMPTS}).`);
375320
- await tp_bridge_sleep(STATE_LOCK_RETRY_DELAY_MS);
375321
- }
375322
- }
375323
- }
375324
375295
  async function runOnTerraform(entity, command, customArgs, opts = {}) {
375325
375296
  gh_provisioner_src_logger.info(`Running on terraform entity '${entity.k8sId}' with command '${command}' customArgs = ${customArgs ? customArgs.join(',') : 'null'} `);
375326
375297
  const streaming = entity.streamTFProvisioner;
375327
375298
  if (command === 'import-with-reimport') {
375328
375299
  // we nuke the tf state
375329
- await runTerraformProvisionerWithLockRetry(entity, 'destroy-state-only', streaming, customArgs, opts.ctl);
375300
+ await runTerraformProvisioner(tp_bridge_buildContext(entity), 'destroy-state-only', streaming, customArgs, opts.ctl);
375330
375301
  // we get the elements we need to import
375331
375302
  await entity.loadAddressesToImport();
375332
- return await runTerraformProvisionerWithLockRetry(entity, 'custom-import', streaming, entity.importDocument, opts.ctl);
375303
+ return await runTerraformProvisioner(tp_bridge_buildContext(entity), 'custom-import', streaming, entity.importDocument, opts.ctl);
375333
375304
  }
375334
375305
  else if (command === 'import') {
375335
375306
  // we get the elements we need to import
375336
375307
  await entity.loadAddressesToImport();
375337
- return await runTerraformProvisionerWithLockRetry(entity, 'custom-import', streaming, entity.importDocument, opts.ctl);
375308
+ return await runTerraformProvisioner(tp_bridge_buildContext(entity), 'custom-import', streaming, entity.importDocument, opts.ctl);
375338
375309
  }
375339
375310
  else {
375340
- return await runTerraformProvisionerWithLockRetry(entity, command, streaming, customArgs, opts.ctl);
375311
+ return await runTerraformProvisioner(tp_bridge_buildContext(entity), command, streaming, customArgs, opts.ctl);
375341
375312
  }
375342
375313
  }
375343
375314
  function tp_bridge_buildContext(entity) {
@@ -379486,9 +379457,9 @@ const crs_analyzerSubcommand = {
379486
379457
  };
379487
379458
 
379488
379459
  ;// CONCATENATED MODULE: ./package.json
379489
- const package_namespaceObject = JSON.parse('{"i8":"2.1.0-snapshot-1"}');
379460
+ const package_namespaceObject = {"i8":"2.1.0"};
379490
379461
  ;// CONCATENATED MODULE: ../../package.json
379491
- const package_namespaceObject_1 = {"i8":"2.0.0"};
379462
+ const package_namespaceObject_1 = {"i8":"2.1.0"};
379492
379463
  ;// CONCATENATED MODULE: ./src/subcommands/index.ts
379493
379464
 
379494
379465
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firestartr/cli",
3
- "version": "2.1.0-snapshot-1",
3
+ "version": "2.1.0",
4
4
  "private": false,
5
5
  "description": "Commandline tool",
6
6
  "main": "build/main.js",