@firestartr/cli 3.2.0-snapshot-01 → 3.2.0-snapshot-02

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
@@ -120985,7 +120985,7 @@ function getCronNextInterval(cronLine, tz) {
120985
120985
 
120986
120986
  /***/ }),
120987
120987
 
120988
- /***/ 44912:
120988
+ /***/ 37524:
120989
120989
  /***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => {
120990
120990
 
120991
120991
  // ESM COMPAT FLAG
@@ -126680,6 +126680,66 @@ async function encryptRepoSecret(owner, repo, section, plaintextValue, octokit)
126680
126680
  }
126681
126681
  }
126682
126682
 
126683
+ ;// CONCATENATED MODULE: ../github/src/orgSecrets.ts
126684
+
126685
+
126686
+
126687
+ async function getOrgPublicKey(org, section, octokit) {
126688
+ logger.info(`Retrieving org public key for ${org} (${section})`);
126689
+ try {
126690
+ if (!octokit) {
126691
+ octokit = await getOctokitForOrg(org);
126692
+ }
126693
+ const { data } = await octokit.rest[`${section}`].getOrgPublicKey({
126694
+ org,
126695
+ });
126696
+ return data;
126697
+ }
126698
+ catch (error) {
126699
+ logger.error(`Error retrieving org public key (${section}) for ${org}: ${error}`);
126700
+ throw error;
126701
+ }
126702
+ }
126703
+ async function encryptOrgSecret(org, section, plaintextValue, preFetchedKey, octokit) {
126704
+ try {
126705
+ const { key_id, key } = preFetchedKey
126706
+ ? preFetchedKey
126707
+ : await getOrgPublicKey(org, section, octokit);
126708
+ await libsodium_wrappers.ready;
126709
+ const publicKey = libsodium_wrappers.from_base64(key, libsodium_wrappers.base64_variants.ORIGINAL);
126710
+ const secretBytes = libsodium_wrappers.from_string(plaintextValue);
126711
+ const encryptedBytes = libsodium_wrappers.crypto_box_seal(secretBytes, publicKey);
126712
+ const encryptedValue = libsodium_wrappers.to_base64(encryptedBytes, libsodium_wrappers.base64_variants.ORIGINAL);
126713
+ return {
126714
+ key_id,
126715
+ encrypted_value: encryptedValue,
126716
+ };
126717
+ }
126718
+ catch (err) {
126719
+ logger.error(`Error encrypting org secret (${section}) for ${org}: ${err}`);
126720
+ throw err;
126721
+ }
126722
+ }
126723
+ async function getOrgSecret(org, section, name, octokit) {
126724
+ logger.info(`Checking org secret ${name} (${section}) for ${org}`);
126725
+ try {
126726
+ if (!octokit) {
126727
+ octokit = await getOctokitForOrg(org);
126728
+ }
126729
+ const response = await octokit.rest[`${section}`].getOrgSecret({
126730
+ org,
126731
+ secret_name: name,
126732
+ });
126733
+ return response.data;
126734
+ }
126735
+ catch (err) {
126736
+ if (err && err.status === 404) {
126737
+ return null;
126738
+ }
126739
+ throw err;
126740
+ }
126741
+ }
126742
+
126683
126743
  ;// CONCATENATED MODULE: ../github/src/profile.ts
126684
126744
  // Profile definitions and store for github package (immutable and ambient profiles)
126685
126745
  const profileStore = new Map();
@@ -127114,6 +127174,7 @@ function withProfile(profileName) {
127114
127174
 
127115
127175
 
127116
127176
 
127177
+
127117
127178
  /* harmony default export */ const github = ({
127118
127179
  org: organization,
127119
127180
  repo: repository,
@@ -127136,6 +127197,9 @@ function withProfile(profileName) {
127136
127197
  encryption: {
127137
127198
  encryptRepoSecret: encryptRepoSecret,
127138
127199
  getRepoPublicKey: getRepoPublicKey,
127200
+ getOrgPublicKey: getOrgPublicKey,
127201
+ encryptOrgSecret: encryptOrgSecret,
127202
+ getOrgSecret: getOrgSecret,
127139
127203
  },
127140
127204
  withProfile: withProfile,
127141
127205
  createProfile: createProfile,
@@ -154116,8 +154180,8 @@ var dist = __nccwpck_require__(84553);
154116
154180
  var dist_default = /*#__PURE__*/__nccwpck_require__.n(dist);
154117
154181
  // EXTERNAL MODULE: ../catalog_common/index.ts + 44 modules
154118
154182
  var catalog_common = __nccwpck_require__(56618);
154119
- // EXTERNAL MODULE: ../github/index.ts + 37 modules
154120
- var github = __nccwpck_require__(44912);
154183
+ // EXTERNAL MODULE: ../github/index.ts + 38 modules
154184
+ var github = __nccwpck_require__(37524);
154121
154185
  ;// CONCATENATED MODULE: ../cdk8s_renderer/src/patches/base.ts
154122
154186
  class BasePatches {
154123
154187
  constructor() { }
@@ -157020,6 +157084,31 @@ function extractAllRefs(claimData) {
157020
157084
  }
157021
157085
  }
157022
157086
  }
157087
+ const orgSecrets = parsedClaim.providers?.github?.org_secrets;
157088
+ if (orgSecrets && typeof orgSecrets === 'object') {
157089
+ const secretRefRegex = /^ref:secretsclaim:([a-zA-Z0-9_-]+):([a-zA-Z0-9_-]+)$/;
157090
+ for (const section of ['actions', 'codespaces', 'dependabot']) {
157091
+ const secrets = orgSecrets[section];
157092
+ if (!Array.isArray(secrets))
157093
+ continue;
157094
+ for (const secret of secrets) {
157095
+ if (secret.value) {
157096
+ const match = secret.value.match(secretRefRegex);
157097
+ if (match) {
157098
+ refs.push(`SecretsClaim-${match[1]}`);
157099
+ }
157100
+ }
157101
+ if (Array.isArray(secret.selected_repositories)) {
157102
+ for (const repoRef of secret.selected_repositories) {
157103
+ const compMatch = repoRef.match(/^component:(.+)$/);
157104
+ if (compMatch) {
157105
+ refs.push(`ComponentClaim-${compMatch[1]}`);
157106
+ }
157107
+ }
157108
+ }
157109
+ }
157110
+ }
157111
+ }
157023
157112
  break;
157024
157113
  }
157025
157114
  }
@@ -158178,6 +158267,30 @@ const organizationSettingsProperties = {
158178
158267
  ],
158179
158268
  },
158180
158269
  },
158270
+ org_secrets: {
158271
+ type: 'object',
158272
+ properties: {
158273
+ actions: {
158274
+ type: 'array',
158275
+ items: {
158276
+ $ref: 'firestartr.dev://github/GithubOrgClaimSecret',
158277
+ },
158278
+ },
158279
+ codespaces: {
158280
+ type: 'array',
158281
+ items: {
158282
+ $ref: 'firestartr.dev://github/GithubOrgClaimSecret',
158283
+ },
158284
+ },
158285
+ dependabot: {
158286
+ type: 'array',
158287
+ items: {
158288
+ $ref: 'firestartr.dev://github/GithubOrgClaimSecret',
158289
+ },
158290
+ },
158291
+ },
158292
+ additionalProperties: false,
158293
+ },
158181
158294
  };
158182
158295
  /* harmony default export */ const github_orgsettings_schema = ({
158183
158296
  $schema: SCHEMA,
@@ -158402,6 +158515,97 @@ const organizationSettingsProperties = {
158402
158515
  },
158403
158516
  });
158404
158517
 
158518
+ ;// CONCATENATED MODULE: ../cdk8s_renderer/src/claims/github/orgSecrets.schema.ts
158519
+
158520
+ /* harmony default export */ const orgSecrets_schema = ({
158521
+ $schema: SCHEMA,
158522
+ $id: 'GithubOrgClaimSecrets',
158523
+ definitions: {
158524
+ GithubOrgClaimSecrets: {
158525
+ $id: 'firestartr.dev://github/GithubOrgClaimSecrets',
158526
+ type: 'object',
158527
+ description: 'Organization-level GitHub Actions secrets',
158528
+ properties: {
158529
+ actions: {
158530
+ type: 'array',
158531
+ items: {
158532
+ $ref: 'firestartr.dev://github/GithubOrgClaimSecret',
158533
+ },
158534
+ },
158535
+ codespaces: {
158536
+ type: 'array',
158537
+ items: {
158538
+ $ref: 'firestartr.dev://github/GithubOrgClaimSecret',
158539
+ },
158540
+ },
158541
+ dependabot: {
158542
+ type: 'array',
158543
+ items: {
158544
+ $ref: 'firestartr.dev://github/GithubOrgClaimSecret',
158545
+ },
158546
+ },
158547
+ },
158548
+ additionalProperties: false,
158549
+ },
158550
+ GithubOrgClaimSecretRef: {
158551
+ $id: 'firestartr.dev://github/GithubOrgClaimSecretRef',
158552
+ type: 'string',
158553
+ description: 'the reference of the secret',
158554
+ pattern: '^ref:secretsclaim:([a-zA-Z0-9_-]+):([a-zA-Z0-9_-]+)$',
158555
+ },
158556
+ GithubOrgClaimSecret: {
158557
+ $id: 'firestartr.dev://github/GithubOrgClaimSecret',
158558
+ type: 'object',
158559
+ description: 'An organization-level secret for GitHub Actions',
158560
+ properties: {
158561
+ name: {
158562
+ type: 'string',
158563
+ description: 'the name of the secret',
158564
+ pattern: '^[A-Za-z0-9_]+$',
158565
+ },
158566
+ value: {
158567
+ $ref: 'firestartr.dev://github/GithubOrgClaimSecretRef',
158568
+ },
158569
+ visibility: {
158570
+ type: 'string',
158571
+ enum: ['all', 'selected', 'private'],
158572
+ description: 'which repositories can access the secret',
158573
+ },
158574
+ selected_repositories: {
158575
+ type: 'array',
158576
+ items: {
158577
+ $ref: 'firestartr.dev://common/FirestartrComponentRef',
158578
+ },
158579
+ description: 'list of repository refs when visibility is selected',
158580
+ },
158581
+ },
158582
+ required: ['name', 'value'],
158583
+ additionalProperties: false,
158584
+ allOf: [
158585
+ {
158586
+ if: {
158587
+ properties: {
158588
+ visibility: { const: 'selected' },
158589
+ },
158590
+ required: ['visibility'],
158591
+ },
158592
+ then: {
158593
+ required: ['selected_repositories'],
158594
+ properties: {
158595
+ selected_repositories: { type: 'array', minItems: 1 },
158596
+ },
158597
+ },
158598
+ else: {
158599
+ properties: {
158600
+ selected_repositories: { type: 'array', maxItems: 0 },
158601
+ },
158602
+ },
158603
+ },
158604
+ ],
158605
+ },
158606
+ },
158607
+ });
158608
+
158405
158609
  ;// CONCATENATED MODULE: ../cdk8s_renderer/src/claims/github/index.ts
158406
158610
 
158407
158611
 
@@ -158412,6 +158616,7 @@ const organizationSettingsProperties = {
158412
158616
 
158413
158617
 
158414
158618
 
158619
+
158415
158620
  const GithubSchemas = [
158416
158621
  github_group_schema,
158417
158622
  github_user_schema,
@@ -158422,6 +158627,7 @@ const GithubSchemas = [
158422
158627
  component_secrets_vars_schema,
158423
158628
  component_labels_schema,
158424
158629
  pages_schema,
158630
+ orgSecrets_schema,
158425
158631
  ];
158426
158632
 
158427
158633
  ;// CONCATENATED MODULE: ../cdk8s_renderer/src/claims/tfworkspaces/terraform.schema.ts
@@ -163274,6 +163480,412 @@ var FirestartrGithubMembershipSpecContextProviderRefKind;
163274
163480
  /** FirestartrProviderConfig */
163275
163481
  FirestartrGithubMembershipSpecContextProviderRefKind["FIRESTARTR_PROVIDER_CONFIG"] = "FirestartrProviderConfig";
163276
163482
  })(FirestartrGithubMembershipSpecContextProviderRefKind || (FirestartrGithubMembershipSpecContextProviderRefKind = {}));
163483
+ /**
163484
+ * A resource to handle GitHub Organization Actions Secrets.
163485
+ *
163486
+ * @schema FirestartrGithubOrganizationSecretSection
163487
+ */
163488
+ class FirestartrGithubOrganizationSecretSection extends lib.ApiObject {
163489
+ /**
163490
+ * Renders a Kubernetes manifest for "FirestartrGithubOrganizationSecretSection".
163491
+ *
163492
+ * This can be used to inline resource manifests inside other objects (e.g. as templates).
163493
+ *
163494
+ * @param props initialization props
163495
+ */
163496
+ static manifest(props) {
163497
+ return {
163498
+ ...FirestartrGithubOrganizationSecretSection.GVK,
163499
+ ...toJson_FirestartrGithubOrganizationSecretSectionProps(props),
163500
+ };
163501
+ }
163502
+ /**
163503
+ * Defines a "FirestartrGithubOrganizationSecretSection" API object
163504
+ * @param scope the scope in which to define this object
163505
+ * @param id a scope-local name for the object
163506
+ * @param props initialization props
163507
+ */
163508
+ constructor(scope, id, props) {
163509
+ super(scope, id, {
163510
+ ...FirestartrGithubOrganizationSecretSection.GVK,
163511
+ ...props,
163512
+ });
163513
+ }
163514
+ /**
163515
+ * Renders the object to Kubernetes JSON.
163516
+ */
163517
+ toJson() {
163518
+ const resolved = super.toJson();
163519
+ return {
163520
+ ...FirestartrGithubOrganizationSecretSection.GVK,
163521
+ ...toJson_FirestartrGithubOrganizationSecretSectionProps(resolved),
163522
+ };
163523
+ }
163524
+ }
163525
+ /**
163526
+ * Returns the apiVersion and kind for "FirestartrGithubOrganizationSecretSection"
163527
+ */
163528
+ FirestartrGithubOrganizationSecretSection.GVK = {
163529
+ apiVersion: 'firestartr.dev/v1',
163530
+ kind: 'FirestartrGithubOrganizationSecretSection',
163531
+ };
163532
+
163533
+ /**
163534
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionProps' to JSON representation.
163535
+ */
163536
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
163537
+ function toJson_FirestartrGithubOrganizationSecretSectionProps(obj) {
163538
+ if (obj === undefined) {
163539
+ return undefined;
163540
+ }
163541
+ const result = {
163542
+ 'metadata': obj.metadata,
163543
+ 'spec': toJson_FirestartrGithubOrganizationSecretSectionSpec(obj.spec),
163544
+ };
163545
+ // filter undefined values
163546
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
163547
+ }
163548
+ /**
163549
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpec' to JSON representation.
163550
+ */
163551
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
163552
+ function toJson_FirestartrGithubOrganizationSecretSectionSpec(obj) {
163553
+ if (obj === undefined) {
163554
+ return undefined;
163555
+ }
163556
+ const result = {
163557
+ 'org': obj.org,
163558
+ 'secrets': toJson_FirestartrGithubOrganizationSecretSectionSpecSecrets(obj.secrets),
163559
+ 'context': toJson_FirestartrGithubOrganizationSecretSectionSpecContext(obj.context),
163560
+ 'firestartr': toJson_FirestartrGithubOrganizationSecretSectionSpecFirestartr(obj.firestartr),
163561
+ 'writeConnectionSecretToRef': toJson_FirestartrGithubOrganizationSecretSectionSpecWriteConnectionSecretToRef(obj.writeConnectionSecretToRef),
163562
+ };
163563
+ // filter undefined values
163564
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
163565
+ }
163566
+ /**
163567
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecSecrets' to JSON representation.
163568
+ */
163569
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
163570
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecSecrets(obj) {
163571
+ if (obj === undefined) {
163572
+ return undefined;
163573
+ }
163574
+ const result = {
163575
+ 'actions': obj.actions?.map(y => toJson_FirestartrGithubOrganizationSecretSectionSpecSecretsActions(y)),
163576
+ 'codespaces': obj.codespaces?.map(y => toJson_FirestartrGithubOrganizationSecretSectionSpecSecretsCodespaces(y)),
163577
+ 'dependabot': obj.dependabot?.map(y => toJson_FirestartrGithubOrganizationSecretSectionSpecSecretsDependabot(y)),
163578
+ };
163579
+ // filter undefined values
163580
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
163581
+ }
163582
+ /**
163583
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecContext' to JSON representation.
163584
+ */
163585
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
163586
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecContext(obj) {
163587
+ if (obj === undefined) {
163588
+ return undefined;
163589
+ }
163590
+ const result = {
163591
+ 'backend': toJson_FirestartrGithubOrganizationSecretSectionSpecContextBackend(obj.backend),
163592
+ 'provider': toJson_FirestartrGithubOrganizationSecretSectionSpecContextProvider(obj.provider),
163593
+ };
163594
+ // filter undefined values
163595
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
163596
+ }
163597
+ /**
163598
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecFirestartr' to JSON representation.
163599
+ */
163600
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
163601
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecFirestartr(obj) {
163602
+ if (obj === undefined) {
163603
+ return undefined;
163604
+ }
163605
+ const result = {
163606
+ 'tfStateKey': obj.tfStateKey,
163607
+ };
163608
+ // filter undefined values
163609
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
163610
+ }
163611
+ /**
163612
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecWriteConnectionSecretToRef' to JSON representation.
163613
+ */
163614
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
163615
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecWriteConnectionSecretToRef(obj) {
163616
+ if (obj === undefined) {
163617
+ return undefined;
163618
+ }
163619
+ const result = {
163620
+ 'name': obj.name,
163621
+ 'outputs': obj.outputs?.map(y => toJson_FirestartrGithubOrganizationSecretSectionSpecWriteConnectionSecretToRefOutputs(y)),
163622
+ };
163623
+ // filter undefined values
163624
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
163625
+ }
163626
+ /**
163627
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecSecretsActions' to JSON representation.
163628
+ */
163629
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
163630
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecSecretsActions(obj) {
163631
+ if (obj === undefined) {
163632
+ return undefined;
163633
+ }
163634
+ const result = {
163635
+ 'name': obj.name,
163636
+ 'ref': toJson_FirestartrGithubOrganizationSecretSectionSpecSecretsActionsRef(obj.ref),
163637
+ 'visibility': obj.visibility,
163638
+ 'selectedRepositories': obj.selectedRepositories?.map(y => y),
163639
+ };
163640
+ // filter undefined values
163641
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
163642
+ }
163643
+ /**
163644
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecSecretsCodespaces' to JSON representation.
163645
+ */
163646
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
163647
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecSecretsCodespaces(obj) {
163648
+ if (obj === undefined) {
163649
+ return undefined;
163650
+ }
163651
+ const result = {
163652
+ 'name': obj.name,
163653
+ 'ref': toJson_FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesRef(obj.ref),
163654
+ 'visibility': obj.visibility,
163655
+ 'selectedRepositories': obj.selectedRepositories?.map(y => y),
163656
+ };
163657
+ // filter undefined values
163658
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
163659
+ }
163660
+ /**
163661
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecSecretsDependabot' to JSON representation.
163662
+ */
163663
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
163664
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecSecretsDependabot(obj) {
163665
+ if (obj === undefined) {
163666
+ return undefined;
163667
+ }
163668
+ const result = {
163669
+ 'name': obj.name,
163670
+ 'ref': toJson_FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotRef(obj.ref),
163671
+ 'visibility': obj.visibility,
163672
+ 'selectedRepositories': obj.selectedRepositories?.map(y => y),
163673
+ };
163674
+ // filter undefined values
163675
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
163676
+ }
163677
+ /**
163678
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecContextBackend' to JSON representation.
163679
+ */
163680
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
163681
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecContextBackend(obj) {
163682
+ if (obj === undefined) {
163683
+ return undefined;
163684
+ }
163685
+ const result = {
163686
+ 'ref': toJson_FirestartrGithubOrganizationSecretSectionSpecContextBackendRef(obj.ref),
163687
+ };
163688
+ // filter undefined values
163689
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
163690
+ }
163691
+ /**
163692
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecContextProvider' to JSON representation.
163693
+ */
163694
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
163695
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecContextProvider(obj) {
163696
+ if (obj === undefined) {
163697
+ return undefined;
163698
+ }
163699
+ const result = {
163700
+ 'ref': toJson_FirestartrGithubOrganizationSecretSectionSpecContextProviderRef(obj.ref),
163701
+ };
163702
+ // filter undefined values
163703
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
163704
+ }
163705
+ /**
163706
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecWriteConnectionSecretToRefOutputs' to JSON representation.
163707
+ */
163708
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
163709
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecWriteConnectionSecretToRefOutputs(obj) {
163710
+ if (obj === undefined) {
163711
+ return undefined;
163712
+ }
163713
+ const result = {
163714
+ 'key': obj.key,
163715
+ };
163716
+ // filter undefined values
163717
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
163718
+ }
163719
+ /**
163720
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecSecretsActionsRef' to JSON representation.
163721
+ */
163722
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
163723
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecSecretsActionsRef(obj) {
163724
+ if (obj === undefined) {
163725
+ return undefined;
163726
+ }
163727
+ const result = {
163728
+ 'kind': obj.kind,
163729
+ 'name': obj.name,
163730
+ 'key': obj.key,
163731
+ };
163732
+ // filter undefined values
163733
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
163734
+ }
163735
+ /* eslint-enable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
163736
+ /**
163737
+ * Which repositories can access the secret.
163738
+ *
163739
+ * @schema FirestartrGithubOrganizationSecretSectionSpecSecretsActionsVisibility
163740
+ */
163741
+ var FirestartrGithubOrganizationSecretSectionSpecSecretsActionsVisibility;
163742
+ (function (FirestartrGithubOrganizationSecretSectionSpecSecretsActionsVisibility) {
163743
+ /** all */
163744
+ FirestartrGithubOrganizationSecretSectionSpecSecretsActionsVisibility["ALL"] = "all";
163745
+ /** selected */
163746
+ FirestartrGithubOrganizationSecretSectionSpecSecretsActionsVisibility["SELECTED"] = "selected";
163747
+ /** private */
163748
+ FirestartrGithubOrganizationSecretSectionSpecSecretsActionsVisibility["PRIVATE"] = "private";
163749
+ })(FirestartrGithubOrganizationSecretSectionSpecSecretsActionsVisibility || (FirestartrGithubOrganizationSecretSectionSpecSecretsActionsVisibility = {}));
163750
+ /**
163751
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesRef' to JSON representation.
163752
+ */
163753
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
163754
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesRef(obj) {
163755
+ if (obj === undefined) {
163756
+ return undefined;
163757
+ }
163758
+ const result = {
163759
+ 'kind': obj.kind,
163760
+ 'name': obj.name,
163761
+ 'key': obj.key,
163762
+ };
163763
+ // filter undefined values
163764
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
163765
+ }
163766
+ /* eslint-enable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
163767
+ /**
163768
+ * Which repositories can access the secret.
163769
+ *
163770
+ * @schema FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesVisibility
163771
+ */
163772
+ var FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesVisibility;
163773
+ (function (FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesVisibility) {
163774
+ /** all */
163775
+ FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesVisibility["ALL"] = "all";
163776
+ /** selected */
163777
+ FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesVisibility["SELECTED"] = "selected";
163778
+ /** private */
163779
+ FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesVisibility["PRIVATE"] = "private";
163780
+ })(FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesVisibility || (FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesVisibility = {}));
163781
+ /**
163782
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotRef' to JSON representation.
163783
+ */
163784
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
163785
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotRef(obj) {
163786
+ if (obj === undefined) {
163787
+ return undefined;
163788
+ }
163789
+ const result = {
163790
+ 'kind': obj.kind,
163791
+ 'name': obj.name,
163792
+ 'key': obj.key,
163793
+ };
163794
+ // filter undefined values
163795
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
163796
+ }
163797
+ /* eslint-enable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
163798
+ /**
163799
+ * Which repositories can access the secret.
163800
+ *
163801
+ * @schema FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotVisibility
163802
+ */
163803
+ var FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotVisibility;
163804
+ (function (FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotVisibility) {
163805
+ /** all */
163806
+ FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotVisibility["ALL"] = "all";
163807
+ /** selected */
163808
+ FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotVisibility["SELECTED"] = "selected";
163809
+ /** private */
163810
+ FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotVisibility["PRIVATE"] = "private";
163811
+ })(FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotVisibility || (FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotVisibility = {}));
163812
+ /**
163813
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecContextBackendRef' to JSON representation.
163814
+ */
163815
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
163816
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecContextBackendRef(obj) {
163817
+ if (obj === undefined) {
163818
+ return undefined;
163819
+ }
163820
+ const result = {
163821
+ 'kind': obj.kind,
163822
+ 'name': obj.name,
163823
+ };
163824
+ // filter undefined values
163825
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
163826
+ }
163827
+ /**
163828
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecContextProviderRef' to JSON representation.
163829
+ */
163830
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
163831
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecContextProviderRef(obj) {
163832
+ if (obj === undefined) {
163833
+ return undefined;
163834
+ }
163835
+ const result = {
163836
+ 'kind': obj.kind,
163837
+ 'name': obj.name,
163838
+ };
163839
+ // filter undefined values
163840
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
163841
+ }
163842
+ /* eslint-enable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
163843
+ /**
163844
+ * The type of Kubernetes resource to reference.
163845
+ *
163846
+ * @schema FirestartrGithubOrganizationSecretSectionSpecSecretsActionsRefKind
163847
+ */
163848
+ var FirestartrGithubOrganizationSecretSectionSpecSecretsActionsRefKind;
163849
+ (function (FirestartrGithubOrganizationSecretSectionSpecSecretsActionsRefKind) {
163850
+ /** Secret */
163851
+ FirestartrGithubOrganizationSecretSectionSpecSecretsActionsRefKind["SECRET"] = "Secret";
163852
+ })(FirestartrGithubOrganizationSecretSectionSpecSecretsActionsRefKind || (FirestartrGithubOrganizationSecretSectionSpecSecretsActionsRefKind = {}));
163853
+ /**
163854
+ * The type of Kubernetes resource to reference.
163855
+ *
163856
+ * @schema FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesRefKind
163857
+ */
163858
+ var FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesRefKind;
163859
+ (function (FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesRefKind) {
163860
+ /** Secret */
163861
+ FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesRefKind["SECRET"] = "Secret";
163862
+ })(FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesRefKind || (FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesRefKind = {}));
163863
+ /**
163864
+ * The type of Kubernetes resource to reference.
163865
+ *
163866
+ * @schema FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotRefKind
163867
+ */
163868
+ var FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotRefKind;
163869
+ (function (FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotRefKind) {
163870
+ /** Secret */
163871
+ FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotRefKind["SECRET"] = "Secret";
163872
+ })(FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotRefKind || (FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotRefKind = {}));
163873
+ /**
163874
+ * @schema FirestartrGithubOrganizationSecretSectionSpecContextBackendRefKind
163875
+ */
163876
+ var FirestartrGithubOrganizationSecretSectionSpecContextBackendRefKind;
163877
+ (function (FirestartrGithubOrganizationSecretSectionSpecContextBackendRefKind) {
163878
+ /** FirestartrProviderConfig */
163879
+ FirestartrGithubOrganizationSecretSectionSpecContextBackendRefKind["FIRESTARTR_PROVIDER_CONFIG"] = "FirestartrProviderConfig";
163880
+ })(FirestartrGithubOrganizationSecretSectionSpecContextBackendRefKind || (FirestartrGithubOrganizationSecretSectionSpecContextBackendRefKind = {}));
163881
+ /**
163882
+ * @schema FirestartrGithubOrganizationSecretSectionSpecContextProviderRefKind
163883
+ */
163884
+ var FirestartrGithubOrganizationSecretSectionSpecContextProviderRefKind;
163885
+ (function (FirestartrGithubOrganizationSecretSectionSpecContextProviderRefKind) {
163886
+ /** FirestartrProviderConfig */
163887
+ FirestartrGithubOrganizationSecretSectionSpecContextProviderRefKind["FIRESTARTR_PROVIDER_CONFIG"] = "FirestartrProviderConfig";
163888
+ })(FirestartrGithubOrganizationSecretSectionSpecContextProviderRefKind || (FirestartrGithubOrganizationSecretSectionSpecContextProviderRefKind = {}));
163277
163889
  /**
163278
163890
  * A resource to handle GitHub Organization Settings.
163279
163891
  *
@@ -166459,6 +167071,83 @@ class GithubOrgVariableSectionChart extends BaseGithubChart {
166459
167071
  }
166460
167072
  }
166461
167073
 
167074
+ ;// CONCATENATED MODULE: ../cdk8s_renderer/src/charts/github/orgSecretSectionChart.ts
167075
+
167076
+
167077
+
167078
+
167079
+ class GithubOrgSecretSectionChart extends BaseGithubChart {
167080
+ template() {
167081
+ const claim = this.get('claim');
167082
+ const firestartrId = this.get('firestartrId');
167083
+ const githubProvider = claim.providers.github;
167084
+ const orgSecrets = githubProvider.org_secrets || {};
167085
+ const renderSecrets = (section) => {
167086
+ const secrets = orgSecrets[section];
167087
+ if (!Array.isArray(secrets))
167088
+ return [];
167089
+ return secrets.map((secret) => {
167090
+ const parts = secret.value.split(':');
167091
+ const selectedRepositories = (secret.selected_repositories || []).map((ref) => {
167092
+ const match = ref.match(/^component:(.+)$/);
167093
+ if (!match) {
167094
+ throw new ChartRenderError('OrgSettingsClaim', claim.name, `Invalid component ref "${ref}" in selected_repositories. Expected format: component:<name>`);
167095
+ }
167096
+ const componentName = match[1];
167097
+ const resolvedCr = this.refResolver('ComponentClaim', componentName);
167098
+ const org = resolvedCr?.spec?.org;
167099
+ const repoName = resolvedCr?.metadata?.annotations?.['firestartr.dev/external-name'] || resolvedCr?.metadata?.name?.replace(/-[0-9a-f-]{36}$/, '');
167100
+ if (!org || !repoName) {
167101
+ throw new ChartRenderError('OrgSettingsClaim', claim.name, `Referenced component "${componentName}" has no GitHub provider configured`);
167102
+ }
167103
+ return `${org}/${repoName}`;
167104
+ });
167105
+ return {
167106
+ name: secret.name,
167107
+ ref: {
167108
+ kind: 'Secret',
167109
+ name: catalog_common/* default */.A.generic.normalizeName(parts[2]),
167110
+ key: parts[3],
167111
+ },
167112
+ visibility: secret.visibility || 'all',
167113
+ selectedRepositories,
167114
+ };
167115
+ });
167116
+ };
167117
+ const template = {
167118
+ metadata: {
167119
+ name: githubProvider.name,
167120
+ },
167121
+ spec: {
167122
+ org: githubProvider.org,
167123
+ secrets: {
167124
+ actions: renderSecrets('actions'),
167125
+ codespaces: renderSecrets('codespaces'),
167126
+ dependabot: renderSecrets('dependabot'),
167127
+ },
167128
+ firestartr: {
167129
+ tfStateKey: firestartrId,
167130
+ },
167131
+ writeConnectionSecretToRef: {
167132
+ name: `firestartrgithuborganizationsecretsection-${githubProvider.name}-secrets-outputs`.toLowerCase(),
167133
+ outputs: [
167134
+ { key: 'actions_secret_names' },
167135
+ { key: 'codespaces_secret_names' },
167136
+ { key: 'dependabot_secret_names' },
167137
+ ],
167138
+ },
167139
+ },
167140
+ };
167141
+ return JSON.parse(JSON.stringify(template));
167142
+ }
167143
+ gvk() {
167144
+ return FirestartrGithubOrganizationSecretSection.GVK;
167145
+ }
167146
+ instanceApiObject(template) {
167147
+ return new FirestartrGithubOrganizationSecretSection(this, template.metadata.name, template);
167148
+ }
167149
+ }
167150
+
166462
167151
  ;// CONCATENATED MODULE: ../cdk8s_renderer/src/charts/github/index.ts
166463
167152
 
166464
167153
 
@@ -166467,6 +167156,7 @@ class GithubOrgVariableSectionChart extends BaseGithubChart {
166467
167156
 
166468
167157
 
166469
167158
 
167159
+
166470
167160
  ;// CONCATENATED MODULE: ../cdk8s_renderer/src/charts/catalog/base.ts
166471
167161
 
166472
167162
  class BaseCatalogChart extends BaseChart {
@@ -167229,6 +167919,7 @@ class SecretsChart extends BaseSecretsChart {
167229
167919
  GithubOrgWebhookChart: GithubOrgWebhookChart,
167230
167920
  GithubOrgSettingsChart: GithubOrgSettingsChart,
167231
167921
  GithubOrgVariableSectionChart: GithubOrgVariableSectionChart,
167922
+ GithubOrgSecretSectionChart: GithubOrgSecretSectionChart,
167232
167923
  });
167233
167924
 
167234
167925
  ;// CONCATENATED MODULE: ../cdk8s_renderer/src/renderer/claims-render.ts
@@ -167280,16 +167971,21 @@ async function renderClaims(catalogScope, firestartrScope, data) {
167280
167971
  const variableSectionPreviousCR = claim.kind === 'OrgSettingsClaim'
167281
167972
  ? getPreviousCRfromClaim(claim, crs, 'FirestartrGithubOrganizationVariableSection')
167282
167973
  : false;
167974
+ const secretSectionPreviousCR = claim.kind === 'OrgSettingsClaim'
167975
+ ? getPreviousCRfromClaim(claim, crs, 'FirestartrGithubOrganizationSecretSection')
167976
+ : false;
167283
167977
  const patches = await extractPatches(renderClaims[claimKey], previousCR, crs);
167284
167978
  let variableSectionPatches = undefined;
167979
+ let secretSectionPatches = undefined;
167285
167980
  if (claim.kind === 'OrgSettingsClaim') {
167286
167981
  variableSectionPatches = await extractPatches(renderClaims[claimKey], variableSectionPreviousCR, crs);
167982
+ secretSectionPatches = await extractPatches(renderClaims[claimKey], secretSectionPreviousCR);
167287
167983
  }
167288
167984
  if (!previousCR) {
167289
167985
  logger.debug(`No CR found for claim ${claimKey}, it will be rendered from scratch`);
167290
167986
  }
167291
167987
  const claimPath = renderClaims[claimKey].claimPath;
167292
- const { firestartrEntity, extraCharts, catalogEntity } = await renderClaim(catalogScope, firestartrScope, claim, patches, previousCR, claimPath, variableSectionPreviousCR, variableSectionPatches, crs);
167988
+ const { firestartrEntity, extraCharts, catalogEntity } = await renderClaim(catalogScope, firestartrScope, claim, patches, previousCR, claimPath, variableSectionPreviousCR, variableSectionPatches, crs, secretSectionPreviousCR, secretSectionPatches);
167293
167989
  if (catalogEntity) {
167294
167990
  result[`${catalogEntity.kind}-${catalogEntity.metadata.name}`] =
167295
167991
  catalogEntity.toJson();
@@ -167318,7 +168014,7 @@ async function renderClaims(catalogScope, firestartrScope, data) {
167318
168014
  }
167319
168015
  return result;
167320
168016
  }
167321
- async function renderClaim(catalogScope, firestartrScope, claim, patches, previousCR = null, claimPath, variableSectionPreviousCR = false, variableSectionPatches, crs) {
168017
+ async function renderClaim(catalogScope, firestartrScope, claim, patches, previousCR = null, claimPath, variableSectionPreviousCR = false, variableSectionPatches, crs, secretSectionPreviousCR = false, secretSectionPatches) {
167322
168018
  let catalogEntity = undefined;
167323
168019
  let firestartrEntity = undefined;
167324
168020
  const extraCharts = [];
@@ -167488,6 +168184,27 @@ async function renderClaim(catalogScope, firestartrScope, claim, patches, previo
167488
168184
  },
167489
168185
  chart: variableSectionObject,
167490
168186
  });
168187
+ const secretSectionFirestartrId = secretSectionPreviousCR
168188
+ ? secretSectionPreviousCR.spec?.firestartr?.tfStateKey
168189
+ : firestartrId
168190
+ ? `${firestartrId}-secrets`
168191
+ : null;
168192
+ const ssRenderPatches = secretSectionPatches
168193
+ ? secretSectionPatches.filter((patch) => !patch.isPostPatch)
168194
+ : renderPatches;
168195
+ const ssPostPatches = secretSectionPatches
168196
+ ? secretSectionPatches.filter((patch) => patch.isPostPatch)
168197
+ : postPatches;
168198
+ const secretSectionChart = new charts.GithubOrgSecretSectionChart(firestartrScope, `github-secrets-${chartId}`, secretSectionFirestartrId, claim, ssRenderPatches);
168199
+ await secretSectionChart.render();
168200
+ const secretSectionObject = await secretSectionChart.postRenderer(ssPostPatches);
168201
+ extraCharts.push({
168202
+ claim: {
168203
+ kind: claim.kind,
168204
+ name: `${claim.name}-secret-section`,
168205
+ },
168206
+ chart: secretSectionObject,
168207
+ });
167491
168208
  }
167492
168209
  break;
167493
168210
  default:
@@ -167610,8 +168327,33 @@ function searchSecretKey(secretClaim, key) {
167610
168327
  }
167611
168328
  function validateOrgSettingsComponentRefs(ref, renderClaims) {
167612
168329
  const claim = renderClaims[ref].claim;
168330
+ validateOrgSecretsSelectedRepositories(claim, renderClaims);
167613
168331
  validateActionsVariablesSelectedRepositories(claim, renderClaims);
167614
168332
  }
168333
+ function validateOrgSecretsSelectedRepositories(claim, renderClaims) {
168334
+ const orgSecrets = claim?.providers?.github?.org_secrets;
168335
+ if (!orgSecrets || typeof orgSecrets !== 'object')
168336
+ return;
168337
+ for (const section of ['actions', 'codespaces', 'dependabot']) {
168338
+ const secrets = orgSecrets[section];
168339
+ if (!Array.isArray(secrets))
168340
+ continue;
168341
+ for (const secret of secrets) {
168342
+ if (!secret.selected_repositories)
168343
+ continue;
168344
+ for (const repoRef of secret.selected_repositories) {
168345
+ const match = repoRef.match(COMPONENT_REF_PATTERN);
168346
+ if (!match)
168347
+ continue;
168348
+ const [, componentName] = match;
168349
+ const expectedKey = `ComponentClaim-${componentName}`;
168350
+ if (!renderClaims[expectedKey]) {
168351
+ throw new Error(`CrossReference error: OrgSettingsClaim/${claim.name} references a non-existent component "${componentName}" in org_secrets.${section}.${secret.name}.selected_repositories`);
168352
+ }
168353
+ }
168354
+ }
168355
+ }
168356
+ }
167615
168357
  function validateActionsVariablesSelectedRepositories(claim, renderClaims) {
167616
168358
  const actionsVariables = claim?.providers?.github?.actions_variables;
167617
168359
  if (!Array.isArray(actionsVariables))
@@ -167742,6 +168484,108 @@ function validateActionsVariablesUniqueness(crs) {
167742
168484
  }
167743
168485
  }
167744
168486
 
168487
+ ;// CONCATENATED MODULE: ../cdk8s_renderer/src/validations/githubOrgSecretSection.ts
168488
+ const GITHUB_ORG_SECRET_SECTION_KIND = 'FirestartrGithubOrganizationSecretSection';
168489
+ const githubOrgSecretSection_FIRESTARTR_CLAIM_REF_ANNOTATION = 'firestartr.dev/claim-ref';
168490
+ const githubOrgSecretSection_CLAIM_REF_LABEL = 'claim-ref';
168491
+ const SECRETS_CLAIM_REF_PATTERN = /^ref:secretsclaim:([a-zA-Z0-9_-]+):([a-zA-Z0-9_-]+)$/;
168492
+ function githubOrgSecretSection_formatResourceRef(name, claimRef) {
168493
+ return claimRef ? `${name} (claim: ${claimRef})` : name;
168494
+ }
168495
+ function validateGithubOrgSecretSectionSingleton(crs) {
168496
+ const refsByOrg = new Map();
168497
+ const seenClaimRefs = new Map();
168498
+ for (const crKey of Object.keys(crs)) {
168499
+ const cr = crs[crKey];
168500
+ if (cr.kind !== GITHUB_ORG_SECRET_SECTION_KIND)
168501
+ continue;
168502
+ const org = cr.spec?.org;
168503
+ if (typeof org !== 'string' || !org)
168504
+ continue;
168505
+ const name = cr.metadata?.name || crKey;
168506
+ const claimRef = cr.metadata?.annotations?.[githubOrgSecretSection_FIRESTARTR_CLAIM_REF_ANNOTATION] ||
168507
+ cr.metadata?.labels?.[githubOrgSecretSection_CLAIM_REF_LABEL];
168508
+ const normalizedOrg = org.toLowerCase();
168509
+ if (claimRef) {
168510
+ const seen = seenClaimRefs.get(normalizedOrg) || new Set();
168511
+ if (seen.has(claimRef))
168512
+ continue;
168513
+ seen.add(claimRef);
168514
+ seenClaimRefs.set(normalizedOrg, seen);
168515
+ }
168516
+ const refs = refsByOrg.get(normalizedOrg) || [];
168517
+ refs.push(githubOrgSecretSection_formatResourceRef(name, claimRef));
168518
+ refsByOrg.set(normalizedOrg, refs);
168519
+ }
168520
+ for (const [org, refs] of refsByOrg.entries()) {
168521
+ if (refs.length < 2)
168522
+ continue;
168523
+ throw new Error(`Duplicate ${GITHUB_ORG_SECRET_SECTION_KIND} resources found for GitHub organization "${org}": ${refs.join(', ')}`);
168524
+ }
168525
+ }
168526
+ function validateSecretNamesUniqueness(crs) {
168527
+ for (const crKey of Object.keys(crs)) {
168528
+ const cr = crs[crKey];
168529
+ if (cr.kind !== GITHUB_ORG_SECRET_SECTION_KIND)
168530
+ continue;
168531
+ const secrets = cr.spec?.secrets;
168532
+ if (!secrets || typeof secrets !== 'object')
168533
+ continue;
168534
+ for (const section of ['actions', 'codespaces', 'dependabot']) {
168535
+ const sectionSecrets = secrets[section];
168536
+ if (!Array.isArray(sectionSecrets))
168537
+ continue;
168538
+ const names = new Map();
168539
+ for (const secret of sectionSecrets) {
168540
+ const secretName = secret?.name;
168541
+ if (!secretName)
168542
+ continue;
168543
+ const normalizedName = secretName.toLowerCase();
168544
+ const previousName = names.get(normalizedName);
168545
+ if (previousName !== undefined) {
168546
+ const org = cr.spec?.org || 'unknown';
168547
+ throw new Error(`Duplicate secret name "${secretName}" found in ${section} section of ${GITHUB_ORG_SECRET_SECTION_KIND} for organization "${org}"`);
168548
+ }
168549
+ names.set(normalizedName, secretName);
168550
+ }
168551
+ }
168552
+ }
168553
+ }
168554
+ function validateOrgSecretsCrossReferences(renderClaims) {
168555
+ for (const claimKey of Object.keys(renderClaims)) {
168556
+ if (!claimKey.startsWith('OrgSettingsClaim-'))
168557
+ continue;
168558
+ const claimData = renderClaims[claimKey];
168559
+ const claim = claimData?.claim;
168560
+ const orgSecrets = claim?.providers?.github?.org_secrets;
168561
+ if (!orgSecrets || typeof orgSecrets !== 'object')
168562
+ continue;
168563
+ for (const section of ['actions', 'codespaces', 'dependabot']) {
168564
+ const secrets = orgSecrets[section];
168565
+ if (!Array.isArray(secrets))
168566
+ continue;
168567
+ for (const secret of secrets) {
168568
+ if (!secret.value)
168569
+ continue;
168570
+ const match = secret.value.match(SECRETS_CLAIM_REF_PATTERN);
168571
+ if (!match)
168572
+ continue;
168573
+ const [, secretClaimName, secretKey] = match;
168574
+ const expectedKey = `SecretsClaim-${secretClaimName}`;
168575
+ if (!renderClaims[expectedKey])
168576
+ continue;
168577
+ const secretClaim = renderClaims[expectedKey]?.claim;
168578
+ const externalSecrets = secretClaim?.providers?.external_secrets?.externalSecrets?.secrets;
168579
+ const keyFound = Array.isArray(externalSecrets) &&
168580
+ externalSecrets.some((s) => s.secretName === secretKey);
168581
+ if (!keyFound) {
168582
+ throw new Error(`CrossReference error: OrgSettingsClaim/${claim.name} references a non-existent secret key "${secretKey}" in SecretsClaim/${secretClaimName} via org_secrets.${section}.${secret.name}`);
168583
+ }
168584
+ }
168585
+ }
168586
+ }
168587
+ }
168588
+
167745
168589
  ;// CONCATENATED MODULE: ../cdk8s_renderer/src/renderer/renderer.ts
167746
168590
 
167747
168591
 
@@ -167754,6 +168598,7 @@ function validateActionsVariablesUniqueness(crs) {
167754
168598
 
167755
168599
 
167756
168600
 
168601
+
167757
168602
  /*
167758
168603
  * Function called when rendering but not importing
167759
168604
  *
@@ -167777,9 +168622,12 @@ async function renderer_render(catalogScope, firestartrScope, claimList) {
167777
168622
  validateComponentPagesPath(data.renderClaims);
167778
168623
  validateClaimRefOwnership(data.fullCrs, result);
167779
168624
  validateTfStateKeyUniqueness(fullCrSet);
168625
+ validateOrgSecretsCrossReferences(data.renderClaims);
167780
168626
  validateGithubOrgSettingsSingleton(fullCrSet);
167781
168627
  validateGithubOrgVariableSectionSingleton(fullCrSet);
167782
168628
  validateActionsVariablesUniqueness(result);
168629
+ validateGithubOrgSecretSectionSingleton(fullCrSet);
168630
+ validateSecretNamesUniqueness(result);
167783
168631
  validateCrSizes(result);
167784
168632
  validatePermissionsUniqueness(result);
167785
168633
  validateNoBackstageAnnotationsInK8sCrs(result);
@@ -351271,6 +352119,7 @@ const kindPluralMap = {
351271
352119
  githuborgwebhooks: 'FirestartrGithubOrgWebhook',
351272
352120
  githuborganizationsettings: 'FirestartrGithubOrganizationSettings',
351273
352121
  githuborganizationvariablesections: 'FirestartrGithubOrganizationVariableSection',
352122
+ githuborganizationsecretsections: 'FirestartrGithubOrganizationSecretSection',
351274
352123
  terraformworkspaces: 'FirestartrTerraformWorkspace',
351275
352124
  providerconfigs: 'FirestartrProviderConfig',
351276
352125
  externalsecrets: 'ExternalSecret',
@@ -353731,6 +354580,7 @@ const kindsWithFinalizer = [
353731
354580
  'FirestartrGithubOrgWebhook',
353732
354581
  'FirestartrGithubOrganizationSettings',
353733
354582
  'FirestartrGithubOrganizationVariableSection',
354583
+ 'FirestartrGithubOrganizationSecretSection',
353734
354584
  'FirestartrGithubRepositorySecretsSection',
353735
354585
  ];
353736
354586
  const kindsWithDependants = [
@@ -356074,6 +356924,9 @@ async function workItemGarbageCollector(queue, bookkeeper) {
356074
356924
 
356075
356925
  // EXTERNAL MODULE: external "child_process"
356076
356926
  var external_child_process_ = __nccwpck_require__(35317);
356927
+ // EXTERNAL MODULE: external "crypto"
356928
+ var external_crypto_ = __nccwpck_require__(76982);
356929
+ var external_crypto_default = /*#__PURE__*/__nccwpck_require__.n(external_crypto_);
356077
356930
  ;// CONCATENATED MODULE: ../terraform_provisioner/src/tf/analyzer.ts
356078
356931
 
356079
356932
  function planLoader(planPath) {
@@ -356468,6 +357321,7 @@ ${providersString}
356468
357321
 
356469
357322
 
356470
357323
 
357324
+
356471
357325
  const TOFU_LOCK_TIMEOUT = '-lock-timeout=60s';
356472
357326
  const MAX_APPLY_ATTEMPTS = 3;
356473
357327
  const TRANSIENT_APPLY_RETRY_DELAY_MS = 1000;
@@ -356840,9 +357694,8 @@ async function configGit() {
356840
357694
  }
356841
357695
  // Import github dynamically to avoid Jest ESM issues when not specifically running this function
356842
357696
  // (see CONSTITUTION and RULES: must not change test machinery)
356843
- const githubModule = await Promise.resolve(/* import() */).then(__nccwpck_require__.bind(__nccwpck_require__, 44912));
357697
+ const githubModule = await Promise.resolve(/* import() */).then(__nccwpck_require__.bind(__nccwpck_require__, 37524));
356844
357698
  const github = githubModule.default || githubModule;
356845
- removeGitConfig();
356846
357699
  const org = catalog_common/* default */.A.environment.getFromEnvironment(catalog_common/* default */.A.types.envVars.org);
356847
357700
  // Provided in your code logic, but may wrap for null fallback if required
356848
357701
  // Here, github.getGithubAppToken is async as used elsewhere
@@ -356854,7 +357707,22 @@ async function configGit() {
356854
357707
  // and the resulting URL stays valid. Mode 0600 because the file holds a bearer token.
356855
357708
  // Residual: the token lives in the rewritten URL. If git prints that URL in an
356856
357709
  // error and it reaches logs, it leaks another way (SC-01), out of scope here.
356857
- external_fs_.writeFileSync(GITCONFIG_PATH, `[url "https://firestartr:${ghToken}@github.com/"]\ninsteadOf = https://github.com/\n`, { mode: 0o600 });
357710
+ // Keep the previous credentials available until a complete 0600 file can be
357711
+ // atomically renamed over it. A same-directory temp keeps rename on one filesystem.
357712
+ const tempPath = `${GITCONFIG_PATH}.${process.pid}.${(0,external_crypto_.randomUUID)()}.tmp`;
357713
+ try {
357714
+ external_fs_.writeFileSync(tempPath, `[url "https://firestartr:${ghToken}@github.com/"]\ninsteadOf = https://github.com/\n`, { mode: 0o600, flag: 'wx' });
357715
+ external_fs_.renameSync(tempPath, GITCONFIG_PATH);
357716
+ }
357717
+ catch (error) {
357718
+ try {
357719
+ external_fs_.rmSync(tempPath, { force: true });
357720
+ }
357721
+ catch {
357722
+ // Best-effort cleanup must not mask the original write or rename error.
357723
+ }
357724
+ throw error;
357725
+ }
356858
357726
  ensureGitConfigExitCleanup();
356859
357727
  }
356860
357728
 
@@ -360375,6 +361243,11 @@ const MODULES = {
360375
361243
  // github-org-variables-section-v0.1.0
360376
361244
  ref: 'fb9c01d0a1e03e5134479da13d0faf55891dfedf',
360377
361245
  },
361246
+ FirestartrGithubOrganizationSecretSection: {
361247
+ module: 'git::https://github.com/prefapp/tfm.git//modules/github-org-secrets-section',
361248
+ // github-org-secrets-section feat/1364-feat-add-github-org-secrets-section-module
361249
+ ref: '170e6cf3d60508ff0566dffb7630e826b50d424a',
361250
+ },
360378
361251
  };
360379
361252
  function getFirestartrDefaultTFM(kind) {
360380
361253
  if (kind in MODULES) {
@@ -360678,9 +361551,6 @@ class EntityGroup extends Entity {
360678
361551
  }
360679
361552
  }
360680
361553
 
360681
- // EXTERNAL MODULE: external "crypto"
360682
- var external_crypto_ = __nccwpck_require__(76982);
360683
- var external_crypto_default = /*#__PURE__*/__nccwpck_require__.n(external_crypto_);
360684
361554
  ;// CONCATENATED MODULE: ../gh_provisioner/src/entities/ghrepositorysecretssection/secrets.ts
360685
361555
 
360686
361556
 
@@ -362289,6 +363159,183 @@ class EntityGHOrgVarsSection extends Entity {
362289
363159
  async loadAddressesToImport() { }
362290
363160
  }
362291
363161
 
363162
+ ;// CONCATENATED MODULE: ../gh_provisioner/src/entities/ghorgsecretsection/secrets.ts
363163
+
363164
+
363165
+
363166
+
363167
+ const secrets_SECTIONS = ['actions', 'codespaces', 'dependabot'];
363168
+
363169
+ async function provisionOrgSecrets(entity, secrets) {
363170
+ gh_provisioner_src_logger.info(`[gh-provisioner] ${entity.k8sId} provisioning org secrets`);
363171
+ const declared = secrets_SECTIONS.some((section) => (secrets[section] || []).length);
363172
+ if (declared && process.env['AVOID_PROVIDER_SECRET_ENCRYPTION']) {
363173
+ throw new Error(`[gh-provisioner] ${entity.k8sId} AVOID_PROVIDER_SECRET_ENCRYPTION is not supported for org secrets: the github-org-secrets-section module only accepts encrypted values`);
363174
+ }
363175
+ for (const section of secrets_SECTIONS) {
363176
+ const sectionSecrets = secrets[section] || [];
363177
+ if (sectionSecrets.length === 0)
363178
+ continue;
363179
+ let preFetchedKey;
363180
+ try {
363181
+ preFetchedKey = await fetchOrgPublicKey(entity, section);
363182
+ }
363183
+ catch (err) {
363184
+ const message = err instanceof Error ? err.message : String(err);
363185
+ throw new Error(`[gh-provisioner] ${entity.k8sId} failed to fetch ${section} org public key: ${message}`);
363186
+ }
363187
+ for (const secret of sectionSecrets) {
363188
+ await provisionOrgSecret(entity, section, secret, preFetchedKey);
363189
+ }
363190
+ }
363191
+ }
363192
+ async function fetchOrgPublicKey(entity, section) {
363193
+ return (await entity.runWithGithubProvider(async () => {
363194
+ return await github["default"].encryption.getOrgPublicKey(entity.cr.spec.org, section);
363195
+ }));
363196
+ }
363197
+ async function provisionOrgSecret(entity, section, secret, preFetchedKey) {
363198
+ gh_provisioner_src_logger.info(`[gh-provisioner] provisioning org secret ${entity.k8sId}/${section}/${secret.name}`);
363199
+ await secrets_createEncryptedSecret(entity, section, secret, preFetchedKey);
363200
+ gh_provisioner_src_logger.info(`[gh-provisioner] org secret provisioned ${section}/${secret.name}`);
363201
+ }
363202
+ async function secrets_createEncryptedSecret(entity, section, secret, preFetchedKey) {
363203
+ const resolved = entity.resolveRef(secret.ref);
363204
+ if (!resolved) {
363205
+ throw new Error(`[gh-provisioner] ${entity.k8sId} cannot resolve secret ref: ${secret.ref.kind}/${secret.ref.name}:${secret.ref.key} — ensure the referenced resource is available as a dependency`);
363206
+ }
363207
+ const plainTextSecret = resolved.getOutput(secret.ref.key);
363208
+ const plaintextSha256 = external_crypto_default().createHash('sha256')
363209
+ .update(plainTextSecret)
363210
+ .digest('hex');
363211
+ const { encrypted_value } = (await entity.runWithGithubProvider(async () => {
363212
+ return await github["default"].encryption.encryptOrgSecret(entity.cr.spec.org, section, plainTextSecret, preFetchedKey);
363213
+ }));
363214
+ entity.patchData({
363215
+ op: PatchOperations.add,
363216
+ path: `/config/${section}/${secret.name}`,
363217
+ value: {
363218
+ value: encrypted_value,
363219
+ visibility: secret.visibility || 'all',
363220
+ ...(secret.selectedRepositories && secret.selectedRepositories.length > 0
363221
+ ? { selected_repositories: secret.selectedRepositories }
363222
+ : {}),
363223
+ },
363224
+ });
363225
+ entity.patchData({
363226
+ op: PatchOperations.add,
363227
+ path: `/config/${section}_sha256/${secret.name}`,
363228
+ value: plaintextSha256,
363229
+ });
363230
+ }
363231
+ async function adoptSecretsIfNeeded(entity, secrets) {
363232
+ for (const section of secrets_SECTIONS) {
363233
+ const sectionSecrets = secrets[section] || [];
363234
+ if (sectionSecrets.length === 0)
363235
+ continue;
363236
+ const managedSecrets = entity.cr.fResolveSelfOutputs(`${section}_secret_names`) || [];
363237
+ const declaredNames = sectionSecrets.map((s) => s.name);
363238
+ const newToModule = declaredNames.filter((name) => !managedSecrets.includes(name));
363239
+ if (newToModule.length === 0) {
363240
+ gh_provisioner_src_logger.debug(`[gh-provisioner] ${entity.k8sId} all declared ${section} secrets are already managed`);
363241
+ continue;
363242
+ }
363243
+ if (managedSecrets.length === 0) {
363244
+ gh_provisioner_src_logger.info(`[gh-provisioner] ${entity.k8sId} no ${section}_secret_names output — first reconciliation, treating all ${newToModule.length} ${section} secret(s) as new to module`);
363245
+ }
363246
+ for (const secretName of newToModule) {
363247
+ try {
363248
+ const existing = (await entity.runWithGithubProvider(async () => {
363249
+ return await github["default"].encryption.getOrgSecret(entity.cr.spec.org, section, secretName);
363250
+ }));
363251
+ if (existing) {
363252
+ gh_provisioner_src_logger.info(`[gh-provisioner] ${entity.k8sId} adopting pre-existing ${section} secret '${secretName}' on GitHub org '${entity.cr.spec.org}'`);
363253
+ entity.patchData({
363254
+ op: PatchOperations.remove,
363255
+ path: `/config/${section}_sha256/${secretName}`,
363256
+ });
363257
+ const resourceType = `github_${section}_organization_secret`;
363258
+ entity.patchImportData({
363259
+ op: PatchOperations.add,
363260
+ path: '/imports/-',
363261
+ value: {
363262
+ to: `${resourceType}.this["${secretName}"]`,
363263
+ id: secretName,
363264
+ },
363265
+ });
363266
+ }
363267
+ }
363268
+ catch (err) {
363269
+ if (err && err.status === 404) {
363270
+ gh_provisioner_src_logger.info(`[gh-provisioner] ${entity.k8sId} ${section} secret '${secretName}' not found on GitHub org '${entity.cr.spec.org}' — will be created by TFM`);
363271
+ }
363272
+ else if (err && (err.status === 401 || err.status === 403)) {
363273
+ gh_provisioner_src_logger.warn(`[gh-provisioner] ${entity.k8sId} token lacks scope to check ${section} secret '${secretName}' on org '${entity.cr.spec.org}' — skipping adoption gracefully`);
363274
+ }
363275
+ else {
363276
+ gh_provisioner_src_logger.warn(`[gh-provisioner] ${entity.k8sId} unexpected error checking ${section} secret '${secretName}' on org '${entity.cr.spec.org}': ${err instanceof Error ? err.message : String(err)}`);
363277
+ }
363278
+ }
363279
+ }
363280
+ }
363281
+ }
363282
+
363283
+ ;// CONCATENATED MODULE: ../gh_provisioner/src/entities/ghorgsecretsection/index.ts
363284
+
363285
+
363286
+
363287
+ class EntityGHOrgSecretSection extends Entity {
363288
+ constructor(artifact, deps) {
363289
+ super(artifact, {
363290
+ config: {
363291
+ org: '',
363292
+ actions: {},
363293
+ codespaces: {},
363294
+ dependabot: {},
363295
+ actions_sha256: {},
363296
+ codespaces_sha256: {},
363297
+ dependabot_sha256: {},
363298
+ },
363299
+ }, deps);
363300
+ }
363301
+ async loadResources(tfOp) {
363302
+ gh_provisioner_src_logger.info(`[gh-provisioner] running ${tfOp} on ${this.k8sId}`);
363303
+ try {
363304
+ const cr = this.cr;
363305
+ const org = cr.spec.org;
363306
+ const secrets = cr.spec.secrets || {};
363307
+ this.patchData({
363308
+ op: PatchOperations.replace,
363309
+ path: '/config/org',
363310
+ value: org,
363311
+ });
363312
+ if (tfOp !== 'destroy' && tfOp !== 'plan-destroy') {
363313
+ await provisionOrgSecrets(this, secrets);
363314
+ }
363315
+ const redactedDoc = JSON.parse(JSON.stringify(this._document, (key, value) => {
363316
+ if (key === 'value' && typeof value === 'string')
363317
+ return '[REDACTED]';
363318
+ return typeof value === 'string' && value.length > 50
363319
+ ? '[REDACTED]'
363320
+ : value;
363321
+ }));
363322
+ this.synthMessage(`[gh-provisioner] ${this.k8sId} config:\n${JSON.stringify(redactedDoc, null, 2)}`);
363323
+ this.synthEnd(`[gh-provisioner] ${this.k8sId} loaded its data`);
363324
+ if (tfOp === 'apply') {
363325
+ await adoptSecretsIfNeeded(this, secrets);
363326
+ }
363327
+ gh_provisioner_src_logger.debug(`[gh-provisioner] ${this.k8sId} loaded its data`);
363328
+ }
363329
+ catch (err) {
363330
+ const message = err instanceof Error ? err.message : String(err);
363331
+ gh_provisioner_src_logger.error(`[gh-provisioner] ${this.k8sId} error loading resources: ${message}`);
363332
+ throw new Error(`[gh-provisioner] ${this.k8sId} error loading resources: ${message}`);
363333
+ }
363334
+ }
363335
+ async postProvision(_tfOp) { }
363336
+ async loadAddressesToImport() { }
363337
+ }
363338
+
362292
363339
  ;// CONCATENATED MODULE: ../gh_provisioner/src/entities/ghorgwebhook/index.ts
362293
363340
 
362294
363341
 
@@ -362363,6 +363410,7 @@ class EntityGHOrgWebHook extends Entity {
362363
363410
 
362364
363411
 
362365
363412
 
363413
+
362366
363414
  function entities_getEntity(cr, deps) {
362367
363415
  const entityClass = getEntityClass(cr.kind);
362368
363416
  return new entityClass(cr, deps);
@@ -362385,6 +363433,8 @@ function getEntityClass(kind) {
362385
363433
  return EntityGHOrgSettings;
362386
363434
  case 'FirestartrGithubOrganizationVariableSection':
362387
363435
  return EntityGHOrgVarsSection;
363436
+ case 'FirestartrGithubOrganizationSecretSection':
363437
+ return EntityGHOrgSecretSection;
362388
363438
  default:
362389
363439
  throw new Error(`kind ${kind} has no entity associated`);
362390
363440
  }
@@ -362638,6 +363688,7 @@ const GITHUB_RESOURCE_KINDS = [
362638
363688
  'FirestartrGithubOrgWebhook',
362639
363689
  'FirestartrGithubOrganizationSettings',
362640
363690
  'FirestartrGithubOrganizationVariableSection',
363691
+ 'FirestartrGithubOrganizationSecretSection',
362641
363692
  ];
362642
363693
  const GITHUB_REPOSITORY_DEPENDENT_KINDS = [
362643
363694
  'FirestartrGithubRepositoryFeature',
@@ -364046,6 +365097,7 @@ const provisionImplementations = {
364046
365097
  githuborgwebhooks: process_operation_processOperation,
364047
365098
  githuborganizationsettings: process_operation_processOperation,
364048
365099
  githuborganizationvariablesections: process_operation_processOperation,
365100
+ githuborganizationsecretsections: process_operation_processOperation,
364049
365101
  fsdummiesa: processFirestartrDummies,
364050
365102
  fsdummiesb: processFirestartrDummies,
364051
365103
  fsdummiesc: processFirestartrDummies,
@@ -364952,7 +366004,7 @@ const crsStatusSubcommand = {
364952
366004
  };
364953
366005
 
364954
366006
  ;// CONCATENATED MODULE: ./package.json
364955
- const package_namespaceObject = /*#__PURE__*/JSON.parse('{"rE":"3.2.0-snapshot-01"}');
366007
+ const package_namespaceObject = /*#__PURE__*/JSON.parse('{"rE":"3.2.0-snapshot-02"}');
364956
366008
  ;// CONCATENATED MODULE: ../../package.json
364957
366009
  const package_namespaceObject_1 = {"rE":"3.1.1"};
364958
366010
  // EXTERNAL MODULE: ../../node_modules/semver/index.js