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

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