@firestartr/cli 1.47.0 → 1.48.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 (26) hide show
  1. package/build/index.js +1297 -766
  2. package/build/packages/catalog_common/index.d.ts +8 -0
  3. package/build/packages/catalog_common/src/io/write.d.ts +2 -2
  4. package/build/packages/catalog_common/src/logger/index.d.ts +2 -0
  5. package/build/packages/catalog_common/src/logger/logger.d.ts +9 -0
  6. package/build/packages/catalog_common/src/logger/utils.d.ts +1 -0
  7. package/build/packages/features_preparer/src/logger.d.ts +9 -0
  8. package/build/packages/features_renderer/index.d.ts +10 -1
  9. package/build/packages/features_renderer/src/auxiliar.d.ts +71 -0
  10. package/build/packages/features_renderer/src/render.d.ts +2 -0
  11. package/build/packages/github/index.d.ts +5 -0
  12. package/build/packages/github/src/check_run.d.ts +83 -0
  13. package/build/packages/github/src/logger.d.ts +9 -0
  14. package/build/packages/operator/src/logger.d.ts +2 -2
  15. package/build/packages/operator/src/user-feedback-ops/gh-checkrun.d.ts +5 -0
  16. package/build/packages/operator/src/user-feedback-ops/tf-checkrun.d.ts +5 -0
  17. package/build/packages/provisioner/src/cdktf.d.ts +3 -1
  18. package/build/packages/provisioner/src/logger.d.ts +9 -0
  19. package/build/packages/provisioner/src/resources/resource.d.ts +10 -0
  20. package/build/packages/provisioner/src/terraform.d.ts +7 -5
  21. package/build/packages/terraform_provisioner/index.d.ts +1 -1
  22. package/build/packages/terraform_provisioner/src/logger.d.ts +9 -0
  23. package/build/packages/terraform_provisioner/src/project_tf.d.ts +4 -0
  24. package/build/packages/terraform_provisioner/src/project_tf_remote.d.ts +4 -0
  25. package/build/packages/terraform_provisioner/src/utils.d.ts +8 -6
  26. package/package.json +1 -1
package/build/index.js CHANGED
@@ -288941,14 +288941,131 @@ var external_path_ = __nccwpck_require__(71017);
288941
288941
  var external_path_default = /*#__PURE__*/__nccwpck_require__.n(external_path_);
288942
288942
  // EXTERNAL MODULE: ../../node_modules/yaml/dist/index.js
288943
288943
  var yaml_dist = __nccwpck_require__(8447);
288944
- // EXTERNAL MODULE: ../../node_modules/debug/src/index.js
288945
- var src = __nccwpck_require__(67984);
288946
- var src_default = /*#__PURE__*/__nccwpck_require__.n(src);
288944
+ // EXTERNAL MODULE: ../../node_modules/winston/lib/winston.js
288945
+ var winston = __nccwpck_require__(66752);
288946
+ var winston_default = /*#__PURE__*/__nccwpck_require__.n(winston);
288947
+ ;// CONCATENATED MODULE: ../catalog_common/src/logger/utils.ts
288948
+ // https://siderite.dev/blog/jsonstringify-with-circular-references.html/#at2011170946
288949
+ function fixCircularReferences(o) {
288950
+ const weirdTypes = [
288951
+ Int8Array,
288952
+ Uint8Array,
288953
+ Uint8ClampedArray,
288954
+ Int16Array,
288955
+ Uint16Array,
288956
+ Int32Array,
288957
+ Uint32Array,
288958
+ BigInt64Array,
288959
+ BigUint64Array,
288960
+ Float32Array,
288961
+ Float64Array,
288962
+ ArrayBuffer,
288963
+ SharedArrayBuffer,
288964
+ DataView,
288965
+ ];
288966
+ const defs = new Map();
288967
+ return (k, v) => {
288968
+ if (k && v === o) {
288969
+ return `[${String(k)} is the same as original object]`;
288970
+ }
288971
+ if (v === undefined || v === null) {
288972
+ return v;
288973
+ }
288974
+ // Check for the Timeout constructor. This will also catch TimersList indirectly
288975
+ // since TimersList is part of the circular structure *of* a Timeout object.
288976
+ if (v && v.constructor && v.constructor.name === 'Timeout') {
288977
+ return '[Node.js internal timer object]';
288978
+ }
288979
+ // An alternative check could be `v instanceof Timeout` but the constructor name
288980
+ // check is more reliable for these internal types.
288981
+ const weirdType = weirdTypes.find((t) => v instanceof t);
288982
+ if (weirdType) {
288983
+ return weirdType.toString();
288984
+ }
288985
+ if (typeof v === 'function') {
288986
+ return v.toString();
288987
+ }
288988
+ if (v && typeof v === 'object') {
288989
+ const def = defs.get(v);
288990
+ if (def) {
288991
+ return `[${String(k)} is the same as ${def}]`;
288992
+ }
288993
+ defs.set(v, String(k));
288994
+ }
288995
+ return v;
288996
+ };
288997
+ }
288998
+
288999
+ ;// CONCATENATED MODULE: ../catalog_common/src/logger/logger.ts
289000
+
289001
+
289002
+ const validLogLevels = [
289003
+ 'error',
289004
+ 'warn',
289005
+ 'info',
289006
+ 'debug',
289007
+ 'verbose',
289008
+ 'silly',
289009
+ ];
289010
+ let initiated = false;
289011
+ let logger = null;
289012
+ // Type guard to check if a value is a valid LogLevel
289013
+ function isValidLogLevel(level) {
289014
+ return (typeof level === 'string' && validLogLevels.includes(level));
289015
+ }
289016
+ function initLogger() {
289017
+ if (initiated)
289018
+ return;
289019
+ const logLevel = process.env.LOG_LEVEL && isValidLogLevel(process.env.LOG_LEVEL)
289020
+ ? process.env.LOG_LEVEL
289021
+ : 'info';
289022
+ logger = winston_default().createLogger({
289023
+ level: logLevel,
289024
+ exitOnError: false,
289025
+ format: winston.format.combine(winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }), winston.format.json()),
289026
+ transports: [
289027
+ new winston.transports.Console({
289028
+ level: logLevel,
289029
+ }),
289030
+ ],
289031
+ });
289032
+ initiated = true;
289033
+ }
289034
+ function doLog(level, args) {
289035
+ initLogger();
289036
+ const [message, data] = args;
289037
+ let finalMessage = message;
289038
+ if (data) {
289039
+ const fx = fixCircularReferences(data.metadata);
289040
+ try {
289041
+ finalMessage =
289042
+ finalMessage + ' | ' + JSON.stringify(data?.metadata, fx, 2);
289043
+ }
289044
+ catch (err) {
289045
+ console.error(`Serializing ${message}: ${err}`);
289046
+ return;
289047
+ }
289048
+ }
289049
+ logger[level].apply(logger, [finalMessage]);
289050
+ }
289051
+ const logger_log = {
289052
+ error: (...args) => doLog('error', args),
289053
+ warn: (...args) => doLog('warn', args),
289054
+ info: (...args) => doLog('info', args),
289055
+ debug: (...args) => doLog('debug', args),
289056
+ verbose: (...args) => doLog('verbose', args),
289057
+ silly: (...args) => doLog('silly', args),
289058
+ };
289059
+ /* harmony default export */ const logger_logger = (logger_log);
289060
+
289061
+ ;// CONCATENATED MODULE: ../catalog_common/src/logger/index.ts
289062
+
289063
+ /* harmony default export */ const src_logger = (logger_logger);
289064
+
288947
289065
  ;// CONCATENATED MODULE: ../catalog_common/src/io/common.ts
288948
289066
 
288949
289067
 
288950
289068
 
288951
- const messageLog = src_default()('firestartr:catalog_common:io:common');
288952
289069
  const ComponentPaths = (/* unused pure expression or super */ null && ([
288953
289070
  'apiVersion',
288954
289071
  'kind',
@@ -289033,25 +289150,25 @@ function transformKind(kind) {
289033
289150
  }
289034
289151
  }
289035
289152
  function getPath(kind, name, catalogPath) {
289036
- messageLog(`Getting path for kind ${kind} and name ${name} in catalog path ${catalogPath}`);
289153
+ src_logger.debug(`Getting path for kind ${kind} and name ${name} in catalog path ${catalogPath}`);
289037
289154
  return external_path_.join(catalogPath, transformKind(kind), name + '.yaml');
289038
289155
  }
289039
289156
  function getKindPath(kind, catalogPath) {
289040
- messageLog(`Getting path for kind ${kind} in catalog path ${catalogPath}`);
289157
+ src_logger.debug(`Getting path for kind ${kind} in catalog path ${catalogPath}`);
289041
289158
  return external_path_.join(catalogPath, transformKind(kind));
289042
289159
  }
289043
289160
  function fromYaml(data) {
289044
289161
  const result = yaml_dist.parse(data);
289045
- messageLog('Loading YAML data: %O', result);
289162
+ src_logger.debug('Loading YAML data: %O', result);
289046
289163
  return result;
289047
289164
  }
289048
289165
  function toYaml(data, opts = {}) {
289049
- messageLog('opts', opts);
289166
+ src_logger.debug('opts', opts);
289050
289167
  const result = yaml_dist.stringify(data);
289051
289168
  return result;
289052
289169
  }
289053
289170
  function dumpYaml(data) {
289054
- messageLog('Dumping object data to YAML %O', data);
289171
+ src_logger.debug('Dumping object data to YAML %O', data);
289055
289172
  return yaml_dist.stringify(data);
289056
289173
  }
289057
289174
 
@@ -289059,7 +289176,6 @@ function dumpYaml(data) {
289059
289176
  var external_child_process_ = __nccwpck_require__(32081);
289060
289177
  ;// CONCATENATED MODULE: ../catalog_common/src/generic/random.ts
289061
289178
 
289062
- const random_messageLog = src_default()('firestartr:catalog_common:generic:random');
289063
289179
  function randomString(length = 10) {
289064
289180
  let result = '';
289065
289181
  const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
@@ -289069,7 +289185,7 @@ function randomString(length = 10) {
289069
289185
  result += characters.charAt(Math.floor(Math.random() * charactersLength));
289070
289186
  counter += 1;
289071
289187
  }
289072
- random_messageLog('Generated random string %s', result);
289188
+ src_logger.debug(`Generated random string ${result}`);
289073
289189
  return result;
289074
289190
  }
289075
289191
  function shuffleArray(array) {
@@ -289104,17 +289220,16 @@ function shuffleObject(obj, shuffleArrays = false) {
289104
289220
 
289105
289221
 
289106
289222
 
289107
- const clone_catalog_messageLog = src_default()('firestartr:catalog_common:io:clone_catalog');
289108
289223
  function cloneCatalog(catalogPath, dest = _calculateRandomDestination()) {
289109
- clone_catalog_messageLog(`Cloning catalog from ${catalogPath} to ${dest}`);
289224
+ src_logger.info(`Cloning catalog from ${catalogPath} to ${dest}`);
289110
289225
  return new Promise((ok, ko) => {
289111
289226
  (0,external_child_process_.exec)(`cp -a ${catalogPath} ${dest}`, (error, _stdout, _stderr) => {
289112
289227
  if (error) {
289113
- clone_catalog_messageLog(`Error cloning catalog: ${error.message}`);
289228
+ src_logger.error(`Error cloning catalog: ${error.message}`);
289114
289229
  return ko(error.message);
289115
289230
  }
289116
289231
  else {
289117
- clone_catalog_messageLog(`Catalog cloned to successfully to ${dest}`);
289232
+ src_logger.info(`Catalog cloned to successfully to ${dest}`);
289118
289233
  return ok(dest);
289119
289234
  }
289120
289235
  });
@@ -289133,29 +289248,28 @@ var external_fs_default = /*#__PURE__*/__nccwpck_require__.n(external_fs_);
289133
289248
 
289134
289249
 
289135
289250
 
289136
- const write_messageLog = src_default()('firestartr:catalog_common:io:write');
289137
289251
  function writeEntity(entity, path) {
289138
289252
  try {
289139
289253
  entity['metadata']['annotations']['fire-starter.dev/timestamp'] =
289140
289254
  Math.floor(Date.now() / 1000).toString();
289141
289255
  //If we have an status, we remove it
289142
- write_messageLog(`Writing to catalog ${path} entity %O`, entity);
289256
+ src_logger.debug(`Writing to catalog ${path} entity ${entity}`);
289143
289257
  external_fs_.writeFileSync(getPath(entity['kind'], entity['metadata']['name'], path), dumpYaml(entity));
289144
289258
  }
289145
289259
  catch (err) {
289146
- write_messageLog('Error writing entity, error %O', err);
289260
+ src_logger.error(`Error writing entity '${entity.kind}', error ${err}`);
289147
289261
  throw `writeEntity: ${entity.kind} ${err}`;
289148
289262
  }
289149
289263
  }
289150
289264
  function writeClaim(claim, claimsPath) {
289151
289265
  try {
289152
289266
  const kindFolder = `${claim['kind']}s`.toLowerCase().replace('claim', '');
289153
- write_messageLog(`Writing to gitops ${claimsPath}/${kindFolder} claim %O`, claim);
289267
+ src_logger.debug(`Writing to gitops ${claimsPath}/${kindFolder} claim ${claim}`);
289154
289268
  external_fs_.mkdirSync(external_path_.join(claimsPath, kindFolder), { recursive: true });
289155
289269
  external_fs_.writeFileSync(getPathClaim(claim['kind'], claim['name'], claimsPath), dumpYaml(claim));
289156
289270
  }
289157
289271
  catch (err) {
289158
- write_messageLog('Error writing claim, error %O', err);
289272
+ src_logger.error(`Error writing claim, error ${err}`);
289159
289273
  throw `writeClaim: ${claim.kind} ${err}`;
289160
289274
  }
289161
289275
  }
@@ -289172,7 +289286,7 @@ function writeYamlFile(fileName, data, pathFile = '/tmp') {
289172
289286
  external_fs_.writeFileSync(external_path_.join(pathFile, fileName), dumpYaml(data));
289173
289287
  }
289174
289288
  catch (err) {
289175
- write_messageLog('Error writing yaml file, error %O', err);
289289
+ src_logger.error(`Error writing yaml file, error ${err}`);
289176
289290
  throw `writeYamlFile: ${fileName} ${err}`;
289177
289291
  }
289178
289292
  }
@@ -289181,23 +289295,23 @@ function getPathClaim(kind, name, claimsPath) {
289181
289295
  }
289182
289296
  function renameEntity(entity, catalogPath, oldname) {
289183
289297
  try {
289184
- write_messageLog('Renaming oldname %s in %O', oldname, entity);
289298
+ src_logger.debug(`Renaming oldname ${oldname} in ${entity}`);
289185
289299
  const oldPath = getPath(entity.kind, oldname, catalogPath);
289186
289300
  const newPath = getPath(entity.kind, entity.metadata.name, catalogPath);
289187
289301
  external_fs_.renameSync(oldPath, newPath);
289188
289302
  }
289189
289303
  catch (err) {
289190
- write_messageLog('Error writing entity, error %O', err);
289304
+ src_logger.error(`Error writing entity, error ${err}`);
289191
289305
  throw `renameEntity: ${entity.kind} ${err}`;
289192
289306
  }
289193
289307
  }
289194
289308
  function removeEntity(entity, catalogPath) {
289195
289309
  try {
289196
- write_messageLog(`Removing entity ${entity.kind}/${entity.metadata.name} in catalog ${catalogPath}`);
289310
+ src_logger.debug(`Removing entity ${entity.kind}/${entity.metadata.name} in catalog ${catalogPath}`);
289197
289311
  external_fs_.rmSync(getPath(entity.kind, entity.metadata.name, catalogPath));
289198
289312
  }
289199
289313
  catch (err) {
289200
- write_messageLog(`Error removing entity ${entity.kind}/${entity.metadata.name} in catalog ${catalogPath}: ${err}`);
289314
+ src_logger.error(`Error removing entity ${entity.kind}/${entity.metadata.name} in catalog ${catalogPath}: ${err}`);
289201
289315
  throw `removeEntity: ${entity.kind} ${err}`;
289202
289316
  }
289203
289317
  }
@@ -289213,21 +289327,21 @@ function moveFile(oldPath, newPath) {
289213
289327
  external_fs_.cpSync(oldPath, newPath);
289214
289328
  external_fs_.rmSync(oldPath);
289215
289329
  }
289216
- function writeFunctionLog(functionName, log) {
289330
+ function writeFunctionLog(functionName, logStream) {
289217
289331
  try {
289218
- external_fs_.writeFileSync(external_path_.join('/tmp', `${functionName}.${randomString(5)}.log`), log + '\n');
289332
+ external_fs_.writeFileSync(external_path_.join('/tmp', `${functionName}.${randomString(5)}.log`), logStream + '\n');
289219
289333
  }
289220
289334
  catch (err) {
289221
- write_messageLog('Error writing log, error %O', err);
289335
+ src_logger.error(`Error writing log, error ${err}`);
289222
289336
  throw `writeLog: ${functionName} ${err}`;
289223
289337
  }
289224
289338
  }
289225
- function writeLogFile(fileName, log) {
289339
+ function writeLogFile(fileName, logStream) {
289226
289340
  try {
289227
- external_fs_.appendFileSync(external_path_.join('/tmp', fileName + '.log'), log + '\n');
289341
+ external_fs_.appendFileSync(external_path_.join('/tmp', fileName + '.log'), logStream + '\n');
289228
289342
  }
289229
289343
  catch (err) {
289230
- write_messageLog('Error writing log, error %O', err);
289344
+ src_logger.error(`Error writing log, error ${err}`);
289231
289345
  throw `writeLog: ${fileName} ${err}`;
289232
289346
  }
289233
289347
  }
@@ -289237,7 +289351,6 @@ function writeLogFile(fileName, log) {
289237
289351
 
289238
289352
 
289239
289353
 
289240
- const read_messageLog = src_default()('firestartr:catalog_common:io:read');
289241
289354
  function readEntity(kind, name, catalogPaths) {
289242
289355
  try {
289243
289356
  if (typeof catalogPaths === 'string') {
@@ -289246,7 +289359,7 @@ function readEntity(kind, name, catalogPaths) {
289246
289359
  let data = false;
289247
289360
  for (const catalogPath of catalogPaths) {
289248
289361
  try {
289249
- read_messageLog(`Reading entity ${kind}/${name} from catalog ${catalogPath}`);
289362
+ src_logger.debug(`Reading entity ${kind}/${name} from catalog ${catalogPath}`);
289250
289363
  const entityPath = getPath(kind, name, catalogPath);
289251
289364
  if (external_fs_.existsSync(entityPath)) {
289252
289365
  if (data) {
@@ -289256,7 +289369,7 @@ function readEntity(kind, name, catalogPaths) {
289256
289369
  }
289257
289370
  }
289258
289371
  catch (err) {
289259
- read_messageLog('readEntity: cached error %s', err);
289372
+ src_logger.debug('readEntity: cached error %s', err);
289260
289373
  if (err === 'DUPLICATED') {
289261
289374
  throw `Error reading entity: Duplicated ${kind}/${name} in ${catalogPaths.join(', ')}`;
289262
289375
  }
@@ -289268,7 +289381,7 @@ function readEntity(kind, name, catalogPaths) {
289268
289381
  return fromYaml(data);
289269
289382
  }
289270
289383
  catch (err) {
289271
- read_messageLog(err);
289384
+ src_logger.error(err);
289272
289385
  throw `readEntity->: ${kind}/${name}: ${err}`;
289273
289386
  }
289274
289387
  }
@@ -289276,13 +289389,13 @@ function listByKind(kind, catalogPaths, callback, exclude = []) {
289276
289389
  if (typeof catalogPaths === 'string') {
289277
289390
  catalogPaths = [catalogPaths];
289278
289391
  }
289279
- read_messageLog('CATALOGS_PATHS_ %O', catalogPaths);
289392
+ src_logger.debug(`CATALOGS_PATHS_ ${catalogPaths}`);
289280
289393
  const list = [];
289281
289394
  catalogPaths.forEach((catalogPath) => {
289282
289395
  list.push(...external_fs_.readdirSync(getKindPath(kind, catalogPath)));
289283
289396
  });
289284
- read_messageLog('LIST_ %O', list);
289285
- read_messageLog(`Listing entities of kind ${kind} from catalogs`);
289397
+ src_logger.debug(`LIST_ ${list}`);
289398
+ src_logger.debug(`Listing entities of kind ${kind} from catalogs`);
289286
289399
  return list
289287
289400
  .filter((file) => file.match(/\.yaml$/))
289288
289401
  .filter((file) => exclude.indexOf(file.replace(/\.yaml/, '')) === -1)
@@ -290213,6 +290326,9 @@ class CsvWriter {
290213
290326
  }
290214
290327
  /* harmony default export */ const csv_generator = (CsvWriter);
290215
290328
 
290329
+ // EXTERNAL MODULE: ../../node_modules/debug/src/index.js
290330
+ var src = __nccwpck_require__(67984);
290331
+ var src_default = /*#__PURE__*/__nccwpck_require__.n(src);
290216
290332
  ;// CONCATENATED MODULE: ../catalog_common/src/generic/logger.ts
290217
290333
 
290218
290334
 
@@ -290275,9 +290391,8 @@ var lodash_default = /*#__PURE__*/__nccwpck_require__.n(lodash);
290275
290391
 
290276
290392
 
290277
290393
  const { camelCase } = (lodash_default());
290278
- const name_log = src_default()('firestartr:catalog_common:generic:name');
290279
290394
  function normalizeName(name) {
290280
- name_log('Normalizing name %s', name);
290395
+ src_logger.debug(`Normalizing name ${name}`);
290281
290396
  return name.replace(/[^a-z0-9]/gi, '-').toLowerCase();
290282
290397
  }
290283
290398
  function transformKeysToCamelCase(obj) {
@@ -290618,7 +290733,6 @@ const ExternalSecretsApiGroup = 'external-secrets.io';
290618
290733
 
290619
290734
  ;// CONCATENATED MODULE: ../catalog_common/src/environment/index.ts
290620
290735
 
290621
- const environment_messageLog = src_default()('firestartr:catalog_common:environment');
290622
290736
  function getFromEnvironment(envVar) {
290623
290737
  return process.env[envVar];
290624
290738
  }
@@ -290636,7 +290750,7 @@ function getFromEnvironmentAsBoolean(envVar) {
290636
290750
  }
290637
290751
  function checkExistOnEnvironment(envVar) {
290638
290752
  const environmentValue = getFromEnvironment(envVar);
290639
- environment_messageLog(`Checking if environment variable ${envVar} exists: ${environmentValue}`);
290753
+ src_logger.debug(`Checking if environment variable ${envVar} exists: ${environmentValue}`);
290640
290754
  if (!environmentValue || environmentValue === '') {
290641
290755
  return false;
290642
290756
  }
@@ -290682,30 +290796,29 @@ const fullMembersTeam = getFromEnvironmentWithDefault(envVars.fullOrgGroup, `${o
290682
290796
  ;// CONCATENATED MODULE: ../catalog_common/src/features/tarballs.ts
290683
290797
 
290684
290798
 
290685
- const tarballs_messageLog = src_default()('firestartr:catalog_common:features:tarballs');
290686
290799
  function getFeatureZipDownloadPath(featureName, version, owner, repo) {
290687
290800
  const featureDownloadPath = `/tmp/${basicFeaturePath(featureName, version, owner, repo)}-zipball.zip`;
290688
- tarballs_messageLog('Feature tarball download path %s', featureDownloadPath);
290801
+ src_logger.debug(`Feature tarball download path ${featureDownloadPath}`);
290689
290802
  return featureDownloadPath;
290690
290803
  }
290691
290804
  function removeFeatureTarball(featureName, version, owner, repo) {
290692
290805
  const featurePath = getFeatureZipDownloadPath(featureName, version, owner, repo);
290693
- tarballs_messageLog('Removing feature tarball %s', featurePath);
290806
+ src_logger.debug(`Removing feature tarball ${featurePath}`);
290694
290807
  external_fs_.unlinkSync(featurePath);
290695
- tarballs_messageLog(`Removed tarball for feature ${featureName} and version ${version}: ${featurePath}`);
290808
+ src_logger.debug(`Removed tarball for feature ${featureName} and version ${version}: ${featurePath}`);
290696
290809
  }
290697
290810
  function featureTarballExists(featureName, version, owner, repo) {
290698
290811
  const featurePath = getFeatureZipDownloadPath(featureName, version, owner, repo);
290699
290812
  const exists = external_fs_.existsSync(featurePath);
290700
- tarballs_messageLog(`Tarball ${featurePath} exists? ${exists}`);
290813
+ src_logger.debug(`Tarball ${featurePath} exists? ${exists}`);
290701
290814
  return exists;
290702
290815
  }
290703
290816
  function getFeaturesExtractPath(featureName, version, owner, repo, options = {}) {
290704
290817
  const { createIfNotExists } = options;
290705
290818
  const extractPath = `/tmp/${basicFeaturePath(featureName, version, owner, repo)}-extract`;
290706
- tarballs_messageLog('Extract path %s', extractPath);
290819
+ src_logger.debug(`Extract path ${extractPath}`);
290707
290820
  if (createIfNotExists && !external_fs_.existsSync(extractPath)) {
290708
- tarballs_messageLog('Extract path %s does not exist, creating', extractPath);
290821
+ src_logger.debug(`Extract path ${extractPath} does not exist, creating`);
290709
290822
  external_fs_.mkdirSync(extractPath, { recursive: true });
290710
290823
  }
290711
290824
  return extractPath;
@@ -290722,17 +290835,16 @@ function trasformLeg(leg) {
290722
290835
 
290723
290836
 
290724
290837
 
290725
- const features_io_messageLog = src_default()('firestartr:catalog_common:features:features_io');
290726
290838
  function getFeatureRenderedPathForEntity(entity, featureName, basePath = '/tmp') {
290727
290839
  const entityFolderName = `${entity.metadata.name}`.toLowerCase();
290728
290840
  return external_path_default().join(basePath, entityFolderName, featureName);
290729
290841
  }
290730
290842
  function getFeatureRenderedConfigForComponent(entity, featureName, basePath = '/tmp/features') {
290731
- features_io_messageLog('Getting rendered config for component %s and feature %s', entity.name, featureName);
290843
+ src_logger.info(`Getting rendered config for component ${entity.name}and feature ${featureName}`);
290732
290844
  const workdir = getFeatureRenderedPathForEntity(entity, featureName, basePath);
290733
290845
  const config = JSON.parse(external_fs_.readFileSync(`${workdir}/output.json`, { encoding: 'utf8' }));
290734
- features_io_messageLog('Feature output: %O', config);
290735
- features_io_messageLog(`Rendered feature ${featureName} for component ${entity.name}. Result: ${(JSON.stringify, config)}`);
290846
+ src_logger.debug(`Feature output: ${config}`);
290847
+ src_logger.debug(`Rendered feature ${featureName} for component ${entity.name}. Result: ${(JSON.stringify, config)}`);
290736
290848
  return config;
290737
290849
  }
290738
290850
 
@@ -290746,7 +290858,6 @@ function getFeatureRenderedConfigForComponent(entity, featureName, basePath = '/
290746
290858
 
290747
290859
  ;// CONCATENATED MODULE: ../catalog_common/src/policies/policies.ts
290748
290860
 
290749
- const policies_log = src_default()('firestartr:catalog_common:policies');
290750
290861
  const FIRESTARTR_POLICIES = [
290751
290862
  {
290752
290863
  name: 'full-control',
@@ -290785,17 +290896,17 @@ function getPolicyByName(policyName) {
290785
290896
  return FIRESTARTR_POLICIES.find((p) => p.name === policyName || p.aliases.includes(policyName));
290786
290897
  }
290787
290898
  function policiesAreCompatible(syncPolicy, generalPolicy) {
290788
- policies_log('Validating policy compatibility: %s %s', syncPolicy, generalPolicy);
290899
+ src_logger.debug('Validating policy compatibility: %s %s', syncPolicy, generalPolicy);
290789
290900
  const syncPolicyWeight = getPolicyByName(syncPolicy)?.weight;
290790
290901
  const generalPolicyWeight = getPolicyByName(generalPolicy)?.weight;
290791
290902
  if (!syncPolicyWeight || !generalPolicyWeight) {
290792
290903
  throw new Error(`Policy ${syncPolicy} or ${generalPolicy} not found`);
290793
290904
  }
290794
290905
  if (generalPolicyWeight >= syncPolicyWeight) {
290795
- policies_log('Policies %s %s are compatible', syncPolicy, generalPolicy);
290906
+ src_logger.debug('Policies %s %s are compatible', syncPolicy, generalPolicy);
290796
290907
  return true;
290797
290908
  }
290798
- policies_log('Policies %s %s are not compatible', syncPolicy, generalPolicy);
290909
+ src_logger.debug('Policies %s %s are not compatible', syncPolicy, generalPolicy);
290799
290910
  return false;
290800
290911
  }
290801
290912
 
@@ -290815,6 +290926,7 @@ function policiesAreCompatible(syncPolicy, generalPolicy) {
290815
290926
 
290816
290927
 
290817
290928
 
290929
+
290818
290930
  /* harmony default export */ const catalog_common = ({
290819
290931
  io: io,
290820
290932
  generic: generic,
@@ -290823,6 +290935,7 @@ function policiesAreCompatible(syncPolicy, generalPolicy) {
290823
290935
  defaults: defaults,
290824
290936
  features: features,
290825
290937
  policies: policies,
290938
+ logger: logger_logger,
290826
290939
  });
290827
290940
 
290828
290941
  ;// CONCATENATED MODULE: ../../node_modules/universal-user-agent/index.js
@@ -297369,13 +297482,16 @@ async function getOctokitFromPat(envVar) {
297369
297482
  }
297370
297483
  /* harmony default export */ const src_auth = ({ getOctokitForOrg });
297371
297484
 
297485
+ ;// CONCATENATED MODULE: ../github/src/logger.ts
297486
+
297487
+ /* harmony default export */ const github_src_logger = (catalog_common.logger);
297488
+
297372
297489
  ;// CONCATENATED MODULE: ../github/src/organization.ts
297373
297490
 
297374
297491
 
297375
- const organization_messageLog = src_default()('firestartr:github:organization');
297376
297492
  const defaultPerPage = 100;
297377
297493
  async function getRepositoryList(org, perPageEntries = defaultPerPage) {
297378
- organization_messageLog(`Getting repository list for ${org} with ${perPageEntries} entries per page`);
297494
+ github_src_logger.info(`Getting repository list for ${org} with ${perPageEntries} entries per page`);
297379
297495
  const octokit = await getOctokitForOrg(org);
297380
297496
  const options = octokit.repos.listForOrg.endpoint.merge({
297381
297497
  org: org,
@@ -297385,7 +297501,7 @@ async function getRepositoryList(org, perPageEntries = defaultPerPage) {
297385
297501
  return await doPaginatedRequest(options);
297386
297502
  }
297387
297503
  async function getTeamList(org, perPageEntries = defaultPerPage) {
297388
- organization_messageLog(`Getting team list for ${org} with ${perPageEntries} entries per page`);
297504
+ github_src_logger.info(`Getting team list for ${org} with ${perPageEntries} entries per page`);
297389
297505
  const octokit = await getOctokitForOrg(org);
297390
297506
  const options = octokit.rest.teams.list.endpoint.merge({
297391
297507
  org: org,
@@ -297394,7 +297510,7 @@ async function getTeamList(org, perPageEntries = defaultPerPage) {
297394
297510
  return await doPaginatedRequest(options);
297395
297511
  }
297396
297512
  async function getUserList(org, perPageEntries = defaultPerPage) {
297397
- organization_messageLog(`Getting user list for ${org} with ${perPageEntries} entries per page`);
297513
+ github_src_logger.info(`Getting user list for ${org} with ${perPageEntries} entries per page`);
297398
297514
  const octokit = await getOctokitForOrg(org);
297399
297515
  const options = await octokit.rest.orgs.listMembers.endpoint.merge({
297400
297516
  org: org,
@@ -297403,7 +297519,7 @@ async function getUserList(org, perPageEntries = defaultPerPage) {
297403
297519
  return await doPaginatedRequest(options);
297404
297520
  }
297405
297521
  async function validateMember(username, org) {
297406
- organization_messageLog(`Validating ${username} is a member of ${org}`);
297522
+ github_src_logger.debug(`Validating ${username} is a member of ${org}`);
297407
297523
  const octokit = await getOctokitForOrg(org);
297408
297524
  const result = await octokit.orgs.checkMembershipForUser({
297409
297525
  org: org,
@@ -297412,7 +297528,7 @@ async function validateMember(username, org) {
297412
297528
  return result;
297413
297529
  }
297414
297530
  async function getUserRoleInOrg(username, org) {
297415
- organization_messageLog(`Getting user ${username} role in ${org}`);
297531
+ github_src_logger.info(`Getting user ${username} role in ${org}`);
297416
297532
  const octokit = await getOctokitForOrg(org);
297417
297533
  const membership = await octokit.orgs.getMembershipForUser({
297418
297534
  org: org,
@@ -297421,13 +297537,13 @@ async function getUserRoleInOrg(username, org) {
297421
297537
  return membership.data.role;
297422
297538
  }
297423
297539
  async function getOrgInfo(org) {
297424
- organization_messageLog(`Getting info for org ${org}`);
297540
+ github_src_logger.info(`Getting info for org ${org}`);
297425
297541
  const octokit = await getOctokitForOrg(org);
297426
297542
  const orgInfo = await octokit.orgs.get({ org });
297427
297543
  return orgInfo.data;
297428
297544
  }
297429
297545
  async function getOrgPlanName(org) {
297430
- organization_messageLog(`Getting plan for org ${org}`);
297546
+ github_src_logger.info(`Getting plan for org ${org}`);
297431
297547
  const orgInfo = await getOrgInfo(org);
297432
297548
  return orgInfo.plan.name;
297433
297549
  }
@@ -297451,9 +297567,8 @@ async function doPaginatedRequest(options) {
297451
297567
 
297452
297568
 
297453
297569
 
297454
- const repository_messageLog = src_default()('firestartr:github:repository');
297455
297570
  async function listReleases(repo, owner = 'prefapp') {
297456
- repository_messageLog(`Getting releases for ${owner}/${repo}`);
297571
+ github_src_logger.info(`Getting releases for ${owner}/${repo}`);
297457
297572
  const octokit = await getOctokitForOrg(owner);
297458
297573
  const response = await octokit.rest.repos.listReleases({
297459
297574
  owner,
@@ -297464,7 +297579,7 @@ async function listReleases(repo, owner = 'prefapp') {
297464
297579
  return response.data;
297465
297580
  }
297466
297581
  async function getReleaseByTag(releaseTag, repo, owner = 'prefapp') {
297467
- repository_messageLog(`Getting release ${releaseTag} for ${owner}/${repo}`);
297582
+ github_src_logger.info(`Getting release ${releaseTag} for ${owner}/${repo}`);
297468
297583
  const octokit = await getOctokitForOrg(owner);
297469
297584
  const response = await octokit.rest.repos.getReleaseByTag({
297470
297585
  owner,
@@ -297479,7 +297594,7 @@ async function getFileFromGithub(path, repo, owner = 'prefapp') {
297479
297594
  return await octokit.rest.repos.getContent({ owner, repo, path });
297480
297595
  }
297481
297596
  async function getContent(path, repo, owner = 'prefapp', ref = '') {
297482
- repository_messageLog(`Getting content for ${owner}/${repo}/${path}`);
297597
+ github_src_logger.info(`Getting content for ${owner}/${repo}/${path}`);
297483
297598
  const octokit = await getOctokitForOrg(owner);
297484
297599
  const opts = {
297485
297600
  owner,
@@ -297493,19 +297608,19 @@ async function getContent(path, repo, owner = 'prefapp', ref = '') {
297493
297608
  return Buffer.from(content.data.content, 'base64').toString('utf8');
297494
297609
  }
297495
297610
  async function getRepoInfo(owner, name) {
297496
- repository_messageLog(`Getting repo info for ${owner}/${name}`);
297611
+ github_src_logger.info(`Getting repo info for ${owner}/${name}`);
297497
297612
  const octokit = await getOctokitForOrg(owner);
297498
297613
  const res = await octokit.repos.get({ owner: owner, repo: name });
297499
297614
  return res['data'];
297500
297615
  }
297501
297616
  async function getPages(owner, name) {
297502
- repository_messageLog(`Getting pages for ${owner}/${name}`);
297617
+ github_src_logger.info(`Getting pages for ${owner}/${name}`);
297503
297618
  const octokit = await getOctokitForOrg(owner);
297504
297619
  const res = await octokit.repos.getPages({ owner: owner, repo: name });
297505
297620
  return res['data'];
297506
297621
  }
297507
297622
  async function getOIDCRepo(owner, name) {
297508
- repository_messageLog(`Getting repo info for ${owner}/${name}`);
297623
+ github_src_logger.info(`Getting repo info for ${owner}/${name}`);
297509
297624
  const octokit = await getOctokitForOrg(owner);
297510
297625
  return await octokit.request(`GET /repos/${owner}/${name}/actions/oidc/customization/sub`, {
297511
297626
  owner: owner,
@@ -297516,7 +297631,7 @@ async function getOIDCRepo(owner, name) {
297516
297631
  });
297517
297632
  }
297518
297633
  async function getBranchProtection(owner, repo, branch = 'main') {
297519
- repository_messageLog(`Getting branch protection for ${owner}/${repo}/${branch}`);
297634
+ github_src_logger.info(`Getting branch protection for ${owner}/${repo}/${branch}`);
297520
297635
  const octokit = await getOctokitForOrg(owner);
297521
297636
  const res = await octokit.repos.getBranchProtection({
297522
297637
  owner: owner,
@@ -297526,13 +297641,13 @@ async function getBranchProtection(owner, repo, branch = 'main') {
297526
297641
  return res['data'];
297527
297642
  }
297528
297643
  async function getTeams(owner, repo) {
297529
- repository_messageLog(`Getting teams for ${owner}/${repo}`);
297644
+ github_src_logger.info(`Getting teams for ${owner}/${repo}`);
297530
297645
  const octokit = await getOctokitForOrg(owner);
297531
297646
  const res = await octokit.repos.listTeams({ owner: owner, repo: repo });
297532
297647
  return res['data'];
297533
297648
  }
297534
297649
  async function getCollaborators(owner, repo, affiliation = 'direct') {
297535
- repository_messageLog(`Getting collaborators for ${owner}/${repo}`);
297650
+ github_src_logger.info(`Getting collaborators for ${owner}/${repo}`);
297536
297651
  const octokit = await getOctokitForOrg(owner);
297537
297652
  const res = await octokit.repos.listCollaborators({
297538
297653
  owner: owner,
@@ -297543,7 +297658,7 @@ async function getCollaborators(owner, repo, affiliation = 'direct') {
297543
297658
  }
297544
297659
  async function setContent(path, fileContent, repo, owner = 'prefapp', branch = 'main', message = '') {
297545
297660
  const base64Content = Buffer.from(fileContent, 'utf8').toString('base64');
297546
- repository_messageLog(`Setting content for ${owner}/${repo}/${path}`);
297661
+ github_src_logger.info(`Setting content for ${owner}/${repo}/${path}`);
297547
297662
  if (message === '') {
297548
297663
  message = `Update ${path}`;
297549
297664
  }
@@ -297551,10 +297666,10 @@ async function setContent(path, fileContent, repo, owner = 'prefapp', branch = '
297551
297666
  try {
297552
297667
  const currentContent = await getFileFromGithub(path, repo, owner);
297553
297668
  sha = currentContent.data.sha;
297554
- repository_messageLog('File already exists, updating it');
297669
+ github_src_logger.debug('File already exists, updating it');
297555
297670
  }
297556
297671
  catch {
297557
- repository_messageLog('File does not exists, creating it');
297672
+ github_src_logger.debug('File does not exist, creating it');
297558
297673
  }
297559
297674
  const octokit = await getOctokitForOrg(owner);
297560
297675
  await octokit.rest.repos.createOrUpdateFileContents({
@@ -297569,7 +297684,7 @@ async function setContent(path, fileContent, repo, owner = 'prefapp', branch = '
297569
297684
  }
297570
297685
  async function uploadFile(destinationPath, filePath, repo, owner = 'prefapp', branch = 'main', message = '') {
297571
297686
  if (!external_fs_.existsSync(filePath)) {
297572
- repository_messageLog(`File ${filePath} does not exists or is not readable`);
297687
+ github_src_logger.error(`File ${filePath} does not exists or is not readable`);
297573
297688
  throw `${filePath} does not exists or is not readable`;
297574
297689
  }
297575
297690
  // Read file contents and call setContent
@@ -297578,16 +297693,16 @@ async function uploadFile(destinationPath, filePath, repo, owner = 'prefapp', br
297578
297693
  }
297579
297694
  async function deleteFile(path, repo, owner = 'prefapp', branch = 'main', message = '') {
297580
297695
  let sha = undefined;
297581
- repository_messageLog(`Deleting file ${owner}/${repo}/${path}`);
297696
+ github_src_logger.info(`Deleting file ${owner}/${repo}/${path}`);
297582
297697
  try {
297583
297698
  const currentContent = await getFileFromGithub(path, repo, owner);
297584
297699
  sha = currentContent.data.sha;
297585
297700
  }
297586
297701
  catch {
297587
- repository_messageLog(`File ${path} does not exist in ${repo}`);
297702
+ github_src_logger.error(`File ${path} does not exist in ${repo}`);
297588
297703
  }
297589
297704
  if (!sha) {
297590
- repository_messageLog(`File ${path} does not exist in ${repo}`);
297705
+ github_src_logger.error(`File ${path} does not exist in ${repo}`);
297591
297706
  throw `File ${path} does not exist in ${repo}`;
297592
297707
  }
297593
297708
  if (message === '') {
@@ -297604,7 +297719,7 @@ async function deleteFile(path, repo, owner = 'prefapp', branch = 'main', messag
297604
297719
  });
297605
297720
  }
297606
297721
  async function addStatusCheck(output, is_failure, head_sha, name, status, repo, owner = 'prefapp') {
297607
- repository_messageLog(`Adding status checks to commit ${head_sha} in ${owner}/${repo}`);
297722
+ github_src_logger.info(`Adding status checks to commit ${head_sha} in ${owner}/${repo}`);
297608
297723
  const octokit = await getOctokitForOrg(owner);
297609
297724
  const payload = { output, head_sha, name, owner, repo, status };
297610
297725
  if (status === 'completed') {
@@ -297613,7 +297728,7 @@ async function addStatusCheck(output, is_failure, head_sha, name, status, repo,
297613
297728
  await octokit.rest.checks.create(payload);
297614
297729
  }
297615
297730
  async function addCommitStatus(state, sha, repo, owner = 'prefapp', target_url = '', description = '', context = '') {
297616
- repository_messageLog(`Adding commit status with state ${state} to SHA ${sha} in ${owner}/${repo}`);
297731
+ github_src_logger.info(`Adding commit status with state ${state} to SHA ${sha} in ${owner}/${repo}`);
297617
297732
  const octokit = await getOctokitForOrg(owner);
297618
297733
  await octokit.rest.repos.createCommitStatus({
297619
297734
  owner,
@@ -297645,9 +297760,8 @@ async function addCommitStatus(state, sha, repo, owner = 'prefapp', target_url =
297645
297760
  ;// CONCATENATED MODULE: ../github/src/team.ts
297646
297761
 
297647
297762
 
297648
- const team_messageLog = src_default()('firestartr:github:team');
297649
297763
  async function getTeamMembers(team, org) {
297650
- team_messageLog(`Getting members for ${org}/${team}`);
297764
+ github_src_logger.info(`Getting members for ${org}/${team}`);
297651
297765
  const octokit = await getOctokitForOrg(org);
297652
297766
  const res = await octokit.rest.teams.listMembersInOrg({
297653
297767
  org: org,
@@ -297656,13 +297770,13 @@ async function getTeamMembers(team, org) {
297656
297770
  return res['data'];
297657
297771
  }
297658
297772
  async function getTeamInfo(team, org) {
297659
- team_messageLog(`Getting info for ${org}/${team}`);
297773
+ github_src_logger.info(`Getting info for ${org}/${team}`);
297660
297774
  const octokit = await getOctokitForOrg(org);
297661
297775
  const res = await octokit.rest.teams.getByName({ org: org, team_slug: team });
297662
297776
  return res['data'];
297663
297777
  }
297664
297778
  async function getTeamRoleUser(org, team, username) {
297665
- team_messageLog(`Getting role for ${username} in ${org}/${team}`);
297779
+ github_src_logger.info(`Getting role for ${username} in ${org}/${team}`);
297666
297780
  const octokit = await getOctokitForOrg(org);
297667
297781
  const res = await octokit.rest.teams.getMembershipForUserInOrg({
297668
297782
  org: org,
@@ -297672,7 +297786,7 @@ async function getTeamRoleUser(org, team, username) {
297672
297786
  return res['data'];
297673
297787
  }
297674
297788
  async function create(org, team, privacy = 'closed') {
297675
- team_messageLog(`Creating team ${org}/${team}`);
297789
+ github_src_logger.info(`Creating team ${org}/${team}`);
297676
297790
  const octokit = await getOctokitForOrg(org);
297677
297791
  return await octokit.rest.teams.create({
297678
297792
  org: org,
@@ -297681,7 +297795,7 @@ async function create(org, team, privacy = 'closed') {
297681
297795
  });
297682
297796
  }
297683
297797
  async function addOrUpdateMember(org, team, username, role = 'member') {
297684
- team_messageLog(`Adding or updating ${username} in ${org}/${team} with role ${role}`);
297798
+ github_src_logger.info(`Adding or updating ${username} in ${org}/${team} with role ${role}`);
297685
297799
  const octokit = await getOctokitForOrg(org);
297686
297800
  return await octokit.rest.teams.addOrUpdateMembershipForUserInOrg({
297687
297801
  org: org,
@@ -297691,7 +297805,7 @@ async function addOrUpdateMember(org, team, username, role = 'member') {
297691
297805
  });
297692
297806
  }
297693
297807
  async function removeMember(org, team, username) {
297694
- team_messageLog(`Removing ${username} from ${org}/${team}`);
297808
+ github_src_logger.info(`Removing ${username} from ${org}/${team}`);
297695
297809
  const octokit = await getOctokitForOrg(org);
297696
297810
  return await octokit.teams.removeMembershipForUserInOrg({
297697
297811
  org: org,
@@ -297711,9 +297825,8 @@ async function removeMember(org, team, username) {
297711
297825
  ;// CONCATENATED MODULE: ../github/src/user.ts
297712
297826
 
297713
297827
 
297714
- const user_messageLog = src_default()('firestartr:github:user');
297715
297828
  async function getUserInfo(name) {
297716
- user_messageLog(`Getting user ${name} info`);
297829
+ github_src_logger.info(`Getting user ${name} info`);
297717
297830
  const octokit = await getOctokitForOrg(name);
297718
297831
  return await octokit.users.getByUsername({ username: name });
297719
297832
  }
@@ -297724,11 +297837,10 @@ async function getUserInfo(name) {
297724
297837
  ;// CONCATENATED MODULE: ../github/src/pull_request.ts
297725
297838
 
297726
297839
 
297727
- const pull_request_messageLog = src_default()('firestartr:github:pull_request');
297728
297840
  const commentMaxSize = 65535;
297729
297841
  async function commentInPR(comment, pr_number, repo, owner = 'prefapp') {
297730
297842
  try {
297731
- pull_request_messageLog(`Commenting ${comment} in PR ${pr_number} of ${owner}/${repo}`);
297843
+ github_src_logger.info(`Commenting ${comment} in PR ${pr_number} of ${owner}/${repo}`);
297732
297844
  const octokit = await getOctokitForOrg(owner);
297733
297845
  await octokit.rest.issues.createComment({
297734
297846
  owner,
@@ -297747,12 +297859,12 @@ async function getPrData(pull_number, repo, owner) {
297747
297859
  return await octokit.rest.pulls.get({ owner, repo, pull_number });
297748
297860
  }
297749
297861
  async function getPrLastCommitSHA(pull_number, repo, owner = 'prefapp') {
297750
- pull_request_messageLog(`Getting last commit SHA for PR ${pull_number} of ${owner}/${repo}`);
297862
+ github_src_logger.info(`Getting last commit SHA for PR ${pull_number} of ${owner}/${repo}`);
297751
297863
  const prData = await getPrData(pull_number, repo, owner);
297752
297864
  return prData.data.head.sha;
297753
297865
  }
297754
297866
  async function getPrMergeCommitSHA(pull_number, repo, owner = 'prefapp') {
297755
- pull_request_messageLog(`Getting merge commit SHA for PR ${pull_number} of ${owner}/${repo}`);
297867
+ github_src_logger.info(`Getting merge commit SHA for PR ${pull_number} of ${owner}/${repo}`);
297756
297868
  const prData = await getPrData(pull_number, repo, owner);
297757
297869
  if (prData.data.merge_commit_sha !== null) {
297758
297870
  return prData.data.merge_commit_sha;
@@ -297790,7 +297902,7 @@ function divideCommentIntoChunks(comment, sizeReduction = 0) {
297790
297902
  return result;
297791
297903
  }
297792
297904
  async function getPrFiles(pr_number, repo, owner = 'prefapp') {
297793
- pull_request_messageLog(`Getting PR details of PR ${pr_number} of ${owner}/${repo}`);
297905
+ github_src_logger.info(`Getting PR details of PR ${pr_number} of ${owner}/${repo}`);
297794
297906
  const octokit = await getOctokitForOrg(owner);
297795
297907
  return await octokit.rest.pulls.listFiles({
297796
297908
  owner,
@@ -297832,9 +297944,8 @@ async function filterPrBy(filter, opts) {
297832
297944
  ;// CONCATENATED MODULE: ../github/src/issues.ts
297833
297945
 
297834
297946
 
297835
- const issues_log = src_default()('firestartr:github:issues');
297836
297947
  async function issues_create(owner, repo, title, body, labels = []) {
297837
- issues_log(`Creating issue in ${owner}/${repo}`);
297948
+ github_src_logger.info(`Creating issue in ${owner}/${repo}`);
297838
297949
  const octokit = await getOctokitForOrg(owner);
297839
297950
  return await octokit.rest.issues.create({
297840
297951
  owner,
@@ -297845,7 +297956,7 @@ async function issues_create(owner, repo, title, body, labels = []) {
297845
297956
  });
297846
297957
  }
297847
297958
  async function update(owner, repo, issue_number, title, body, labels = []) {
297848
- issues_log(`Updating issue ${issue_number} in ${owner}/${repo}`);
297959
+ github_src_logger.info(`Updating issue ${issue_number} in ${owner}/${repo}`);
297849
297960
  const octokit = await getOctokitForOrg(owner);
297850
297961
  return await octokit.rest.issues.update({
297851
297962
  owner,
@@ -297857,7 +297968,7 @@ async function update(owner, repo, issue_number, title, body, labels = []) {
297857
297968
  });
297858
297969
  }
297859
297970
  async function filterBy(owner, repo, title, labels, state = 'open', creator = undefined, assignee = undefined) {
297860
- issues_log(`Filtering issues by title in ${owner}/${repo}`);
297971
+ github_src_logger.info(`Filtering issues by title in ${owner}/${repo}`);
297861
297972
  const octokit = await getOctokitForOrg(owner);
297862
297973
  const resp = await octokit.rest.issues.listForRepo({
297863
297974
  owner,
@@ -297872,7 +297983,7 @@ async function filterBy(owner, repo, title, labels, state = 'open', creator = un
297872
297983
  return resp.data.filter((issue) => issue.title.includes(title));
297873
297984
  }
297874
297985
  async function upsertByTitle(owner, repo, title, body, labels = []) {
297875
- issues_log(`Upserting issue by title in ${owner}/${repo}`);
297986
+ github_src_logger.info(`Upserting issue by title in ${owner}/${repo}`);
297876
297987
  const foundIssues = await filterBy(owner, repo, title, labels.join(','));
297877
297988
  if (foundIssues.length > 0) {
297878
297989
  return update(owner, repo, foundIssues[0].number, title, body, labels);
@@ -297882,7 +297993,7 @@ async function upsertByTitle(owner, repo, title, body, labels = []) {
297882
297993
  }
297883
297994
  }
297884
297995
  async function issues_close(owner, repo, issue_number) {
297885
- issues_log(`Closing issue ${issue_number} in ${owner}/${repo}`);
297996
+ github_src_logger.info(`Closing issue ${issue_number} in ${owner}/${repo}`);
297886
297997
  const octokit = await getOctokitForOrg(owner);
297887
297998
  return await octokit.rest.issues.update({
297888
297999
  owner,
@@ -297902,10 +298013,9 @@ async function issues_close(owner, repo, issue_number) {
297902
298013
  ;// CONCATENATED MODULE: ../github/src/branches.ts
297903
298014
 
297904
298015
 
297905
- const branches_messageLog = src_default()('firestartr:github:branches');
297906
298016
  const SHA1_EMPTY_TREE = '4b825dc642cb6eb9a060e54bf8d69288fbee4904';
297907
298017
  async function listBranches(repo, owner = 'prefapp') {
297908
- branches_messageLog(`Getting branches for ${owner}/${repo}`);
298018
+ github_src_logger.info(`Getting branches for ${owner}/${repo}`);
297909
298019
  const octokit = await getOctokitForOrg(owner);
297910
298020
  const response = await octokit.rest.repos.listBranches({
297911
298021
  owner,
@@ -297916,7 +298026,7 @@ async function listBranches(repo, owner = 'prefapp') {
297916
298026
  return response.data;
297917
298027
  }
297918
298028
  async function getBranch(repo, branch, owner = 'prefapp') {
297919
- branches_messageLog(`Getting branch ${branch} for ${owner}/${repo}`);
298029
+ github_src_logger.info(`Getting branch ${branch} for ${owner}/${repo}`);
297920
298030
  const octokit = await getOctokitForOrg(owner);
297921
298031
  const response = await octokit.rest.repos.getBranch({
297922
298032
  owner,
@@ -297926,7 +298036,7 @@ async function getBranch(repo, branch, owner = 'prefapp') {
297926
298036
  return response.data;
297927
298037
  }
297928
298038
  async function createBranch(repo, branch, sha, owner = 'prefapp') {
297929
- branches_messageLog(`Creating branch ${branch} for ${owner}/${repo}`);
298039
+ github_src_logger.info(`Creating branch ${branch} for ${owner}/${repo}`);
297930
298040
  const octokit = await getOctokitForOrg(owner);
297931
298041
  const response = await octokit.rest.git.createRef({
297932
298042
  owner,
@@ -297937,7 +298047,7 @@ async function createBranch(repo, branch, sha, owner = 'prefapp') {
297937
298047
  return response.data;
297938
298048
  }
297939
298049
  async function createOrphanBranch(repo, branch, owner = 'prefapp') {
297940
- branches_messageLog(`Creating orphan branch ${branch} for ${owner}/${repo}`);
298050
+ github_src_logger.info(`Creating orphan branch ${branch} for ${owner}/${repo}`);
297941
298051
  const octokit = await getOctokitForOrg(owner);
297942
298052
  // Create a commit with an empty tree
297943
298053
  const { data: commit } = await octokit.request('POST /repos/{owner}/{repo}/git/commits', {
@@ -297963,6 +298073,268 @@ async function createOrphanBranch(repo, branch, owner = 'prefapp') {
297963
298073
  createOrphanBranch,
297964
298074
  });
297965
298075
 
298076
+ ;// CONCATENATED MODULE: ../github/src/check_run.ts
298077
+
298078
+
298079
+ const FLUSH_TIMEOUT = 4; // seconds
298080
+ const GITHUB_OUTPUT_TEXT_LIMIT = 65000; // ~65k hard limit for output.text
298081
+ /**
298082
+ * Streams text updates to a callback on a fixed cadence, with a size-triggered early flush.
298083
+ * Does NOT clear content on flush (so the consumer can send the full, current log each time).
298084
+ */
298085
+ class CheckRunBuffer {
298086
+ constructor(initial = '', onFlush, opts) {
298087
+ this.content = initial;
298088
+ this.updated = Boolean(initial);
298089
+ this.onFlush = onFlush;
298090
+ this.flushIntervalMs = (opts?.intervalSec ?? FLUSH_TIMEOUT) * 1000;
298091
+ this.timer = setInterval(() => {
298092
+ this.flush();
298093
+ }, this.flushIntervalMs);
298094
+ if (initial)
298095
+ this.flush();
298096
+ }
298097
+ stop() {
298098
+ if (this.timer !== null) {
298099
+ clearInterval(this.timer);
298100
+ this.timer = null;
298101
+ }
298102
+ }
298103
+ update(data = '') {
298104
+ if (!data)
298105
+ return;
298106
+ this.content += data;
298107
+ this.updated = true;
298108
+ }
298109
+ flush() {
298110
+ if (!this.updated)
298111
+ return;
298112
+ try {
298113
+ this.onFlush(this.content);
298114
+ }
298115
+ finally {
298116
+ this.updated = false;
298117
+ }
298118
+ }
298119
+ snapshot() {
298120
+ return this.content;
298121
+ }
298122
+ }
298123
+ class GithubCheckRun {
298124
+ constructor(octokit, params) {
298125
+ this.hasCommented = false;
298126
+ this.closing = false;
298127
+ this.closed = false;
298128
+ this.lastStatus = 'in_progress';
298129
+ this.detailsFormatter = (s) => s;
298130
+ this.octokit = octokit;
298131
+ this.owner = params.owner;
298132
+ this.repo = params.repo;
298133
+ this.headSHA = params.headSHA;
298134
+ this.name = params.name;
298135
+ this.detailsUrl = params.detailsUrl;
298136
+ this.title = params.title ?? params.name;
298137
+ if (params.summary)
298138
+ this._summaryOverride = params.summary;
298139
+ this.pullNumber = params.pullNumber;
298140
+ this.includeCheckRunComment = Boolean(params.includeCheckRunComment);
298141
+ this.checkRunComment = params.checkRunComment;
298142
+ this.buffer = new CheckRunBuffer('', (data) => this.__updateCheckRun(data).catch(() => { }), { intervalSec: FLUSH_TIMEOUT });
298143
+ }
298144
+ /**
298145
+ * Configure markdown formatting for the details (output.text).
298146
+ * Example: ch.mdOptionsDetails({ quotes: 'terraform' })
298147
+ * Result:
298148
+ * ```terraform
298149
+ * <log>
298150
+ * ```
298151
+ */
298152
+ mdOptionsDetails(opts) {
298153
+ const lang = (opts?.quotes ?? '').trim();
298154
+ if (!lang) {
298155
+ this.detailsFormatter = (s) => s;
298156
+ return;
298157
+ }
298158
+ const fenceOpen = '```' + lang + '\n';
298159
+ const fenceClose = '\n```';
298160
+ const overhead = fenceOpen.length + fenceClose.length;
298161
+ this.detailsFormatter = (body) => {
298162
+ const maxBody = Math.max(0, GITHUB_OUTPUT_TEXT_LIMIT - overhead);
298163
+ const safeBody = body.length > maxBody ? truncateRight(body, maxBody) : body;
298164
+ return fenceOpen + safeBody + fenceClose;
298165
+ };
298166
+ }
298167
+ set summary(data) {
298168
+ this._summaryOverride = data;
298169
+ // Push an immediate update if already created and not closed.
298170
+ if (!this.closed && this.checkRunId) {
298171
+ // do not mutate buffer flags; just send current snapshot using new summary
298172
+ this.__updateCheckRun(this.buffer.snapshot()).catch(() => { });
298173
+ }
298174
+ }
298175
+ get summary() {
298176
+ return this._summaryOverride;
298177
+ }
298178
+ /**
298179
+ * Append log text and optionally set status ('queued' | 'in_progress').
298180
+ */
298181
+ update(text, status) {
298182
+ if (this.closed)
298183
+ return;
298184
+ if (status)
298185
+ this.lastStatus = status;
298186
+ if (text)
298187
+ this.buffer.update(text);
298188
+ }
298189
+ /**
298190
+ * Finalize the check with a conclusion. Flushes buffered text, marks completed.
298191
+ */
298192
+ async close(finalText, ok) {
298193
+ if (this.closed || this.closing)
298194
+ return;
298195
+ this.closing = true;
298196
+ this.buffer.stop();
298197
+ const finalContent = this.buffer.snapshot() + (finalText || '');
298198
+ try {
298199
+ await this.__ensureCreated();
298200
+ const { text, summary } = this.buildOutputTextAndSummary(finalContent);
298201
+ await this.octokit.rest.checks.update({
298202
+ owner: this.owner,
298203
+ repo: this.repo,
298204
+ check_run_id: this.checkRunId,
298205
+ conclusion: ok ? 'success' : 'failure',
298206
+ completed_at: new Date().toISOString(),
298207
+ output: {
298208
+ title: this.title,
298209
+ summary,
298210
+ text,
298211
+ },
298212
+ });
298213
+ this.closed = true;
298214
+ }
298215
+ finally {
298216
+ this.closing = false;
298217
+ }
298218
+ }
298219
+ // -------------------- Internals --------------------
298220
+ async __ensureCreated() {
298221
+ if (this.checkRunId)
298222
+ return;
298223
+ const startedAt = new Date().toISOString();
298224
+ const res = await this.octokit.rest.checks.create({
298225
+ owner: this.owner,
298226
+ repo: this.repo,
298227
+ name: this.name,
298228
+ head_sha: this.headSHA,
298229
+ status: 'in_progress',
298230
+ started_at: startedAt,
298231
+ details_url: this.detailsUrl,
298232
+ output: {
298233
+ title: this.title,
298234
+ summary: this._summaryOverride ?? '',
298235
+ text: undefined,
298236
+ },
298237
+ });
298238
+ this.checkRunId = res.data.id;
298239
+ if (this.includeCheckRunComment &&
298240
+ this.pullNumber !== undefined &&
298241
+ !this.hasCommented) {
298242
+ const link = this.__buildCheckRunUrl();
298243
+ const formattedLink = `[here](${link})`;
298244
+ const base = this.checkRunComment ?? '';
298245
+ const body = base ? `${base}${formattedLink}` : formattedLink;
298246
+ await this.octokit.rest.issues.createComment({
298247
+ owner: this.owner,
298248
+ repo: this.repo,
298249
+ issue_number: this.pullNumber,
298250
+ body,
298251
+ });
298252
+ this.hasCommented = true;
298253
+ }
298254
+ }
298255
+ async __updateCheckRun(allContent) {
298256
+ if (this.closed || this.closing)
298257
+ return;
298258
+ await this.__ensureCreated();
298259
+ const { text, summary } = this.buildOutputTextAndSummary(allContent);
298260
+ await this.octokit.rest.checks.update({
298261
+ owner: this.owner,
298262
+ repo: this.repo,
298263
+ check_run_id: this.checkRunId,
298264
+ status: this.lastStatus,
298265
+ output: {
298266
+ title: this.title,
298267
+ summary,
298268
+ text,
298269
+ },
298270
+ });
298271
+ }
298272
+ __buildCheckRunUrl() {
298273
+ if (this.checkRunId) {
298274
+ return `https://github.com/${this.owner}/${this.repo}/runs/${this.checkRunId}?check_suite_focus=true`;
298275
+ }
298276
+ return `https://github.com/${this.owner}/${this.repo}/commit/${this.headSHA}/checks?check_suite_focus=true`;
298277
+ }
298278
+ buildOutputTextAndSummary(full) {
298279
+ if (!full) {
298280
+ return {
298281
+ text: undefined,
298282
+ summary: this._summaryOverride ?? '',
298283
+ };
298284
+ }
298285
+ let text = this.detailsFormatter(full);
298286
+ let truncated = false;
298287
+ if (text.length > GITHUB_OUTPUT_TEXT_LIMIT) {
298288
+ text = truncateRight(text, GITHUB_OUTPUT_TEXT_LIMIT);
298289
+ truncated = true;
298290
+ }
298291
+ else {
298292
+ truncated = text.length < full.length;
298293
+ }
298294
+ let summary = this._summaryOverride ?? '';
298295
+ if (this._summaryOverride && truncated) {
298296
+ summary = `${summary}\n\n... (log truncated to ~${GITHUB_OUTPUT_TEXT_LIMIT.toLocaleString()} chars)`;
298297
+ }
298298
+ return { text, summary };
298299
+ }
298300
+ }
298301
+ // -------------------- Helpers --------------------
298302
+ function truncateRight(s, max) {
298303
+ if (s.length <= max)
298304
+ return s;
298305
+ const HARD = Math.max(0, max - 3);
298306
+ return s.slice(0, HARD) + '...';
298307
+ }
298308
+ /**
298309
+ * Factory: build a GithubCheckRun using an installation token for the given org.
298310
+ */
298311
+ async function createCheckRunForOrg(org, owner, repo, name, opts) {
298312
+ const octokit = await getOctokitForOrg(org);
298313
+ let headSHA = opts?.headSHA;
298314
+ if (!headSHA && typeof opts?.pullNumber === 'number') {
298315
+ headSHA = await getPrMergeCommitSHA(opts.pullNumber, repo, owner);
298316
+ }
298317
+ if (!headSHA) {
298318
+ throw new Error('createCheckRunForOrg: either opts.headSHA or opts.pullNumber must be provided');
298319
+ }
298320
+ return new GithubCheckRun(octokit, {
298321
+ owner,
298322
+ repo,
298323
+ headSHA,
298324
+ name,
298325
+ detailsUrl: opts?.detailsUrl,
298326
+ title: opts?.title,
298327
+ summary: opts?.summary,
298328
+ pullNumber: opts?.pullNumber,
298329
+ includeCheckRunComment: Boolean(opts?.includeCheckRunComment),
298330
+ checkRunComment: opts?.checkRunComment,
298331
+ });
298332
+ }
298333
+ async function createCheckRun(owner, repo, name, opts) {
298334
+ return createCheckRunForOrg(owner, owner, repo, name, opts);
298335
+ }
298336
+ const CheckRun = GithubCheckRun;
298337
+
297966
298338
  ;// CONCATENATED MODULE: ../github/index.ts
297967
298339
 
297968
298340
 
@@ -297973,6 +298345,7 @@ async function createOrphanBranch(repo, branch, owner = 'prefapp') {
297973
298345
 
297974
298346
 
297975
298347
 
298348
+
297976
298349
  /* harmony default export */ const github_0 = ({
297977
298350
  org: organization,
297978
298351
  repo: repository,
@@ -297986,6 +298359,10 @@ async function createOrphanBranch(repo, branch, owner = 'prefapp') {
297986
298359
  pulls: pull_request,
297987
298360
  issues: issues,
297988
298361
  branches: branches,
298362
+ feedback: {
298363
+ createCheckRun: createCheckRun,
298364
+ CheckRun: CheckRun,
298365
+ },
297989
298366
  });
297990
298367
 
297991
298368
  ;// CONCATENATED MODULE: ../cdk8s_renderer/src/patches/base.ts
@@ -300247,11 +300624,17 @@ class TFWorkspaceNormalizer extends Normalizer {
300247
300624
  }
300248
300625
  async function normalizeModuleContent(tfRootModulePath) {
300249
300626
  let content = '';
300627
+ const files = {};
300250
300628
  await crawl(tfRootModulePath, (entry) => {
300251
300629
  return entry.endsWith('.tf');
300252
300630
  }, (entry, data) => {
300631
+ files[entry] = data;
300632
+ });
300633
+ Object.keys(files)
300634
+ .sort()
300635
+ .forEach((entry) => {
300253
300636
  content += `# ${external_path_.basename(entry)}
300254
- ${data}
300637
+ ${files[entry]}
300255
300638
  `;
300256
300639
  });
300257
300640
  return content;
@@ -301500,14 +301883,14 @@ async function loadSchema(schemaURI) {
301500
301883
 
301501
301884
 
301502
301885
  const ajv = new (_2020_default())({ useDefaults: true });
301503
- let initiated = false;
301886
+ let validation_initiated = false;
301504
301887
  const validations = {};
301505
301888
  function prepareValidation(schemaId) {
301506
- if (!initiated)
301889
+ if (!validation_initiated)
301507
301890
  ajv.addSchema(base_schemas.schemas);
301508
301891
  if (!validations[schemaId])
301509
301892
  validations[schemaId] = ajv.getSchema(schemaId);
301510
- initiated = true;
301893
+ validation_initiated = true;
301511
301894
  return validations[schemaId];
301512
301895
  }
301513
301896
  function validateClaim(data, schemaId = 'firestartr.dev://common/ClaimEnvelope') {
@@ -303141,7 +303524,7 @@ function addTraceabilityStamp(context, content) {
303141
303524
 
303142
303525
 
303143
303526
 
303144
- const render_messageLog = src_default()('firestartr:features_renderer');
303527
+ const messageLog = src_default()('firestartr:features_renderer');
303145
303528
  function render(featurePath, featureRenderPath, entity, firestartrConfig = {}, featureArgs = {}) {
303146
303529
  const configData = validate_validate(featurePath);
303147
303530
  const context = buildContext(entity, configData.args, firestartrConfig, featureArgs);
@@ -303152,7 +303535,7 @@ function render(featurePath, featureRenderPath, entity, firestartrConfig = {}, f
303152
303535
  // For now let's keep upgradeable flag for backward compatibility
303153
303536
  // by default it's false
303154
303537
  const userManaged = file.user_managed ?? file.upgradeable ?? false;
303155
- render_messageLog(`Rendering ${src} to ${dest}`);
303538
+ messageLog(`Rendering ${src} to ${dest}`);
303156
303539
  // render the content of the file
303157
303540
  const content = addTraceability(context, src, renderContent(external_fs_default().readFileSync(external_path_default().join(featurePath, 'templates', src)).toString(), context));
303158
303541
  const destFilePath = external_path_default().join(`${featureRenderPath}`, dest);
@@ -303205,6 +303588,209 @@ function renderContent(template, ctx) {
303205
303588
  return mustache_mustache.render(template, ctx, {}, ['{{|', '|}}']);
303206
303589
  }
303207
303590
 
303591
+ // EXTERNAL MODULE: external "node:fs"
303592
+ var external_node_fs_ = __nccwpck_require__(87561);
303593
+ // EXTERNAL MODULE: external "node:path"
303594
+ var external_node_path_ = __nccwpck_require__(49411);
303595
+ ;// CONCATENATED MODULE: external "node:os"
303596
+ const external_node_os_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:os");
303597
+ ;// CONCATENATED MODULE: ../features_renderer/src/auxiliar.ts
303598
+ // src/auxiliar.ts
303599
+
303600
+
303601
+
303602
+
303603
+
303604
+
303605
+
303606
+ const renderTestsSchema = {
303607
+ $schema: 'http://json-schema.org/draft-07/schema#',
303608
+ type: 'object',
303609
+ additionalProperties: false,
303610
+ required: ['tests'],
303611
+ properties: {
303612
+ tests: {
303613
+ type: 'array',
303614
+ minItems: 1,
303615
+ items: {
303616
+ type: 'object',
303617
+ additionalProperties: false,
303618
+ required: ['name', 'cr'],
303619
+ properties: {
303620
+ name: { type: 'string', minLength: 1 },
303621
+ cr: { type: 'string', minLength: 1 },
303622
+ args: { type: 'object' },
303623
+ },
303624
+ },
303625
+ },
303626
+ },
303627
+ };
303628
+ const YAML_FILE_REGEX = /\.[yY]a?ml$/;
303629
+ /* ---------- Core helpers ---------- */
303630
+ function formatAjvErrors(errors) {
303631
+ if (!errors || errors.length === 0)
303632
+ return 'Unknown schema error';
303633
+ return errors
303634
+ .map((e) => {
303635
+ const where = e.instancePath && e.instancePath.length ? e.instancePath : '/';
303636
+ const msg = e.message ?? 'validation error';
303637
+ return `- ${where} ${msg}`;
303638
+ })
303639
+ .join('\n');
303640
+ }
303641
+ function ensureUniqueTestNames(doc) {
303642
+ const seen = new Set();
303643
+ for (const t of doc.tests) {
303644
+ if (seen.has(t.name)) {
303645
+ throw new Error(`Duplicate test name "${t.name}" in render_tests.yaml`);
303646
+ }
303647
+ seen.add(t.name);
303648
+ }
303649
+ }
303650
+ function loadAndValidateRenderTests(featurePath) {
303651
+ const file = external_node_path_.join(featurePath, 'render_tests.yaml');
303652
+ if (!external_node_fs_.existsSync(file)) {
303653
+ throw new Error(`render_tests.yaml is required but not found at ${file}`);
303654
+ }
303655
+ const raw = loadYaml(file);
303656
+ const ajv = new (ajv_default())({ allErrors: true, strict: true });
303657
+ const validate = ajv.compile(renderTestsSchema);
303658
+ const ok = validate(raw);
303659
+ if (!ok) {
303660
+ throw new Error(`render_tests.yaml schema validation failed:\n${formatAjvErrors(validate.errors ?? [])}`);
303661
+ }
303662
+ const doc = raw;
303663
+ ensureUniqueTestNames(doc);
303664
+ return doc;
303665
+ }
303666
+ function resolveCrPath(featurePath, crRelPath) {
303667
+ if (external_node_path_.isAbsolute(crRelPath)) {
303668
+ throw new Error(`CR path must be relative to the feature root, got absolute: ${crRelPath}`);
303669
+ }
303670
+ const resolved = external_node_path_.resolve(featurePath, crRelPath);
303671
+ if (!external_node_fs_.existsSync(resolved)) {
303672
+ throw new Error(`CR file not found (resolved from "${crRelPath}"): ${resolved}`);
303673
+ }
303674
+ return resolved;
303675
+ }
303676
+ function listYamlFiles(dir) {
303677
+ if (!fs.existsSync(dir))
303678
+ return [];
303679
+ let entries;
303680
+ try {
303681
+ entries = fs.readdirSync(dir, { withFileTypes: true });
303682
+ }
303683
+ catch (e) {
303684
+ const msg = e instanceof Error ? e.message : String(e);
303685
+ throw new Error(`Failed to read directory "${dir}": ${msg}`);
303686
+ }
303687
+ return entries
303688
+ .filter((e) => e.isFile() && YAML_FILE_REGEX.test(e.name))
303689
+ .map((e) => path.join(dir, e.name));
303690
+ }
303691
+ function loadYaml(file) {
303692
+ try {
303693
+ const configDataRaw = common_slurpFile(external_node_path_.join(file));
303694
+ return catalog_common.io.fromYaml(configDataRaw);
303695
+ }
303696
+ catch (e) {
303697
+ const msg = e instanceof Error ? e.message : String(e);
303698
+ throw new Error(`Failed to parse YAML "${file}": ${msg}`);
303699
+ }
303700
+ }
303701
+ function ensureSafeTmpNames(name) {
303702
+ if (typeof name !== 'string' || !name.trim()) {
303703
+ throw new Error('Test "name" must be a non-empty string');
303704
+ }
303705
+ if (name.length > 128) {
303706
+ throw new Error('Test "name" is too long (max 128 characters)');
303707
+ }
303708
+ if (external_node_path_.isAbsolute(name)) {
303709
+ throw new Error(`Test "name" must be relative, got absolute: "${name}"`);
303710
+ }
303711
+ if (name.includes('..')) {
303712
+ throw new Error('Test "name" must not contain ".."');
303713
+ }
303714
+ if (!/^[A-Za-z0-9._-]+$/.test(name)) {
303715
+ throw new Error('Test "name" may only contain letters, numbers, ".", "_", or "-"');
303716
+ }
303717
+ }
303718
+ async function mkNamedTmp(...names) {
303719
+ for (const name of names) {
303720
+ ensureSafeTmpNames(name);
303721
+ }
303722
+ const dir = external_node_path_.join(external_node_os_namespaceObject.tmpdir(), ...names);
303723
+ await promises_namespaceObject.rm(dir, { recursive: true, force: true });
303724
+ await promises_namespaceObject.mkdir(dir, { recursive: true });
303725
+ return dir;
303726
+ }
303727
+ async function mkTmp(prefix = 'feature-render-') {
303728
+ return await fsp.mkdtemp(path.join(os.tmpdir(), prefix));
303729
+ }
303730
+ function buildExpectedOutput(config, renderDir) {
303731
+ const files = (config.files || []).map((f) => ({
303732
+ localPath: external_node_path_.join(renderDir, f.dest),
303733
+ repoPath: f.dest,
303734
+ userManaged: f.user_managed,
303735
+ }));
303736
+ return {
303737
+ files,
303738
+ patches: config.patches || [],
303739
+ };
303740
+ }
303741
+ /* ---------- Context-style API for a render temp dir ---------- */
303742
+ async function createRenderContext(prefix = 'feature-render-') {
303743
+ const dir = await mkTmp(prefix);
303744
+ const join = (...p) => path.join(dir, ...p);
303745
+ return {
303746
+ getContextPath: () => dir,
303747
+ join,
303748
+ getFile: async (relPath, { yaml: asYaml = false, json: asJson = false, } = {}) => {
303749
+ const data = await fsp.readFile(join(relPath), 'utf8');
303750
+ if (asYaml)
303751
+ return common.io.fromYaml(data);
303752
+ if (asJson)
303753
+ return JSON.parse(data);
303754
+ return data;
303755
+ },
303756
+ getFilePath: (relPath) => join(relPath),
303757
+ setFile: async (relPath, contents) => {
303758
+ await fsp.mkdir(path.dirname(join(relPath)), { recursive: true });
303759
+ await fsp.writeFile(join(relPath), contents);
303760
+ },
303761
+ exists: async (relPath) => {
303762
+ try {
303763
+ await fsp.access(join(relPath));
303764
+ return true;
303765
+ }
303766
+ catch {
303767
+ return false;
303768
+ }
303769
+ },
303770
+ getOutputJson: async () => {
303771
+ const p = join('output.json');
303772
+ const raw = await fsp.readFile(p, 'utf8');
303773
+ return JSON.parse(raw);
303774
+ },
303775
+ list: async (relPath = '.') => {
303776
+ const entries = await fsp.readdir(join(relPath), {
303777
+ withFileTypes: true,
303778
+ });
303779
+ return entries.map((e) => ({ name: e.name, isDir: e.isDirectory() }));
303780
+ },
303781
+ remove: async () => {
303782
+ await fsp.rm(dir, { recursive: true, force: true });
303783
+ },
303784
+ };
303785
+ }
303786
+ /* harmony default export */ const auxiliar = ({
303787
+ mkNamedTmp,
303788
+ loadYaml,
303789
+ buildExpectedOutput,
303790
+ loadAndValidateRenderTests,
303791
+ resolveCrPath,
303792
+ });
303793
+
303208
303794
  ;// CONCATENATED MODULE: ../features_renderer/src/update_file.ts
303209
303795
 
303210
303796
 
@@ -303216,22 +303802,29 @@ function updateFileContent(featureRenderPath, filePath, content) {
303216
303802
 
303217
303803
 
303218
303804
 
303805
+
303219
303806
  /* harmony default export */ const features_renderer = ({
303220
303807
  validate: validate_validate,
303221
303808
  render: render,
303222
303809
  updateFileContent: updateFileContent,
303810
+ auxiliar: auxiliar,
303811
+ buildContext: buildContext,
303812
+ renderContent: renderContent,
303223
303813
  });
303224
303814
 
303815
+ ;// CONCATENATED MODULE: ../features_preparer/src/logger.ts
303816
+
303817
+ /* harmony default export */ const features_preparer_src_logger = (catalog_common.logger);
303818
+
303225
303819
  ;// CONCATENATED MODULE: ../features_preparer/src/renderer.ts
303226
303820
 
303227
303821
 
303228
303822
 
303229
303823
 
303230
- const renderer_messageLog = src_default()('firestartr:features_preparer:renderer');
303231
303824
  function renderFeature(featureName, version, owner, repo, featureOwner, renderPath = '/tmp', featureArgs = {}) {
303232
303825
  const extractPath = external_path_default().join(catalog_common.features.tarballs.getFeaturesExtractPath(featureName, version, owner, repo), 'packages', featureName);
303233
303826
  const renderedPath = catalog_common.features.features.getFeatureRenderedPathForEntity(featureOwner, featureName, renderPath);
303234
- renderer_messageLog(`Rendering feature ${featureName} to ${renderedPath} with component ${JSON.stringify(featureOwner)}`);
303827
+ features_preparer_src_logger.info(`Rendering feature ${featureName} to ${renderedPath} with component ${JSON.stringify(featureOwner)}`);
303235
303828
  return features_renderer.render(extractPath, renderedPath, featureOwner, {}, featureArgs);
303236
303829
  }
303237
303830
 
@@ -303270,7 +303863,6 @@ async function downloadZipBall(url, filePath) {
303270
303863
 
303271
303864
 
303272
303865
 
303273
- const installer_log = src_default()('firestartr:features_preparer:installer');
303274
303866
  async function getFeatureConfigFromRef(featureName, featureRef, featureOwner, // -> cr
303275
303867
  featureArgs = {}, repo = 'features', owner = 'prefapp') {
303276
303868
  // reference is the featureRef directly
@@ -303301,12 +303893,12 @@ async function prepareFeature(featureName, version, repo = 'features', owner = '
303301
303893
  async function downloadFeatureZip(repo, featureName, reference, owner = 'prefapp') {
303302
303894
  try {
303303
303895
  const zipballExtractPath = catalog_common.features.tarballs.getFeaturesExtractPath(featureName, reference, owner, repo, { createIfNotExists: false });
303304
- console.log(`Zipball extract path: ${zipballExtractPath}`);
303896
+ features_preparer_src_logger.debug(`Zipball extract path: ${zipballExtractPath}`);
303305
303897
  if (external_fs_.existsSync(zipballExtractPath)) {
303306
- console.log(`Zipball extract path ${zipballExtractPath} already exists, reusing it.`);
303898
+ features_preparer_src_logger.debug(`Zipball extract path ${zipballExtractPath} already exists, reusing it.`);
303307
303899
  return zipballExtractPath;
303308
303900
  }
303309
- installer_log(`Feature ${[featureName, reference, owner, repo].join('-')} has not been downloaded yet, downloading`);
303901
+ features_preparer_src_logger.info(`Feature ${[featureName, reference, owner, repo].join('-')} has not been downloaded yet, downloading`);
303310
303902
  const octokit = await github_0.getOctokitForOrg(owner);
303311
303903
  const response = await octokit.request('GET /repos/{owner}/{repo}/zipball/{reference}', {
303312
303904
  request: {
@@ -303317,28 +303909,28 @@ async function downloadFeatureZip(repo, featureName, reference, owner = 'prefapp
303317
303909
  reference,
303318
303910
  });
303319
303911
  const randomZipTmpPath = `/tmp/${catalog_common.generic.randomString(20)}.zip`;
303320
- console.log(`Downloading feature ${featureName} version ${reference} to ${randomZipTmpPath}`);
303912
+ features_preparer_src_logger.info(`Downloading feature ${featureName} version ${reference} to ${randomZipTmpPath}`);
303321
303913
  if (external_fs_.existsSync(randomZipTmpPath)) {
303322
- console.log(`Temporary zip file ${randomZipTmpPath} already exists, removing it.`);
303914
+ features_preparer_src_logger.debug(`Temporary zip file ${randomZipTmpPath} already exists, removing it.`);
303323
303915
  external_fs_.unlinkSync(randomZipTmpPath);
303324
303916
  }
303325
303917
  const randomExtractPath = `/tmp/${catalog_common.generic.randomString(20)}`;
303326
- console.log(`Extracting feature ${featureName} version ${reference} to ${randomExtractPath}`);
303918
+ features_preparer_src_logger.debug(`Extracting feature ${featureName} version ${reference} to ${randomExtractPath}`);
303327
303919
  external_fs_.rmSync(randomExtractPath, { recursive: true, force: true });
303328
303920
  await downloadZipBall(response.url, randomZipTmpPath);
303329
303921
  const zip = new (adm_zip_default())(randomZipTmpPath);
303330
303922
  const mainEntry = zip.getEntries()[0].entryName;
303331
- console.log(`Main entry in zip: ${mainEntry}`);
303332
- console.log(`Extracting zip to ${randomExtractPath}`);
303923
+ features_preparer_src_logger.debug(`Main entry in zip: ${mainEntry}`);
303924
+ features_preparer_src_logger.debug(`Extracting zip to ${randomExtractPath}`);
303333
303925
  zip.extractAllTo(randomExtractPath, true);
303334
- console.log(`Renaming main entry ${mainEntry} to ${zipballExtractPath}`);
303926
+ features_preparer_src_logger.debug(`Renaming main entry ${mainEntry} to ${zipballExtractPath}`);
303335
303927
  external_fs_.renameSync(`${randomExtractPath}/${mainEntry}`, zipballExtractPath);
303336
- console.log(`Removing temporary zip file ${randomZipTmpPath}`);
303928
+ features_preparer_src_logger.debug(`Removing temporary zip file ${randomZipTmpPath}`);
303337
303929
  external_fs_.unlinkSync(randomZipTmpPath);
303338
303930
  return zipballExtractPath;
303339
303931
  }
303340
303932
  catch (error) {
303341
- console.error(error);
303933
+ features_preparer_src_logger.error(`Error on prepare feature with tag ${reference}: ${error}`);
303342
303934
  throw new Error(`Error for feature with tag ${reference}: ${error}. GitHub response: ${error}`);
303343
303935
  }
303344
303936
  }
@@ -308927,60 +309519,9 @@ const scaffoldSubcommand = {
308927
309519
 
308928
309520
  // EXTERNAL MODULE: ../../node_modules/@kubernetes/client-node/dist/index.js
308929
309521
  var client_node_dist = __nccwpck_require__(54851);
308930
- // EXTERNAL MODULE: ../../node_modules/winston/lib/winston.js
308931
- var winston = __nccwpck_require__(66752);
308932
- var winston_default = /*#__PURE__*/__nccwpck_require__.n(winston);
308933
309522
  ;// CONCATENATED MODULE: ../operator/src/logger.ts
308934
309523
 
308935
- const validLogLevels = [
308936
- 'error',
308937
- 'warn',
308938
- 'info',
308939
- 'debug',
308940
- 'verbose',
308941
- 'silly',
308942
- ];
308943
- let logger_initiated = false;
308944
- let logger = null;
308945
- // Type guard to check if a value is a valid LogLevel
308946
- function isValidLogLevel(level) {
308947
- return (typeof level === 'string' && validLogLevels.includes(level));
308948
- }
308949
- function initLogger() {
308950
- if (logger_initiated)
308951
- return;
308952
- const logLevel = process.env.LOG_LEVEL && isValidLogLevel(process.env.LOG_LEVEL)
308953
- ? process.env.LOG_LEVEL
308954
- : 'info';
308955
- logger = winston_default().createLogger({
308956
- level: logLevel,
308957
- exitOnError: false,
308958
- format: winston.format.combine(winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }), winston.format.json()),
308959
- transports: [
308960
- new winston.transports.Console({
308961
- level: logLevel,
308962
- }),
308963
- ],
308964
- });
308965
- logger_initiated = true;
308966
- }
308967
- function doLog(level, args) {
308968
- initLogger();
308969
- const [message, metadata] = args;
308970
- // eslint-disable-next-line prefer-spread
308971
- logger[level].apply(logger, [
308972
- message + ' | ' + JSON.stringify({ ...metadata }),
308973
- ]);
308974
- }
308975
- const logger_log = {
308976
- error: (...args) => doLog('error', args),
308977
- warn: (...args) => doLog('warn', args),
308978
- info: (...args) => doLog('info', args),
308979
- debug: (...args) => doLog('debug', args),
308980
- verbose: (...args) => doLog('verbose', args),
308981
- silly: (...args) => doLog('silly', args),
308982
- };
308983
- /* harmony default export */ const src_logger = (logger_log);
309524
+ /* harmony default export */ const operator_src_logger = (catalog_common.logger);
308984
309525
 
308985
309526
  ;// CONCATENATED MODULE: ../operator/src/store.ts
308986
309527
 
@@ -308991,13 +309532,7 @@ class Store {
308991
309532
  this.kind = kind;
308992
309533
  }
308993
309534
  add(item) {
308994
- src_logger.debug('STORE_ADD_ITEM', {
308995
- metadata: {
308996
- name: item.metadata.name,
308997
- kind: this.kind,
308998
- namespace: item.metadata.namespace,
308999
- },
309000
- });
309535
+ operator_src_logger.debug(`Added item '${item.metadata.name}' of kind '${this.kind}' to the store in namespace '${item.metadata.namespace}'`);
309001
309536
  this.store[itemPath(this.kind, item)] = {
309002
309537
  item,
309003
309538
  };
@@ -309006,13 +309541,7 @@ class Store {
309006
309541
  return 'deletionTimestamp' in item.metadata;
309007
309542
  }
309008
309543
  markToDelete(item) {
309009
- src_logger.debug('STORE_MARKED_ITEM_TO_DELETE', {
309010
- metadata: {
309011
- name: item.metadata.name,
309012
- kind: this.kind,
309013
- namespace: item.metadata.namespace,
309014
- },
309015
- });
309544
+ operator_src_logger.debug(`Marked item '${item.metadata.name}' of kind '${this.kind}' for deletion in namespace '${item.metadata.namespace}'`);
309016
309545
  this.store[itemPath(this.kind, item)] = {
309017
309546
  item,
309018
309547
  markedToDelete: true,
@@ -309045,24 +309574,11 @@ class Store {
309045
309574
  item,
309046
309575
  };
309047
309576
  if (updated)
309048
- src_logger.debug('STORE_ITEM_MODIFIED', {
309049
- metadata: {
309050
- name: item.metadata.name,
309051
- kind: this.kind,
309052
- namespace: item.metadata.namespace,
309053
- patches,
309054
- },
309055
- });
309577
+ operator_src_logger.debug(`Modified item '${item.metadata.name}' of kind '${this.kind}' in namespace '${item.metadata.namespace}' with patches ${JSON.stringify(patches)}`);
309056
309578
  return updated;
309057
309579
  }
309058
309580
  remove(item) {
309059
- src_logger.debug('STORE_ITEM_REMOVED', {
309060
- metadata: {
309061
- name: item.metadata.name,
309062
- kind: this.kind,
309063
- namespace: item.metadata.namespace,
309064
- },
309065
- });
309581
+ operator_src_logger.debug(`Removed item '${item.metadata.name}' of kind '${this.kind}' from namespace '${item.metadata.namespace}'`);
309066
309582
  delete this.store[itemPath(this.kind, item)];
309067
309583
  }
309068
309584
  getItem(item) {
@@ -309109,7 +309625,7 @@ async function getItem(kind, namespace, item) {
309109
309625
  }
309110
309626
  async function getItemByItemPath(itemPath, apiGroup = catalog_common.types.controller.FirestartrApiGroup, apiVersion = 'v1') {
309111
309627
  try {
309112
- src_logger.debug('CTL_GET_ITEM', { metadata: { itemPath } });
309628
+ operator_src_logger.debug(`The ctl is getting the item at '${itemPath}'.`);
309113
309629
  const { kc, opts } = await ctl_getConnection();
309114
309630
  opts.headers['Content-Type'] = 'application/json';
309115
309631
  opts.headers['Accept'] = 'application/json';
@@ -309119,14 +309635,14 @@ async function getItemByItemPath(itemPath, apiGroup = catalog_common.types.contr
309119
309635
  const r = await fetch(url, { method: 'get', headers: opts.headers });
309120
309636
  if (!r.ok) {
309121
309637
  const err = new Error(`Error on getItemByItemPath: ${itemPath}: ${r.statusText}`);
309122
- console.log(err.stack);
309638
+ operator_src_logger.error(`Error on getItemByItemPath: ${itemPath}: ${r.statusText}`);
309123
309639
  throw err;
309124
309640
  }
309125
309641
  const jsonResponse = await r.json();
309126
309642
  return jsonResponse;
309127
309643
  }
309128
309644
  catch (e) {
309129
- console.dir(e, { depth: null });
309645
+ operator_src_logger.error(`Error on getItemByItemPath: ${e}`);
309130
309646
  throw e;
309131
309647
  }
309132
309648
  }
@@ -309146,17 +309662,15 @@ async function writeManifest(kind, namespace, item, apiSlug) {
309146
309662
  return jsonResponse;
309147
309663
  }
309148
309664
  function writeSecret(secret, namespace) {
309149
- log.debug('CTL_WRITE_SECRET', {
309150
- metadata: { namespace, name: secret.metadata.name },
309151
- });
309665
+ log.debug(`The ctl is writing the secret '${secret.metadata.name}' in namespace '${namespace}'.`);
309152
309666
  return writeManifest('secrets', namespace, secret, `api/v1/namespaces/${namespace}/secrets/${secret.metadata.name}`);
309153
309667
  }
309154
309668
  async function writeStatus(kind, namespace, item) {
309155
- src_logger.debug('CTL_WRITE_STATUS', { metadata: { item } });
309669
+ operator_src_logger.debug(`The ctl is writing the status for item '${item.kind}/${item.metadata.name}' in namespace '${item.metadata.namespace}'.`);
309156
309670
  return await writeManifest(kind, namespace, item, `apis/firestartr.dev/v1/namespaces/${namespace}/${kind}/${item.metadata.name}/status`);
309157
309671
  }
309158
309672
  function writeFinalizer(kind, namespace, item) {
309159
- log.debug('CTL_WRITE_FINALIZER', { metadata: { item } });
309673
+ log.debug(`The ctl is writing the status for item '${item.kind}/${item.metadata.name}' in namespace '${item.metadata.namespace}'.`);
309160
309674
  return writeManifest(kind, namespace, item, `apis/firestartr.dev/v1/namespaces/${namespace}/${kind}/${item.metadata.name}/metadata/finalizers`);
309161
309675
  }
309162
309676
  async function listItems(kind, namespace, kc, opts) {
@@ -309171,7 +309685,7 @@ async function listItems(kind, namespace, kc, opts) {
309171
309685
  return await r.json();
309172
309686
  }
309173
309687
  catch (err) {
309174
- console.dir(err);
309688
+ log.error(`On listItems: ${err}`);
309175
309689
  throw err;
309176
309690
  }
309177
309691
  }
@@ -309198,15 +309712,10 @@ async function* observeList(kind, namespace, revision, kc, opts) {
309198
309712
  }
309199
309713
  catch (err) {
309200
309714
  if (err instanceof TypeError) {
309201
- log.error('CTL_OBSERVE_LIST_ERROR_CHUNKS', {
309202
- metadata: { namespace, kind, revision, error: err },
309203
- });
309715
+ log.error(`The ctl encountered an error while listing chunks for '${kind}' with revision '${revision}' in namespace '${namespace}': '${err}'.`);
309204
309716
  }
309205
309717
  else {
309206
- log.error('CTL_OBSERVE_LIST_UNKNOWN_ERROR_CHUNKS', {
309207
- metadata: { namespace, kind, revision, error: err },
309208
- });
309209
- console.error(err);
309718
+ log.error(`The ctl encountered an unknown error while listing chunks for '${kind}' with revision '${revision}' in namespace '${namespace}': '${err}'.`);
309210
309719
  }
309211
309720
  }
309212
309721
  }
@@ -309229,7 +309738,7 @@ async function ctl_getConnection() {
309229
309738
  return { kc, opts };
309230
309739
  }
309231
309740
  catch (err) {
309232
- console.dir(err, { depth: null });
309741
+ operator_src_logger.error(`getConnection: ${err}`);
309233
309742
  throw err;
309234
309743
  }
309235
309744
  }
@@ -309288,9 +309797,7 @@ async function deleteSecret(secretName, namespace) {
309288
309797
  }
309289
309798
  catch (e) {
309290
309799
  if (e && e.code === 404) {
309291
- src_logger.error('CTL_DELETE_SECRET_NOT_FOUND', {
309292
- metadata: { secretName, namespace },
309293
- });
309800
+ operator_src_logger.error(`The ctl failed to delete the secret '${secretName}' in namespace '${namespace}' because it was not found.`);
309294
309801
  return null;
309295
309802
  }
309296
309803
  else {
@@ -309324,9 +309831,7 @@ async function getSecret(namespace, secretName) {
309324
309831
  }
309325
309832
  catch (e) {
309326
309833
  if (e.response && e.response.statusCode === 404) {
309327
- src_logger.error('CTL_SECRET_NOT_FOUND', {
309328
- metadata: { secretName, namespace },
309329
- });
309834
+ operator_src_logger.error(`The ctl could not find the secret '${secretName}' in namespace '${namespace}'.`);
309330
309835
  return null;
309331
309836
  }
309332
309837
  else {
@@ -309357,13 +309862,7 @@ async function getTFResult(namespace, item) {
309357
309862
  * @param {any} item - Object to check if has been renamed
309358
309863
  */
309359
309864
  async function checkIfRenamed(namespace, item) {
309360
- log.debug('CTL_CHECK_IF_RENAMED', {
309361
- metadata: {
309362
- kind: item.kind,
309363
- name: item.metadata.name,
309364
- namespace,
309365
- },
309366
- });
309865
+ log.debug(`The ctl is checking if item '${item.kind}/${item.metadata.name}' in namespace '${namespace}' has been renamed.`);
309367
309866
  const oldName = item.metadata?.labels?.[common.types.controller.FirestartrLabelOldName];
309368
309867
  // If the item does not have firestartr.dev/old-name label, it has not been renamed
309369
309868
  if (!oldName)
@@ -309379,9 +309878,7 @@ async function checkIfRenamed(namespace, item) {
309379
309878
  });
309380
309879
  if (!r.ok) {
309381
309880
  if (r.status === 404) {
309382
- log.debug('CTL_CHECK_IF_RENAMED_OLDNAME_NOT_FOUND', {
309383
- metadata: { kind: item.kind, name: item.metadata.name, namespace },
309384
- });
309881
+ log.debug(`The ctl is checking for a rename of item '${item.kind}/${item.metadata.name}' in namespace '${namespace}', but the old item name was not found.`);
309385
309882
  return false;
309386
309883
  }
309387
309884
  }
@@ -309389,21 +309886,17 @@ async function checkIfRenamed(namespace, item) {
309389
309886
  return true;
309390
309887
  }
309391
309888
  catch (err) {
309392
- console.log(err);
309889
+ log.debug(err);
309393
309890
  return false;
309394
309891
  }
309395
309892
  }
309396
309893
  async function upsertFinalizer(kind, namespace, item, finalizer) {
309397
309894
  if ('finalizers' in item.metadata &&
309398
309895
  item.metadata.finalizers.includes(finalizer)) {
309399
- src_logger.debug('CTL_UPSERT_FINALIZER_ALREADY_SET', {
309400
- metadata: { finalizer, kind, name: item.metadata.name, namespace },
309401
- });
309896
+ operator_src_logger.debug(`The ctl tried to upsert the finalizer '${finalizer}' for '${kind}/${item.metadata.name}' in namespace '${namespace}', but it was already set.`);
309402
309897
  return;
309403
309898
  }
309404
- src_logger.debug('CTL_UPSERT_FINALIZER_SETTING', {
309405
- metadata: { finalizer, kind, name: item.metadata.name, namespace },
309406
- });
309899
+ operator_src_logger.debug(`The ctl is setting the finalizer '${finalizer}' for '${kind}/${item.metadata.name}' in namespace '${namespace}'.`);
309407
309900
  const { kc, opts } = await ctl_getConnection();
309408
309901
  const url = `${kc.getCurrentCluster().server}/apis/firestartr.dev/v1/namespaces/${namespace}/${kind}/${item.metadata.name}`;
309409
309902
  opts.headers['Content-Type'] = 'application/json-patch+json';
@@ -309444,14 +309937,7 @@ async function upsertFinalizer(kind, namespace, item, finalizer) {
309444
309937
  async function unsetFinalizer(kind, namespace, item, finalizer) {
309445
309938
  const { kc, opts } = await ctl_getConnection();
309446
309939
  const name = typeof item === 'string' ? item : item.metadata.name;
309447
- src_logger.debug('CTL_REMOVE_FINALIZER', {
309448
- metadata: {
309449
- finalizer,
309450
- kind,
309451
- name,
309452
- namespace,
309453
- },
309454
- });
309940
+ operator_src_logger.debug(`The ctl is removing the finalizer '${finalizer}' from '${kind}/${name}' in namespace '${namespace}'.`);
309455
309941
  const url = `${kc.getCurrentCluster().server}/apis/firestartr.dev/v1/namespaces/${namespace}/${kind}/${name}`;
309456
309942
  opts.headers['Content-Type'] = 'application/json-patch+json';
309457
309943
  opts.headers['Accept'] = '*';
@@ -309513,8 +309999,7 @@ async function writePlanInGithubPR(prUrl, planText) {
309513
309999
  await github_0.pulls.commentInPR(message, +pr_number, repo, owner);
309514
310000
  }
309515
310001
  catch (err) {
309516
- console.error(err);
309517
- console.log('Cannot write plan in PR');
310002
+ operator_src_logger.error(`writePlanInGithubPR: Cannot write plan in PR: ${err}`);
309518
310003
  }
309519
310004
  }
309520
310005
  async function addApplyCommitStatus(cr, state, targetURL = '', description = '', context = '') {
@@ -309522,15 +310007,7 @@ async function addApplyCommitStatus(cr, state, targetURL = '', description = '',
309522
310007
  await addCommitStatusToPrMergeCommit(cr.metadata.annotations['firestartr.dev/last-state-pr'], state, targetURL, description, context);
309523
310008
  }
309524
310009
  catch (e) {
309525
- src_logger.error('CTL_ADD_APPLY_COMMIT_STATUS_ERROR', {
309526
- metadata: {
309527
- state,
309528
- targetURL,
309529
- description,
309530
- cr_metadata: cr.metadata,
309531
- error: e,
309532
- },
309533
- });
310010
+ log.error(`The ctl encountered an error while adding commit status for custom resource '${cr.metadata.name}' in namespace '${cr.metadata.namespace}'. State: '${state}'. Target URL: '${targetURL}'. Description: '${description}'. Error: '${e}'.`);
309534
310011
  }
309535
310012
  }
309536
310013
  async function addDestroyCommitStatus(cr, state, description = '', context = '') {
@@ -309539,50 +310016,33 @@ async function addDestroyCommitStatus(cr, state, description = '', context = '')
309539
310016
  await addCommitStatusToPrMergeCommit(prUrl, state, '', description, context);
309540
310017
  }
309541
310018
  catch (e) {
309542
- src_logger.error('CTL_ADD_DESTROY_COMMIT_STATUS_ERROR', {
309543
- metadata: {
309544
- state,
309545
- description,
309546
- cr_metadata: cr.metadata,
309547
- error: e,
309548
- },
309549
- });
310019
+ operator_src_logger.error(`The ctl encountered an error while adding the destroy commit status for custom resource '${cr.metadata.name}' in namespace '${cr.metadata.namespace}'. State: '${state}'. Description: '${description}'. Error: '${e}'.`);
309550
310020
  }
309551
310021
  }
309552
310022
  async function addPlanStatusCheck(prUrl, summary, status = 'in_progress', isFailure = false) {
309553
310023
  try {
309554
- src_logger.debug('CTL_ADD_PLAN_STATUS_CHECK_SUMMARY_LENGTH', {
309555
- metadata: { length: summary.length },
309556
- });
310024
+ operator_src_logger.debug(`The ctl is checking the length of the plan summary, which is '${summary.length}'.`);
309557
310025
  if (summary.length > MAX_CHARS_OUPUT_PLAN) {
309558
310026
  const mustDrop = summary.length - MAX_CHARS_OUPUT_PLAN;
309559
310027
  summary = summary.substring(mustDrop);
309560
- src_logger.debug('CTL_ADD_PLAN_STATUS_CHECK_SUMMARY_TOO_LENGTHY', {
309561
- metadata: { mustDrop, length: summary.length },
309562
- });
310028
+ operator_src_logger.debug(`The ctl found the plan summary too lengthy (length: '${summary.length}'). The summary must drop because '${mustDrop}'.`);
309563
310029
  }
309564
310030
  await ctl_addStatusCheck({ summary, title: 'Terraform Plan Results' }, isFailure, 'terraform_plan', prUrl, status);
309565
310031
  }
309566
310032
  catch (e) {
309567
- src_logger.error('CTL_ADD_PLAN_STATUS_CHECK_ERROR', {
309568
- metadata: { prUrl, status, isFailure, error: e },
309569
- });
310033
+ operator_src_logger.error(`The ctl encountered an error while adding plan status for PR '${prUrl}' with status '${status}'. Is Failure: '${isFailure}'. Error: '${e}'.`);
309570
310034
  }
309571
310035
  }
309572
310036
  async function ctl_addStatusCheck(output, isFailure, name, prAnnotationValue, status) {
309573
310037
  const { owner, repo, prNumber } = catalog_common.generic.getOwnerRepoPrNumberFromAnnotationValue(prAnnotationValue);
309574
310038
  const branchSha = await github_0.pulls.getPrLastCommitSHA(prNumber, repo, owner);
309575
- src_logger.info('CTL_ADD_STATUS_CHECK', {
309576
- metadata: { owner, repo, branchSha, prAnnotationValue, name },
309577
- });
310039
+ operator_src_logger.info(`The ctl is adding a status check for '${owner}/${repo}' on branch '${branchSha}' with PR annotation value '${prAnnotationValue}' and name '${name}'.`);
309578
310040
  await github_0.repo.addStatusCheck(output, isFailure, branchSha, name, status, repo, owner);
309579
310041
  }
309580
310042
  async function addCommitStatusToPrMergeCommit(prAnnotationValue, state, targetURL, description, context) {
309581
310043
  const { owner, repo, prNumber } = catalog_common.generic.getOwnerRepoPrNumberFromAnnotationValue(prAnnotationValue);
309582
310044
  const branchSha = await github_0.pulls.getPrMergeCommitSHA(prNumber, repo, owner);
309583
- src_logger.info('CTL_ADD_COMMIT_STATUS', {
309584
- metadata: { owner, repo, branchSha, state, targetURL },
309585
- });
310045
+ operator_src_logger.info(`The ctl is adding a commit status for '${owner}/${repo}' on branch '${branchSha}'. State: '${state}'. Target URL: '${targetURL}'.`);
309586
310046
  await github_0.repo.addCommitStatus(state, branchSha, repo, owner, targetURL, description, context);
309587
310047
  }
309588
310048
  async function getLastStatePrInfo(cr) {
@@ -309650,62 +310110,42 @@ async function observe(plural, namespace, onAdd, onChange, onDelete, _onRename)
309650
310110
  informer.on('add', (obj) => {
309651
310111
  store.add(obj);
309652
310112
  if (store.hasDeletionTimestamp(obj)) {
309653
- src_logger.info('REFLECTOR_ITEM_MARKED_TO_DELETION', {
309654
- metadata: { kind: obj.kind, name: obj.metadata.name },
309655
- });
310113
+ operator_src_logger.info(`Reflector has marked item '${obj.kind}/${obj.metadata.name}' for deletion.`);
309656
310114
  store.markToDelete(obj);
309657
310115
  onDelete(obj);
309658
310116
  }
309659
310117
  else {
309660
- src_logger.info('REFLECTOR_ITEM_ADDED', {
309661
- metadata: { kind: obj.kind, name: obj.metadata.name },
309662
- });
310118
+ operator_src_logger.info(`Reflector has added item '${obj.kind}/${obj.metadata.name}'.`);
309663
310119
  onAdd(obj);
309664
310120
  }
309665
310121
  });
309666
310122
  informer.on('update', (obj) => {
309667
- src_logger.info('REFLECTOR_ITEM_UPDATED', {
309668
- metadata: {
309669
- kind: obj.kind,
309670
- name: obj.metadata.name,
309671
- resourceVersion: obj.metadata.resourceVersion,
309672
- },
309673
- });
310123
+ operator_src_logger.info(`Reflector has updated item '${obj.kind}/${obj.metadata.name}' to a new resource version: '${obj.metadata.resourceVersion}'.`);
309674
310124
  if (!store.getItem(obj).markedToDelete &&
309675
310125
  store.hasDeletionTimestamp(obj) &&
309676
310126
  (store.hasBeenMarkedToDelete(obj) || store.modified(obj))) {
309677
- src_logger.info('REFLECTOR_ITEM_UPDATED_MARKED_TO_DELETION', {
309678
- metadata: { kind: obj.kind, name: obj.metadata.name },
309679
- });
310127
+ operator_src_logger.info(`Reflector has updated item '${obj.kind}/${obj.metadata.name}' and marked it for deletion.`);
309680
310128
  store.markToDelete(obj);
309681
310129
  onDelete(obj);
309682
310130
  }
309683
310131
  else if (store.modified(obj)) {
309684
- src_logger.info('REFLECTOR_ITEM_UPDATED_AND_MODIFIED', {
309685
- metadata: { kind: obj.kind, name: obj.metadata.name },
309686
- });
310132
+ operator_src_logger.info(`Reflector has updated and modified item '${obj.kind}/${obj.metadata.name}'.`);
309687
310133
  onChange(obj);
309688
310134
  }
309689
310135
  });
309690
310136
  informer.on('delete', (obj) => {
309691
310137
  // deleted from the etcd
309692
- src_logger.info('REFLECTOR_ITEM_DELETED', {
309693
- metadata: { kind: obj.kind, name: obj.metadata.name },
309694
- });
310138
+ operator_src_logger.info(`Reflector has deleted item '${obj.kind}/${obj.metadata.name}' from the etcd.`);
309695
310139
  store.remove(obj);
309696
310140
  });
309697
310141
  informer.on('error', (err) => {
309698
- src_logger.error('REFLECTOR_ITEM_ERROR', {
309699
- metadata: { error: err, plural, namespace },
309700
- });
310142
+ operator_src_logger.error(`An error occurred in the reflector for '${plural}' in namespace '${namespace}': '${err}'.`);
309701
310143
  setTimeout(async () => {
309702
310144
  try {
309703
310145
  await informer.start();
309704
310146
  }
309705
310147
  catch (err) {
309706
- src_logger.error('REFLECTOR_INFORMER_START_ERROR', {
309707
- metadata: { error: err, plural, namespace },
309708
- });
310148
+ operator_src_logger.error(`Failed to start the reflector informer for '${plural}' in namespace '${namespace}': '${err}'.`);
309709
310149
  }
309710
310150
  }, 5000);
309711
310151
  });
@@ -309725,13 +310165,13 @@ async function needsProvisioningOnCreate(cr) {
309725
310165
  const fCrLog = (cr) => `The item ${cr.kind}: ${cr.metadata.name}`;
309726
310166
  // NO STATUS
309727
310167
  if (!('status' in cr) || !('conditions' in cr.status)) {
309728
- src_logger.debug('STATUS_NO_STATUS_NOR_CONDITION', { metadata: { cr } });
310168
+ operator_src_logger.debug(`The custom resource '${cr.kind}/${cr.metadata.name}' is missing a status and any conditions.`);
309729
310169
  return true;
309730
310170
  }
309731
310171
  // ERROR
309732
310172
  const errCond = getConditionByType(cr.status.conditions, 'ERROR');
309733
310173
  if (errCond && errCond.status === 'True') {
309734
- src_logger.debug('STATUS_ERROR_SKIP_PROVISION', { metadata: { cr } });
310174
+ operator_src_logger.debug(`Skipping the provisioning process for custom resource '${cr.kind}/${cr.metadata.name}' due to a status error.`);
309735
310175
  return false;
309736
310176
  }
309737
310177
  // PROVISIONED
@@ -309739,7 +310179,7 @@ async function needsProvisioningOnCreate(cr) {
309739
310179
  if (provCond &&
309740
310180
  provCond.status === 'True' &&
309741
310181
  provCond.observedGeneration >= cr.metadata.generation) {
309742
- src_logger.debug('STATUS_ALREADY_PROVISIONED', { metadata: { cr } });
310182
+ operator_src_logger.debug(`The custom resource '${cr.kind}/${cr.metadata.name}' is already provisioned; skipping the process.`);
309743
310183
  return false;
309744
310184
  }
309745
310185
  // DELETED
@@ -309747,29 +310187,20 @@ async function needsProvisioningOnCreate(cr) {
309747
310187
  if (delCond &&
309748
310188
  delCond.status === 'True' &&
309749
310189
  delCond.observedGeneration >= cr.metadata.generation) {
309750
- src_logger.debug('STATUS_ALREADY_DELETED', { metadata: { cr } });
310190
+ operator_src_logger.debug(`The custom resource '${cr.kind}/${cr.metadata.name}' has already been deleted; no action is required.`);
309751
310191
  return false;
309752
310192
  }
309753
310193
  // PROVISIONING
309754
310194
  const provisioningCondition = getConditionByType(cr.status.conditions, 'PROVISIONING');
309755
310195
  if (provisioningCondition && provisioningCondition.status === 'True') {
309756
- src_logger.debug('STATUS_IN_PROVISIONING_REPROVISIONING', { metadata: { cr } });
310196
+ operator_src_logger.debug(`The custom resource '${cr.kind}/${cr.metadata.name}' is currently in a provisioning or reprovisioning state.`);
309757
310197
  return true;
309758
310198
  }
309759
- src_logger.debug('STATUS_NOT_HANDLED_STATE_SKIP_PROVISIONING', { metadata: { cr } });
310199
+ operator_src_logger.debug(`Skipping the provisioning process for custom resource '${cr.kind}/${cr.metadata.name}' because its current state is not handled.`);
309760
310200
  return false;
309761
310201
  }
309762
310202
  async function updateTransition(itemPath, reason, type, statusValue, message = '', updateStatusOnly = false) {
309763
- src_logger.info('STATUS_UPDATE_TRANSITION_FOR_ITEM', {
309764
- metadata: {
309765
- itemPath,
309766
- reason,
309767
- type,
309768
- statusValue,
309769
- message,
309770
- updateStatusOnly,
309771
- },
309772
- });
310203
+ operator_src_logger.info(`The item at '${itemPath}' transitioned to a new status of '${statusValue}' (type: '${type}'). The reason for the change is '${reason}' with the message: '${message}'. This was a status-only update: '${updateStatusOnly}'.`);
309773
310204
  const k8sItem = await getItemByItemPath(itemPath);
309774
310205
  if (!('status' in k8sItem))
309775
310206
  k8sItem.status = {};
@@ -309852,7 +310283,7 @@ async function syncer(enqueue) {
309852
310283
  void loop(enqueue);
309853
310284
  return {
309854
310285
  addItem(itemPath) {
309855
- src_logger.info('SYNC_ADD_ITEM', { metadata: { itemPath } });
310286
+ operator_src_logger.info(`Added item of path '${itemPath}' for synchronization`);
309856
310287
  void itemIsSyncable(itemPath).then((itemSyncInfo) => {
309857
310288
  if (!itemSyncInfo.syncable) {
309858
310289
  return;
@@ -309864,7 +310295,7 @@ async function syncer(enqueue) {
309864
310295
  }, helperCalculateRevisionTime(itemSyncInfo.period)),
309865
310296
  needsRevision: false,
309866
310297
  };
309867
- src_logger.info('Configured syncing for item %s %s', itemPath, syncWatchers[itemPath]);
310298
+ operator_src_logger.info(`Configured synchronization for item at path '${itemPath}'`);
309868
310299
  });
309869
310300
  },
309870
310301
  updateItem(itemPath) {
@@ -309872,13 +310303,13 @@ async function syncer(enqueue) {
309872
310303
  // log('Item %s not found, ignoring...', itemPath)
309873
310304
  // return
309874
310305
  //}
309875
- src_logger.debug('SYNC_UPDATE_ITEM', { metadata: { itemPath } });
310306
+ operator_src_logger.debug(`Updated item of path '${itemPath}' during synchronization`);
309876
310307
  void itemIsSyncable(itemPath).then((itemSyncInfo) => {
309877
310308
  if (!itemSyncInfo.syncable) {
309878
310309
  if (syncWatchers[itemPath]) {
309879
310310
  clearInterval(syncWatchers[itemPath].lastRevision);
309880
310311
  delete syncWatchers[itemPath];
309881
- src_logger.info('SYNC_REMOVE_FOR_ITEM', { metadata: { itemPath } });
310312
+ operator_src_logger.info(`Removed item of path '${itemPath}' from synchronization`);
309882
310313
  }
309883
310314
  }
309884
310315
  else {
@@ -309892,26 +310323,19 @@ async function syncer(enqueue) {
309892
310323
  }, helperCalculateRevisionTime(itemSyncInfo.period)),
309893
310324
  needsRevision: false,
309894
310325
  };
309895
- src_logger.debug('SYNC_CONFIGURED_FOR_ITEM', {
309896
- metadata: {
309897
- itemPath,
309898
- watcher: syncWatchers[itemPath],
309899
- },
309900
- });
310326
+ operator_src_logger.debug(`Configured synchronization for item at path '${itemPath}' with watcher '${syncWatchers[itemPath]}'`);
309901
310327
  }
309902
310328
  });
309903
310329
  },
309904
310330
  deleteItem(itemPath) {
309905
310331
  if (!syncWatchers[itemPath]) {
309906
- src_logger.debug('SYNC_DELETE_ITEM_NOT_FOUND_IGNORE', {
309907
- metadata: { itemPath },
309908
- });
310332
+ operator_src_logger.debug(`Ignored deletion attempt for item at path '${itemPath}' as it was not found during synchronization`);
309909
310333
  return;
309910
310334
  }
309911
- src_logger.debug('SYNC_DELETE_ITEM', { metadata: { itemPath } });
310335
+ operator_src_logger.debug(`Deleted item of path '${itemPath}' during synchronization`);
309912
310336
  clearInterval(syncWatchers[itemPath].lastRevision);
309913
310337
  delete syncWatchers[itemPath];
309914
- src_logger.debug('SYNC_DELETE_ITEM_DELETED', { metadata: { itemPath } });
310338
+ operator_src_logger.debug(`Successfully deleted item at path '${itemPath}' during synchronization`);
309915
310339
  },
309916
310340
  };
309917
310341
  }
@@ -309983,13 +310407,7 @@ async function initRetry(enqueue) {
309983
310407
  function retry(itemPath) {
309984
310408
  if (retryWatchers[itemPath]) {
309985
310409
  retryWatchers[itemPath].retryCounter++;
309986
- src_logger.debug('RETRY_FAILED', {
309987
- metadata: {
309988
- itemPath,
309989
- remainRetries: MAXRETRY - retryWatchers[itemPath].retryCounter,
309990
- nextRetry: NEXT_RETRY_SECS * retryWatchers[itemPath].retryCounter,
309991
- },
309992
- });
310410
+ operator_src_logger.debug(`Failed to process item '${itemPath}'. Retrying in '${NEXT_RETRY_SECS * retryWatchers[itemPath].retryCounter}' seconds. Remaining retries: '${MAXRETRY - retryWatchers[itemPath].retryCounter}'.`);
309993
310411
  retryWatchers[itemPath].retry = false;
309994
310412
  retryWatchers[itemPath].nextRetry = setTimeout(() => {
309995
310413
  if (itemPath in retryWatchers)
@@ -310040,12 +310458,7 @@ async function getItemIfNeededRetry(watcher) {
310040
310458
  }
310041
310459
  catch (e) {
310042
310460
  if (e.message && e.message.includes('Error on getItemByItemPath')) {
310043
- src_logger.debug('RETRY_ERROR_ITEM_NOT_FOUND', {
310044
- metadata: {
310045
- message: 'item not found, removed from the retry process',
310046
- itemPath: watcher.itemPath,
310047
- },
310048
- });
310461
+ operator_src_logger.debug(`Item '${watcher.itemPath}' not found, so it has been removed from the retry process.`);
310049
310462
  removeFromRetry(watcher.itemPath);
310050
310463
  return null;
310051
310464
  }
@@ -310085,9 +310498,7 @@ async function resolve(cr, getItemByItemPath, getSecret, namespace = 'default')
310085
310498
  async function resolveSecretRef(namespace, crDependency, getSecret) {
310086
310499
  let secretName = `${crDependency['kind']}-${crDependency['metadata']['name']}-outputs`.toLowerCase();
310087
310500
  if (crDependency.kind === 'FirestartrProviderConfig') {
310088
- src_logger.debug('RESOLVER_SKIP_SECRET_RESOLUTION_FOR', {
310089
- metadata: { kind: 'FirestartrProviderConfig', namespace, crDependency },
310090
- });
310501
+ operator_src_logger.debug(`The resolver is skipping secret resolution for '${crDependency.kind}/${crDependency.metadata.name}' of kind 'FirestartrProviderConfig' in namespace '${namespace}'.`);
310091
310502
  return undefined;
310092
310503
  }
310093
310504
  if (crDependency.kind === 'ExternalSecret') {
@@ -310095,9 +310506,7 @@ async function resolveSecretRef(namespace, crDependency, getSecret) {
310095
310506
  }
310096
310507
  const secret = await getSecret(namespace, secretName);
310097
310508
  if (!secret) {
310098
- src_logger.error('RESOLVER_SECRET_NOT_SOLVABLE', {
310099
- metadata: { secretName, crDependency, namespace },
310100
- });
310509
+ operator_src_logger.error(`The resolver could not find the secret '${secretName}' required by custom resource dependency '${crDependency}' in namespace '${namespace}'.`);
310101
310510
  console.error(`Could not resolve secret ${secretName}`);
310102
310511
  }
310103
310512
  return secret;
@@ -310233,9 +310642,7 @@ const kindsWithFinalizer = [
310233
310642
  */
310234
310643
  async function observeKind(pluralKind, namespace, queue, compute) {
310235
310644
  const lastWorkItems = {};
310236
- src_logger.info('INFORMER_OBSERVE_START', {
310237
- metadata: { kind: pluralKind, namespace },
310238
- });
310645
+ operator_src_logger.info(`The informer has started observing the '${pluralKind}' resource in namespace '${namespace}'.`);
310239
310646
  // onSync
310240
310647
  const enqueueCallback = (event) => {
310241
310648
  return async (item) => {
@@ -310252,13 +310659,7 @@ async function observeKind(pluralKind, namespace, queue, compute) {
310252
310659
  await observe(pluralKind, namespace,
310253
310660
  // on add
310254
310661
  async (item) => {
310255
- src_logger.info('INFORMER_ON_ITEM_ADDED', {
310256
- metadata: {
310257
- kind: pluralKind,
310258
- namespace,
310259
- name: item.metadata.name,
310260
- },
310261
- });
310662
+ operator_src_logger.info(`The informer has detected a new item, '${item.metadata.name}', for '${pluralKind}' in namespace '${namespace}'.`);
310262
310663
  await handleUpsertFinalizer(pluralKind, namespace, item);
310263
310664
  const workItem = await inform(pluralKind, item, 'onAdd', getLastWorkItem(pluralKind, lastWorkItems, item));
310264
310665
  syncCtl.addItem(informer_itemPath(pluralKind, item));
@@ -310269,13 +310670,7 @@ async function observeKind(pluralKind, namespace, queue, compute) {
310269
310670
  },
310270
310671
  // on modify
310271
310672
  async (item) => {
310272
- src_logger.info('INFORMER_ON_ITEM_MODIFIED', {
310273
- metadata: {
310274
- kind: pluralKind,
310275
- namespace,
310276
- name: item.metadata.name,
310277
- },
310278
- });
310673
+ operator_src_logger.info(`The informer has detected that item '${item.metadata.name}' for '${pluralKind}' in namespace '${namespace}' was modified.`);
310279
310674
  const workItem = await inform(pluralKind, item, 'onUpdate', getLastWorkItem(pluralKind, lastWorkItems, item));
310280
310675
  if (workItem) {
310281
310676
  setLastWorkItem(pluralKind, lastWorkItems, item, workItem);
@@ -310284,13 +310679,7 @@ async function observeKind(pluralKind, namespace, queue, compute) {
310284
310679
  },
310285
310680
  // on delete
310286
310681
  async (item) => {
310287
- src_logger.info('INFORMER_ON_ITEM_DELETED', {
310288
- metadata: {
310289
- kind: pluralKind,
310290
- namespace,
310291
- name: item.metadata.name,
310292
- },
310293
- });
310682
+ operator_src_logger.info(`The informer has detected that item '${item.metadata.name}' for '${pluralKind}' in namespace '${namespace}' was deleted.`);
310294
310683
  const workItem = await inform(pluralKind, item, 'onMarkedToDeletion', getLastWorkItem(pluralKind, lastWorkItems, item));
310295
310684
  if (workItem) {
310296
310685
  setLastWorkItem(pluralKind, lastWorkItems, item, workItem);
@@ -310300,17 +310689,11 @@ async function observeKind(pluralKind, namespace, queue, compute) {
310300
310689
  },
310301
310690
  // on rename
310302
310691
  async (item) => {
310303
- src_logger.info('INFORMER_ON_ITEM_RENAMED', {
310304
- metadata: {
310305
- kind: pluralKind,
310306
- namespace,
310307
- name: item.metadata.name,
310308
- },
310309
- });
310692
+ operator_src_logger.info(`The informer has detected that an item for '${pluralKind}' in namespace '${namespace}' has been renamed to '${item.metadata.name}'.`);
310310
310693
  const workItem = await inform(pluralKind, item, 'onRename', getLastWorkItem(pluralKind, lastWorkItems, item));
310311
310694
  // Add the renamed item to the sync queue
310312
310695
  syncCtl.addItem(informer_itemPath(pluralKind, item));
310313
- src_logger.debug('INFORMER_RENAMING_ITEM', { metadata: { workItem } });
310696
+ operator_src_logger.debug(`The informer is renaming item '${workItem.item.metadata.name}' of kind '${workItem.item.kind}' due to a change in its name.`);
310314
310697
  if (workItem) {
310315
310698
  const oldName = workItem.item.metadata.labels[catalog_common.types.controller.FirestartrLabelOldName];
310316
310699
  await handleUnsetFinalizer(pluralKind, namespace, item);
@@ -310371,7 +310754,7 @@ function enqueue(pluralKind, workItem, queue, compute, syncCtl, retryCtl) {
310371
310754
  syncCtl.updateItem(informer_itemPath(pluralKind, item));
310372
310755
  }
310373
310756
  else {
310374
- src_logger.debug('INFORMER_NOT_SPEC_OPERATION', { metadata: { operation } });
310757
+ operator_src_logger.debug(`The informer received an item with an operation type of '${operation}', which is not a specific operation.`);
310375
310758
  }
310376
310759
  };
310377
310760
  queue(workItem);
@@ -310414,9 +310797,7 @@ async function inform(pluralKind, item, op, lastWorkItem = null) {
310414
310797
  return workItem;
310415
310798
  case 'onRename':
310416
310799
  if (await needsProvisioningOnCreate(item)) {
310417
- src_logger.debug('INFORMER_ON_RENAME_NEEDS_PROVISION_ON_CREATE', {
310418
- metadata: { item },
310419
- });
310800
+ operator_src_logger.debug(`The informer is triggering a new provisioning process for the renamed item '${item.kind}/${item.metadata.name}'.`);
310420
310801
  workItem = {
310421
310802
  operation: OperationType.RENAMED,
310422
310803
  item,
@@ -310688,15 +311069,7 @@ let INIT = false;
310688
311069
  * @param {WorkItem} workItem - WorkItem to process
310689
311070
  */
310690
311071
  async function processItem(workItem) {
310691
- src_logger.info('PROCESSOR_NEW_WORKITEM', {
310692
- metadata: {
310693
- operation: workItem.operation,
310694
- workStatus: workItem.workStatus,
310695
- kind: workItem.item.kind,
310696
- name: workItem.item.metadata.name,
310697
- namespace: workItem.item.metadata.namespace,
310698
- },
310699
- });
311072
+ operator_src_logger.info(`The processor received a new work item for '${workItem.operation}' operation on '${workItem.item.kind}/${workItem.item.metadata.name}' in namespace '${workItem.item.metadata.namespace}'. Current work status is '${workItem.workStatus}'.`);
310700
311073
  queue.push(workItem);
310701
311074
  if (!INIT) {
310702
311075
  processItem_loop().catch((err) => {
@@ -310717,15 +311090,7 @@ async function processItem_loop() {
310717
311090
  const logMessage = `${new Date().toISOString()} : Processing OPERATION: ${w.operation} ITEM: ${w.item.kind}/${w.item.metadata.name}`;
310718
311091
  catalog_common.io.writeLogFile('process_item', logMessage);
310719
311092
  const timeout = createTimeout(w);
310720
- src_logger.info('PROCESSOR_PROCESSING_WORKITEM', {
310721
- metadata: {
310722
- operation: w.operation,
310723
- workStatus: w.workStatus,
310724
- kind: w.item.kind,
310725
- name: w.item.metadata.name,
310726
- namespace: w.item.metadata.namespace,
310727
- },
310728
- });
311093
+ 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}'.`);
310729
311094
  await runWorkItem(w);
310730
311095
  clearTimeout(timeout);
310731
311096
  }
@@ -310741,15 +311106,7 @@ function createTimeout(w) {
310741
311106
  return setTimeout(() => {
310742
311107
  //throw new Error('Timeout on workitem ' + w);
310743
311108
  console.error('Timeout on workitem %O', w);
310744
- src_logger.error('PROCESSOR_TIMEOUT_ON_WORKITEM', {
310745
- metadata: {
310746
- operation: w.operation,
310747
- workStatus: w.workStatus,
310748
- kind: w.item.kind,
310749
- name: w.item.metadata.name,
310750
- namespace: w.item.metadata.namespace,
310751
- },
310752
- });
311109
+ 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}'.`);
310753
311110
  process.exit(1);
310754
311111
  }, TIMEOUTS[w.operation] * 1000);
310755
311112
  }
@@ -310775,7 +311132,7 @@ function processItem_wait(t = 2000) {
310775
311132
  return new Promise((ok) => setTimeout(ok, t));
310776
311133
  }
310777
311134
  async function runWorkItem(workItem) {
310778
- src_logger.debug('PROCESSOR_RUNNING_WORK_ITEM', { metadata: { workItem } });
311135
+ operator_src_logger.debug(`The processor is now running the '${workItem.operation}' operation for item '${workItem.item.kind}/${workItem.item.metadata.name}' in namespace '${workItem.item.metadata.namespace}'.`);
310779
311136
  if (!workItem.getItem || !workItem.process || !workItem.operation)
310780
311137
  return;
310781
311138
  try {
@@ -310787,33 +311144,17 @@ async function runWorkItem(workItem) {
310787
311144
  await updateTransition(workItem.handler.itemPath(), condition.reason, condition.type, condition.status, condition.message, condition.updateStatusOnly || false);
310788
311145
  }
310789
311146
  workItem.workStatus = WorkStatus.FINISHED;
310790
- src_logger.debug('PROCESSOR_REMAIN_ITEMS_IN_QUEUE', {
310791
- metadata: { remainingItems: queue.length },
310792
- });
311147
+ operator_src_logger.debug(`The processor has '${queue.length}' items remaining in the queue.`);
310793
311148
  }
310794
311149
  catch (e) {
310795
311150
  if (e instanceof Error &&
310796
311151
  e.message.includes('Error on getItemByItemPath')) {
310797
- src_logger.debug('PROCESSOR_ERROR_ITEM_NOT_FOUND', {
310798
- metadata: {
310799
- workItem,
310800
- message: 'item was not found, removing work item from queue',
310801
- },
310802
- });
311152
+ operator_src_logger.debug(`Item '${workItem.item.kind}/${workItem.item.metadata.name}' was not found, so its work item is being removed from the processor queue.`);
310803
311153
  workItem.workStatus = WorkStatus.FINISHED;
310804
311154
  return;
310805
311155
  }
310806
311156
  else {
310807
- src_logger.error('PROCESSOR_ERROR_PROCESSING_WORKITEM', {
310808
- metadata: {
310809
- operation: workItem.operation,
310810
- workStatus: workItem.workStatus,
310811
- kind: workItem.item.kind,
310812
- name: workItem.item.metadata.name,
310813
- namespace: workItem.item.metadata.namespace,
310814
- error: e,
310815
- },
310816
- });
311157
+ operator_src_logger.error(`An error occurred while the processor was handling the '${workItem.operation}' operation for item '${workItem.item.kind}/${workItem.item.metadata.name}' in namespace '${workItem.item.metadata.namespace}'. Current work status is '${workItem.workStatus}'. The error was: '${e}'.`);
310817
311158
  console.error(e);
310818
311159
  }
310819
311160
  return;
@@ -310825,11 +311166,7 @@ async function runWorkItem(workItem) {
310825
311166
  */
310826
311167
  async function workItemGarbageCollector(queue) {
310827
311168
  while (1) {
310828
- src_logger.debug('PROCESS_ITEM_GARBAGE_COLLECTOR_RUN', {
310829
- metadata: {
310830
- workItemsFound: queue.length,
310831
- },
310832
- });
311169
+ operator_src_logger.debug(`The garbage collector processed '${queue.length}' work items.`);
310833
311170
  for (const [index, wi] of queue.entries()) {
310834
311171
  if (wi.workStatus === WorkStatus.FINISHED) {
310835
311172
  // Because the queue is a constant, we cannot reassign it, instead we
@@ -310838,11 +311175,7 @@ async function workItemGarbageCollector(queue) {
310838
311175
  queue.splice(index, 1);
310839
311176
  }
310840
311177
  }
310841
- src_logger.debug('PROCESS_ITEM_GARBAGE_COLLECTOR_FINISHED', {
310842
- metadata: {
310843
- workItemsLeft: queue.length,
310844
- },
310845
- });
311178
+ operator_src_logger.debug(`The garbage collector finished its run, leaving '${queue.length}' work items in the queue.`);
310846
311179
  await processItem_wait(10 * 1000);
310847
311180
  }
310848
311181
  }
@@ -310854,11 +311187,14 @@ if (process.env.GARBAGE_QUEUE_COLLECTOR) {
310854
311187
  var cdktf_lib = __nccwpck_require__(95933);
310855
311188
  // EXTERNAL MODULE: ../../node_modules/@cdktf/provider-github/lib/provider/index.js
310856
311189
  var lib_provider = __nccwpck_require__(95107);
310857
- ;// CONCATENATED MODULE: ../provisioner/src/entities/base/Entity.ts
311190
+ ;// CONCATENATED MODULE: ../provisioner/src/logger.ts
310858
311191
 
311192
+ /* harmony default export */ const provisioner_src_logger = (catalog_common.logger);
311193
+
311194
+ ;// CONCATENATED MODULE: ../provisioner/src/entities/base/Entity.ts
310859
311195
 
310860
- const Entity_log = src_default()('firestartr:provisioner:entity:base');
310861
311196
  const EXTERNAL_NAME_ANNOTATION = 'firestartr.dev/external-name';
311197
+
310862
311198
  class Metadata {
310863
311199
  constructor(metadata) {
310864
311200
  this._metadata = metadata;
@@ -310905,11 +311241,13 @@ class Entity {
310905
311241
  }
310906
311242
  resolveRef(ref, propertyRef) {
310907
311243
  if (!this.deps) {
310908
- throw `resolveRef:
311244
+ const ErrorMessage = `resolveRef:
310909
311245
 
310910
311246
  Entity with kind ${this.kind} ${this.metadata.name}
310911
311247
 
310912
311248
  does not have any dependencies`;
311249
+ provisioner_src_logger.error(ErrorMessage);
311250
+ throw new Error(ErrorMessage);
310913
311251
  }
310914
311252
  const { kind, name, needsSecret } = ref;
310915
311253
  if (!needsSecret) {
@@ -310918,22 +311256,26 @@ class Entity {
310918
311256
  }
310919
311257
  else {
310920
311258
  if (!propertyRef) {
310921
- throw `resolveRef:
311259
+ const ErrorMessage = `resolveRef:
310922
311260
 
310923
311261
  Entity with kind ${this.kind} ${this.metadata.name}
310924
311262
 
310925
311263
  needs a propertyRef to resolve the secret`;
311264
+ provisioner_src_logger.error(ErrorMessage);
311265
+ throw new Error(ErrorMessage);
310926
311266
  }
310927
311267
  return Buffer.from(this.deps[`${kind}-${name}`].secret.data[propertyRef], 'base64').toString('utf8');
310928
311268
  }
310929
311269
  }
310930
311270
  resolveSecretRef(ref) {
310931
311271
  if (!this.deps) {
310932
- throw `resolveSecretRef:
311272
+ const ErrorMessage = `resolveSecretRef:
310933
311273
 
310934
311274
  Entity with kind ${this.kind} ${this.metadata.name}
310935
311275
 
310936
311276
  does not have any dependencies`;
311277
+ provisioner_src_logger.error(ErrorMessage);
311278
+ throw new Error(ErrorMessage);
310937
311279
  }
310938
311280
  const { name, key } = ref;
310939
311281
  return Buffer.from(this.deps[`Secret-${name}`].cr.data[key], 'base64').toString('utf8');
@@ -310941,11 +311283,13 @@ class Entity {
310941
311283
  resolveOutputs(scope) {
310942
311284
  if (this.spec.writeConnectionSecretToRef) {
310943
311285
  if (!this.mainResource) {
310944
- throw `resolveOutputs:
311286
+ const ErrorMessage = `resolveOutputs:
310945
311287
 
310946
311288
  Entity with kind ${this.kind} ${this.metadata.name}
310947
311289
 
310948
311290
  does not have a mainResource`;
311291
+ provisioner_src_logger.error(ErrorMessage);
311292
+ throw new Error(ErrorMessage);
310949
311293
  }
310950
311294
  /**
310951
311295
  * We don't currently support writing outputs to modules
@@ -310955,13 +311299,15 @@ class Entity {
310955
311299
  const keys = this.getKeysFrom(this.mainResource);
310956
311300
  const outputs = this.spec.writeConnectionSecretToRef.outputs;
310957
311301
  for (const o of outputs) {
310958
- Entity_log('OUTPUT %s', o.key);
311302
+ provisioner_src_logger.debug('OUTPUT %s', o.key);
310959
311303
  if (!keys.includes(o.key)) {
310960
- throw `resolveOutputs:
311304
+ const ErrorMessage = `resolveOutputs:
310961
311305
 
310962
311306
  Entity with kind ${this.kind} ${this.metadata.name}
310963
311307
 
310964
311308
  does not have the output ${o.key}`;
311309
+ provisioner_src_logger.error(ErrorMessage);
311310
+ throw new Error(ErrorMessage);
310965
311311
  }
310966
311312
  new cdktf_lib.TerraformOutput(scope, o.key, {
310967
311313
  value: this.mainResource.getAnyMapAttribute(this.camelToSnake(o.key)),
@@ -310994,7 +311340,6 @@ var repository_file = __nccwpck_require__(79507);
310994
311340
  ;// CONCATENATED MODULE: ../provisioner/src/entities/firestartrgithubrepository/helpers/CodeownersHelper.ts
310995
311341
 
310996
311342
 
310997
- const CodeownersHelper_messageLog = src_default()('firestartr:provisioner:entities:component:helpers:codeownerscreator');
310998
311343
  function provisionCodeowners(scope, repo, branchDefault, fsGithubRepository) {
310999
311344
  const config = {
311000
311345
  dependsOn: [repo, branchDefault],
@@ -311005,7 +311350,7 @@ function provisionCodeowners(scope, repo, branchDefault, fsGithubRepository) {
311005
311350
  overwriteOnCreate: true,
311006
311351
  repository: repo.name,
311007
311352
  };
311008
- CodeownersHelper_messageLog(`Content of the codeowners: ${fsGithubRepository.spec.repo.codeowners}`);
311353
+ provisioner_src_logger.debug(`Content of the codeowners: ${fsGithubRepository.spec.repo.codeowners}`);
311009
311354
  const tfStateKey = `_${fsGithubRepository.getTfStateKey()}-codeowners`;
311010
311355
  new repository_file/* RepositoryFile */.h(scope, tfStateKey, config);
311011
311356
  }
@@ -311018,9 +311363,8 @@ var repository_collaborator = __nccwpck_require__(33786);
311018
311363
 
311019
311364
 
311020
311365
 
311021
- const RepositoryTeamsHelper_messageLog = src_default()('firestartr:provisioner:entities:component:helpers:repositoryteamshelper');
311022
311366
  function provisionPermissions(scope, repo, fsGithubRepository) {
311023
- RepositoryTeamsHelper_messageLog(`provisionRepositoryTeams with name ${fsGithubRepository.metadata.name} in org ${fsGithubRepository.spec.org}`);
311367
+ provisioner_src_logger.info(`provisionRepositoryTeams with name ${fsGithubRepository.metadata.name} in org ${fsGithubRepository.spec.org}`);
311024
311368
  for (const permission of fsGithubRepository.spec.permissions) {
311025
311369
  if ('ref' in permission) {
311026
311370
  const tfStateKey = `_${fsGithubRepository.getTfStateKey()}-${permission.ref.kind}-${permission.ref.name}-tr`;
@@ -311066,9 +311410,8 @@ var branch_protection_v3 = __nccwpck_require__(31706);
311066
311410
 
311067
311411
 
311068
311412
 
311069
- const RepositoryHelper_messageLog = src_default()('firestartr:provisioner:entities:component:helpers:repositoryhelper');
311070
311413
  function provisionRepository(scope, fsGithubRepository) {
311071
- RepositoryHelper_messageLog(`provisionRepository with name ${fsGithubRepository.metadata.name} in org ${fsGithubRepository.spec.org}`);
311414
+ provisioner_src_logger.info(`provisionRepository with name ${fsGithubRepository.metadata.name} in org ${fsGithubRepository.spec.org}`);
311072
311415
  const config = {
311073
311416
  name: fsGithubRepository.metadata.name,
311074
311417
  description: fsGithubRepository.spec.repo.description,
@@ -311105,7 +311448,7 @@ function provisionRepository(scope, fsGithubRepository) {
311105
311448
  return repo;
311106
311449
  }
311107
311450
  function provisionBranchProtections(scope, repo, fsGithubRepository) {
311108
- RepositoryHelper_messageLog(`provisionBranchProtections with name ${fsGithubRepository.metadata.name} in org ${fsGithubRepository.spec.org}`);
311451
+ provisioner_src_logger.info(`provisionBranchProtections with name ${fsGithubRepository.metadata.name} in org ${fsGithubRepository.spec.org}`);
311109
311452
  for (const branchProtection of fsGithubRepository.spec.branchProtections) {
311110
311453
  const tfStateKey = `_${fsGithubRepository.getTfStateKey()}-${branchProtection.pattern}-bp`;
311111
311454
  const statusChecks = {
@@ -311130,8 +311473,6 @@ function provisionBranchProtections(scope, repo, fsGithubRepository) {
311130
311473
 
311131
311474
  ;// CONCATENATED MODULE: ../provisioner/src/config/config.ts
311132
311475
 
311133
-
311134
- const config_messageLog = src_default()('firestartr:provisioner:config');
311135
311476
  /**
311136
311477
  * @description Valid plans for the account
311137
311478
  * @type {Set<string>}
@@ -311238,13 +311579,12 @@ class FirestartrGithubRepository_FirestartrGithubRepository extends Entity {
311238
311579
 
311239
311580
 
311240
311581
 
311241
- const provisioner_messageLog = src_default()('firestartr:provisioner:features:provisioner');
311242
311582
  function provisionFeatureFiles(scope, feature) {
311243
- provisioner_messageLog(`Provisioning feature ${feature.spec.type} for ${feature.spec.repositoryTarget.name}`);
311244
- provisioner_messageLog('Feature output json: %O', feature);
311583
+ provisioner_src_logger.info(`Provisioning feature ${feature.spec.type} for ${feature.spec.repositoryTarget.name}`);
311584
+ provisioner_src_logger.debug('Feature output json: %O', feature);
311245
311585
  if (feature.spec.files) {
311246
311586
  for (const file of feature.spec.files) {
311247
- provisioner_messageLog('Provisioning file %O', file);
311587
+ provisioner_src_logger.debug('Provisioning file %O', file);
311248
311588
  const lifecycleArg = file.userManaged
311249
311589
  ? { ignoreChanges: ['content'] }
311250
311590
  : {};
@@ -311279,8 +311619,6 @@ class FirestartrGithubRepositoryFeature_FirestartrGithubRepositoryFeature extend
311279
311619
  var lib_membership = __nccwpck_require__(27501);
311280
311620
  ;// CONCATENATED MODULE: ../provisioner/src/entities/firestartrgithubmembership/helpers/MembershipHelper.ts
311281
311621
 
311282
-
311283
- const MembershipHelper_messageLog = src_default()('firestartr:provisioner:modules:artifacts:userartifact');
311284
311622
  function provisionMembership(scope, fsGithubMembership) {
311285
311623
  const tfStateKey = `_${fsGithubMembership.getTfStateKey()}`;
311286
311624
  const membership = new lib_membership/* Membership */.E(scope, tfStateKey, {
@@ -311295,8 +311633,6 @@ function provisionMembership(scope, fsGithubMembership) {
311295
311633
  var team_membership = __nccwpck_require__(93268);
311296
311634
  ;// CONCATENATED MODULE: ../provisioner/src/entities/firestartrgithubmembership/helpers/MembershipAllGroupHelper.ts
311297
311635
 
311298
-
311299
- const MembershipAllGroupHelper_messageLog = src_default()('firestartr:provisioner:modules:artifacts:membership:all-group-helper');
311300
311636
  function provisionAllGroupMembershipRelation(scope, fsGithubMembership) {
311301
311637
  const tfStateKey = `_${fsGithubMembership.getTfStateKey()}`;
311302
311638
  const config = {
@@ -311327,11 +311663,10 @@ class FirestartrGithubMembership_FirestartrGithubMembership extends Entity {
311327
311663
  var lib_team = __nccwpck_require__(57889);
311328
311664
  ;// CONCATENATED MODULE: ../provisioner/src/entities/firestartrgithubgroup/helpers/TeamsHelper.ts
311329
311665
 
311330
-
311331
311666
  // import { TeamConfigAux } from '../auxiliars/TeamConfigAux';
311332
- const TeamsHelper_messageLog = src_default()('firestartr:provisioner:entities:component:helpers:repositoryhelper');
311667
+
311333
311668
  function provisionGroup(scope, fsGithubGroup) {
311334
- TeamsHelper_messageLog(`provisionGroup with name ${fsGithubGroup.metadata.name} in org ${fsGithubGroup.spec.org}`);
311669
+ provisioner_src_logger.info(`provisionGroup with name ${fsGithubGroup.metadata.name} in org ${fsGithubGroup.spec.org}`);
311335
311670
  const config = {
311336
311671
  name: fsGithubGroup.metadata.name,
311337
311672
  description: fsGithubGroup.spec.description,
@@ -311349,11 +311684,10 @@ function provisionGroup(scope, fsGithubGroup) {
311349
311684
  ;// CONCATENATED MODULE: ../provisioner/src/entities/firestartrgithubgroup/helpers/TeamMembersHelper.ts
311350
311685
 
311351
311686
 
311352
- const TeamMembersHelper_messageLog = src_default()('firestartr:provisioner:entities:component:helpers:teamsmembershiphelper');
311353
311687
  function provisionMembers(scope, team, fsGithubGroup) {
311354
- TeamMembersHelper_messageLog(`provisionMembers of group ${fsGithubGroup.metadata.name} in org ${fsGithubGroup.spec.org}`);
311688
+ provisioner_src_logger.info(`provisionMembers of group ${fsGithubGroup.metadata.name} in org ${fsGithubGroup.spec.org}`);
311355
311689
  for (const member of fsGithubGroup.spec.members) {
311356
- TeamMembersHelper_messageLog(`Provisioning user ${member.ref.name} for group ${fsGithubGroup.metadata.name}`);
311690
+ provisioner_src_logger.info(`Provisioning user ${member.ref.name} for group ${fsGithubGroup.metadata.name}`);
311357
311691
  const tfStateKey = `_${fsGithubGroup.getTfStateKey()}-${member.ref.kind}-${member.ref.name}-tr`;
311358
311692
  if (member.ref.kind === 'FirestartrGithubMembership') {
311359
311693
  const username = fsGithubGroup.resolveRef(member.ref);
@@ -311388,8 +311722,6 @@ class FirestartrGithubGroup_FirestartrGithubGroup extends Entity {
311388
311722
  var organization_webhook = __nccwpck_require__(80516);
311389
311723
  ;// CONCATENATED MODULE: ../provisioner/src/entities/firestartrgithuborgwebhook/helpers/OrgWebhookHelper.ts
311390
311724
 
311391
-
311392
- const OrgWebhookHelper_messageLog = src_default()('firestartr:provisioner:modules:artifacts:orgwebhook');
311393
311725
  function provisionOrgWebhook(scope, fsGithubOrgWebhook) {
311394
311726
  const tfStateKey = `_${fsGithubOrgWebhook.getTfStateKey()}`;
311395
311727
  const webhookConfig = {
@@ -311655,7 +311987,6 @@ var FirestartrTerraformProvider;
311655
311987
 
311656
311988
 
311657
311989
 
311658
- const GithubStack_messageLog = src_default()('firestartr:provisioner:stacks:githubstack');
311659
311990
  class GithubStack extends BaseStack {
311660
311991
  async provisionEntity(isImport, entity, deps, tfStatePath, orgConfig) {
311661
311992
  try {
@@ -311671,7 +312002,7 @@ class GithubStack extends BaseStack {
311671
312002
  }
311672
312003
  }
311673
312004
  catch (err) {
311674
- GithubStack_messageLog('Error: provisionEntity: %s', err);
312005
+ provisioner_src_logger.error('Error: provisionEntity: %s', err);
311675
312006
  throw err;
311676
312007
  }
311677
312008
  }
@@ -311692,7 +312023,6 @@ class GithubStack extends BaseStack {
311692
312023
 
311693
312024
 
311694
312025
 
311695
- const TerraformModuleStack_messageLog = src_default()('firestartr:provisioner:stacks:terraformmodulestack');
311696
312026
  class TerraformModuleStack extends BaseStack {
311697
312027
  async provisionEntity(isImport, entity, deps, tfStatePath, orgConfig) {
311698
312028
  try {
@@ -311705,7 +312035,7 @@ class TerraformModuleStack extends BaseStack {
311705
312035
  }
311706
312036
  }
311707
312037
  catch (err) {
311708
- TerraformModuleStack_messageLog('Error: provisionEntity: %s', err);
312038
+ provisioner_src_logger.error('Error: provisionEntity: %s', err);
311709
312039
  throw err;
311710
312040
  }
311711
312041
  }
@@ -311761,9 +312091,10 @@ function __calculateTFStatePath(entity) {
311761
312091
  ;// CONCATENATED MODULE: ../provisioner/src/cdktf.ts
311762
312092
 
311763
312093
 
311764
- async function runCDKTF(entityPath, action, depsPath) {
312094
+ async function runCDKTF(entityPath, action, depsPath, stream) {
311765
312095
  return new Promise((ok, ko) => {
311766
312096
  const cdktfProcess = (0,external_child_process_.spawn)('cdktf', [action, '--log-level', 'DEBUG', '--auto-approve'], {
312097
+ stdio: ['inherit', 'pipe', 'pipe'],
311767
312098
  cwd: process.env.IS_DEV_LOCAL_ENVIRONMENT
311768
312099
  ? '/library/packages/provisioner'
311769
312100
  : '/library/provisioner',
@@ -311791,10 +312122,14 @@ async function runCDKTF(entityPath, action, depsPath) {
311791
312122
  const logparsed = log.toString();
311792
312123
  if (!logparsed.includes('Synthesizing')) {
311793
312124
  output += catalog_common.io.stripAnsi(logparsed);
312125
+ if (stream)
312126
+ stream.write(catalog_common.io.stripAnsi(logparsed));
311794
312127
  }
311795
312128
  });
311796
312129
  cdktfProcess.stderr.on('data', (log) => {
311797
312130
  output += catalog_common.io.stripAnsi(log.toString());
312131
+ if (stream)
312132
+ stream.write(catalog_common.io.stripAnsi(log.toString()));
311798
312133
  });
311799
312134
  cdktfProcess.on('exit', async (code) => {
311800
312135
  if (code !== 0) {
@@ -311812,7 +312147,6 @@ async function runCDKTF(entityPath, action, depsPath) {
311812
312147
 
311813
312148
 
311814
312149
 
311815
- const installer_messageLog = src_default()('firestartr:provisioner:features:installer');
311816
312150
  async function installer_installFeaturesForComponent(component, store) {
311817
312151
  const componentFeatures = component.spec?.provisioner?.features || '[]';
311818
312152
  const componentFeaturesToInstall = componentFeatures.filter((feature) => {
@@ -311821,7 +312155,7 @@ async function installer_installFeaturesForComponent(component, store) {
311821
312155
  });
311822
312156
  if (componentFeaturesToInstall.length > 0) {
311823
312157
  for (const feature of componentFeaturesToInstall) {
311824
- installer_messageLog('Installing feature %s for component %s', feature.name, component.metadata.name);
312158
+ log.info('Installing feature %s for component %s', feature.name, component.metadata.name);
311825
312159
  // Get feature config
311826
312160
  const featureConfig = common.features.features.getFeatureRenderedConfigForComponent(component, feature.name);
311827
312161
  // prepare files
@@ -311834,7 +312168,7 @@ async function installer_installFeaturesForComponent(component, store) {
311834
312168
  }
311835
312169
  }
311836
312170
  else {
311837
- installer_messageLog(`No features to install for component ${component.metadata.name}`);
312171
+ log.error(`No features to install for component ${component.metadata.name}`);
311838
312172
  }
311839
312173
  return store;
311840
312174
  }
@@ -311861,7 +312195,7 @@ async function getFileContentFromGithubIfExists(path, repositoryName, owner) {
311861
312195
  }
311862
312196
  catch (e) {
311863
312197
  if (e.status === 404) {
311864
- installer_messageLog(`File ${path} not found in ${repositoryName}`);
312198
+ log.debug(`File ${path} not found in ${repositoryName}`);
311865
312199
  return false;
311866
312200
  }
311867
312201
  throw e;
@@ -311886,7 +312220,6 @@ function isFreshInstallation(featureName, component) {
311886
312220
 
311887
312221
 
311888
312222
 
311889
- const preparer_messageLog = src_default()('firestartr:provisioner:features:installer');
311890
312223
  async function preparer_prepareFeaturesForComponent(component, store) {
311891
312224
  // those are the features to maintain
311892
312225
  let componentFeatures = component.spec?.provisioner?.features || [];
@@ -311901,7 +312234,7 @@ async function preparer_prepareFeaturesForComponent(component, store) {
311901
312234
  if (componentFeatures.length > 0) {
311902
312235
  const entityPath = dumpArtifactYaml(component);
311903
312236
  for (const feature of componentFeatures) {
311904
- preparer_messageLog('Installing feature %s for component %s', feature.name, component.metadata.name);
312237
+ log.info('Installing feature %s for component %s', feature.name, component.metadata.name);
311905
312238
  await featuresPreparer.getFeatureConfig(feature.name, feature.version, entityPath);
311906
312239
  // Get feature config
311907
312240
  const featureConfig = common.features.features.getFeatureRenderedConfigForComponent(component, feature.name);
@@ -311925,17 +312258,17 @@ const external_node_readline_namespaceObject = __WEBPACK_EXTERNAL_createRequire(
311925
312258
 
311926
312259
 
311927
312260
 
311928
- const terraform_messageLog = src_default()('firestartr:provisioner:terraform');
311929
- async function runTerraform(entity, command) {
312261
+ async function runTerraform(entity, command, stream) {
311930
312262
  let entityID = `${entity.kind.toLowerCase()}--${entity['spec']['firestartr']['tfStateKey']}`;
311931
312263
  if (entity.kind === 'FirestartrGithubRepositoryFeature')
311932
312264
  entityID = `${entity.kind.toLowerCase()}--${entity.metadata.name}`;
311933
312265
  const workDir = external_path_.join(process.env.IS_DEV_LOCAL_ENVIRONMENT
311934
312266
  ? '/library/packages/provisioner'
311935
312267
  : '/library/provisioner', 'cdktf.out', 'stacks', entityID);
311936
- terraform_messageLog(`Running terraform with command ${command} in ${workDir}`);
312268
+ provisioner_src_logger.info(`Running terraform with command ${command} in ${workDir}`);
311937
312269
  return new Promise((ok, ko) => {
311938
312270
  const terraformProcess = (0,external_child_process_.spawn)('terraform', [...command], {
312271
+ stdio: ['inherit', 'pipe', 'pipe'],
311939
312272
  cwd: workDir,
311940
312273
  env: {
311941
312274
  PATH: process.env.PATH,
@@ -311953,17 +312286,18 @@ async function runTerraform(entity, command) {
311953
312286
  terraformProcess.stdout.on('data', (log) => {
311954
312287
  const line = catalog_common.io.stripAnsi(log.toString());
311955
312288
  output += line;
311956
- console.log(line);
312289
+ if (stream)
312290
+ stream.write(line);
311957
312291
  });
311958
312292
  terraformProcess.stderr.on('data', (log) => {
311959
312293
  const line = catalog_common.io.stripAnsi(log.toString());
311960
312294
  output += line;
311961
- console.log(line);
312295
+ if (stream)
312296
+ stream.write(line);
311962
312297
  });
311963
312298
  terraformProcess.on('exit', async (code) => {
311964
312299
  console.log(`child process exited with code ${code}`);
311965
312300
  if (code !== 0) {
311966
- console.log(output);
311967
312301
  ko(output);
311968
312302
  }
311969
312303
  else {
@@ -311972,13 +312306,13 @@ async function runTerraform(entity, command) {
311972
312306
  });
311973
312307
  });
311974
312308
  }
311975
- function terraformInit(entity) {
311976
- return runTerraform(entity, ['init', '-no-color']);
312309
+ function terraformInit(entity, stream) {
312310
+ return runTerraform(entity, ['init', '-no-color'], stream);
311977
312311
  }
311978
- function terraformPlan(entity) {
311979
- return runTerraform(entity, ['plan', '-no-color']);
312312
+ function terraformPlan(entity, stream) {
312313
+ return runTerraform(entity, ['plan', '-no-color'], stream);
311980
312314
  }
311981
- async function terraformApply(entity, isImport = false, skipPlan = false) {
312315
+ async function terraformApply(entity, isImport = false, skipPlan = false, stream) {
311982
312316
  let line = false;
311983
312317
  if (isImport && !skipPlan) {
311984
312318
  console.log(`
@@ -311997,15 +312331,15 @@ Type 'yes' to continue:`);
311997
312331
  });
311998
312332
  }
311999
312333
  if (line === 'yes' || skipPlan) {
312000
- return runTerraform(entity, ['apply', '-no-color', '-auto-approve']);
312334
+ return runTerraform(entity, ['apply', '-no-color', '-auto-approve'], stream);
312001
312335
  }
312002
312336
  else {
312003
312337
  console.log(`🚀 Skipping apply for entity ${entity.kind} ${entity.metadata.name}`);
312004
312338
  return Promise.resolve('');
312005
312339
  }
312006
312340
  }
312007
- function terraformDestroy(entity) {
312008
- return runTerraform(entity, ['destroy', '-no-color', '-auto-approve']);
312341
+ function terraformDestroy(entity, stream) {
312342
+ return runTerraform(entity, ['destroy', '-no-color', '-auto-approve'], stream);
312009
312343
  }
312010
312344
 
312011
312345
  ;// CONCATENATED MODULE: ../provisioner/src/features/uninstaller.ts
@@ -312014,12 +312348,11 @@ function terraformDestroy(entity) {
312014
312348
 
312015
312349
 
312016
312350
 
312017
- const uninstaller_messageLog = src_default()('firestartr:provisioner:features:uninstaller');
312018
312351
  async function untrackManagedFiles(feature, deps) {
312019
312352
  if (!feature.spec.files || feature.spec.files.length < 1)
312020
312353
  return;
312021
- uninstaller_messageLog('Removing managed files from the Terraform State');
312022
- uninstaller_messageLog('Synthing the project...');
312354
+ provisioner_src_logger.debug('Removing managed files from the Terraform State');
312355
+ provisioner_src_logger.debug('Synthing the project...');
312023
312356
  const randomFilenameFeature = `${catalog_common.generic.randomString(20)}.yaml`;
312024
312357
  const randomFilenameDeps = `${catalog_common.generic.randomString(20)}_deps.yaml`;
312025
312358
  catalog_common.io.writeYamlFile(randomFilenameFeature, feature, '/tmp');
@@ -312027,7 +312360,7 @@ async function untrackManagedFiles(feature, deps) {
312027
312360
  await runCDKTF(external_path_.join('/tmp', randomFilenameFeature), 'synth', external_path_.join('/tmp', randomFilenameDeps));
312028
312361
  await runTerraform(feature, ['init']);
312029
312362
  for (const file of feature.spec.files.filter((file) => file.userManaged === true)) {
312030
- uninstaller_messageLog(`Removing from the state file ${file.path}`);
312363
+ provisioner_src_logger.debug(`Removing from the state file ${file.path}`);
312031
312364
  // Terraform replaces / with -- and . with - in the state file names, so we do the same to get the state file name
312032
312365
  const stateFileName = `${feature.spec.type}-${file.path}`
312033
312366
  .replace(/\//g, '--')
@@ -312100,14 +312433,46 @@ function getNextStatus(status) {
312100
312433
 
312101
312434
 
312102
312435
 
312436
+
312437
+
312103
312438
  class Resource {
312104
312439
  setLogger(fn) {
312105
312440
  this.logFn = fn;
312106
312441
  }
312442
+ setSynthStreamLogs(callbacks) {
312443
+ this.synthStreamCallbacks = callbacks;
312444
+ }
312445
+ setTFStreamLogs(callbacks) {
312446
+ this.tfStreamCallbacks = callbacks;
312447
+ }
312448
+ async onSyncStreaming() {
312449
+ if (!this.logStream) {
312450
+ this.logStream = new external_stream_.PassThrough();
312451
+ }
312452
+ if (this.synthStreamCallbacks) {
312453
+ const callbacks = await this.synthStreamCallbacks.prepare();
312454
+ this.setLogStream(callbacks.fnData, callbacks.fnEnd);
312455
+ }
312456
+ }
312457
+ async onTFStreaming() {
312458
+ if (!this.logStream) {
312459
+ this.logStream = new external_stream_.PassThrough();
312460
+ }
312461
+ if (this.tfStreamCallbacks) {
312462
+ const callbacks = await this.tfStreamCallbacks.prepare();
312463
+ this.setLogStream(callbacks.fnData, callbacks.fnEnd);
312464
+ }
312465
+ }
312466
+ setLogStream(fnData, fnEnd, reopen = true) {
312467
+ if (reopen || !this.logStream)
312468
+ this.logStream = new external_stream_.PassThrough();
312469
+ this.logStream.on('data', (data) => fnData(data.toString()));
312470
+ this.logStream.on('end', () => fnEnd());
312471
+ }
312107
312472
  constructor(mainCR, operation, deps = []) {
312108
312473
  this.data = {};
312109
312474
  this.output = '';
312110
- this.logFn = (msg) => console.log(msg);
312475
+ this.logFn = (msg) => provisioner_src_logger.debug(msg);
312111
312476
  this.set('main_artifact', mainCR);
312112
312477
  this.set('operation', operation);
312113
312478
  this.set('deps', deps);
@@ -312117,36 +312482,46 @@ class Resource {
312117
312482
  await this.synth();
312118
312483
  await this.runTerraform();
312119
312484
  await this.postprocess();
312485
+ if (this.logStream) {
312486
+ this.logStream.end();
312487
+ this.logStream = null;
312488
+ }
312120
312489
  }
312121
312490
  artifact() {
312122
312491
  return this.get('main_artifact');
312123
312492
  }
312124
312493
  async synth() {
312494
+ await this.onSyncStreaming();
312125
312495
  const randomFilenameArtifact = `${catalog_common.generic.randomString(20)}.yaml`;
312126
312496
  const randomFilenameDeps = `${catalog_common.generic.randomString(20)}_deps.yaml`;
312127
312497
  catalog_common.io.writeYamlFile(randomFilenameArtifact, this.get('main_artifact'), '/tmp');
312128
312498
  catalog_common.io.writeYamlFile(randomFilenameDeps, this.get('deps'), '/tmp');
312129
- await runCDKTF(external_path_.join('/tmp', randomFilenameArtifact), 'synth', external_path_.join('/tmp', randomFilenameDeps));
312499
+ await runCDKTF(external_path_.join('/tmp', randomFilenameArtifact), 'synth', external_path_.join('/tmp', randomFilenameDeps), this.logStream);
312500
+ if (this.logStream) {
312501
+ this.logStream.end();
312502
+ this.logStream = null;
312503
+ }
312130
312504
  }
312131
312505
  log(msg) {
312132
312506
  this.logFn(msg);
312133
312507
  }
312134
312508
  async runTerraform() {
312509
+ await this.onTFStreaming();
312135
312510
  let output = '';
312136
- output += await terraformInit(this.get('main_artifact'));
312137
- output += await terraformPlan(this.get('main_artifact'));
312511
+ output += await terraformInit(this.get('main_artifact'), this.logStream);
312512
+ output += await terraformPlan(this.get('main_artifact'), this.logStream);
312138
312513
  if (this.get('operation') === 'CREATE' ||
312139
312514
  this.get('operation') === 'UPDATE') {
312140
- output += await terraformApply(this.get('main_artifact'), false, true);
312515
+ output += await terraformApply(this.get('main_artifact'), false, true, this.logStream);
312141
312516
  }
312142
312517
  else if (this.get('operation') === 'DELETE') {
312143
- output += await terraformDestroy(this.get('main_artifact'));
312518
+ output += await terraformDestroy(this.get('main_artifact'), this.logStream);
312144
312519
  }
312145
312520
  else if (this.get('operation') === 'IMPORT') {
312146
- output += await terraformApply(this.get('main_artifact'), true, false);
312521
+ output += await terraformApply(this.get('main_artifact'), true, false, this.logStream);
312147
312522
  }
312148
312523
  else if (this.get('operation') === 'IMPORT_SKIP_PLAN') {
312149
- output += await terraformApply(this.get('main_artifact'), true, true);
312524
+ output += await terraformApply(this.get('main_artifact'), true, true, this.logStream);
312150
312525
  }
312151
312526
  else {
312152
312527
  throw new Error(`unknown operation: ${this.get('operation')}`);
@@ -312171,7 +312546,6 @@ class Resource {
312171
312546
 
312172
312547
 
312173
312548
 
312174
- const github_feature_log = src_default()('firestartr:provisioner:github_repository_feature');
312175
312549
  class github_feature_FirestartrGithubRepositoryFeature extends Resource {
312176
312550
  static kind() {
312177
312551
  return 'FirestartrGithubRepositoryFeature';
@@ -312179,19 +312553,19 @@ class github_feature_FirestartrGithubRepositoryFeature extends Resource {
312179
312553
  async preprocess() {
312180
312554
  switch (this.get('operation')) {
312181
312555
  case 'CREATE':
312182
- github_feature_log('CREATED');
312556
+ provisioner_src_logger.debug('Creating FirestartrGithubRepositoryFeature');
312183
312557
  await this._updateManagedFiles();
312184
312558
  break;
312185
312559
  case 'UPDATE':
312186
- github_feature_log('UPDATED');
312560
+ provisioner_src_logger.debug('Updating FirestartrGithubRepositoryFeature');
312187
312561
  await this._updateManagedFiles();
312188
312562
  break;
312189
312563
  case 'DELETE':
312190
- github_feature_log('DELETE');
312564
+ provisioner_src_logger.debug('Deleting FirestartrGithubRepositoryFeature');
312191
312565
  await untrackManagedFiles(this.get('main_artifact'), this.get('deps'));
312192
312566
  break;
312193
312567
  default:
312194
- github_feature_log(`UNKNOWN: ${this.get('operation')}`);
312568
+ provisioner_src_logger.debug(`Unknown operation '${this.get('operation')}' for FirestartrGithubRepositoryFeature`);
312195
312569
  }
312196
312570
  }
312197
312571
  async _updateManagedFiles() {
@@ -312205,7 +312579,7 @@ class github_feature_FirestartrGithubRepositoryFeature extends Resource {
312205
312579
  file.content = newContent;
312206
312580
  }
312207
312581
  catch (e) {
312208
- github_feature_log(`File ${file.path} not found in repo ${repoInfo.ref.name} on branch ${repoInfo.branch}. File content not updated`);
312582
+ provisioner_src_logger.error(`File ${file.path} not found in repo ${repoInfo.ref.name} on branch ${repoInfo.branch}. File content not updated`);
312209
312583
  }
312210
312584
  }
312211
312585
  }
@@ -312285,7 +312659,6 @@ async function provisionRegularBranch(repo, branchName, sourceBranch, org) {
312285
312659
 
312286
312660
 
312287
312661
 
312288
- const github_repository_log = src_default()('firestartr:provisioner:github_repository');
312289
312662
  class github_repository_FirestartrGithubRepository extends Resource {
312290
312663
  static kind() {
312291
312664
  return 'FirestartrGithubRepository';
@@ -312293,22 +312666,23 @@ class github_repository_FirestartrGithubRepository extends Resource {
312293
312666
  async preprocess() {
312294
312667
  switch (this.get('operation')) {
312295
312668
  case 'CREATE':
312296
- github_repository_log('CREATE');
312669
+ provisioner_src_logger.debug('Creating FirestartrGithubRepository');
312297
312670
  break;
312298
312671
  case 'UPDATE':
312299
- github_repository_log('UPDATED');
312672
+ provisioner_src_logger.debug('Updating FirestartrGithubRepository');
312300
312673
  break;
312301
312674
  case 'DELETE':
312302
- github_repository_log('DELETED');
312675
+ provisioner_src_logger.debug('Deleted FirestartrGithubRepository');
312303
312676
  break;
312304
312677
  case 'IMPORT':
312305
- github_repository_log('IMPORT');
312678
+ provisioner_src_logger.debug('Importing FirestartrGithubRepository');
312306
312679
  break;
312307
312680
  case 'IMPORT_SKIP_PLAN':
312308
- github_repository_log('IMPORT_SKIP_PLAN');
312681
+ provisioner_src_logger.debug('Import skipping plan for FirestartrGithubRepository');
312309
312682
  break;
312310
312683
  default:
312311
- github_repository_log('UNKNOWN');
312684
+ provisioner_src_logger.debug('Unknown operation for FirestartrGithubRepository ' +
312685
+ this.get('operation'));
312312
312686
  }
312313
312687
  }
312314
312688
  async postprocess() {
@@ -312316,20 +312690,20 @@ class github_repository_FirestartrGithubRepository extends Resource {
312316
312690
  switch (this.get('operation')) {
312317
312691
  case 'CREATE':
312318
312692
  case 'UPDATE':
312319
- github_repository_log('CREATE & UPDATE');
312693
+ provisioner_src_logger.debug(`Created and updated FirestartrGithubRepository ${cr.metadata.name}`);
312320
312694
  await provisionAdditionalBranches(cr);
312321
312695
  break;
312322
312696
  case 'DELETE':
312323
- github_repository_log('DELETED');
312697
+ provisioner_src_logger.debug(`Deleted FirestartrGithubRepository ${cr.metadata.name}`);
312324
312698
  break;
312325
312699
  case 'IMPORT':
312326
- github_repository_log('IMPORT');
312700
+ provisioner_src_logger.debug(`Imported FirestartrGithubRepository ${cr.metadata.name}`);
312327
312701
  break;
312328
312702
  case 'IMPORT_SKIP_PLAN':
312329
- github_repository_log('IMPORT_SKIP_PLAN');
312703
+ provisioner_src_logger.debug(`Imported skipped plan FirestartrGithubRepository ${cr.metadata.name}`);
312330
312704
  break;
312331
312705
  default:
312332
- github_repository_log('UNKNOWN');
312706
+ provisioner_src_logger.debug(`Finished for unknown operation ${this.get('operation')} for FirestartrGithubRepository`);
312333
312707
  }
312334
312708
  }
312335
312709
  }
@@ -312337,7 +312711,6 @@ class github_repository_FirestartrGithubRepository extends Resource {
312337
312711
  ;// CONCATENATED MODULE: ../provisioner/src/resources/github_membership/index.ts
312338
312712
 
312339
312713
 
312340
- const github_membership_log = src_default()('firestartr:provisioner:github_membership');
312341
312714
  class github_membership_FirestartrGithubMembership extends Resource {
312342
312715
  static kind() {
312343
312716
  return 'FirestartrGithubMembership';
@@ -312345,22 +312718,23 @@ class github_membership_FirestartrGithubMembership extends Resource {
312345
312718
  async preprocess() {
312346
312719
  switch (this.get('operation')) {
312347
312720
  case 'CREATE':
312348
- github_membership_log('CREATE');
312721
+ provisioner_src_logger.debug('Creating FirestartrGithubMembership');
312349
312722
  break;
312350
312723
  case 'UPDATE':
312351
- github_membership_log('UPDATED');
312724
+ provisioner_src_logger.debug('Updating FirestartrGithubMembership');
312352
312725
  break;
312353
312726
  case 'DELETE':
312354
- github_membership_log('DELETED');
312727
+ provisioner_src_logger.debug('Deleted FirestartrGithubMembership');
312355
312728
  break;
312356
312729
  case 'IMPORT':
312357
- github_membership_log('IMPORT');
312730
+ provisioner_src_logger.debug('Importing FirestartrGithubMembership');
312358
312731
  break;
312359
312732
  case 'IMPORT_SKIP_PLAN':
312360
- github_membership_log('IMPORT_SKIP_PLAN');
312733
+ provisioner_src_logger.debug('Import skipping plan for FirestartrGithubMembership');
312361
312734
  break;
312362
312735
  default:
312363
- github_membership_log('UNKNOWN');
312736
+ provisioner_src_logger.debug('Unknown operation for FirestartrGithubMembership ' +
312737
+ this.get('operation'));
312364
312738
  }
312365
312739
  }
312366
312740
  }
@@ -312368,7 +312742,6 @@ class github_membership_FirestartrGithubMembership extends Resource {
312368
312742
  ;// CONCATENATED MODULE: ../provisioner/src/resources/github_group/index.ts
312369
312743
 
312370
312744
 
312371
- const github_group_log = src_default()('firestartr:provisioner:github_group');
312372
312745
  class github_group_FirestartrGithubGroup extends Resource {
312373
312746
  static kind() {
312374
312747
  return 'FirestartrGithubGroup';
@@ -312376,22 +312749,23 @@ class github_group_FirestartrGithubGroup extends Resource {
312376
312749
  async preprocess() {
312377
312750
  switch (this.get('operation')) {
312378
312751
  case 'CREATE':
312379
- github_group_log('CREATE');
312752
+ provisioner_src_logger.debug('Creating FirestartrGithubGroup');
312380
312753
  break;
312381
312754
  case 'UPDATE':
312382
- github_group_log('UPDATED');
312755
+ provisioner_src_logger.debug('Updating FirestartrGithubGroup');
312383
312756
  break;
312384
312757
  case 'DELETE':
312385
- github_group_log('DELETED');
312758
+ provisioner_src_logger.debug('Deleted FirestartrGithubGroup');
312386
312759
  break;
312387
312760
  case 'IMPORT':
312388
- github_group_log('IMPORT');
312761
+ provisioner_src_logger.debug('Importing FirestartrGithubGroup');
312389
312762
  break;
312390
312763
  case 'IMPORT_SKIP_PLAN':
312391
- github_group_log('IMPORT_SKIP_PLAN');
312764
+ provisioner_src_logger.debug('Import skipping plan for FirestartrGithubGroup');
312392
312765
  break;
312393
312766
  default:
312394
- github_group_log('UNKNOWN');
312767
+ provisioner_src_logger.debug('Unknown operation for FirestartrGithubGroup ' +
312768
+ this.get('operation'));
312395
312769
  }
312396
312770
  }
312397
312771
  }
@@ -312399,14 +312773,13 @@ class github_group_FirestartrGithubGroup extends Resource {
312399
312773
  ;// CONCATENATED MODULE: ../provisioner/src/resources/terraform_module/index.ts
312400
312774
 
312401
312775
 
312402
- const terraform_module_log = src_default()('firestartr:provisioner:terraform_module');
312403
312776
  class FirestartrTerraformModule extends Resource {
312404
312777
  static kind() {
312405
312778
  return 'FirestartrTerraformModule';
312406
312779
  }
312407
312780
  async preprocess() {
312408
312781
  const operation = this.get('operation');
312409
- terraform_module_log(operation);
312782
+ provisioner_src_logger.debug(`Running operation '${operation}' for FirestartrTerraformModule`);
312410
312783
  switch (operation) {
312411
312784
  case 'CREATE':
312412
312785
  break;
@@ -312427,7 +312800,6 @@ class FirestartrTerraformModule extends Resource {
312427
312800
  ;// CONCATENATED MODULE: ../provisioner/src/resources/github_orgWebhook/index.ts
312428
312801
 
312429
312802
 
312430
- const github_orgWebhook_log = src_default()('firestartr:provisioner:github_orgWebhook');
312431
312803
  class github_orgWebhook_FirestartrGithubOrgWebhook extends Resource {
312432
312804
  static kind() {
312433
312805
  return 'FirestartrGithubOrgWebhook';
@@ -312435,22 +312807,23 @@ class github_orgWebhook_FirestartrGithubOrgWebhook extends Resource {
312435
312807
  async preprocess() {
312436
312808
  switch (this.get('operation')) {
312437
312809
  case 'CREATE':
312438
- github_orgWebhook_log('CREATE');
312810
+ provisioner_src_logger.debug('Creating FirestartrGithubOrgWebhook');
312439
312811
  break;
312440
312812
  case 'UPDATE':
312441
- github_orgWebhook_log('UPDATED');
312813
+ provisioner_src_logger.debug('Updating FirestartrGithubOrgWebhook');
312442
312814
  break;
312443
312815
  case 'DELETE':
312444
- github_orgWebhook_log('DELETED');
312816
+ provisioner_src_logger.debug('Deleted FirestartrGithubOrgWebhook');
312445
312817
  break;
312446
312818
  case 'IMPORT':
312447
- github_orgWebhook_log('IMPORT');
312819
+ provisioner_src_logger.debug('Importing FirestartrGithubOrgWebhook');
312448
312820
  break;
312449
312821
  case 'IMPORT_SKIP_PLAN':
312450
- github_orgWebhook_log('IMPORT_SKIP_PLAN');
312822
+ provisioner_src_logger.debug('Import skipping plan for FirestartrGithubOrgWebhook');
312451
312823
  break;
312452
312824
  default:
312453
- github_orgWebhook_log('UNKNOWN');
312825
+ provisioner_src_logger.debug('Unknown operation for FirestartrGithubOrgWebhook ' +
312826
+ this.get('operation'));
312454
312827
  }
312455
312828
  }
312456
312829
  }
@@ -312487,6 +312860,12 @@ async function runProvisioner(data, opts) {
312487
312860
  ? 'DELETE'
312488
312861
  : 'UNKNOWN';
312489
312862
  const resource = createInstanceOf(mainCr, operation, deps);
312863
+ if ('logStreamCallbacksCDKTF' in opts) {
312864
+ resource.setSynthStreamLogs(opts['logStreamCallbacksCDKTF']);
312865
+ }
312866
+ if ('logStreamCallbacksTF' in opts) {
312867
+ resource.setTFStreamLogs(opts['logStreamCallbacksTF']);
312868
+ }
312490
312869
  await resource.run();
312491
312870
  return resource;
312492
312871
  }
@@ -312505,7 +312884,6 @@ function createInstanceOf(entity, op, deps) {
312505
312884
 
312506
312885
 
312507
312886
 
312508
- const provisioner_messageLog_0 = src_default()('firestartr:provisioner:main');
312509
312887
  async function deploy(app) {
312510
312888
  const entity = catalog_common.io.fromYaml(external_fs_.readFileSync(catalog_common.environment.getFromEnvironment(catalog_common.types.envVars.cdktfEntityPath), 'utf8'));
312511
312889
  const deps = catalog_common.io.fromYaml(external_fs_.readFileSync(catalog_common.environment.getFromEnvironment(catalog_common.types.envVars.cdktfDepsPath), 'utf8'));
@@ -312514,7 +312892,7 @@ async function deploy(app) {
312514
312892
  : false;
312515
312893
  catalog_common.io.removeFile(catalog_common.environment.getFromEnvironment(catalog_common.types.envVars.cdktfEntityPath));
312516
312894
  catalog_common.io.removeFile(catalog_common.environment.getFromEnvironment(catalog_common.types.envVars.cdktfDepsPath));
312517
- provisioner_messageLog_0('Entity to provision: %O', entity);
312895
+ provisioner_src_logger.info(`Entity to provision: ${entity}`);
312518
312896
  const orgConfig = {
312519
312897
  bucket: catalog_common.environment.getFromEnvironment(catalog_common.types.envVars.s3Bucket),
312520
312898
  dynamodbTable: catalog_common.environment.getFromEnvironment(catalog_common.types.envVars.s3Lock),
@@ -312532,7 +312910,7 @@ async function deploy(app) {
312532
312910
  app.synth();
312533
312911
  }
312534
312912
  catch (e) {
312535
- void provisioner_messageLog_0('Error: deploy: %s', e);
312913
+ provisioner_src_logger.error('Error: deploy: %s', e);
312536
312914
  throw e;
312537
312915
  }
312538
312916
  }
@@ -312554,26 +312932,20 @@ if (process.env.RUN_PROVISIONER) {
312554
312932
  async function tryPublishApply(item, planOutput, kind) {
312555
312933
  try {
312556
312934
  if (!('firestartr.dev/last-state-pr' in item.metadata.annotations)) {
312557
- src_logger.debug('USER_FEEDBACK_PUBLISH_APPLY_NO_LAST_STATE', {
312558
- metadata: { name: item.metadata.name, kind },
312559
- });
312935
+ operator_src_logger.debug(`The user feedback for the '${kind}/${item.metadata.name}' apply operation could not be published because the last state was not found.`);
312560
312936
  return;
312561
312937
  }
312562
312938
  await publishApply(item, planOutput, kind);
312563
312939
  }
312564
312940
  catch (e) {
312565
- src_logger.error('USER_FEEDBACK_PUBLISH_APPLY_ERROR', {
312566
- metadata: { name: item.metadata.name, kind, error: e },
312567
- });
312941
+ operator_src_logger.error(`The user feedback for the '${kind}/${item.metadata.name}' apply operation failed to publish due to an error: '${e}'.`);
312568
312942
  }
312569
312943
  }
312570
312944
  async function tryPublishDestroy(item, destroyOutput) {
312571
312945
  let lastPr = null;
312572
312946
  try {
312573
312947
  const { repo, org } = extractPrInfo(item);
312574
- src_logger.debug('USER_FEEDBACK_PUBLISH_DESTROY', {
312575
- metadata: { item, repo, org },
312576
- });
312948
+ operator_src_logger.debug(`The user feedback for the '${item.kind}/${item.metadata.name}' destroy operation is being published for repository '${repo}' in organization '${org}'.`);
312577
312949
  lastPr = await github_0.pulls.filterPrBy({
312578
312950
  title: `hydrate: ${item.metadata.name}`,
312579
312951
  state: 'closed',
@@ -312584,9 +312956,7 @@ async function tryPublishDestroy(item, destroyOutput) {
312584
312956
  maxRetries: 3,
312585
312957
  });
312586
312958
  if (!lastPr) {
312587
- src_logger.debug('USER_FEEDBACK_PUBLISH_DESTROY_NO_LAST_STATE', {
312588
- metadata: { item },
312589
- });
312959
+ operator_src_logger.debug(`The user feedback for the '${item.kind}/${item.metadata.name}' destroy operation could not be published because the last state was not found.`);
312590
312960
  return;
312591
312961
  }
312592
312962
  const dividedOutput = github_0.pulls.divideCommentIntoChunks(destroyOutput, 250);
@@ -312604,20 +312974,14 @@ async function tryPublishDestroy(item, destroyOutput) {
312604
312974
  ${commentContent}
312605
312975
  \`\`\`
312606
312976
  </details>`;
312607
- src_logger.debug('USER_FEEDBACK_PUBLISH_COMMENT', {
312608
- metadata: { lastPr: lastPr.number, repo, org, item },
312609
- });
312977
+ operator_src_logger.debug(`The user feedback for item '${item.kind}/${item.metadata.name}' is being published as a comment on pull request '${lastPr.number}' for repository '${repo}' in organization '${org}'.`);
312610
312978
  await github_0.pulls.commentInPR(comment, lastPr.number, repo, org);
312611
- src_logger.debug('USER_FEEDBACK_PUBLISH_DESTROY_COMMENT', {
312612
- metadata: { lastPr: lastPr.number, item },
312613
- });
312979
+ operator_src_logger.debug(`The user feedback for the '${item.kind}/${item.metadata.name}' destroy operation is being published as a comment on pull request '${lastPr.number}'.`);
312614
312980
  currentCommentNo += 1;
312615
312981
  }
312616
312982
  }
312617
312983
  catch (e) {
312618
- src_logger.error('USER_FEEDBACK_PUBLISH_ERROR', {
312619
- metadata: { lastPr: lastPr.number, item, error: e },
312620
- });
312984
+ operator_src_logger.error(`An error occurred while publishing user feedback for item '${item.kind}/${item.metadata.name}' on pull request '${lastPr.number}': '${e}'.`);
312621
312985
  }
312622
312986
  }
312623
312987
  async function publishApply(item, applyOutput, kind) {
@@ -312654,9 +313018,7 @@ function tryCreateErrorSummary(title, errorMsg) {
312654
313018
  return summaryText;
312655
313019
  }
312656
313020
  catch (e) {
312657
- src_logger.error('USER_FEEDBACK_GETTING_ERROR_SUMMARY', {
312658
- metadata: { error: e, title, errorMsg },
312659
- });
313021
+ operator_src_logger.error(`An error occurred while getting the error summary for '${title}'. The error was '${e}', with the message: '${errorMsg}'.`);
312660
313022
  return `Error when getting error summary: ${e}`;
312661
313023
  }
312662
313024
  }
@@ -312678,9 +313040,7 @@ async function tryPublishError(item, reason, message) {
312678
313040
  await publishError(item, reason, message);
312679
313041
  }
312680
313042
  catch (e) {
312681
- src_logger.error('USER_FEEDBACK_TRY_PUBLISH_ERROR', {
312682
- metadata: { item, error: e, reason },
312683
- });
313043
+ operator_src_logger.error(`The user feedback for item '${item.kind}/${item.metadata.name}' failed to publish due to an error: '${e}'. Reason: '${reason}'.`);
312684
313044
  }
312685
313045
  }
312686
313046
  async function publishError(item, reason, message) {
@@ -312718,6 +313078,53 @@ ${commentContent}
312718
313078
  }
312719
313079
  }
312720
313080
 
313081
+ ;// CONCATENATED MODULE: ../operator/src/user-feedback-ops/gh-checkrun.ts
313082
+
313083
+ async function GHCheckRun(cmd, item) {
313084
+ const prInfo = gh_checkrun_extractPrInfo(item);
313085
+ if (!prInfo.prNumber) {
313086
+ throw new Error('TFCheckRun: prNumber not retrievable');
313087
+ }
313088
+ const checkRun = await github_0.feedback.createCheckRun(prInfo.org, prInfo.repo, helperCreateCheckRunName(cmd, item), {
313089
+ //Number(pr_number),
313090
+ pullNumber: Number(prInfo.prNumber),
313091
+ includeCheckRunComment: true,
313092
+ checkRunComment: `The Github ${item.kind} is being processed (cmd=${cmd}). Details: `,
313093
+ });
313094
+ checkRun.mdOptionsDetails({
313095
+ quotes: 'terraform',
313096
+ });
313097
+ checkRun.update('Initiating', 'queued');
313098
+ return {
313099
+ fnData: (d) => {
313100
+ checkRun.update(d.toString(), 'in_progress');
313101
+ },
313102
+ fnEnd: () => {
313103
+ checkRun.close('OK', true);
313104
+ },
313105
+ fnOnError: (err) => {
313106
+ checkRun.close('KO', false);
313107
+ },
313108
+ };
313109
+ }
313110
+ function helperCreateCheckRunName(cmd, item) {
313111
+ return `Github Provisioner / ${item.kind} - ${cmd}`;
313112
+ }
313113
+ function gh_checkrun_extractPrInfo(item) {
313114
+ const prInfo = item.metadata.annotations['firestartr.dev/last-state-pr'];
313115
+ const prNumber = prInfo.split('#')[1];
313116
+ if (!prNumber)
313117
+ throw new Error('No PR number found in CR');
313118
+ const orgRepo = prInfo.split('#')[0];
313119
+ const org = orgRepo.split('/')[0];
313120
+ if (!org)
313121
+ throw new Error('No org found in CR');
313122
+ const repo = orgRepo.split('/')[1];
313123
+ if (!repo)
313124
+ throw new Error('No repo found in CR');
313125
+ return { prNumber, repo, org };
313126
+ }
313127
+
312721
313128
  ;// CONCATENATED MODULE: ../operator/cdktf.ts
312722
313129
 
312723
313130
 
@@ -312727,8 +313134,8 @@ ${commentContent}
312727
313134
 
312728
313135
 
312729
313136
 
312730
- const cdktf_log = src_default()('firestartr:operator:cdktf');
312731
313137
  function processOperation(item, op, handler) {
313138
+ operator_src_logger.info(`Processing operation ${op} on ${item.kind}/${item.metadata?.name}`);
312732
313139
  try {
312733
313140
  switch (op) {
312734
313141
  case OperationType.UPDATED:
@@ -312750,7 +313157,7 @@ function processOperation(item, op, handler) {
312750
313157
  }
312751
313158
  }
312752
313159
  catch (e) {
312753
- cdktf_log(`Operation ${op} failed: ${e}`);
313160
+ operator_src_logger.error(`Operation ${op} failed: ${e}`);
312754
313161
  throw e;
312755
313162
  }
312756
313163
  }
@@ -312801,6 +313208,9 @@ async function* sync(item, op, handler) {
312801
313208
  };
312802
313209
  }
312803
313210
  async function* markedToDeletion(item, op, handler) {
313211
+ // here we store the current callbacks that
313212
+ // are being used (synth|tf-apply...)
313213
+ let checkRunCtl;
312804
313214
  try {
312805
313215
  void cleanTerraformState();
312806
313216
  const type = 'DELETING';
@@ -312825,15 +313235,38 @@ async function* markedToDeletion(item, op, handler) {
312825
313235
  status: 'True',
312826
313236
  message: 'Destroying process started',
312827
313237
  };
312828
- if (item.metadata.annotations['firestartr.dev/last-state-pr'] || false) {
312829
- await addDestroyCommitStatus(item, 'pending', 'Performing destroy operation...', `Terraform Destroy ${item.metadata.name}`);
312830
- }
312831
313238
  const deps = await handler.resolveReferences();
313239
+ const annotation = 'firestartr.dev/last-state-pr';
313240
+ const statePr = item?.metadata?.annotations?.[annotation];
313241
+ const hasStatePr = typeof statePr === 'string' && statePr.trim().length > 0;
313242
+ if (!hasStatePr) {
313243
+ operator_src_logger.warn(`CR ${item?.kind ?? 'UnknownKind'}/${item?.metadata?.name ?? 'unknown'} ` +
313244
+ `has no "${annotation}" annotation; skipping GitHub Check Runs (synth, terraform apply).`);
313245
+ }
313246
+ else {
313247
+ operator_src_logger.debug(`CR ${item.kind}/${item.metadata.name} uses "${annotation}" = ${statePr}`);
313248
+ }
312832
313249
  const destroyOutput = await provisioner.runProvisioner({
312833
313250
  mainCr: item,
312834
313251
  deps,
312835
313252
  }, {
312836
313253
  delete: true,
313254
+ ...(hasStatePr
313255
+ ? {
313256
+ logStreamCallbacksCDKTF: {
313257
+ prepare: async () => {
313258
+ checkRunCtl = await GHCheckRun('synth', item);
313259
+ return checkRunCtl;
313260
+ },
313261
+ },
313262
+ logStreamCallbacksTF: {
313263
+ prepare: async () => {
313264
+ checkRunCtl = await GHCheckRun('terraform destroy', item);
313265
+ return checkRunCtl;
313266
+ },
313267
+ },
313268
+ }
313269
+ : {}),
312837
313270
  });
312838
313271
  const output = destroyOutput.output;
312839
313272
  await tryPublishDestroy(item, output);
@@ -312859,10 +313292,11 @@ async function* markedToDeletion(item, op, handler) {
312859
313292
  status: 'True',
312860
313293
  message: e.toString(),
312861
313294
  };
313295
+ // if there is a current checkRun working
313296
+ // we close it with an error
313297
+ if (checkRunCtl)
313298
+ checkRunCtl.fnOnError(e);
312862
313299
  await handler.writeTerraformOutputInTfResult(item, e);
312863
- if (item.metadata.annotations['firestartr.dev/last-state-pr'] || false) {
312864
- await addDestroyCommitStatus(item, 'failure', 'Destroy operation failed', `Terraform Destroy ${item.metadata.name}`);
312865
- }
312866
313300
  void handler.error();
312867
313301
  }
312868
313302
  }
@@ -312881,6 +313315,9 @@ async function* nothing(item, op, handler) {
312881
313315
  * @param handler -
312882
313316
  */
312883
313317
  async function* doApply(item, op, handler) {
313318
+ // here we store the current callbacks that
313319
+ // are being used (synth|tf-apply...)
313320
+ let checkRunCtl;
312884
313321
  try {
312885
313322
  cleanTerraformState();
312886
313323
  yield {
@@ -312922,16 +313359,41 @@ async function* doApply(item, op, handler) {
312922
313359
  opts['create'] = true;
312923
313360
  }
312924
313361
  const deps = await handler.resolveReferences();
312925
- cdktf_log('Item %s has the following dependencies: %O', item.metadata.name, deps);
312926
- if (item.metadata.annotations['firestartr.dev/last-state-pr'] || false) {
312927
- await addApplyCommitStatus(item, 'pending', catalog_common.generic.getPrLinkFromAnnotationValue(item.metadata.annotations['firestartr.dev/last-state-pr']), 'Performing apply operation...', `Terraform Apply ${item.metadata.name}`);
313362
+ operator_src_logger.info(`Item ${item.metadata.name} has the following dependencies: ${deps}`);
313363
+ const annotation = 'firestartr.dev/last-state-pr';
313364
+ const statePr = item?.metadata?.annotations?.[annotation];
313365
+ const hasStatePr = typeof statePr === 'string' && statePr.trim().length > 0;
313366
+ if (!hasStatePr) {
313367
+ operator_src_logger.warn(`CR ${item?.kind ?? 'UnknownKind'}/${item?.metadata?.name ?? 'unknown'} ` +
313368
+ `has no "${annotation}" annotation; skipping GitHub Check Runs (synth, terraform apply).`);
313369
+ }
313370
+ else {
313371
+ operator_src_logger.debug(`CR ${item.kind}/${item.metadata.name} uses "${annotation}" = ${statePr}`);
312928
313372
  }
312929
313373
  const applyOutput = await provisioner.runProvisioner({
312930
313374
  mainCr: item,
312931
313375
  deps,
312932
- }, opts);
313376
+ }, {
313377
+ ...opts,
313378
+ ...(hasStatePr
313379
+ ? {
313380
+ logStreamCallbacksCDKTF: {
313381
+ prepare: async () => {
313382
+ checkRunCtl = await GHCheckRun('synth', item);
313383
+ return checkRunCtl;
313384
+ },
313385
+ },
313386
+ logStreamCallbacksTF: {
313387
+ prepare: async () => {
313388
+ checkRunCtl = await GHCheckRun('terraform apply', item);
313389
+ return checkRunCtl;
313390
+ },
313391
+ },
313392
+ }
313393
+ : {}),
313394
+ });
312933
313395
  await tryPublishApply(item, applyOutput?.data?.output, item.kind);
312934
- const terraformOutputJson = await provisioner.runTerraform(item, ['output', '-json']);
313396
+ const terraformOutputJson = await provisioner.runTerraform(item, ['output', '-json'], null);
312935
313397
  if (!terraformOutputJson) {
312936
313398
  throw new Error(`Terraform output is empty for ${item.kind}/${item.metadata.name}`);
312937
313399
  }
@@ -312959,9 +313421,6 @@ async function* doApply(item, op, handler) {
312959
313421
  message: 'doApply',
312960
313422
  };
312961
313423
  await handler.writeTerraformOutputInTfResult(item, output);
312962
- if (item.metadata.annotations['firestartr.dev/last-state-pr'] || false) {
312963
- await addApplyCommitStatus(item, 'success', catalog_common.generic.getPrLinkFromAnnotationValue(item.metadata.annotations['firestartr.dev/last-state-pr']), 'Apply operation completed', `Terraform Apply ${item.metadata.name}`);
312964
- }
312965
313424
  handler.success();
312966
313425
  }
312967
313426
  catch (e) {
@@ -312973,7 +313432,11 @@ async function* doApply(item, op, handler) {
312973
313432
  error = e;
312974
313433
  }
312975
313434
  await tryPublishApply(item, error, item.kind);
312976
- cdktf_log('Error applying item %s: %O', item.metadata.name, error);
313435
+ // if there is a current checkRun working
313436
+ // we close it with an error
313437
+ if (checkRunCtl)
313438
+ checkRunCtl.fnOnError(error);
313439
+ operator_src_logger.error(`Error applying item ${item.metadata.name}: ${error}`);
312977
313440
  yield {
312978
313441
  item,
312979
313442
  reason: op,
@@ -312995,9 +313458,6 @@ async function* doApply(item, op, handler) {
312995
313458
  status: 'False',
312996
313459
  message: error.toString(),
312997
313460
  };
312998
- if (item.metadata.annotations['firestartr.dev/last-state-pr'] || false) {
312999
- await addApplyCommitStatus(item, 'failure', catalog_common.generic.getPrLinkFromAnnotationValue(item.metadata.annotations['firestartr.dev/last-state-pr']), 'Apply operation failed', `Terraform Apply ${item.metadata.name}`);
313000
- }
313001
313461
  handler.error();
313002
313462
  if (error) {
313003
313463
  await handler.writeTerraformOutputInTfResult(item, error);
@@ -313114,57 +313574,72 @@ class TFPlanItemVersion extends TFPlanItem {
313114
313574
  }
313115
313575
  }
313116
313576
 
313577
+ ;// CONCATENATED MODULE: ../terraform_provisioner/src/logger.ts
313578
+
313579
+ /* harmony default export */ const terraform_provisioner_src_logger = (catalog_common.logger);
313580
+
313117
313581
  ;// CONCATENATED MODULE: ../terraform_provisioner/src/utils.ts
313118
313582
 
313119
313583
 
313120
- //import Debug from "debug"
313121
313584
 
313122
- //const infolog: Debug.Debugger = Debug('firestartr:operator:cmd:terraform')
313585
+
313123
313586
  async function utils_validate(path, secrets) {
313124
313587
  return await tfExec(path, ['validate'], secrets);
313125
313588
  }
313126
- async function init(path, secrets) {
313127
- return await tfExec(path, ['init'], secrets);
313589
+ async function init(path, secrets, stream) {
313590
+ return await tfExec(path, ['init'], secrets, ['-input=false'], stream);
313128
313591
  }
313129
- async function initFromModule(path, source, secrets) {
313130
- return tfExec(path, ['init', `-from-module=${source}`], secrets, []);
313592
+ async function initFromModule(path, source, secrets, stream) {
313593
+ return tfExec(path, ['init', `-from-module=${source}`], secrets, [], stream);
313131
313594
  }
313132
- async function plan(path, secrets, format, args = ['plan']) {
313133
- const plan = await tfExec(path, args.concat(format === 'json' ? ['-json'] : []), secrets);
313595
+ async function plan(path, secrets, format, args = ['plan'], stream) {
313596
+ terraform_provisioner_src_logger.info(`Running terraform plan with ${format} in path ${path}`);
313597
+ const plan = await tfExec(path, args.concat(format === 'json' ? ['-json'] : []), secrets, ['-input=false'], stream);
313134
313598
  if (format === 'json') {
313135
313599
  const tfPlan = planGet(plan);
313136
313600
  return tfPlan;
313137
313601
  }
313138
313602
  return plan;
313139
313603
  }
313140
- async function apply(path, secrets) {
313141
- return await tfExec(path, ['apply', '-auto-approve'], secrets);
313604
+ async function apply(path, secrets, stream) {
313605
+ terraform_provisioner_src_logger.debug(`Running terraform apply in path ${path}`);
313606
+ return await tfExec(path, ['apply', '-auto-approve'], secrets, ['-input=false'], stream);
313142
313607
  }
313143
- async function destroy(path, secrets) {
313144
- return await tfExec(path, ['destroy', '-auto-approve'], secrets);
313608
+ async function destroy(path, secrets, stream) {
313609
+ terraform_provisioner_src_logger.debug(`Running terraform destroy in path ${path}`);
313610
+ return await tfExec(path, ['destroy', '-auto-approve'], secrets, ['-input=false'], stream);
313145
313611
  }
313146
313612
  async function output(path, secrets) {
313613
+ terraform_provisioner_src_logger.debug(`Running terraform output in path ${path}`);
313147
313614
  return await tfExec(path, ['output', '-json'], secrets, []);
313148
313615
  }
313149
- async function tfExec(path, args, secrets, extraArgs = ['-input=false']) {
313616
+ async function tfExec(path, args, secrets, extraArgs = ['-input=false'], stream) {
313150
313617
  // Format to TF_VAR variables -> https://developer.hashicorp.com/terraform/cli/config/environment-variables#tf_var_name
313151
313618
  for (const secret of secrets) {
313152
313619
  process.env[`${secret.key}`] = secret.value;
313153
313620
  }
313621
+ terraform_provisioner_src_logger.info(`Spawning terraform process ['terraform ${args.concat(extraArgs).join(' ')}'] in path '${path}'`);
313154
313622
  process.env['TF_PLUGIN_CACHE_DIR'] = '/home/terraform-plugins-cache';
313155
313623
  return new Promise((ok, ko) => {
313156
- const tfProcess = (0,external_child_process_.spawn)('terraform', args.concat(extraArgs), { cwd: path });
313157
- tfProcess.stdout.pipe(process.stdout);
313158
- tfProcess.stderr.pipe(process.stderr);
313624
+ const tfProcess = (0,external_child_process_.spawn)('terraform', args.concat(extraArgs), {
313625
+ cwd: path,
313626
+ stdio: ['inherit', 'pipe', 'pipe'],
313627
+ });
313159
313628
  let output = '';
313160
313629
  let flagStdoutEnd = false;
313161
313630
  let flagStderrEnd = false;
313162
313631
  let outputErrors = '';
313163
313632
  tfProcess.stdout.on('data', (log) => {
313164
- output += catalog_common.io.stripAnsi(log.toString());
313633
+ const line = catalog_common.io.stripAnsi(log.toString());
313634
+ output += line;
313635
+ if (stream)
313636
+ stream.write(line);
313165
313637
  });
313166
313638
  tfProcess.stderr.on('data', (log) => {
313167
- outputErrors += catalog_common.io.stripAnsi(log.toString());
313639
+ const line = catalog_common.io.stripAnsi(log.toString());
313640
+ outputErrors += line;
313641
+ if (stream)
313642
+ stream.write(line);
313168
313643
  });
313169
313644
  tfProcess.stdout.on('end', () => {
313170
313645
  flagStdoutEnd = true;
@@ -313179,9 +313654,12 @@ async function tfExec(path, args, secrets, extraArgs = ['-input=false']) {
313179
313654
  await catalog_common.generic.sleep(500);
313180
313655
  }
313181
313656
  if (code !== 0) {
313182
- ko(output + outputErrors);
313657
+ terraform_provisioner_src_logger.error(`Terraform output ${path}: ${output + outputErrors}`);
313658
+ terraform_provisioner_src_logger.error(`Terraform output ${path}: ${[output, outputErrors].join('')}`);
313659
+ ko([output, outputErrors].join(''));
313183
313660
  }
313184
313661
  else {
313662
+ terraform_provisioner_src_logger.info(`Terraform output ${path}: ${output}`);
313185
313663
  ok(output);
313186
313664
  }
313187
313665
  });
@@ -313195,7 +313673,9 @@ async function configureGit(ghToken) {
313195
313673
  'url."https://' + ghToken + '@github.com".insteadOf',
313196
313674
  'https://github.com',
313197
313675
  ];
313198
- const gitProcess = spawn('git', options);
313676
+ const gitProcess = spawn('git', options, {
313677
+ stdio: ['inherit', 'pipe', 'pipe'],
313678
+ });
313199
313679
  let output = '';
313200
313680
  gitProcess.on('data', (log) => {
313201
313681
  output += common.io.stripAnsi(log.toString());
@@ -313550,6 +314030,7 @@ function fCheckString(keys, refs) {
313550
314030
 
313551
314031
 
313552
314032
 
314033
+
313553
314034
  class project_tf_TFProjectManager {
313554
314035
  constructor(ctx) {
313555
314036
  this.tfOutput = '';
@@ -313558,6 +314039,14 @@ class project_tf_TFProjectManager {
313558
314039
  this.tfVarsJsonWriter = new WriterTfVarsJson(ctx.values, ctx.references);
313559
314040
  this.secrets = ctx.secrets;
313560
314041
  }
314042
+ setStreamCallbacks(fnData, fnEnd, reopen = true) {
314043
+ if (reopen || !this.stream)
314044
+ this.stream = new external_stream_.PassThrough();
314045
+ this.stream.on('data', (data) => {
314046
+ fnData(data.toString());
314047
+ });
314048
+ this.stream.on('end', fnEnd);
314049
+ }
313561
314050
  getOutput() {
313562
314051
  return this.tfOutput;
313563
314052
  }
@@ -313568,10 +314057,10 @@ class project_tf_TFProjectManager {
313568
314057
  this.tfVarsJsonWriter.writeToTerraformProject(external_path_.join(this.projectPath, 'terraform.tfvars.json'));
313569
314058
  }
313570
314059
  async __init() {
313571
- this.tfOutput += await init(this.projectPath, this.secrets);
314060
+ this.tfOutput += await init(this.projectPath, this.secrets, this.stream);
313572
314061
  }
313573
314062
  async __initFromModule() {
313574
- this.tfOutput += await init(this.projectPath, this.secrets);
314063
+ this.tfOutput += await init(this.projectPath, this.secrets, this.stream);
313575
314064
  }
313576
314065
  async validate() {
313577
314066
  await this.__init();
@@ -313581,24 +314070,27 @@ class project_tf_TFProjectManager {
313581
314070
  await this.__init();
313582
314071
  if (format === 'json')
313583
314072
  this.tfOutput = null;
313584
- this.tfOutput = await plan(this.projectPath, this.secrets, format);
314073
+ this.tfOutput = await plan(this.projectPath, this.secrets, format, ['plan'], this.stream);
314074
+ if (this.stream)
314075
+ this.stream.end();
313585
314076
  }
313586
314077
  async planDestroy(format) {
313587
314078
  await this.__init();
313588
314079
  if (format === 'json')
313589
314080
  this.tfOutput = null;
313590
- this.tfOutput = await plan(this.projectPath, this.secrets, format, [
313591
- 'plan',
313592
- '-destroy',
313593
- ]);
314081
+ this.tfOutput = await plan(this.projectPath, this.secrets, format, ['plan', '-destroy'], this.stream);
313594
314082
  }
313595
314083
  async apply() {
313596
314084
  await this.__init();
313597
- this.tfOutput += await apply(this.projectPath, this.secrets);
314085
+ this.tfOutput += await apply(this.projectPath, this.secrets, this.stream);
314086
+ if (this.stream)
314087
+ this.stream.end();
313598
314088
  }
313599
314089
  async destroy() {
313600
314090
  await this.__init();
313601
- this.tfOutput += await destroy(this.projectPath, this.secrets);
314091
+ this.tfOutput += await destroy(this.projectPath, this.secrets, this.stream);
314092
+ if (this.stream)
314093
+ this.stream.end();
313602
314094
  }
313603
314095
  async output() {
313604
314096
  await this.__init();
@@ -313692,6 +314184,7 @@ var lib_ajv_default = /*#__PURE__*/__nccwpck_require__.n(lib_ajv);
313692
314184
 
313693
314185
 
313694
314186
 
314187
+
313695
314188
  class TFProjectManagerRemote {
313696
314189
  constructor(ctx) {
313697
314190
  this.tfOutput = '';
@@ -313704,6 +314197,14 @@ class TFProjectManagerRemote {
313704
314197
  getOutput() {
313705
314198
  return this.tfOutput;
313706
314199
  }
314200
+ setStreamCallbacks(fnData, fnEnd, reopen = true) {
314201
+ if (reopen || !this.stream)
314202
+ this.stream = new external_stream_.PassThrough();
314203
+ this.stream.on('data', (data) => {
314204
+ fnData(data.toString());
314205
+ });
314206
+ this.stream.on('end', fnEnd);
314207
+ }
313707
314208
  async build() {
313708
314209
  external_fs_.rmSync(this.projectPath, { recursive: true, force: true });
313709
314210
  await this.__configGit();
@@ -313735,19 +314236,25 @@ insteadOf = https://github.com`);
313735
314236
  async plan(format) {
313736
314237
  await this.__init();
313737
314238
  if (format === 'json') {
313738
- this.tfOutput = await plan(this.projectPath, this.secrets, format);
314239
+ this.tfOutput = await plan(this.projectPath, this.secrets, format, ['plan'], this.stream);
313739
314240
  }
313740
314241
  else {
313741
- this.tfOutput += await plan(this.projectPath, this.secrets, format);
314242
+ this.tfOutput += await plan(this.projectPath, this.secrets, format, ['plan'], this.stream);
313742
314243
  }
314244
+ if (this.stream)
314245
+ this.stream.end();
313743
314246
  }
313744
314247
  async apply() {
313745
314248
  await this.__init();
313746
- this.tfOutput += await apply(this.projectPath, this.secrets);
314249
+ this.tfOutput += await apply(this.projectPath, this.secrets, this.stream);
314250
+ if (this.stream)
314251
+ this.stream.end();
313747
314252
  }
313748
314253
  async destroy() {
313749
314254
  await this.__init();
313750
- this.tfOutput += await destroy(this.projectPath, this.secrets);
314255
+ this.tfOutput += await destroy(this.projectPath, this.secrets, this.stream);
314256
+ if (this.stream)
314257
+ this.stream.end();
313751
314258
  }
313752
314259
  async planDestroy(format) {
313753
314260
  await this.__init();
@@ -313776,6 +314283,7 @@ insteadOf = https://github.com`);
313776
314283
 
313777
314284
 
313778
314285
 
314286
+
313779
314287
  const terraform_provisioner_ajv = new (lib_ajv_default())();
313780
314288
  const terraform_provisioner_validate = terraform_provisioner_ajv.compile(terraform_provisioner_src_schema);
313781
314289
  function validateContext(context) {
@@ -313793,7 +314301,8 @@ async function run() {
313793
314301
  await execCommand(command, tfProject);
313794
314302
  }
313795
314303
  // Programatic API
313796
- async function runTerraformProvisioner(context, command = 'init') {
314304
+ async function runTerraformProvisioner(context, command = 'init', streaming) {
314305
+ terraform_provisioner_src_logger.info(`Running command ${command} on a ${context.type} project`);
313797
314306
  validateContext(context);
313798
314307
  let tfProject = {};
313799
314308
  if (context.type === 'Inline') {
@@ -313802,10 +314311,14 @@ async function runTerraformProvisioner(context, command = 'init') {
313802
314311
  else if (context.type === 'Remote') {
313803
314312
  tfProject = new TFProjectManagerRemote(context);
313804
314313
  }
314314
+ if (streaming) {
314315
+ tfProject.setStreamCallbacks(streaming.fnData, streaming.fnEnd);
314316
+ }
313805
314317
  const output = await execCommand(command, tfProject);
313806
314318
  return output;
313807
314319
  }
313808
314320
  async function execCommand(command, tfProject) {
314321
+ terraform_provisioner_src_logger.info(`Executing command ${command} on ${tfProject.projectPath}`);
313809
314322
  await tfProject.build();
313810
314323
  switch (command) {
313811
314324
  case 'init':
@@ -313914,6 +314427,52 @@ async function* errorPolicyCompatibility(syncPolicy, generalPolicy, item, op) {
313914
314427
  await tryPublishError(item, op, message);
313915
314428
  }
313916
314429
 
314430
+ ;// CONCATENATED MODULE: ../operator/src/user-feedback-ops/tf-checkrun.ts
314431
+
314432
+ async function TFCheckRun(cmd, item) {
314433
+ const prInfo = tf_checkrun_extractPrInfo(item);
314434
+ if (!prInfo.prNumber) {
314435
+ throw new Error('TFCheckRun: prNumber not retrievable');
314436
+ }
314437
+ const checkRun = await github_0.feedback.createCheckRun(prInfo.org, prInfo.repo, tf_checkrun_helperCreateCheckRunName(cmd), {
314438
+ //Number(pr_number),
314439
+ pullNumber: Number(prInfo.prNumber),
314440
+ includeCheckRunComment: true,
314441
+ checkRunComment: `The TFWorkspace is being processed (cmd=${cmd}). Details: `,
314442
+ });
314443
+ checkRun.mdOptionsDetails({
314444
+ quotes: 'terraform',
314445
+ });
314446
+ checkRun.update('Initiating', 'queued');
314447
+ return {
314448
+ fnData: (d) => {
314449
+ checkRun.update(d.toString(), 'in_progress');
314450
+ },
314451
+ fnEnd: () => {
314452
+ checkRun.close('OK', true);
314453
+ },
314454
+ fnOnError: (err) => {
314455
+ checkRun.close('KO', false);
314456
+ },
314457
+ };
314458
+ }
314459
+ function tf_checkrun_helperCreateCheckRunName(cmd) {
314460
+ return `TFWorkspace - ${cmd}`;
314461
+ }
314462
+ function tf_checkrun_extractPrInfo(item) {
314463
+ const prInfo = item.metadata.annotations['firestartr.dev/last-state-pr'];
314464
+ const prNumber = prInfo.split('#')[1];
314465
+ if (!prNumber)
314466
+ throw new Error('No PR number found in CR');
314467
+ const org = prInfo.split('#')[0].split('/')[0];
314468
+ if (!org)
314469
+ throw new Error('No org found in CR');
314470
+ const repo = prInfo.split('#')[0].split('/')[1];
314471
+ if (!repo)
314472
+ throw new Error('No repo found in CR');
314473
+ return { prNumber, repo, org };
314474
+ }
314475
+
313917
314476
  ;// CONCATENATED MODULE: ../operator/src/tfworkspaces/process-operation.ts
313918
314477
 
313919
314478
 
@@ -313924,6 +314483,7 @@ async function* errorPolicyCompatibility(syncPolicy, generalPolicy, item, op) {
313924
314483
 
313925
314484
 
313926
314485
 
314486
+
313927
314487
  const TF_PROJECTS_PATH = '/tmp/tfworkspaces';
313928
314488
  function process_operation_processOperation(item, op, handler) {
313929
314489
  try {
@@ -313957,7 +314517,7 @@ function process_operation_processOperation(item, op, handler) {
313957
314517
  }
313958
314518
  }
313959
314519
  catch (e) {
313960
- src_logger.error('TERRAFORM_PROCESSOR_OP_ERROR', { metadata: { op, error: e } });
314520
+ operator_src_logger.error(`The Terraform processor encountered an error during operation '${op}': '${e}'.`);
313961
314521
  throw e;
313962
314522
  }
313963
314523
  }
@@ -313990,9 +314550,7 @@ async function* doPlanJSONFormat(item, op, handler) {
313990
314550
  message: 'Planning process started',
313991
314551
  };
313992
314552
  const deps = await handler.resolveReferences();
313993
- src_logger.info('TERRAFORM_PROCESSOR_PLAN_ASSESS_DEPS', {
313994
- metadata: { item, deps },
313995
- });
314553
+ operator_src_logger.info(`The Terraform processor is planning to assess dependencies for item '${item.kind}/${item.metadata.name}' with dependencies: '${deps}'.`);
313996
314554
  const context = buildProvisionerContext(item, deps);
313997
314555
  let planType = 'plan-json';
313998
314556
  if ('deletionTimestamp' in item.metadata) {
@@ -314055,9 +314613,7 @@ async function* doPlanJSONFormat(item, op, handler) {
314055
314613
  }
314056
314614
  catch (e) {
314057
314615
  console.error(e);
314058
- src_logger.error('TERRAFORM_PROCESSOR_PLAN_OBSERVE_ERROR', {
314059
- metadata: { item, error: e },
314060
- });
314616
+ operator_src_logger.error(`The Terraform processor encountered an error while observing the plan for item '${item.kind}/${item.metadata.name}': '${e}'.`);
314061
314617
  yield {
314062
314618
  item,
314063
314619
  reason: op,
@@ -314143,9 +314699,7 @@ async function* process_operation_sync(item, op, handler, syncPolicy, generalPol
314143
314699
  message: 'Sync process started',
314144
314700
  };
314145
314701
  if (!syncPolicy) {
314146
- src_logger.debug('TERRAFORM_PROCESSOR_NO_SYNC_POLICY_ONLY_OBSERVE', {
314147
- metadata: { op, item },
314148
- });
314702
+ operator_src_logger.debug(`The Terraform processor is only observing item '${item.kind}/${item.metadata.name}' because no sync policy was found for operation '${op}'.`);
314149
314703
  yield* doPlanJSONFormat(item, op, handler);
314150
314704
  return;
314151
314705
  }
@@ -314164,9 +314718,7 @@ async function* process_operation_sync(item, op, handler, syncPolicy, generalPol
314164
314718
  break;
314165
314719
  }
314166
314720
  default: {
314167
- src_logger.debug('TERRAFORM_PROCESSOR_POLICY_NOT_SUPPORTED', {
314168
- metadata: { syncPolicy, item },
314169
- });
314721
+ operator_src_logger.debug(`The Terraform processor detected a sync policy '${syncPolicy}' for item '${item.kind}/${item.metadata.name}' that is not supported.`);
314170
314722
  yield* doPlanJSONFormat(item, op, handler);
314171
314723
  break;
314172
314724
  }
@@ -314291,6 +314843,7 @@ async function* process_operation_nothing(item, op, handler) {
314291
314843
  * @param handler -
314292
314844
  */
314293
314845
  async function* process_operation_doApply(item, op, handler) {
314846
+ const checkRunCtl = await TFCheckRun('apply', item);
314294
314847
  try {
314295
314848
  yield {
314296
314849
  item,
@@ -314337,14 +314890,9 @@ async function* process_operation_doApply(item, op, handler) {
314337
314890
  message: 'Provisioning process started',
314338
314891
  };
314339
314892
  const deps = await handler.resolveReferences();
314340
- src_logger.info('TERRAFORM_PROCESSOR_APPLY_ASSESS_DEPS', {
314341
- metadata: { item, deps },
314342
- });
314893
+ operator_src_logger.info(`The Terraform processor is applying and assessing dependencies for item '${item.kind}/${item.metadata.name}' with dependencies: '${deps}'.`);
314343
314894
  const context = buildProvisionerContext(item, deps);
314344
- if (item.metadata.annotations['firestartr.dev/last-state-pr'] || false) {
314345
- await addApplyCommitStatus(item, 'pending', catalog_common.generic.getPrLinkFromAnnotationValue(item.metadata.annotations['firestartr.dev/last-state-pr']), 'Performing apply operation...', `Terraform Apply ${item.metadata.name}`);
314346
- }
314347
- const applyOutput = await runTerraformProvisioner(context, 'apply');
314895
+ const applyOutput = await runTerraformProvisioner(context, 'apply', checkRunCtl);
314348
314896
  await tryPublishApply(item, applyOutput, 'TFWorkspace');
314349
314897
  const terraformOutputJson = await runTerraformProvisioner(context, 'output');
314350
314898
  if (!terraformOutputJson) {
@@ -314376,17 +314924,13 @@ async function* process_operation_doApply(item, op, handler) {
314376
314924
  message: 'doApply',
314377
314925
  };
314378
314926
  await handler.writeTerraformOutputInTfResult(item, output);
314379
- if (item.metadata.annotations['firestartr.dev/last-state-pr'] || false) {
314380
- await addApplyCommitStatus(item, 'success', catalog_common.generic.getPrLinkFromAnnotationValue(item.metadata.annotations['firestartr.dev/last-state-pr']), 'Apply operation completed', `Terraform Apply ${item.metadata.name}`);
314381
- }
314382
314927
  handler.success();
314383
314928
  }
314384
314929
  catch (e) {
314930
+ checkRunCtl.fnOnError(e);
314385
314931
  console.error(e);
314386
314932
  await tryPublishApply(item, e, 'TFWorkspace');
314387
- src_logger.error('TERRAFORM_PROCESSOR_APPLY_ERROR', {
314388
- metadata: { item, op, error: e },
314389
- });
314933
+ operator_src_logger.error(`The Terraform processor encountered an error during operation '${op}' for item '${item.kind}/${item.metadata.name}': '${e}'.`);
314390
314934
  yield {
314391
314935
  item,
314392
314936
  reason: op,
@@ -314408,9 +314952,6 @@ async function* process_operation_doApply(item, op, handler) {
314408
314952
  status: 'False',
314409
314953
  message: JSON.stringify(e),
314410
314954
  };
314411
- if (item.metadata.annotations['firestartr.dev/last-state-pr'] || false) {
314412
- await addApplyCommitStatus(item, 'failure', catalog_common.generic.getPrLinkFromAnnotationValue(item.metadata.annotations['firestartr.dev/last-state-pr']), 'Apply operation failed', `Terraform Apply ${item.metadata.name}`);
314413
- }
314414
314955
  handler.error();
314415
314956
  if (e) {
314416
314957
  await handler.writeTerraformOutputInTfResult(item, e);
@@ -314715,30 +315256,22 @@ async function tryAcquireOrRenewLease(namespace, leaseDurationSeconds) {
314715
315256
  const name = 'firestartr-lease';
314716
315257
  const currentPod = await getCurrentPod(namespace);
314717
315258
  try {
314718
- src_logger.debug('LEADER_ELECTION_TRYING_ACQUIRE_LEASE', {
314719
- metadata: { name, namespace },
314720
- });
315259
+ operator_src_logger.debug(`Attempting to acquire the leader election lease for '${name}' in namespace '${namespace}'.`);
314721
315260
  const lease = await k8sApi.readNamespacedLease(name, namespace);
314722
315261
  const weAreTheLeader = lease.body.metadata.ownerReferences[0].uid === currentPod.metadata.uid;
314723
315262
  if (!weAreTheLeader) {
314724
- src_logger.debug('LEADER_ELECTION_LEASE_ACQUIRED_BY_ANOTHER_POD', {
314725
- metadata: { name, namespace },
314726
- });
315263
+ operator_src_logger.debug(`Another pod has acquired the leader election lease for '${name}' in namespace '${namespace}'.`);
314727
315264
  throw new LeaseAcquisitionError('Lease already acquired by another pod');
314728
315265
  }
314729
315266
  lease.body.spec.acquireTime = new client_node_dist.V1MicroTime();
314730
315267
  lease.body.spec.renewTime = new client_node_dist.V1MicroTime();
314731
315268
  lease.body.spec.leaseDurationSeconds = 30;
314732
- src_logger.debug('LEADER_ELECTION_LEASE_RENEWING', {
314733
- metadata: { name, namespace },
314734
- });
315269
+ operator_src_logger.debug(`Renewing the leader election lease for '${name}' in namespace '${namespace}'.`);
314735
315270
  await k8sApi.replaceNamespacedLease(name, namespace, lease.body);
314736
315271
  }
314737
315272
  catch (err) {
314738
315273
  if (err.response && err.response.statusCode === 404) {
314739
- src_logger.debug('LEADER_ELECTION_LEASE_NOT_FOUND_CREATING', {
314740
- metadata: { name, namespace },
314741
- });
315274
+ operator_src_logger.debug(`The leader election lease for '${name}' in namespace '${namespace}' was not found. Creating a new one.`);
314742
315275
  const lease = {
314743
315276
  apiVersion: 'coordination.k8s.io/v1',
314744
315277
  kind: 'Lease',
@@ -314761,16 +315294,12 @@ async function tryAcquireOrRenewLease(namespace, leaseDurationSeconds) {
314761
315294
  },
314762
315295
  };
314763
315296
  await k8sApi.createNamespacedLease(namespace, lease);
314764
- src_logger.debug('LEADER_ELECTION_LEASE_CREATED', {
314765
- metadata: { name, namespace },
314766
- });
315297
+ operator_src_logger.debug(`A new leader election lease has been created for '${name}' in namespace '${namespace}'.`);
314767
315298
  }
314768
315299
  else {
314769
315300
  if (err.response)
314770
315301
  console.log(err.response);
314771
- src_logger.debug('LEADER_ELECTION_LEASE_RENEWAL_ERROR', {
314772
- metadata: { name, namespace, error: err },
314773
- });
315302
+ operator_src_logger.debug(`An error occurred while renewing the leader election lease for '${name}' in namespace '${namespace}': '${err}'.`);
314774
315303
  throw err;
314775
315304
  }
314776
315305
  }
@@ -314781,9 +315310,7 @@ async function tryAcquireOrRenewLease(namespace, leaseDurationSeconds) {
314781
315310
  async function acquireLease(namespace, cb, interval = 10000) {
314782
315311
  try {
314783
315312
  await tryAcquireOrRenewLease(namespace, interval / 1000);
314784
- src_logger.debug('LEADER_ELECTION_LEASE_ACQUIRED_EXEC_CALLBACK', {
314785
- metadata: { namespace },
314786
- });
315313
+ operator_src_logger.debug(`Successfully acquired the leader election lease in namespace '${namespace}'. Executing the callback.`);
314787
315314
  cb();
314788
315315
  }
314789
315316
  catch (err) {
@@ -314791,9 +315318,7 @@ async function acquireLease(namespace, cb, interval = 10000) {
314791
315318
  if (err instanceof LeaseAcquisitionError) {
314792
315319
  console.error(`Failed to acquire Lease, retrying in ${interval / 1000} seconds`);
314793
315320
  }
314794
- src_logger.silly('LEADER_ELECTION_LEASE_ACQUIRED_FAILED_RETRY', {
314795
- metadata: { retryIn: interval / 1000 },
314796
- });
315321
+ operator_src_logger.silly(`Failed to acquire the leader election lease; will retry in '${interval / 1000}' seconds.`);
314797
315322
  await setTimeout(() => acquireLease(namespace, cb), interval);
314798
315323
  }
314799
315324
  }
@@ -314822,7 +315347,7 @@ function processOperationPlan(item, op, handler) {
314822
315347
  }
314823
315348
  }
314824
315349
  catch (e) {
314825
- src_logger.error('TFWORKSPACE_PROCESSOR_PLAN_ERROR', {
315350
+ operator_src_logger.error('TFWORKSPACE_PROCESSOR_PLAN_ERROR', {
314826
315351
  metadata: { item, error: e, op },
314827
315352
  });
314828
315353
  throw e;
@@ -314873,7 +315398,7 @@ async function* doPlanPlainTextFormat(item, op, handler, action) {
314873
315398
  message: 'Planning process started',
314874
315399
  };
314875
315400
  const deps = await handler.resolveReferences();
314876
- src_logger.info('TFWORKSPACE_PROCESSOR_PLAN_ASSESS_DEPS', {
315401
+ operator_src_logger.info('TFWORKSPACE_PROCESSOR_PLAN_ASSESS_DEPS', {
314877
315402
  metadata: { item, deps },
314878
315403
  });
314879
315404
  const context = processOperationPlan_buildProvisionerContext(item, deps);
@@ -314909,7 +315434,7 @@ async function* doPlanPlainTextFormat(item, op, handler, action) {
314909
315434
  }
314910
315435
  catch (e) {
314911
315436
  await processOperationPlan_publishPlan(item, JSON.stringify(e));
314912
- src_logger.error('TFWORKSPACE_PROCESSOR_PLAN_OBSERVING_ERROR', {
315437
+ operator_src_logger.error('TFWORKSPACE_PROCESSOR_PLAN_OBSERVING_ERROR', {
314913
315438
  metadata: { item, error: e },
314914
315439
  });
314915
315440
  yield {
@@ -314967,7 +315492,7 @@ async function* processOperationPlan_doPlanJSONFormat(item, op, handler, action)
314967
315492
  message: 'Planning process started',
314968
315493
  };
314969
315494
  const deps = await handler.resolveReferences();
314970
- src_logger.info('TFWORKSPACE_PROCESSOR_PLAN_DO_PLAN_ASSESS_DEPS', {
315495
+ operator_src_logger.info('TFWORKSPACE_PROCESSOR_PLAN_DO_PLAN_ASSESS_DEPS', {
314971
315496
  metadata: { item, deps },
314972
315497
  });
314973
315498
  const context = processOperationPlan_buildProvisionerContext(item, deps);
@@ -315027,7 +315552,7 @@ async function* processOperationPlan_doPlanJSONFormat(item, op, handler, action)
315027
315552
  }
315028
315553
  catch (e) {
315029
315554
  console.error(e);
315030
- src_logger.error('TFWORKSPACE_PROCESSOR_PLAN_DO_PLAN_ERROR', {
315555
+ operator_src_logger.error('TFWORKSPACE_PROCESSOR_PLAN_DO_PLAN_ERROR', {
315031
315556
  metadata: { item, error: e },
315032
315557
  });
315033
315558
  yield {
@@ -315394,42 +315919,30 @@ async function ctx_buildContext(claim, namespace, command) {
315394
315919
  let cr = null;
315395
315920
  let deps = null;
315396
315921
  compute['resolveDeps'] = async () => {
315397
- src_logger.debug('TFWORKSPACE_RESOLVE_DEPS_FOR_CLAIM', {
315398
- metadata: { name: claim.name },
315399
- });
315922
+ operator_src_logger.debug(`The Terraform workspace is resolving dependencies for the claim '${claim.name}'.`);
315400
315923
  // First, we bring the previous CR, if any, to get the tfStateKey
315401
- src_logger.debug('TFWORKSPACE_RESOLVE_GET_PREVIOUS_CR', {
315402
- metadata: { name: claim.name },
315403
- });
315924
+ operator_src_logger.debug(`The Terraform workspace is resolving and getting the previous custom resource for claim '${claim.name}'.`);
315404
315925
  previousCR = await getCRfromClaimRef(claim.kind, claim.name, namespace);
315405
315926
  let tfStateKey = null;
315406
315927
  if (previousCR) {
315407
- src_logger.debug('TFWORKSPACE_RESOLVE_PREVIOUS_CR_FOUND', {
315408
- metadata: { name: claim.name },
315409
- });
315928
+ operator_src_logger.debug(`The Terraform workspace found a previous custom resource for claim '${claim.name}'.`);
315410
315929
  tfStateKey = previousCR.spec.firestartr.tfStateKey;
315411
315930
  }
315412
315931
  else
315413
- src_logger.debug('TFWORKSPACE_RESOLVE_PREVIOUS_CR_NOT_FOUND', {
315414
- metadata: { name: claim.name },
315415
- });
315932
+ operator_src_logger.debug(`The Terraform workspace did not find a previous custom resource for claim '${claim.name}'.`);
315416
315933
  // Then we render the claim passing a function to resolve the refs in the k8s API
315417
- src_logger.debug('TFWORKSPACE_RESOLVE_START_RENDERING', {
315418
- metadata: { name: claim.name },
315419
- });
315934
+ operator_src_logger.debug(`The Terraform workspace is starting the rendering process for claim '${claim.name}'.`);
315420
315935
  cr = await cdk8s_renderer.renderTfWorkspace(claim, tfStateKey, getTFWorkspaceRefs, namespace);
315421
315936
  cr['metadata']['namespace'] = namespace;
315422
- src_logger.debug('TFWORKSPACE_RESOLVE_CR_RENDERED', { metadata: { cr } });
315937
+ operator_src_logger.debug(`The Terraform workspace has finished rendering the custom resource '${cr.kind}/${cr.metadata.name}' in namespace '${cr.metadata.namespace}'.`);
315423
315938
  // Finally, we resolve the deps in the rendered CR
315424
315939
  deps = await resolve(cr, getItemByItemPath, getSecret, namespace);
315425
- src_logger.debug('TFWORKSPACE_RESOLVE_DEPS_RESOLVED', {
315426
- metadata: { name: claim.name },
315427
- });
315940
+ operator_src_logger.debug(`The Terraform workspace has finished resolving all dependencies for claim '${claim.name}'.`);
315428
315941
  };
315429
315942
  compute['dryRunExec'] = async () => {
315430
315943
  // We assume that if there is no previous CR, we are creating a new one
315431
315944
  // This will be preceeded by the resolveDeps function
315432
- src_logger.debug('TFWORKSPACE_DRY_RUN_VALIDATING_CR', { metadata: { cr } });
315945
+ operator_src_logger.debug(`The Terraform workspace is dry-running the validation for custom resource '${cr.kind}/${cr.metadata.name}' in namespace '${cr.metadata.namespace}'.`);
315433
315946
  if (!previousCR) {
315434
315947
  await createDryRun(cr, namespace);
315435
315948
  }
@@ -315437,17 +315950,15 @@ async function ctx_buildContext(claim, namespace, command) {
315437
315950
  cr.metadata.resourceVersion = previousCR.metadata.resourceVersion;
315438
315951
  await updateDryRun(cr, namespace);
315439
315952
  }
315440
- src_logger.debug('TFWORKSPACE_DRY_RUN_VALIDATED_CR', { metadata: { cr } });
315953
+ operator_src_logger.debug(`The Terraform workspace has finished validating the custom resource '${cr.kind}/${cr.metadata.name}' in namespace '${cr.metadata.namespace}'.`);
315441
315954
  };
315442
315955
  compute['runProvision'] = async () => {
315443
- src_logger.debug('TFWORKSPACE_RUN_PROVISION_INIT_TERRAFORM', {
315956
+ operator_src_logger.debug('TFWORKSPACE_RUN_PROVISION_INIT_TERRAFORM', {
315444
315957
  metadata: { cr, command },
315445
315958
  });
315446
315959
  const data = await buildProvisionerContext(cr, deps);
315447
315960
  const result = await runTerraformProvisioner(data, command);
315448
- src_logger.debug('TFWORKSPACE_RUN_PROVISION_FINISHED_TERRAFORM', {
315449
- metadata: { cr, command },
315450
- });
315961
+ operator_src_logger.debug(`The Terraform workspace has finished the '${command}' command for provisioning custom resource '${cr.kind}/${cr.metadata.name}' in namespace '${cr.metadata.namespace}'.`);
315451
315962
  return result;
315452
315963
  };
315453
315964
  return new Ctx({}, compute);
@@ -315600,27 +316111,28 @@ var sdk_metrics_build_src = __nccwpck_require__(84016);
315600
316111
  ;// CONCATENATED MODULE: ../operator/src/metrics/CRStates.ts
315601
316112
 
315602
316113
 
316114
+
315603
316115
  const INTERVAL_IN_SEGS = 60;
315604
316116
  class CRStateMetrics {
315605
316117
  constructor(kind, namespace, meter) {
315606
316118
  this.kind = kind;
315607
- this.provisionedGauge = meter.createGauge(`firestartr_${this.kind}_provisioned_total`, {
315608
- description: `Total number of ${this.kind} in PROVISIONED state`,
316119
+ this.provisionedGauge = meter.createGauge('firestartr_provisioned_total', {
316120
+ description: 'Total number of CRs in PROVISIONED state',
315609
316121
  });
315610
- this.provisioningGauge = meter.createGauge(`firestartr_${this.kind}_provisioning_total`, {
315611
- description: `Total number of ${this.kind} in PROVISIONING state`,
316122
+ this.provisioningGauge = meter.createGauge('firestartr_provisioning_total', {
316123
+ description: 'Total number of CRs in PROVISIONING state',
315612
316124
  });
315613
- this.outOfSyncGauge = meter.createGauge(`firestartr_${this.kind}_out_of_sync_total`, {
315614
- description: `Total number of ${this.kind} in OUT_OF_SYNC state`,
316125
+ this.outOfSyncGauge = meter.createGauge('firestartr_out_of_sync_total', {
316126
+ description: 'Total number of CRs in OUT_OF_SYNC state',
315615
316127
  });
315616
- this.errorGauge = meter.createGauge(`firestartr_${this.kind}_error_total`, {
315617
- description: `Total number of ${this.kind} in ERROR state`,
316128
+ this.errorGauge = meter.createGauge('firestartr_error_total', {
316129
+ description: 'Total number of CRs in ERROR state',
315618
316130
  });
315619
- this.planningGauge = meter.createGauge(`firestartr_${this.kind}_planning_total`, {
315620
- description: `Total number of ${this.kind} in PLANNING state`,
316131
+ this.planningGauge = meter.createGauge('firestartr_planning_total', {
316132
+ description: 'Total number of CRs in PLANNING state',
315621
316133
  });
315622
- this.deletedGauge = meter.createGauge(`firestartr_${this.kind}_deleted_total`, {
315623
- description: `Total number of ${this.kind} in DELETED state`,
316134
+ this.deletedGauge = meter.createGauge('firestartr_deleted_total', {
316135
+ description: 'Total number of CRs in DELETED state',
315624
316136
  });
315625
316137
  this.namespace = namespace;
315626
316138
  }
@@ -315677,19 +316189,33 @@ class CRStateMetrics {
315677
316189
  }
315678
316190
  this.provisionedGauge.record(provisionedCount, {
315679
316191
  namespace: this.namespace,
316192
+ kind: this.kind,
315680
316193
  });
315681
316194
  this.provisioningGauge.record(provisioningCount, {
315682
316195
  namespace: this.namespace,
316196
+ kind: this.kind,
316197
+ });
316198
+ this.planningGauge.record(planningCount, {
316199
+ namespace: this.namespace,
316200
+ kind: this.kind,
316201
+ });
316202
+ this.deletedGauge.record(deletedCount, {
316203
+ namespace: this.namespace,
316204
+ kind: this.kind,
316205
+ });
316206
+ this.outOfSyncGauge.record(outOfSyncCount, {
316207
+ namespace: this.namespace,
316208
+ kind: this.kind,
316209
+ });
316210
+ this.errorGauge.record(errorCount, {
316211
+ namespace: this.namespace,
316212
+ kind: this.kind,
315683
316213
  });
315684
- this.planningGauge.record(planningCount, { namespace: this.namespace });
315685
- this.deletedGauge.record(deletedCount, { namespace: this.namespace });
315686
- this.outOfSyncGauge.record(outOfSyncCount, { namespace: this.namespace });
315687
- this.errorGauge.record(errorCount, { namespace: this.namespace });
315688
316214
  }
315689
316215
  catch (err) {
315690
- console.log(err);
316216
+ console.log(`CRStateMetrics: update ${err}`);
315691
316217
  this.onUpdate = false;
315692
- throw new Error(`CRStateMetrics: update ${err}`);
316218
+ operator_src_logger.error('CR_METRICS_UPDATE', { error: err });
315693
316219
  }
315694
316220
  this.onUpdate = false;
315695
316221
  }
@@ -315783,7 +316309,7 @@ async function startCRStates(meter, kindList, namespace) {
315783
316309
 
315784
316310
  const deploymentName = catalog_common.environment.getFromEnvironment(catalog_common.types.envVars.operatorDeploymentName) || 'firestartr-firestartr-controller';
315785
316311
  const DEFAULT_OPERATOR_DEPLOY = (/* unused pure expression or super */ null && (deploymentName));
315786
- async function tfPlanner(claimFilePath, claim, namespace, debug, jobTtl, cmd = 'plan') {
316312
+ async function tfPlanner(claimFilePath, claim, namespace, debug, jobTtl = 300, cmd = 'plan') {
315787
316313
  const { kc } = await getConnection();
315788
316314
  const k8sApi = kc.makeApiClient(client.AppsV1Api);
315789
316315
  const batchV1Api = kc.makeApiClient(client.BatchV1Api);
@@ -315803,10 +316329,12 @@ async function tfPlanner(claimFilePath, claim, namespace, debug, jobTtl, cmd = '
315803
316329
  ? '/library/scripts/run.sh'
315804
316330
  : '/library/run.sh';
315805
316331
  job.spec = new client.V1JobSpec();
315806
- if (jobTtl)
315807
- job.spec.ttlSecondsAfterFinished = jobTtl;
316332
+ job.spec.ttlSecondsAfterFinished = jobTtl;
315808
316333
  job.spec.template = controllerDeploy.body.spec
315809
316334
  .template;
316335
+ // set activeDeadlineSeconds to force terminate jobs that exceed this time
316336
+ // see https://kubernetes.io/docs/concepts/workloads/controllers/job/#job-termination-and-cleanup
316337
+ job.spec.activeDeadlineSeconds = 3600;
315810
316338
  job.spec.template.spec.containers[0].command = [
315811
316339
  'sh',
315812
316340
  '-c',
@@ -315818,9 +316346,12 @@ async function tfPlanner(claimFilePath, claim, namespace, debug, jobTtl, cmd = '
315818
316346
  }
315819
316347
  job.spec.template.spec.restartPolicy = 'Never';
315820
316348
  job.metadata = metadata;
316349
+ // we exclude logs to be sent to datadog
316350
+ job.spec.template.metadata.annotations = {
316351
+ 'ad.datadoghq.com/logs_exclude': 'true',
316352
+ };
315821
316353
  await batchV1Api.createNamespacedJob(namespace, job);
315822
316354
  await copyClaimAndGetLogs(namespace, job.metadata.name, claimFilePath);
315823
- await batchV1Api.deleteNamespacedJob(job.metadata.name, namespace);
315824
316355
  }
315825
316356
  async function copyClaimAndGetLogs(namespace, jobName, sourcePath) {
315826
316357
  const { kc } = await getConnection();
@@ -315974,7 +316505,7 @@ function runOperator(opts) {
315974
316505
  importModeActive = importMode;
315975
316506
  if (importModeSkipPlan)
315976
316507
  importModeSkipPlanActive = importModeSkipPlan;
315977
- src_logger.info('START_OPERATOR', { ...opts });
316508
+ operator_src_logger.info(`started the operator with options ${JSON.stringify(opts)}`);
315978
316509
  const run = ignoreLease
315979
316510
  ? (_namespace, cb) => cb()
315980
316511
  : acquireLease;
@@ -315994,7 +316525,7 @@ function runOperator(opts) {
315994
316525
  .catch((e) => {
315995
316526
  console.log('exit catch kind', kind);
315996
316527
  console.error(e);
315997
- src_logger.error('CRASHED', { kind, error: e });
316528
+ operator_src_logger.error('CRASHED', { kind, error: e });
315998
316529
  })
315999
316530
  .finally(() => {
316000
316531
  console.log('kind', kind);
@@ -316026,7 +316557,7 @@ function getProvisionImplementation(plural) {
316026
316557
  }
316027
316558
  if (!implementation)
316028
316559
  throw new Error(`No implementation found for ${plural}`);
316029
- src_logger.info('GOT_PROVISION_IMPL', { kind: plural });
316560
+ operator_src_logger.info(`Retrieved the provision implementation for the kind '${plural}'`);
316030
316561
  return implementation;
316031
316562
  }
316032
316563