@firestartr/cli 2.8.0-snapshot-variant-cloning-2 → 2.8.0-snapshot-c392b2c

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 CHANGED
@@ -281913,6 +281913,16 @@ async function getRepoInfo(owner, name) {
281913
281913
  const res = await octokit.repos.get({ owner: owner, repo: name });
281914
281914
  return res['data'];
281915
281915
  }
281916
+ async function getRepoSecret(owner, repo, secretName) {
281917
+ logger.info(`Getting repo secret ${owner}/${repo}/${secretName}`);
281918
+ const octokit = await getOctokitForOrg(owner);
281919
+ const response = await octokit.rest.actions.getRepoSecret({
281920
+ owner,
281921
+ repo,
281922
+ secret_name: secretName,
281923
+ });
281924
+ return response.data;
281925
+ }
281916
281926
  async function repoExists(owner, name) {
281917
281927
  logger.info(`Checking if repo exists: ${owner}/${name}`);
281918
281928
  try {
@@ -282089,6 +282099,7 @@ async function isEmptyRepo(owner, name) {
282089
282099
  uploadFile,
282090
282100
  deleteFile,
282091
282101
  getRepoInfo,
282102
+ getRepoSecret,
282092
282103
  repoExists,
282093
282104
  getPages,
282094
282105
  getBranchProtection,
@@ -283365,6 +283376,15 @@ function createFacade(profileName) {
283365
283376
  const response = await octokit.rest.repos.get({ owner, repo: name });
283366
283377
  return response.data;
283367
283378
  },
283379
+ getRepoSecret: async (owner, repo, secretName) => {
283380
+ const octokit = await getOctokitForOrg(owner);
283381
+ const response = await octokit.rest.actions.getRepoSecret({
283382
+ owner,
283383
+ repo,
283384
+ secret_name: secretName,
283385
+ });
283386
+ return response.data;
283387
+ },
283368
283388
  repoExists: async (owner, name) => {
283369
283389
  try {
283370
283390
  const octokit = await getOctokitForOrg(owner);
@@ -323642,18 +323662,41 @@ const CLAIM_REF_ANNOTATION = 'firestartr.dev/claim-ref';
323642
323662
  ;// CONCATENATED MODULE: ../cdk8s_renderer/src/renderer/previous-crs-extractor.ts
323643
323663
 
323644
323664
 
323665
+ const VARIANT_OF_ANNOTATION = 'firestartr.dev/variant-of';
323666
+ function isVariantCR(cr) {
323667
+ return cr.metadata?.annotations?.[VARIANT_OF_ANNOTATION] !== undefined;
323668
+ }
323645
323669
  function getPreviousCRfromClaim(claim, previousCRs) {
323646
323670
  const previousCRsKeys = Object.keys(previousCRs);
323671
+ const isVariantClaim = !!claim._parentClaimName;
323647
323672
  for (const previousCRKey of previousCRsKeys) {
323648
323673
  const previousCR = previousCRs[previousCRKey];
323649
323674
  if (isCatalogEntity(previousCR))
323650
323675
  continue;
323651
323676
  if (isExcludedFromPreviousCR(previousCR.kind))
323652
323677
  continue;
323653
- if (previousCR.metadata.annotations[CLAIM_REF_ANNOTATION] ===
323654
- `${claim.kind}/${claim.name}`) {
323678
+ const crVariant = isVariantCR(previousCR);
323679
+ if (isVariantClaim && !crVariant)
323680
+ continue;
323681
+ if (!isVariantClaim && crVariant)
323682
+ continue;
323683
+ const crClaimRef = previousCR.metadata.annotations[CLAIM_REF_ANNOTATION];
323684
+ if (crClaimRef === `${claim.kind}/${claim.name}`) {
323655
323685
  return previousCR;
323656
323686
  }
323687
+ // For variant claims, the claim-ref annotation uses the parent claim name
323688
+ // (via _parentClaimName), but claim.name is the composed name.
323689
+ // Match on parent claim-ref plus composed provider name as CR name prefix.
323690
+ if (isVariantClaim &&
323691
+ crClaimRef === `${claim.kind}/${claim._parentClaimName}`) {
323692
+ for (const provider of Object.keys(claim.providers || {})) {
323693
+ const providerName = claim.providers[provider]?.name;
323694
+ if (providerName &&
323695
+ previousCR.metadata.name.startsWith(providerName + '-')) {
323696
+ return previousCR;
323697
+ }
323698
+ }
323699
+ }
323657
323700
  }
323658
323701
  return false;
323659
323702
  }
@@ -325136,6 +325179,8 @@ function toJson_FirestartrGithubRepositorySpecBranchProtections(obj) {
325136
325179
  'enforceAdmins': obj.enforceAdmins,
325137
325180
  'requireSignedCommits': obj.requireSignedCommits,
325138
325181
  'requireConversationResolution': obj.requireConversationResolution,
325182
+ 'bypassPullRequestAllowances': toJson_FirestartrGithubRepositorySpecBranchProtectionsBypassPullRequestAllowances(obj.bypassPullRequestAllowances),
325183
+ 'pushAllowances': toJson_FirestartrGithubRepositorySpecBranchProtectionsPushAllowances(obj.pushAllowances),
325139
325184
  };
325140
325185
  // filter undefined values
325141
325186
  return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
@@ -325331,6 +325376,38 @@ function toJson_FirestartrGithubRepositorySpecVarsActions(obj) {
325331
325376
  // filter undefined values
325332
325377
  return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
325333
325378
  }
325379
+ /**
325380
+ * Converts an object of type 'FirestartrGithubRepositorySpecBranchProtectionsBypassPullRequestAllowances' to JSON representation.
325381
+ */
325382
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
325383
+ function toJson_FirestartrGithubRepositorySpecBranchProtectionsBypassPullRequestAllowances(obj) {
325384
+ if (obj === undefined) {
325385
+ return undefined;
325386
+ }
325387
+ const result = {
325388
+ 'apps': obj.apps?.map(y => y),
325389
+ 'teams': obj.teams?.map(y => y),
325390
+ 'users': obj.users?.map(y => y),
325391
+ };
325392
+ // filter undefined values
325393
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
325394
+ }
325395
+ /**
325396
+ * Converts an object of type 'FirestartrGithubRepositorySpecBranchProtectionsPushAllowances' to JSON representation.
325397
+ */
325398
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
325399
+ function toJson_FirestartrGithubRepositorySpecBranchProtectionsPushAllowances(obj) {
325400
+ if (obj === undefined) {
325401
+ return undefined;
325402
+ }
325403
+ const result = {
325404
+ 'apps': obj.apps?.map(y => y),
325405
+ 'teams': obj.teams?.map(y => y),
325406
+ 'users': obj.users?.map(y => y),
325407
+ };
325408
+ // filter undefined values
325409
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
325410
+ }
325334
325411
  /**
325335
325412
  * Converts an object of type 'FirestartrGithubRepositorySpecWriteConnectionSecretToRefOutputs' to JSON representation.
325336
325413
  */
@@ -337607,6 +337684,15 @@ const TF_CACHES_PATH = '/tmp/tfcaches';
337607
337684
  function generateSessionId() {
337608
337685
  return Math.random().toString(36).substring(2, 6).padEnd(4, '0');
337609
337686
  }
337687
+ async function tearUpSessionWorkspace(item, deps, sessionId, failureContext) {
337688
+ try {
337689
+ const context = buildProvisionerContext(item, deps, sessionId);
337690
+ await runTerraformProvisioner(context, 'tear-up-project');
337691
+ }
337692
+ catch (error) {
337693
+ operator_src_logger.warn(`Workspace cleanup failed${failureContext ? ` after ${failureContext}` : ''}: ${error}`);
337694
+ }
337695
+ }
337610
337696
  function processOperation(item, op, handler) {
337611
337697
  try {
337612
337698
  const policy = getPolicy(item, 'firestartr.dev/policy');
@@ -337782,18 +337868,7 @@ async function* doPlanJSONFormat(item, op, handler, setResult = function (_r) {
337782
337868
  // Tear up the session workspace only if the project was created
337783
337869
  // (Terraform execution started), regardless of its success or failure.
337784
337870
  if (terraformExecutionStarted) {
337785
- try {
337786
- const tearContext = buildProvisionerContext(item, deps, sessionId);
337787
- await runTerraformProvisioner(tearContext, 'tear-up-project');
337788
- }
337789
- catch (tearErr) {
337790
- if (error) {
337791
- operator_src_logger.warn(`Workspace cleanup failed after plan error: ${tearErr}`);
337792
- }
337793
- else {
337794
- operator_src_logger.warn(`Workspace cleanup failed: ${tearErr}`);
337795
- }
337796
- }
337871
+ await tearUpSessionWorkspace(item, deps, sessionId, error ? 'plan error' : undefined);
337797
337872
  }
337798
337873
  if (error) {
337799
337874
  if (op === OperationType.SYNC || op === OperationType.RETRY_SYNC) {
@@ -338112,18 +338187,7 @@ async function* process_operation_markedToDeletion(item, op, handler) {
338112
338187
  // Tear up the session workspace only if the project was created
338113
338188
  // (Terraform execution started), regardless of its success or failure.
338114
338189
  if (terraformExecutionStarted) {
338115
- try {
338116
- const tearContext = buildProvisionerContext(item, deps, sessionId);
338117
- await runTerraformProvisioner(tearContext, 'tear-up-project');
338118
- }
338119
- catch (tearErr) {
338120
- if (error) {
338121
- operator_src_logger.warn(`Workspace cleanup failed after destroy error: ${tearErr}`);
338122
- }
338123
- else {
338124
- operator_src_logger.warn(`Workspace cleanup failed: ${tearErr}`);
338125
- }
338126
- }
338190
+ await tearUpSessionWorkspace(item, deps, sessionId, error ? 'destroy error' : undefined);
338127
338191
  }
338128
338192
  if (error) {
338129
338193
  yield {
@@ -338283,18 +338347,7 @@ async function* doApply(item, op, handler) {
338283
338347
  // Tear up the session workspace only if the project was created
338284
338348
  // (Terraform execution started), regardless of its success or failure.
338285
338349
  if (terraformExecutionStarted) {
338286
- try {
338287
- const tearContext = buildProvisionerContext(item, deps, sessionId);
338288
- await runTerraformProvisioner(tearContext, 'tear-up-project');
338289
- }
338290
- catch (tearErr) {
338291
- if (error) {
338292
- operator_src_logger.warn(`Workspace cleanup failed after provisioning error: ${tearErr}`);
338293
- }
338294
- else {
338295
- operator_src_logger.warn(`Workspace cleanup failed: ${tearErr}`);
338296
- }
338297
- }
338350
+ await tearUpSessionWorkspace(item, deps, sessionId, error ? 'provisioning error' : undefined);
338298
338351
  }
338299
338352
  if (error) {
338300
338353
  yield {
@@ -339475,8 +339528,8 @@ const MODULES = {
339475
339528
  },
339476
339529
  FirestartrGithubRepository: {
339477
339530
  module: 'git::https://github.com/prefapp/tfm.git//modules/github-repo',
339478
- // github-repo-v0.7.0
339479
- ref: 'd919ffbff4349c453f75a3b7246b8306a45b12e3',
339531
+ // github-repo-v0.8.0
339532
+ ref: 'c51e2fe8c4f99aa34577b6a5f721a382ff217771',
339480
339533
  },
339481
339534
  FirestartrGithubRepositoryFeature: {
339482
339535
  module: 'git::https://github.com/prefapp/tfm.git//modules/github-files-set',
@@ -339495,8 +339548,8 @@ const MODULES = {
339495
339548
  },
339496
339549
  FirestartrGithubOrganizationSettings: {
339497
339550
  module: 'git::https://github.com/prefapp/tfm.git//modules/github-org-settings',
339498
- // org settings module merged to main (prefapp/tfm#1253)
339499
- ref: 'cf2e2ae487b6cc3f7b208f46a92f5b5f97f8fef2',
339551
+ // github-org-settings-v0.1.0
339552
+ ref: 'c30c5dfdaddf2bca9e966a726d45970c98576e9e',
339500
339553
  },
339501
339554
  };
339502
339555
  function getFirestartrDefaultTFM(kind) {
@@ -340225,9 +340278,7 @@ function provisionBranchProtections(entity) {
340225
340278
  return;
340226
340279
  }
340227
340280
  for (const protection of protections) {
340228
- // This shape should match the compatible Terraform contract
340229
340281
  const output = {};
340230
- // Only emit legacy fields in allowed order
340231
340282
  output.branch = protection.branch;
340232
340283
  output.statusChecks =
340233
340284
  'statusChecks' in protection ? (protection.statusChecks ?? []) : [];
@@ -340243,7 +340294,20 @@ function provisionBranchProtections(entity) {
340243
340294
  if ('requireConversationResolution' in protection)
340244
340295
  output.requireConversationResolution =
340245
340296
  protection.requireConversationResolution;
340246
- // Only keep fields that are present, including explicit false/empty
340297
+ if (protection.bypassPullRequestAllowances) {
340298
+ output.bypassPullRequestAllowances = {
340299
+ apps: protection.bypassPullRequestAllowances.apps || [],
340300
+ teams: protection.bypassPullRequestAllowances.teams || [],
340301
+ users: protection.bypassPullRequestAllowances.users || [],
340302
+ };
340303
+ }
340304
+ if (protection.pushAllowances) {
340305
+ output.pushAllowances = {
340306
+ apps: protection.pushAllowances.apps || [],
340307
+ teams: protection.pushAllowances.teams || [],
340308
+ users: protection.pushAllowances.users || [],
340309
+ };
340310
+ }
340247
340311
  gh_provisioner_src_logger.debug(`[gh-provisioner] Adding branch protection config: ${JSON.stringify(output)}`);
340248
340312
  entity.patchData({
340249
340313
  op: PatchOperations.add,
@@ -340394,7 +340458,6 @@ class EntityGHRepo extends base_Entity {
340394
340458
  await provisionDefaultBranch(this);
340395
340459
  await provisionCodeowners(this);
340396
340460
  await provisionVariables(this);
340397
- // Add branch protections to config if defined
340398
340461
  provisionBranchProtections(this);
340399
340462
  await provisionOIDCSubjectClaim(this);
340400
340463
  await provisionPermissions(this);
@@ -521919,7 +521982,7 @@ const crsStatusSubcommand = {
521919
521982
  };
521920
521983
 
521921
521984
  ;// CONCATENATED MODULE: ./package.json
521922
- const package_namespaceObject = JSON.parse('{"i8":"2.8.0-snapshot-variant-cloning-2"}');
521985
+ const package_namespaceObject = JSON.parse('{"i8":"2.8.0-snapshot-c392b2c"}');
521923
521986
  ;// CONCATENATED MODULE: ../../package.json
521924
521987
  const package_namespaceObject_1 = {"i8":"2.7.1"};
521925
521988
  ;// CONCATENATED MODULE: ./src/subcommands/index.ts
@@ -1530,6 +1530,14 @@ export interface FirestartrGithubRepositorySpecBranchProtections {
1530
1530
  * @schema FirestartrGithubRepositorySpecBranchProtections#requireConversationResolution
1531
1531
  */
1532
1532
  readonly requireConversationResolution?: boolean;
1533
+ /**
1534
+ * @schema FirestartrGithubRepositorySpecBranchProtections#bypassPullRequestAllowances
1535
+ */
1536
+ readonly bypassPullRequestAllowances?: FirestartrGithubRepositorySpecBranchProtectionsBypassPullRequestAllowances;
1537
+ /**
1538
+ * @schema FirestartrGithubRepositorySpecBranchProtections#pushAllowances
1539
+ */
1540
+ readonly pushAllowances?: FirestartrGithubRepositorySpecBranchProtectionsPushAllowances;
1533
1541
  }
1534
1542
  /**
1535
1543
  * Converts an object of type 'FirestartrGithubRepositorySpecBranchProtections' to JSON representation.
@@ -1760,6 +1768,48 @@ export interface FirestartrGithubRepositorySpecVarsActions {
1760
1768
  * Converts an object of type 'FirestartrGithubRepositorySpecVarsActions' to JSON representation.
1761
1769
  */
1762
1770
  export declare function toJson_FirestartrGithubRepositorySpecVarsActions(obj: FirestartrGithubRepositorySpecVarsActions | undefined): Record<string, any> | undefined;
1771
+ /**
1772
+ * @schema FirestartrGithubRepositorySpecBranchProtectionsBypassPullRequestAllowances
1773
+ */
1774
+ export interface FirestartrGithubRepositorySpecBranchProtectionsBypassPullRequestAllowances {
1775
+ /**
1776
+ * @schema FirestartrGithubRepositorySpecBranchProtectionsBypassPullRequestAllowances#apps
1777
+ */
1778
+ readonly apps?: string[];
1779
+ /**
1780
+ * @schema FirestartrGithubRepositorySpecBranchProtectionsBypassPullRequestAllowances#teams
1781
+ */
1782
+ readonly teams?: string[];
1783
+ /**
1784
+ * @schema FirestartrGithubRepositorySpecBranchProtectionsBypassPullRequestAllowances#users
1785
+ */
1786
+ readonly users?: string[];
1787
+ }
1788
+ /**
1789
+ * Converts an object of type 'FirestartrGithubRepositorySpecBranchProtectionsBypassPullRequestAllowances' to JSON representation.
1790
+ */
1791
+ export declare function toJson_FirestartrGithubRepositorySpecBranchProtectionsBypassPullRequestAllowances(obj: FirestartrGithubRepositorySpecBranchProtectionsBypassPullRequestAllowances | undefined): Record<string, any> | undefined;
1792
+ /**
1793
+ * @schema FirestartrGithubRepositorySpecBranchProtectionsPushAllowances
1794
+ */
1795
+ export interface FirestartrGithubRepositorySpecBranchProtectionsPushAllowances {
1796
+ /**
1797
+ * @schema FirestartrGithubRepositorySpecBranchProtectionsPushAllowances#apps
1798
+ */
1799
+ readonly apps?: string[];
1800
+ /**
1801
+ * @schema FirestartrGithubRepositorySpecBranchProtectionsPushAllowances#teams
1802
+ */
1803
+ readonly teams?: string[];
1804
+ /**
1805
+ * @schema FirestartrGithubRepositorySpecBranchProtectionsPushAllowances#users
1806
+ */
1807
+ readonly users?: string[];
1808
+ }
1809
+ /**
1810
+ * Converts an object of type 'FirestartrGithubRepositorySpecBranchProtectionsPushAllowances' to JSON representation.
1811
+ */
1812
+ export declare function toJson_FirestartrGithubRepositorySpecBranchProtectionsPushAllowances(obj: FirestartrGithubRepositorySpecBranchProtectionsPushAllowances | undefined): Record<string, any> | undefined;
1763
1813
  /**
1764
1814
  * @schema FirestartrGithubRepositorySpecWriteConnectionSecretToRefOutputs
1765
1815
  */
@@ -26,6 +26,7 @@ declare const _default: {
26
26
  uploadFile: typeof import("./src/repository").uploadFile;
27
27
  deleteFile: typeof import("./src/repository").deleteFile;
28
28
  getRepoInfo: typeof import("./src/repository").getRepoInfo;
29
+ getRepoSecret: typeof import("./src/repository").getRepoSecret;
29
30
  repoExists: typeof import("./src/repository").repoExists;
30
31
  getPages: typeof import("./src/repository").getPages;
31
32
  getBranchProtection: typeof import("./src/repository").getBranchProtection;
@@ -800,6 +800,11 @@ export declare function getRepoInfo(owner: string, name: string): Promise<{
800
800
  [key: string]: unknown;
801
801
  };
802
802
  }>;
803
+ export declare function getRepoSecret(owner: string, repo: string, secretName: string): Promise<{
804
+ name: string;
805
+ created_at: string;
806
+ updated_at: string;
807
+ }>;
803
808
  export declare function repoExists(owner: string, name: string): Promise<boolean>;
804
809
  export declare function getPages(owner: string, name: string): Promise<{
805
810
  url: string;
@@ -1336,6 +1341,7 @@ declare const _default: {
1336
1341
  uploadFile: typeof uploadFile;
1337
1342
  deleteFile: typeof deleteFile;
1338
1343
  getRepoInfo: typeof getRepoInfo;
1344
+ getRepoSecret: typeof getRepoSecret;
1339
1345
  repoExists: typeof repoExists;
1340
1346
  getPages: typeof getPages;
1341
1347
  getBranchProtection: typeof getBranchProtection;
@@ -824,6 +824,11 @@ export declare function withProfile(profileName: string): {
824
824
  [key: string]: unknown;
825
825
  };
826
826
  }>;
827
+ getRepoSecret: (owner: string, repo: string, secretName: string) => Promise<{
828
+ name: string;
829
+ created_at: string;
830
+ updated_at: string;
831
+ }>;
827
832
  repoExists: (owner: string, name: string) => Promise<boolean>;
828
833
  };
829
834
  team: {
@@ -1,5 +1,4 @@
1
1
  import { OperationType } from '../informer';
2
- export declare function generateSessionId(): string;
3
2
  export declare function processOperation(item: any, op: OperationType, handler: any): AsyncGenerator<{
4
3
  item: any;
5
4
  reason: OperationType;
@@ -28,19 +27,6 @@ export declare function sync(item: any, op: OperationType, handler: any, syncPol
28
27
  status: string;
29
28
  message: any;
30
29
  }, void, unknown>;
31
- /**
32
- *
33
- * @param {any} item - CR to be applied
34
- * @param op - Operation type
35
- * @param handler -
36
- */
37
- export declare function doApply(item: any, op: OperationType, handler: any): AsyncGenerator<{
38
- item: any;
39
- reason: OperationType;
40
- type: string;
41
- status: string;
42
- message: string;
43
- }, void, unknown>;
44
30
  /**
45
31
  * @description Adapts the CR to the format expected by the terraform provisioner
46
32
  * @param item - CR to be applied
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firestartr/cli",
3
- "version": "2.8.0-snapshot-variant-cloning-2",
3
+ "version": "2.8.0-snapshot-c392b2c",
4
4
  "private": false,
5
5
  "description": "Commandline tool",
6
6
  "main": "build/main.js",