@firestartr/cli 1.53.0-snapshot-1 → 1.53.0-snapshot-3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.js +80 -96
- package/build/packages/cdk8s_renderer/imports/firestartr.dev.d.ts +4 -0
- package/build/packages/cdk8s_renderer/src/claims/base/schemas/domain.schema.d.ts +1 -0
- package/build/packages/cdk8s_renderer/src/claims/base/schemas/index.d.ts +1 -0
- package/build/packages/cdk8s_renderer/src/claims/github/repositoryFeature.d.ts +1 -0
- package/build/packages/features_renderer/src/schema.d.ts +3 -0
- package/build/packages/operator/src/user-feedback-ops/tf-checkrun.d.ts +1 -1
- package/build/packages/operator/src/user-feedback-ops/user-feedback-ops.d.ts +5 -0
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -354119,6 +354119,7 @@ async function getUserInfo(name) {
|
|
|
354119
354119
|
});
|
|
354120
354120
|
|
|
354121
354121
|
;// CONCATENATED MODULE: ../github/src/sticky_comment.ts
|
|
354122
|
+
|
|
354122
354123
|
const locks = new Map();
|
|
354123
354124
|
async function withLock(key, fn) {
|
|
354124
354125
|
const prev = locks.get(key) ?? Promise.resolve();
|
|
@@ -354152,6 +354153,7 @@ async function readStickyIdFromPrBody(octokit, owner, repo, pr, kind) {
|
|
|
354152
354153
|
const prResp = await octokit.rest.pulls.get({ owner, repo, pull_number: pr });
|
|
354153
354154
|
const body = prResp.data?.body ?? '';
|
|
354154
354155
|
const m = body.match(prIdRegex(kind));
|
|
354156
|
+
github_src_logger.info(`readStickyIdFromPrBody: owner=${owner} repo=${repo} pr=${pr} kind=${kind} => id=${m ? m[1] : 'undefined'}`);
|
|
354155
354157
|
return m ? Number(m[1]) : undefined;
|
|
354156
354158
|
}
|
|
354157
354159
|
async function writeStickyIdToPrBody(octokit, owner, repo, pr, kind, id) {
|
|
@@ -354159,6 +354161,7 @@ async function writeStickyIdToPrBody(octokit, owner, repo, pr, kind, id) {
|
|
|
354159
354161
|
const body = get.data?.body ?? '';
|
|
354160
354162
|
const rx = prIdRegex(kind);
|
|
354161
354163
|
const marker = prIdMarker(kind, id);
|
|
354164
|
+
github_src_logger.info(`writeStickyIdToPrBody: owner=${owner} repo=${repo} pr=${pr} kind=${kind} id=${id}`);
|
|
354162
354165
|
const next = rx.test(body)
|
|
354163
354166
|
? body.replace(rx, marker)
|
|
354164
354167
|
: body
|
|
@@ -354181,6 +354184,7 @@ async function upsertStickyComment(octokit, params) {
|
|
|
354181
354184
|
// 1) PR-body registry fast path
|
|
354182
354185
|
const idFromPr = await readStickyIdFromPrBody(octokit, owner, repo, pullNumber, kind);
|
|
354183
354186
|
if (idFromPr) {
|
|
354187
|
+
github_src_logger.info(`upsertStickyComment: found existing comment ID ${idFromPr} from PR body for kind=${kind}`);
|
|
354184
354188
|
await octokit.rest.issues.updateComment({
|
|
354185
354189
|
owner,
|
|
354186
354190
|
repo,
|
|
@@ -354189,7 +354193,7 @@ async function upsertStickyComment(octokit, params) {
|
|
|
354189
354193
|
});
|
|
354190
354194
|
return;
|
|
354191
354195
|
}
|
|
354192
|
-
// 2) Try to find
|
|
354196
|
+
// 2) Try to find existing comments by kind marker
|
|
354193
354197
|
try {
|
|
354194
354198
|
const all = await octokit.paginate(octokit.rest.issues.listComments, {
|
|
354195
354199
|
owner,
|
|
@@ -354198,20 +354202,42 @@ async function upsertStickyComment(octokit, params) {
|
|
|
354198
354202
|
per_page: 100,
|
|
354199
354203
|
});
|
|
354200
354204
|
const marker = bodyMarker(kind);
|
|
354201
|
-
const
|
|
354202
|
-
if (
|
|
354205
|
+
const matches = all.filter((c) => typeof c.body === 'string' && c.body.includes(marker));
|
|
354206
|
+
if (matches.length > 0) {
|
|
354207
|
+
// Sort by created_at to identify the oldest comment
|
|
354208
|
+
const sorted = matches.sort((a, b) => new Date(a.created_at).getTime() - new Date(b.created_at).getTime());
|
|
354209
|
+
const primaryComment = sorted[0];
|
|
354210
|
+
// Update the primary (oldest) comment
|
|
354211
|
+
github_src_logger.info(`upsertStickyComment: found existing comment ID ${primaryComment.id} by marker for kind=${kind}, updating it and deleting ${sorted.length - 1} duplicates`);
|
|
354203
354212
|
await octokit.rest.issues.updateComment({
|
|
354204
354213
|
owner,
|
|
354205
354214
|
repo,
|
|
354206
|
-
comment_id:
|
|
354215
|
+
comment_id: primaryComment.id,
|
|
354207
354216
|
body: fullBody,
|
|
354208
354217
|
});
|
|
354209
|
-
|
|
354218
|
+
// Store its ID in PR body
|
|
354219
|
+
await writeStickyIdToPrBody(octokit, owner, repo, pullNumber, kind, primaryComment.id);
|
|
354220
|
+
// Delete all duplicate comments (from index 1 onwards)
|
|
354221
|
+
for (let i = 1; i < sorted.length; i++) {
|
|
354222
|
+
github_src_logger.info(`upsertStickyComment: deleting duplicate comment ID ${sorted[i].id} for kind=${kind}`);
|
|
354223
|
+
try {
|
|
354224
|
+
await octokit.rest.issues.deleteComment({
|
|
354225
|
+
owner,
|
|
354226
|
+
repo,
|
|
354227
|
+
comment_id: sorted[i].id,
|
|
354228
|
+
});
|
|
354229
|
+
}
|
|
354230
|
+
catch (deleteErr) {
|
|
354231
|
+
// Log but continue deleting others
|
|
354232
|
+
github_src_logger.warn(`Failed to delete duplicate comment ${sorted[i].id} for ${kind}: ${deleteErr}`);
|
|
354233
|
+
}
|
|
354234
|
+
}
|
|
354210
354235
|
return;
|
|
354211
354236
|
}
|
|
354212
354237
|
}
|
|
354213
|
-
catch {
|
|
354238
|
+
catch (err) {
|
|
354214
354239
|
// if paginate/listComments not available, we'll fall back to creating
|
|
354240
|
+
github_src_logger.warn(`Failed to list comments for kind=${kind} on PR #${pullNumber}: ${err}`);
|
|
354215
354241
|
}
|
|
354216
354242
|
// 3) Create new comment and register
|
|
354217
354243
|
const created = await octokit.rest.issues.createComment({
|
|
@@ -357701,6 +357727,7 @@ const external_node_child_process_namespaceObject = __WEBPACK_EXTERNAL_createReq
|
|
|
357701
357727
|
},
|
|
357702
357728
|
owner: {
|
|
357703
357729
|
type: 'string',
|
|
357730
|
+
pattern: '^(user|group):[a-zA-Z0-9_-]+$',
|
|
357704
357731
|
},
|
|
357705
357732
|
},
|
|
357706
357733
|
required: ['description', 'owner'],
|
|
@@ -359463,6 +359490,9 @@ var ajv_default = /*#__PURE__*/__nccwpck_require__.n(dist_ajv);
|
|
|
359463
359490
|
upgradable: {
|
|
359464
359491
|
type: 'boolean',
|
|
359465
359492
|
},
|
|
359493
|
+
target_branch: {
|
|
359494
|
+
type: 'string',
|
|
359495
|
+
},
|
|
359466
359496
|
},
|
|
359467
359497
|
required: ['dest', 'src'],
|
|
359468
359498
|
title: 'File',
|
|
@@ -360367,6 +360397,7 @@ function render(featurePath, featureRenderPath, entity, firestartrConfig = {}, f
|
|
|
360367
360397
|
// For now let's keep upgradeable flag for backward compatibility
|
|
360368
360398
|
// by default it's false
|
|
360369
360399
|
const userManaged = file.user_managed ?? file.upgradeable ?? false;
|
|
360400
|
+
const targetBranch = file.target_branch ?? '';
|
|
360370
360401
|
features_renderer_src_logger.debug(`Rendering ${src} to ${dest}`);
|
|
360371
360402
|
// render the content of the file
|
|
360372
360403
|
const content = addTraceability(context, src, renderContent(external_fs_default().readFileSync(external_path_default().join(featurePath, 'templates', src)).toString(), context));
|
|
@@ -360379,6 +360410,7 @@ function render(featurePath, featureRenderPath, entity, firestartrConfig = {}, f
|
|
|
360379
360410
|
localPath: destFilePath,
|
|
360380
360411
|
repoPath: dest,
|
|
360381
360412
|
userManaged: userManaged,
|
|
360413
|
+
targetBranch,
|
|
360382
360414
|
});
|
|
360383
360415
|
output.patches = context.config.patches;
|
|
360384
360416
|
// Not used anymore
|
|
@@ -362542,6 +362574,7 @@ function toJson_FirestartrGithubRepositoryFeatureSpecFiles(obj) {
|
|
|
362542
362574
|
'path': obj.path,
|
|
362543
362575
|
'userManaged': obj.userManaged,
|
|
362544
362576
|
'content': obj.content,
|
|
362577
|
+
'targetBranch': obj.targetBranch,
|
|
362545
362578
|
};
|
|
362546
362579
|
// filter undefined values
|
|
362547
362580
|
return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
|
|
@@ -363987,7 +364020,12 @@ class FeatureRepoChart extends BaseGithubChart {
|
|
|
363987
364020
|
version: claim.feature.version,
|
|
363988
364021
|
org: claim.org,
|
|
363989
364022
|
repositoryTarget,
|
|
363990
|
-
files: claim.files
|
|
364023
|
+
files: claim.files.map((file) => {
|
|
364024
|
+
return {
|
|
364025
|
+
...file,
|
|
364026
|
+
targetBranch: file.targetBranch,
|
|
364027
|
+
};
|
|
364028
|
+
}),
|
|
363991
364029
|
firestartr: {
|
|
363992
364030
|
tfStateKey: claim.firestartr.tfStateKey,
|
|
363993
364031
|
},
|
|
@@ -364219,10 +364257,10 @@ class GithubRepositoryChart extends BaseGithubChart {
|
|
|
364219
364257
|
this.set('features', features);
|
|
364220
364258
|
}
|
|
364221
364259
|
async postRenderSecretsSection(cr) {
|
|
364222
|
-
|
|
364223
|
-
if
|
|
364224
|
-
|
|
364225
|
-
|
|
364260
|
+
// we always render the secretsSection
|
|
364261
|
+
// even if it is empty because we don't have a proper
|
|
364262
|
+
// way to know if there were secrets and now they have been
|
|
364263
|
+
// erased
|
|
364226
364264
|
const secretsSectionChart = await (await new RepoSecretsSectionChart(this, 'secrets-section', cr.spec.firestartr.tfStateKey, this.get('claim'), [], cr).render()).postRenderer([]);
|
|
364227
364265
|
this.set('secrets_section', {
|
|
364228
364266
|
claim: {
|
|
@@ -367328,7 +367366,7 @@ async function writePlanInGithubPR(prUrl, planText) {
|
|
|
367328
367366
|
${planText}
|
|
367329
367367
|
\`\`\`
|
|
367330
367368
|
`;
|
|
367331
|
-
await github_0.pulls.commentInPR(message, +pr_number, repo, owner, '
|
|
367369
|
+
await github_0.pulls.commentInPR(message, +pr_number, repo, owner, 'terraform:plan');
|
|
367332
367370
|
}
|
|
367333
367371
|
catch (err) {
|
|
367334
367372
|
operator_src_logger.error(`writePlanInGithubPR: Cannot write plan in PR: ${err}`);
|
|
@@ -369329,13 +369367,16 @@ function provisionFeatureFiles(scope, feature) {
|
|
|
369329
369367
|
provisioner_src_logger.info(`Provisioning feature ${feature.spec.type} for ${feature.spec.repositoryTarget.name}`);
|
|
369330
369368
|
provisioner_src_logger.debug('Feature output json: %O', feature);
|
|
369331
369369
|
if (feature.spec.files) {
|
|
369370
|
+
const defaultBranchName = feature.spec.repositoryTarget.branch;
|
|
369332
369371
|
for (const file of feature.spec.files) {
|
|
369333
369372
|
provisioner_src_logger.debug('Provisioning file %O', file);
|
|
369334
369373
|
const lifecycleArg = file.userManaged
|
|
369335
369374
|
? { ignoreChanges: ['content'] }
|
|
369336
369375
|
: {};
|
|
369337
369376
|
const repoConfig = {
|
|
369338
|
-
branch:
|
|
369377
|
+
branch: file.targetBranch.length === 0
|
|
369378
|
+
? defaultBranchName
|
|
369379
|
+
: file.targetBranch,
|
|
369339
369380
|
commitMessage: `feat: ${feature.spec.type} ${feature.spec.version}`,
|
|
369340
369381
|
content: cdktf_lib.Fn.base64decode(file.content),
|
|
369341
369382
|
file: file.path,
|
|
@@ -370819,9 +370860,10 @@ if (process.env.RUN_PROVISIONER) {
|
|
|
370819
370860
|
;// CONCATENATED MODULE: ../operator/src/user-feedback-ops/user-feedback-ops.ts
|
|
370820
370861
|
|
|
370821
370862
|
|
|
370863
|
+
const LAST_STATE_PR_ANNOTATION = 'firestartr.dev/last-state-pr';
|
|
370822
370864
|
async function tryPublishApply(item, planOutput, kind) {
|
|
370823
370865
|
try {
|
|
370824
|
-
if (!(
|
|
370866
|
+
if (!(LAST_STATE_PR_ANNOTATION in item.metadata.annotations)) {
|
|
370825
370867
|
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.`);
|
|
370826
370868
|
return;
|
|
370827
370869
|
}
|
|
@@ -370865,7 +370907,7 @@ ${commentContent}
|
|
|
370865
370907
|
\`\`\`
|
|
370866
370908
|
</details>`;
|
|
370867
370909
|
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}'.`);
|
|
370868
|
-
await github_0.pulls.commentInPR(comment, lastPr.number, repo, org, '
|
|
370910
|
+
await github_0.pulls.commentInPR(comment, lastPr.number, repo, org, 'tfworkspace:destroy');
|
|
370869
370911
|
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}'.`);
|
|
370870
370912
|
currentCommentNo += 1;
|
|
370871
370913
|
}
|
|
@@ -370891,7 +370933,7 @@ async function publishApply(item, applyOutput, kind) {
|
|
|
370891
370933
|
${commentContent}
|
|
370892
370934
|
\`\`\`
|
|
370893
370935
|
</details>`;
|
|
370894
|
-
await github_0.pulls.commentInPR(comment,
|
|
370936
|
+
await github_0.pulls.commentInPR(comment, prNumber, repo, org, 'apply');
|
|
370895
370937
|
currentCommentNo += 1;
|
|
370896
370938
|
}
|
|
370897
370939
|
}
|
|
@@ -370912,8 +370954,10 @@ function tryCreateErrorSummary(title, errorMsg) {
|
|
|
370912
370954
|
return `Error when getting error summary: ${e}`;
|
|
370913
370955
|
}
|
|
370914
370956
|
}
|
|
370915
|
-
function extractPrInfo(item) {
|
|
370916
|
-
const prInfo = item.metadata.annotations[
|
|
370957
|
+
function extractPrInfo(item, annotation = LAST_STATE_PR_ANNOTATION) {
|
|
370958
|
+
const prInfo = item.metadata.annotations[annotation];
|
|
370959
|
+
if (!prInfo)
|
|
370960
|
+
throw new Error(`No ${annotation} annotation found in CR`);
|
|
370917
370961
|
const prNumber = prInfo.split('#')[1];
|
|
370918
370962
|
if (!prNumber)
|
|
370919
370963
|
throw new Error('No PR number found in CR');
|
|
@@ -370923,7 +370967,11 @@ function extractPrInfo(item) {
|
|
|
370923
370967
|
const repo = prInfo.split('#')[0].split('/')[1];
|
|
370924
370968
|
if (!repo)
|
|
370925
370969
|
throw new Error('No repo found in CR');
|
|
370926
|
-
|
|
370970
|
+
const prNumberInt = parseInt(prNumber, 10);
|
|
370971
|
+
if (isNaN(prNumberInt)) {
|
|
370972
|
+
throw new Error(`Invalid PR number found in CR: '${prNumber}'`);
|
|
370973
|
+
}
|
|
370974
|
+
return { prNumber: prNumberInt, repo, org };
|
|
370927
370975
|
}
|
|
370928
370976
|
async function tryPublishError(item, reason, message) {
|
|
370929
370977
|
try {
|
|
@@ -370940,7 +370988,7 @@ async function publishError(item, reason, message) {
|
|
|
370940
370988
|
#### ℹ️ Details:
|
|
370941
370989
|
${message}
|
|
370942
370990
|
`;
|
|
370943
|
-
await github_0.pulls.commentInPR(comment,
|
|
370991
|
+
await github_0.pulls.commentInPR(comment, prNumber, repo, org, 'logs');
|
|
370944
370992
|
}
|
|
370945
370993
|
async function publishPlan(item, planOutput, prNumber, repo, org) {
|
|
370946
370994
|
try {
|
|
@@ -370959,7 +371007,7 @@ async function publishPlan(item, planOutput, prNumber, repo, org) {
|
|
|
370959
371007
|
${commentContent}
|
|
370960
371008
|
\`\`\`
|
|
370961
371009
|
</details>`;
|
|
370962
|
-
await github_0.pulls.commentInPR(comment, prNumber, repo, org, '
|
|
371010
|
+
await github_0.pulls.commentInPR(comment, prNumber, repo, org, 'tfworkspace:plan');
|
|
370963
371011
|
currentCommentNo += 1;
|
|
370964
371012
|
}
|
|
370965
371013
|
}
|
|
@@ -370970,8 +371018,9 @@ ${commentContent}
|
|
|
370970
371018
|
|
|
370971
371019
|
;// CONCATENATED MODULE: ../operator/src/user-feedback-ops/gh-checkrun.ts
|
|
370972
371020
|
|
|
371021
|
+
|
|
370973
371022
|
async function GHCheckRun(cmd, item) {
|
|
370974
|
-
const prInfo =
|
|
371023
|
+
const prInfo = extractPrInfo(item);
|
|
370975
371024
|
if (!prInfo.prNumber) {
|
|
370976
371025
|
throw new Error('TFCheckRun: prNumber not retrievable');
|
|
370977
371026
|
}
|
|
@@ -371000,20 +371049,6 @@ async function GHCheckRun(cmd, item) {
|
|
|
371000
371049
|
function helperCreateCheckRunName(cmd, item) {
|
|
371001
371050
|
return `${item.kind} - ${cmd}`;
|
|
371002
371051
|
}
|
|
371003
|
-
function gh_checkrun_extractPrInfo(item) {
|
|
371004
|
-
const prInfo = item.metadata.annotations['firestartr.dev/last-state-pr'];
|
|
371005
|
-
const prNumber = prInfo.split('#')[1];
|
|
371006
|
-
if (!prNumber)
|
|
371007
|
-
throw new Error('No PR number found in CR');
|
|
371008
|
-
const orgRepo = prInfo.split('#')[0];
|
|
371009
|
-
const org = orgRepo.split('/')[0];
|
|
371010
|
-
if (!org)
|
|
371011
|
-
throw new Error('No org found in CR');
|
|
371012
|
-
const repo = orgRepo.split('/')[1];
|
|
371013
|
-
if (!repo)
|
|
371014
|
-
throw new Error('No repo found in CR');
|
|
371015
|
-
return { prNumber, repo, org };
|
|
371016
|
-
}
|
|
371017
371052
|
|
|
371018
371053
|
;// CONCATENATED MODULE: ../operator/cdktf.ts
|
|
371019
371054
|
|
|
@@ -372314,9 +372349,10 @@ async function* errorPolicyCompatibility(syncPolicy, generalPolicy, item, op) {
|
|
|
372314
372349
|
;// CONCATENATED MODULE: ../operator/src/user-feedback-ops/tf-checkrun.ts
|
|
372315
372350
|
|
|
372316
372351
|
|
|
372352
|
+
|
|
372317
372353
|
async function TFCheckRun(cmd, item) {
|
|
372318
372354
|
try {
|
|
372319
|
-
const prInfo =
|
|
372355
|
+
const prInfo = extractPrInfo(item);
|
|
372320
372356
|
const checkRun = await github_0.feedback.createCheckRun(prInfo.org, prInfo.repo, tf_checkrun_helperCreateCheckRunName(cmd), {
|
|
372321
372357
|
pullNumber: Number(prInfo.prNumber),
|
|
372322
372358
|
includeCheckRunComment: true,
|
|
@@ -372333,7 +372369,7 @@ async function TFCheckRun(cmd, item) {
|
|
|
372333
372369
|
fnEnd: () => {
|
|
372334
372370
|
checkRun.close('OK', true);
|
|
372335
372371
|
},
|
|
372336
|
-
fnOnError: (
|
|
372372
|
+
fnOnError: (_) => {
|
|
372337
372373
|
checkRun.close('KO', false);
|
|
372338
372374
|
},
|
|
372339
372375
|
};
|
|
@@ -372342,30 +372378,15 @@ async function TFCheckRun(cmd, item) {
|
|
|
372342
372378
|
// log error and return empty fns
|
|
372343
372379
|
logger_logger.warn('Error in TFCheckRun:', e);
|
|
372344
372380
|
return {
|
|
372345
|
-
fnData: (
|
|
372381
|
+
fnData: (_) => { },
|
|
372346
372382
|
fnEnd: () => { },
|
|
372347
|
-
fnOnError: (
|
|
372383
|
+
fnOnError: (_) => { },
|
|
372348
372384
|
};
|
|
372349
372385
|
}
|
|
372350
372386
|
}
|
|
372351
372387
|
function tf_checkrun_helperCreateCheckRunName(cmd) {
|
|
372352
372388
|
return `TFWorkspace - ${cmd}`;
|
|
372353
372389
|
}
|
|
372354
|
-
function tf_checkrun_extractPrInfo(item) {
|
|
372355
|
-
const prInfo = item.metadata.annotations['firestartr.dev/last-state-pr'];
|
|
372356
|
-
if (!prInfo)
|
|
372357
|
-
throw new Error('No firestartr.dev/last-state-pr field in CR');
|
|
372358
|
-
const prNumber = prInfo.split('#')[1];
|
|
372359
|
-
if (!prNumber)
|
|
372360
|
-
throw new Error('No PR number found in CR');
|
|
372361
|
-
const org = prInfo.split('#')[0].split('/')[0];
|
|
372362
|
-
if (!org)
|
|
372363
|
-
throw new Error('No org found in CR');
|
|
372364
|
-
const repo = prInfo.split('#')[0].split('/')[1];
|
|
372365
|
-
if (!repo)
|
|
372366
|
-
throw new Error('No repo found in CR');
|
|
372367
|
-
return { prNumber, repo, org };
|
|
372368
|
-
}
|
|
372369
372390
|
|
|
372370
372391
|
;// CONCATENATED MODULE: ../operator/src/utils/index.ts
|
|
372371
372392
|
const secretRegex = /\$\{\{ secrets\.(.*?) \}\}/g;
|
|
@@ -373235,7 +373256,6 @@ async function acquireLease(namespace, cb, interval = 10000) {
|
|
|
373235
373256
|
|
|
373236
373257
|
|
|
373237
373258
|
|
|
373238
|
-
|
|
373239
373259
|
const processOperationPlan_TF_PROJECTS_PATH = '/tmp/tfworkspaces';
|
|
373240
373260
|
function processOperationPlan(item, op, handler) {
|
|
373241
373261
|
try {
|
|
@@ -373311,7 +373331,8 @@ async function* doPlanPlainTextFormat(item, op, handler, action) {
|
|
|
373311
373331
|
await addPlanStatusCheck(item.metadata.annotations['firestartr.dev/last-state-pr'], 'Terraform plan in progress...');
|
|
373312
373332
|
}
|
|
373313
373333
|
const tfPlanOutput = await runTerraformProvisioner(context, action);
|
|
373314
|
-
|
|
373334
|
+
const { prNumber, repo, org } = extractPrInfo(item, 'firestartr.dev/pull-request-plan');
|
|
373335
|
+
await publishPlan(item, tfPlanOutput, prNumber, repo, org);
|
|
373315
373336
|
yield {
|
|
373316
373337
|
item,
|
|
373317
373338
|
reason: op,
|
|
@@ -373338,7 +373359,8 @@ async function* doPlanPlainTextFormat(item, op, handler, action) {
|
|
|
373338
373359
|
}
|
|
373339
373360
|
}
|
|
373340
373361
|
catch (e) {
|
|
373341
|
-
|
|
373362
|
+
const { prNumber, repo, org } = extractPrInfo(item, 'firestartr.dev/pull-request-plan');
|
|
373363
|
+
await publishPlan(item, JSON.stringify(e), prNumber, repo, org);
|
|
373342
373364
|
operator_src_logger.error('TFWORKSPACE_PROCESSOR_PLAN_OBSERVING_ERROR', {
|
|
373343
373365
|
metadata: { item, error: e },
|
|
373344
373366
|
});
|
|
@@ -373653,7 +373675,6 @@ function processOperationPlan_clearLocalTfProjects() {
|
|
|
373653
373675
|
external_fs_.rmSync(processOperationPlan_TF_PROJECTS_PATH, { recursive: true, force: true });
|
|
373654
373676
|
}
|
|
373655
373677
|
function processOperationPlan_getErrorOutputMessage(cr, key, ref) {
|
|
373656
|
-
const result = '';
|
|
373657
373678
|
if (cr.spec.source === 'Remote') {
|
|
373658
373679
|
return `
|
|
373659
373680
|
|
|
@@ -373686,43 +373707,6 @@ function processOperationPlan_getErrorOutputMessage(cr, key, ref) {
|
|
|
373686
373707
|
throw new Error(`❌ Source ${cr.spec.source} not supported`);
|
|
373687
373708
|
}
|
|
373688
373709
|
}
|
|
373689
|
-
async function processOperationPlan_publishPlan(item, planOutput) {
|
|
373690
|
-
try {
|
|
373691
|
-
const prInfo = item.metadata.annotations['firestartr.dev/pull-request-plan'];
|
|
373692
|
-
if (!prInfo)
|
|
373693
|
-
throw new Error('No PR info found in CR');
|
|
373694
|
-
const prNumber = prInfo.split('#')[1];
|
|
373695
|
-
if (!prNumber)
|
|
373696
|
-
throw new Error('No PR number found in CR');
|
|
373697
|
-
const org = prInfo.split('#')[0].split('/')[0];
|
|
373698
|
-
if (!org)
|
|
373699
|
-
throw new Error('No org found in CR');
|
|
373700
|
-
const repo = prInfo.split('#')[0].split('/')[1];
|
|
373701
|
-
if (!repo)
|
|
373702
|
-
throw new Error('No repo found in CR');
|
|
373703
|
-
const dividedOutput = github_0.pulls.divideCommentIntoChunks(planOutput, 250);
|
|
373704
|
-
let currentCommentNo = 1;
|
|
373705
|
-
for (const commentContent of dividedOutput) {
|
|
373706
|
-
const comment = `<h1>
|
|
373707
|
-
<img width="25" src="https://raw.githubusercontent.com/firestartr-pro/docs/refs/heads/main/logos/square-nobg.png"> Plan Finished
|
|
373708
|
-
</h1>
|
|
373709
|
-
<p><b>TFWorkspace: </b>${item.metadata.name}</p>
|
|
373710
|
-
|
|
373711
|
-
<details id=github>
|
|
373712
|
-
<summary>PLAN LOGS ${dividedOutput.length > 1 ? '(Part ' + currentCommentNo + ')' : ''}</summary>
|
|
373713
|
-
|
|
373714
|
-
\`\`\`shell
|
|
373715
|
-
${commentContent}
|
|
373716
|
-
\`\`\`
|
|
373717
|
-
</details>`;
|
|
373718
|
-
await github_0.pulls.commentInPR(comment, parseInt(prNumber), repo, org, 'logs');
|
|
373719
|
-
currentCommentNo += 1;
|
|
373720
|
-
}
|
|
373721
|
-
}
|
|
373722
|
-
catch (e) {
|
|
373723
|
-
console.error(e);
|
|
373724
|
-
}
|
|
373725
|
-
}
|
|
373726
373710
|
function processOperationPlan_getPolicy(item) {
|
|
373727
373711
|
const policy = item.metadata.annotations &&
|
|
373728
373712
|
item.metadata.annotations['firestartr.dev/policy'];
|
|
@@ -1581,6 +1581,10 @@ export interface FirestartrGithubRepositoryFeatureSpecFiles {
|
|
|
1581
1581
|
* @schema FirestartrGithubRepositoryFeatureSpecFiles#content
|
|
1582
1582
|
*/
|
|
1583
1583
|
readonly content: string;
|
|
1584
|
+
/**
|
|
1585
|
+
* @schema FirestartrGithubRepositoryFeatureSpecFiles#targetBranch
|
|
1586
|
+
*/
|
|
1587
|
+
readonly targetBranch?: string;
|
|
1584
1588
|
}
|
|
1585
1589
|
/**
|
|
1586
1590
|
* Converts an object of type 'FirestartrGithubRepositoryFeatureSpecFiles' to JSON representation.
|
|
@@ -2,6 +2,11 @@ export declare function tryPublishApply(item: any, planOutput: string, kind: str
|
|
|
2
2
|
export declare function tryPublishDestroy(item: any, destroyOutput: string): Promise<void>;
|
|
3
3
|
export declare function publishApply(item: any, applyOutput: string, kind: string): Promise<void>;
|
|
4
4
|
export declare function tryCreateErrorSummary(title: string, errorMsg: string): string;
|
|
5
|
+
export declare function extractPrInfo(item: any, annotation?: 'firestartr.dev/last-state-pr' | 'firestartr.dev/pull-request-plan'): {
|
|
6
|
+
prNumber: number;
|
|
7
|
+
repo: string;
|
|
8
|
+
org: string;
|
|
9
|
+
};
|
|
5
10
|
export declare function tryPublishError(item: any, reason: string, message: string): Promise<void>;
|
|
6
11
|
export declare function publishError(item: any, reason: string, message: string): Promise<void>;
|
|
7
12
|
export declare function publishPlan(item: any, planOutput: string, prNumber: number, repo: string, org: string): Promise<void>;
|