@firestartr/cli 2.11.0-snapshot-mco-3 → 2.11.0-snapshot-org-secrets-00

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
@@ -128727,7 +128727,7 @@ function getCronNextInterval(cronLine, tz) {
128727
128727
 
128728
128728
  /***/ }),
128729
128729
 
128730
- /***/ 99029:
128730
+ /***/ 3342:
128731
128731
  /***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => {
128732
128732
 
128733
128733
  // ESM COMPAT FLAG
@@ -134407,6 +134407,66 @@ async function encryptRepoSecret(owner, repo, section, plaintextValue, octokit)
134407
134407
  }
134408
134408
  }
134409
134409
 
134410
+ ;// CONCATENATED MODULE: ../github/src/orgSecrets.ts
134411
+
134412
+
134413
+
134414
+ async function getOrgPublicKey(org, section, octokit) {
134415
+ logger.info(`Retrieving org public key for ${org} (${section})`);
134416
+ try {
134417
+ if (!octokit) {
134418
+ octokit = await getOctokitForOrg(org);
134419
+ }
134420
+ const { data } = await octokit.rest[`${section}`].getOrgPublicKey({
134421
+ org,
134422
+ });
134423
+ return data;
134424
+ }
134425
+ catch (error) {
134426
+ logger.error(`Error retrieving org public key (${section}) for ${org}: ${error}`);
134427
+ throw error;
134428
+ }
134429
+ }
134430
+ async function encryptOrgSecret(org, section, plaintextValue, preFetchedKey, octokit) {
134431
+ try {
134432
+ const { key_id, key } = preFetchedKey
134433
+ ? preFetchedKey
134434
+ : await getOrgPublicKey(org, section, octokit);
134435
+ await libsodium_wrappers.ready;
134436
+ const publicKey = libsodium_wrappers.from_base64(key, libsodium_wrappers.base64_variants.ORIGINAL);
134437
+ const secretBytes = libsodium_wrappers.from_string(plaintextValue);
134438
+ const encryptedBytes = libsodium_wrappers.crypto_box_seal(secretBytes, publicKey);
134439
+ const encryptedValue = libsodium_wrappers.to_base64(encryptedBytes, libsodium_wrappers.base64_variants.ORIGINAL);
134440
+ return {
134441
+ key_id,
134442
+ encrypted_value: encryptedValue,
134443
+ };
134444
+ }
134445
+ catch (err) {
134446
+ logger.error(`Error encrypting org secret (${section}) for ${org}: ${err}`);
134447
+ throw err;
134448
+ }
134449
+ }
134450
+ async function getOrgSecret(org, section, name, octokit) {
134451
+ logger.info(`Checking org secret ${name} (${section}) for ${org}`);
134452
+ try {
134453
+ if (!octokit) {
134454
+ octokit = await getOctokitForOrg(org);
134455
+ }
134456
+ const response = await octokit.rest[`${section}`].getOrgSecret({
134457
+ org,
134458
+ secret_name: name,
134459
+ });
134460
+ return response.data;
134461
+ }
134462
+ catch (err) {
134463
+ if (err && err.status === 404) {
134464
+ return null;
134465
+ }
134466
+ throw err;
134467
+ }
134468
+ }
134469
+
134410
134470
  ;// CONCATENATED MODULE: ../github/src/profile.ts
134411
134471
  // Profile definitions and store for github package (immutable and ambient profiles)
134412
134472
  const profileStore = new Map();
@@ -134841,6 +134901,7 @@ function withProfile(profileName) {
134841
134901
 
134842
134902
 
134843
134903
 
134904
+
134844
134905
  /* harmony default export */ const github = ({
134845
134906
  org: organization,
134846
134907
  repo: repository,
@@ -134863,6 +134924,9 @@ function withProfile(profileName) {
134863
134924
  encryption: {
134864
134925
  encryptRepoSecret: encryptRepoSecret,
134865
134926
  getRepoPublicKey: getRepoPublicKey,
134927
+ getOrgPublicKey: getOrgPublicKey,
134928
+ encryptOrgSecret: encryptOrgSecret,
134929
+ getOrgSecret: getOrgSecret,
134866
134930
  },
134867
134931
  withProfile: withProfile,
134868
134932
  createProfile: createProfile,
@@ -159640,8 +159704,8 @@ var dist = __nccwpck_require__(44516);
159640
159704
  var dist_default = /*#__PURE__*/__nccwpck_require__.n(dist);
159641
159705
  // EXTERNAL MODULE: ../catalog_common/index.ts + 44 modules
159642
159706
  var catalog_common = __nccwpck_require__(78542);
159643
- // EXTERNAL MODULE: ../github/index.ts + 37 modules
159644
- var github = __nccwpck_require__(99029);
159707
+ // EXTERNAL MODULE: ../github/index.ts + 38 modules
159708
+ var github = __nccwpck_require__(3342);
159645
159709
  ;// CONCATENATED MODULE: ../cdk8s_renderer/src/patches/base.ts
159646
159710
  class BasePatches {
159647
159711
  constructor() { }
@@ -162502,6 +162566,31 @@ function extractAllRefs(claimData) {
162502
162566
  }
162503
162567
  }
162504
162568
  }
162569
+ const orgSecrets = parsedClaim.providers?.github?.org_secrets;
162570
+ if (orgSecrets && typeof orgSecrets === 'object') {
162571
+ const secretRefRegex = /^ref:secretsclaim:([a-zA-Z0-9_-]+):([a-zA-Z0-9_-]+)$/;
162572
+ for (const section of ['actions', 'codespaces', 'dependabot']) {
162573
+ const secrets = orgSecrets[section];
162574
+ if (!Array.isArray(secrets))
162575
+ continue;
162576
+ for (const secret of secrets) {
162577
+ if (secret.value) {
162578
+ const match = secret.value.match(secretRefRegex);
162579
+ if (match) {
162580
+ refs.push(`SecretsClaim-${match[1]}`);
162581
+ }
162582
+ }
162583
+ if (Array.isArray(secret.selected_repositories)) {
162584
+ for (const repoRef of secret.selected_repositories) {
162585
+ const compMatch = repoRef.match(/^component:(.+)$/);
162586
+ if (compMatch) {
162587
+ refs.push(`ComponentClaim-${compMatch[1]}`);
162588
+ }
162589
+ }
162590
+ }
162591
+ }
162592
+ }
162593
+ }
162505
162594
  break;
162506
162595
  }
162507
162596
  }
@@ -163660,6 +163749,30 @@ const organizationSettingsProperties = {
163660
163749
  ],
163661
163750
  },
163662
163751
  },
163752
+ org_secrets: {
163753
+ type: 'object',
163754
+ properties: {
163755
+ actions: {
163756
+ type: 'array',
163757
+ items: {
163758
+ $ref: 'firestartr.dev://github/GithubOrgClaimSecret',
163759
+ },
163760
+ },
163761
+ codespaces: {
163762
+ type: 'array',
163763
+ items: {
163764
+ $ref: 'firestartr.dev://github/GithubOrgClaimSecret',
163765
+ },
163766
+ },
163767
+ dependabot: {
163768
+ type: 'array',
163769
+ items: {
163770
+ $ref: 'firestartr.dev://github/GithubOrgClaimSecret',
163771
+ },
163772
+ },
163773
+ },
163774
+ additionalProperties: false,
163775
+ },
163663
163776
  };
163664
163777
  /* harmony default export */ const github_orgsettings_schema = ({
163665
163778
  $schema: SCHEMA,
@@ -163884,6 +163997,75 @@ const organizationSettingsProperties = {
163884
163997
  },
163885
163998
  });
163886
163999
 
164000
+ ;// CONCATENATED MODULE: ../cdk8s_renderer/src/claims/github/orgSecrets.schema.ts
164001
+
164002
+ /* harmony default export */ const orgSecrets_schema = ({
164003
+ $schema: SCHEMA,
164004
+ $id: 'GithubOrgClaimSecrets',
164005
+ definitions: {
164006
+ GithubOrgClaimSecrets: {
164007
+ $id: 'firestartr.dev://github/GithubOrgClaimSecrets',
164008
+ type: 'object',
164009
+ description: 'Organization-level GitHub Actions secrets',
164010
+ properties: {
164011
+ actions: {
164012
+ type: 'array',
164013
+ items: {
164014
+ $ref: 'firestartr.dev://github/GithubOrgClaimSecret',
164015
+ },
164016
+ },
164017
+ codespaces: {
164018
+ type: 'array',
164019
+ items: {
164020
+ $ref: 'firestartr.dev://github/GithubOrgClaimSecret',
164021
+ },
164022
+ },
164023
+ dependabot: {
164024
+ type: 'array',
164025
+ items: {
164026
+ $ref: 'firestartr.dev://github/GithubOrgClaimSecret',
164027
+ },
164028
+ },
164029
+ },
164030
+ additionalProperties: false,
164031
+ },
164032
+ GithubOrgClaimSecretRef: {
164033
+ $id: 'firestartr.dev://github/GithubOrgClaimSecretRef',
164034
+ type: 'string',
164035
+ description: 'the reference of the secret',
164036
+ pattern: '^ref:secretsclaim:([a-zA-Z0-9_-]+):([a-zA-Z0-9_-]+)$',
164037
+ },
164038
+ GithubOrgClaimSecret: {
164039
+ $id: 'firestartr.dev://github/GithubOrgClaimSecret',
164040
+ type: 'object',
164041
+ description: 'An organization-level secret for GitHub Actions',
164042
+ properties: {
164043
+ name: {
164044
+ type: 'string',
164045
+ description: 'the name of the secret',
164046
+ },
164047
+ value: {
164048
+ $ref: 'firestartr.dev://github/GithubOrgClaimSecretRef',
164049
+ },
164050
+ visibility: {
164051
+ type: 'string',
164052
+ enum: ['all', 'selected', 'private'],
164053
+ description: 'which repositories can access the secret',
164054
+ },
164055
+ selected_repositories: {
164056
+ type: 'array',
164057
+ items: {
164058
+ type: 'string',
164059
+ },
164060
+ description: 'list of repository refs when visibility is selected',
164061
+ },
164062
+ },
164063
+ required: ['name', 'value'],
164064
+ additionalProperties: false,
164065
+ },
164066
+ },
164067
+ });
164068
+
163887
164069
  ;// CONCATENATED MODULE: ../cdk8s_renderer/src/claims/github/index.ts
163888
164070
 
163889
164071
 
@@ -163894,6 +164076,7 @@ const organizationSettingsProperties = {
163894
164076
 
163895
164077
 
163896
164078
 
164079
+
163897
164080
  const GithubSchemas = [
163898
164081
  github_group_schema,
163899
164082
  github_user_schema,
@@ -163904,6 +164087,7 @@ const GithubSchemas = [
163904
164087
  component_secrets_vars_schema,
163905
164088
  component_labels_schema,
163906
164089
  pages_schema,
164090
+ orgSecrets_schema,
163907
164091
  ];
163908
164092
 
163909
164093
  ;// CONCATENATED MODULE: ../cdk8s_renderer/src/claims/tfworkspaces/terraform.schema.ts
@@ -168000,6 +168184,412 @@ var FirestartrGithubMembershipSpecContextProviderRefKind;
168000
168184
  /** FirestartrProviderConfig */
168001
168185
  FirestartrGithubMembershipSpecContextProviderRefKind["FIRESTARTR_PROVIDER_CONFIG"] = "FirestartrProviderConfig";
168002
168186
  })(FirestartrGithubMembershipSpecContextProviderRefKind || (FirestartrGithubMembershipSpecContextProviderRefKind = {}));
168187
+ /**
168188
+ * A resource to handle GitHub Organization Actions Secrets.
168189
+ *
168190
+ * @schema FirestartrGithubOrganizationSecretSection
168191
+ */
168192
+ class FirestartrGithubOrganizationSecretSection extends lib.ApiObject {
168193
+ /**
168194
+ * Renders a Kubernetes manifest for "FirestartrGithubOrganizationSecretSection".
168195
+ *
168196
+ * This can be used to inline resource manifests inside other objects (e.g. as templates).
168197
+ *
168198
+ * @param props initialization props
168199
+ */
168200
+ static manifest(props) {
168201
+ return {
168202
+ ...FirestartrGithubOrganizationSecretSection.GVK,
168203
+ ...toJson_FirestartrGithubOrganizationSecretSectionProps(props),
168204
+ };
168205
+ }
168206
+ /**
168207
+ * Defines a "FirestartrGithubOrganizationSecretSection" API object
168208
+ * @param scope the scope in which to define this object
168209
+ * @param id a scope-local name for the object
168210
+ * @param props initialization props
168211
+ */
168212
+ constructor(scope, id, props) {
168213
+ super(scope, id, {
168214
+ ...FirestartrGithubOrganizationSecretSection.GVK,
168215
+ ...props,
168216
+ });
168217
+ }
168218
+ /**
168219
+ * Renders the object to Kubernetes JSON.
168220
+ */
168221
+ toJson() {
168222
+ const resolved = super.toJson();
168223
+ return {
168224
+ ...FirestartrGithubOrganizationSecretSection.GVK,
168225
+ ...toJson_FirestartrGithubOrganizationSecretSectionProps(resolved),
168226
+ };
168227
+ }
168228
+ }
168229
+ /**
168230
+ * Returns the apiVersion and kind for "FirestartrGithubOrganizationSecretSection"
168231
+ */
168232
+ FirestartrGithubOrganizationSecretSection.GVK = {
168233
+ apiVersion: 'firestartr.dev/v1',
168234
+ kind: 'FirestartrGithubOrganizationSecretSection',
168235
+ };
168236
+
168237
+ /**
168238
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionProps' to JSON representation.
168239
+ */
168240
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
168241
+ function toJson_FirestartrGithubOrganizationSecretSectionProps(obj) {
168242
+ if (obj === undefined) {
168243
+ return undefined;
168244
+ }
168245
+ const result = {
168246
+ 'metadata': obj.metadata,
168247
+ 'spec': toJson_FirestartrGithubOrganizationSecretSectionSpec(obj.spec),
168248
+ };
168249
+ // filter undefined values
168250
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
168251
+ }
168252
+ /**
168253
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpec' to JSON representation.
168254
+ */
168255
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
168256
+ function toJson_FirestartrGithubOrganizationSecretSectionSpec(obj) {
168257
+ if (obj === undefined) {
168258
+ return undefined;
168259
+ }
168260
+ const result = {
168261
+ 'org': obj.org,
168262
+ 'secrets': toJson_FirestartrGithubOrganizationSecretSectionSpecSecrets(obj.secrets),
168263
+ 'context': toJson_FirestartrGithubOrganizationSecretSectionSpecContext(obj.context),
168264
+ 'firestartr': toJson_FirestartrGithubOrganizationSecretSectionSpecFirestartr(obj.firestartr),
168265
+ 'writeConnectionSecretToRef': toJson_FirestartrGithubOrganizationSecretSectionSpecWriteConnectionSecretToRef(obj.writeConnectionSecretToRef),
168266
+ };
168267
+ // filter undefined values
168268
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
168269
+ }
168270
+ /**
168271
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecSecrets' to JSON representation.
168272
+ */
168273
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
168274
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecSecrets(obj) {
168275
+ if (obj === undefined) {
168276
+ return undefined;
168277
+ }
168278
+ const result = {
168279
+ 'actions': obj.actions?.map(y => toJson_FirestartrGithubOrganizationSecretSectionSpecSecretsActions(y)),
168280
+ 'codespaces': obj.codespaces?.map(y => toJson_FirestartrGithubOrganizationSecretSectionSpecSecretsCodespaces(y)),
168281
+ 'dependabot': obj.dependabot?.map(y => toJson_FirestartrGithubOrganizationSecretSectionSpecSecretsDependabot(y)),
168282
+ };
168283
+ // filter undefined values
168284
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
168285
+ }
168286
+ /**
168287
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecContext' to JSON representation.
168288
+ */
168289
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
168290
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecContext(obj) {
168291
+ if (obj === undefined) {
168292
+ return undefined;
168293
+ }
168294
+ const result = {
168295
+ 'backend': toJson_FirestartrGithubOrganizationSecretSectionSpecContextBackend(obj.backend),
168296
+ 'provider': toJson_FirestartrGithubOrganizationSecretSectionSpecContextProvider(obj.provider),
168297
+ };
168298
+ // filter undefined values
168299
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
168300
+ }
168301
+ /**
168302
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecFirestartr' to JSON representation.
168303
+ */
168304
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
168305
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecFirestartr(obj) {
168306
+ if (obj === undefined) {
168307
+ return undefined;
168308
+ }
168309
+ const result = {
168310
+ 'tfStateKey': obj.tfStateKey,
168311
+ };
168312
+ // filter undefined values
168313
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
168314
+ }
168315
+ /**
168316
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecWriteConnectionSecretToRef' to JSON representation.
168317
+ */
168318
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
168319
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecWriteConnectionSecretToRef(obj) {
168320
+ if (obj === undefined) {
168321
+ return undefined;
168322
+ }
168323
+ const result = {
168324
+ 'name': obj.name,
168325
+ 'outputs': obj.outputs?.map(y => toJson_FirestartrGithubOrganizationSecretSectionSpecWriteConnectionSecretToRefOutputs(y)),
168326
+ };
168327
+ // filter undefined values
168328
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
168329
+ }
168330
+ /**
168331
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecSecretsActions' to JSON representation.
168332
+ */
168333
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
168334
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecSecretsActions(obj) {
168335
+ if (obj === undefined) {
168336
+ return undefined;
168337
+ }
168338
+ const result = {
168339
+ 'name': obj.name,
168340
+ 'ref': toJson_FirestartrGithubOrganizationSecretSectionSpecSecretsActionsRef(obj.ref),
168341
+ 'visibility': obj.visibility,
168342
+ 'selectedRepositories': obj.selectedRepositories?.map(y => y),
168343
+ };
168344
+ // filter undefined values
168345
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
168346
+ }
168347
+ /**
168348
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecSecretsCodespaces' to JSON representation.
168349
+ */
168350
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
168351
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecSecretsCodespaces(obj) {
168352
+ if (obj === undefined) {
168353
+ return undefined;
168354
+ }
168355
+ const result = {
168356
+ 'name': obj.name,
168357
+ 'ref': toJson_FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesRef(obj.ref),
168358
+ 'visibility': obj.visibility,
168359
+ 'selectedRepositories': obj.selectedRepositories?.map(y => y),
168360
+ };
168361
+ // filter undefined values
168362
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
168363
+ }
168364
+ /**
168365
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecSecretsDependabot' to JSON representation.
168366
+ */
168367
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
168368
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecSecretsDependabot(obj) {
168369
+ if (obj === undefined) {
168370
+ return undefined;
168371
+ }
168372
+ const result = {
168373
+ 'name': obj.name,
168374
+ 'ref': toJson_FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotRef(obj.ref),
168375
+ 'visibility': obj.visibility,
168376
+ 'selectedRepositories': obj.selectedRepositories?.map(y => y),
168377
+ };
168378
+ // filter undefined values
168379
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
168380
+ }
168381
+ /**
168382
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecContextBackend' to JSON representation.
168383
+ */
168384
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
168385
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecContextBackend(obj) {
168386
+ if (obj === undefined) {
168387
+ return undefined;
168388
+ }
168389
+ const result = {
168390
+ 'ref': toJson_FirestartrGithubOrganizationSecretSectionSpecContextBackendRef(obj.ref),
168391
+ };
168392
+ // filter undefined values
168393
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
168394
+ }
168395
+ /**
168396
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecContextProvider' to JSON representation.
168397
+ */
168398
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
168399
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecContextProvider(obj) {
168400
+ if (obj === undefined) {
168401
+ return undefined;
168402
+ }
168403
+ const result = {
168404
+ 'ref': toJson_FirestartrGithubOrganizationSecretSectionSpecContextProviderRef(obj.ref),
168405
+ };
168406
+ // filter undefined values
168407
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
168408
+ }
168409
+ /**
168410
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecWriteConnectionSecretToRefOutputs' to JSON representation.
168411
+ */
168412
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
168413
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecWriteConnectionSecretToRefOutputs(obj) {
168414
+ if (obj === undefined) {
168415
+ return undefined;
168416
+ }
168417
+ const result = {
168418
+ 'key': obj.key,
168419
+ };
168420
+ // filter undefined values
168421
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
168422
+ }
168423
+ /**
168424
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecSecretsActionsRef' to JSON representation.
168425
+ */
168426
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
168427
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecSecretsActionsRef(obj) {
168428
+ if (obj === undefined) {
168429
+ return undefined;
168430
+ }
168431
+ const result = {
168432
+ 'kind': obj.kind,
168433
+ 'name': obj.name,
168434
+ 'key': obj.key,
168435
+ };
168436
+ // filter undefined values
168437
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
168438
+ }
168439
+ /* eslint-enable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
168440
+ /**
168441
+ * Which repositories can access the secret.
168442
+ *
168443
+ * @schema FirestartrGithubOrganizationSecretSectionSpecSecretsActionsVisibility
168444
+ */
168445
+ var FirestartrGithubOrganizationSecretSectionSpecSecretsActionsVisibility;
168446
+ (function (FirestartrGithubOrganizationSecretSectionSpecSecretsActionsVisibility) {
168447
+ /** all */
168448
+ FirestartrGithubOrganizationSecretSectionSpecSecretsActionsVisibility["ALL"] = "all";
168449
+ /** selected */
168450
+ FirestartrGithubOrganizationSecretSectionSpecSecretsActionsVisibility["SELECTED"] = "selected";
168451
+ /** private */
168452
+ FirestartrGithubOrganizationSecretSectionSpecSecretsActionsVisibility["PRIVATE"] = "private";
168453
+ })(FirestartrGithubOrganizationSecretSectionSpecSecretsActionsVisibility || (FirestartrGithubOrganizationSecretSectionSpecSecretsActionsVisibility = {}));
168454
+ /**
168455
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesRef' to JSON representation.
168456
+ */
168457
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
168458
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesRef(obj) {
168459
+ if (obj === undefined) {
168460
+ return undefined;
168461
+ }
168462
+ const result = {
168463
+ 'kind': obj.kind,
168464
+ 'name': obj.name,
168465
+ 'key': obj.key,
168466
+ };
168467
+ // filter undefined values
168468
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
168469
+ }
168470
+ /* eslint-enable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
168471
+ /**
168472
+ * Which repositories can access the secret.
168473
+ *
168474
+ * @schema FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesVisibility
168475
+ */
168476
+ var FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesVisibility;
168477
+ (function (FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesVisibility) {
168478
+ /** all */
168479
+ FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesVisibility["ALL"] = "all";
168480
+ /** selected */
168481
+ FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesVisibility["SELECTED"] = "selected";
168482
+ /** private */
168483
+ FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesVisibility["PRIVATE"] = "private";
168484
+ })(FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesVisibility || (FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesVisibility = {}));
168485
+ /**
168486
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotRef' to JSON representation.
168487
+ */
168488
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
168489
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotRef(obj) {
168490
+ if (obj === undefined) {
168491
+ return undefined;
168492
+ }
168493
+ const result = {
168494
+ 'kind': obj.kind,
168495
+ 'name': obj.name,
168496
+ 'key': obj.key,
168497
+ };
168498
+ // filter undefined values
168499
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
168500
+ }
168501
+ /* eslint-enable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
168502
+ /**
168503
+ * Which repositories can access the secret.
168504
+ *
168505
+ * @schema FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotVisibility
168506
+ */
168507
+ var FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotVisibility;
168508
+ (function (FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotVisibility) {
168509
+ /** all */
168510
+ FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotVisibility["ALL"] = "all";
168511
+ /** selected */
168512
+ FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotVisibility["SELECTED"] = "selected";
168513
+ /** private */
168514
+ FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotVisibility["PRIVATE"] = "private";
168515
+ })(FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotVisibility || (FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotVisibility = {}));
168516
+ /**
168517
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecContextBackendRef' to JSON representation.
168518
+ */
168519
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
168520
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecContextBackendRef(obj) {
168521
+ if (obj === undefined) {
168522
+ return undefined;
168523
+ }
168524
+ const result = {
168525
+ 'kind': obj.kind,
168526
+ 'name': obj.name,
168527
+ };
168528
+ // filter undefined values
168529
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
168530
+ }
168531
+ /**
168532
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecContextProviderRef' to JSON representation.
168533
+ */
168534
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
168535
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecContextProviderRef(obj) {
168536
+ if (obj === undefined) {
168537
+ return undefined;
168538
+ }
168539
+ const result = {
168540
+ 'kind': obj.kind,
168541
+ 'name': obj.name,
168542
+ };
168543
+ // filter undefined values
168544
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
168545
+ }
168546
+ /* eslint-enable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
168547
+ /**
168548
+ * The type of Kubernetes resource to reference.
168549
+ *
168550
+ * @schema FirestartrGithubOrganizationSecretSectionSpecSecretsActionsRefKind
168551
+ */
168552
+ var FirestartrGithubOrganizationSecretSectionSpecSecretsActionsRefKind;
168553
+ (function (FirestartrGithubOrganizationSecretSectionSpecSecretsActionsRefKind) {
168554
+ /** Secret */
168555
+ FirestartrGithubOrganizationSecretSectionSpecSecretsActionsRefKind["SECRET"] = "Secret";
168556
+ })(FirestartrGithubOrganizationSecretSectionSpecSecretsActionsRefKind || (FirestartrGithubOrganizationSecretSectionSpecSecretsActionsRefKind = {}));
168557
+ /**
168558
+ * The type of Kubernetes resource to reference.
168559
+ *
168560
+ * @schema FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesRefKind
168561
+ */
168562
+ var FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesRefKind;
168563
+ (function (FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesRefKind) {
168564
+ /** Secret */
168565
+ FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesRefKind["SECRET"] = "Secret";
168566
+ })(FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesRefKind || (FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesRefKind = {}));
168567
+ /**
168568
+ * The type of Kubernetes resource to reference.
168569
+ *
168570
+ * @schema FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotRefKind
168571
+ */
168572
+ var FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotRefKind;
168573
+ (function (FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotRefKind) {
168574
+ /** Secret */
168575
+ FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotRefKind["SECRET"] = "Secret";
168576
+ })(FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotRefKind || (FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotRefKind = {}));
168577
+ /**
168578
+ * @schema FirestartrGithubOrganizationSecretSectionSpecContextBackendRefKind
168579
+ */
168580
+ var FirestartrGithubOrganizationSecretSectionSpecContextBackendRefKind;
168581
+ (function (FirestartrGithubOrganizationSecretSectionSpecContextBackendRefKind) {
168582
+ /** FirestartrProviderConfig */
168583
+ FirestartrGithubOrganizationSecretSectionSpecContextBackendRefKind["FIRESTARTR_PROVIDER_CONFIG"] = "FirestartrProviderConfig";
168584
+ })(FirestartrGithubOrganizationSecretSectionSpecContextBackendRefKind || (FirestartrGithubOrganizationSecretSectionSpecContextBackendRefKind = {}));
168585
+ /**
168586
+ * @schema FirestartrGithubOrganizationSecretSectionSpecContextProviderRefKind
168587
+ */
168588
+ var FirestartrGithubOrganizationSecretSectionSpecContextProviderRefKind;
168589
+ (function (FirestartrGithubOrganizationSecretSectionSpecContextProviderRefKind) {
168590
+ /** FirestartrProviderConfig */
168591
+ FirestartrGithubOrganizationSecretSectionSpecContextProviderRefKind["FIRESTARTR_PROVIDER_CONFIG"] = "FirestartrProviderConfig";
168592
+ })(FirestartrGithubOrganizationSecretSectionSpecContextProviderRefKind || (FirestartrGithubOrganizationSecretSectionSpecContextProviderRefKind = {}));
168003
168593
  /**
168004
168594
  * A resource to handle GitHub Organization Settings.
168005
168595
  *
@@ -171455,6 +172045,78 @@ class GithubOrgVariableSectionChart extends BaseGithubChart {
171455
172045
  }
171456
172046
  }
171457
172047
 
172048
+ ;// CONCATENATED MODULE: ../cdk8s_renderer/src/charts/github/orgSecretSectionChart.ts
172049
+
172050
+
172051
+
172052
+ class GithubOrgSecretSectionChart extends BaseGithubChart {
172053
+ template() {
172054
+ const claim = this.get('claim');
172055
+ const firestartrId = this.get('firestartrId');
172056
+ const githubProvider = claim.providers.github;
172057
+ const orgSecrets = githubProvider.org_secrets || {};
172058
+ const renderSecrets = (section) => {
172059
+ const secrets = orgSecrets[section];
172060
+ if (!Array.isArray(secrets))
172061
+ return [];
172062
+ return secrets.map((secret) => {
172063
+ const parts = secret.value.split(':');
172064
+ const selectedRepositories = (secret.selected_repositories || []).map((ref) => {
172065
+ const match = ref.match(/^component:(.+)$/);
172066
+ if (!match) {
172067
+ throw new ChartRenderError('OrgSettingsClaim', claim.name, `Invalid component ref "${ref}" in selected_repositories. Expected format: component:<name>`);
172068
+ }
172069
+ const componentName = match[1];
172070
+ const resolvedCr = this.refResolver('ComponentClaim', componentName);
172071
+ const org = resolvedCr?.spec?.org;
172072
+ const repoName = resolvedCr?.metadata?.annotations?.['firestartr.dev/external-name'] || resolvedCr?.metadata?.name?.replace(/-[0-9a-f-]{36}$/, '');
172073
+ if (!org || !repoName) {
172074
+ throw new ChartRenderError('OrgSettingsClaim', claim.name, `Referenced component "${componentName}" has no GitHub provider configured`);
172075
+ }
172076
+ return `${org}/${repoName}`;
172077
+ });
172078
+ return {
172079
+ name: secret.name,
172080
+ ref: {
172081
+ kind: 'Secret',
172082
+ name: parts[2],
172083
+ key: parts[3],
172084
+ },
172085
+ visibility: secret.visibility || 'all',
172086
+ selectedRepositories,
172087
+ };
172088
+ });
172089
+ };
172090
+ const template = {
172091
+ metadata: {
172092
+ name: githubProvider.name,
172093
+ },
172094
+ spec: {
172095
+ org: githubProvider.org,
172096
+ secrets: {
172097
+ actions: renderSecrets('actions'),
172098
+ codespaces: renderSecrets('codespaces'),
172099
+ dependabot: renderSecrets('dependabot'),
172100
+ },
172101
+ firestartr: {
172102
+ tfStateKey: firestartrId,
172103
+ },
172104
+ writeConnectionSecretToRef: {
172105
+ name: `firestartrgithuborganizationsecretsection-${githubProvider.name}-secrets-outputs`.toLowerCase(),
172106
+ outputs: [{ key: 'managed_secrets' }, { key: 'secret_ids' }],
172107
+ },
172108
+ },
172109
+ };
172110
+ return JSON.parse(JSON.stringify(template));
172111
+ }
172112
+ gvk() {
172113
+ return FirestartrGithubOrganizationSecretSection.GVK;
172114
+ }
172115
+ instanceApiObject(template) {
172116
+ return new FirestartrGithubOrganizationSecretSection(this, template.metadata.name, template);
172117
+ }
172118
+ }
172119
+
171458
172120
  ;// CONCATENATED MODULE: ../cdk8s_renderer/src/charts/github/index.ts
171459
172121
 
171460
172122
 
@@ -171463,6 +172125,7 @@ class GithubOrgVariableSectionChart extends BaseGithubChart {
171463
172125
 
171464
172126
 
171465
172127
 
172128
+
171466
172129
  ;// CONCATENATED MODULE: ../cdk8s_renderer/src/charts/catalog/base.ts
171467
172130
 
171468
172131
  class BaseCatalogChart extends BaseChart {
@@ -172225,6 +172888,7 @@ class SecretsChart extends BaseSecretsChart {
172225
172888
  GithubOrgWebhookChart: GithubOrgWebhookChart,
172226
172889
  GithubOrgSettingsChart: GithubOrgSettingsChart,
172227
172890
  GithubOrgVariableSectionChart: GithubOrgVariableSectionChart,
172891
+ GithubOrgSecretSectionChart: GithubOrgSecretSectionChart,
172228
172892
  });
172229
172893
 
172230
172894
  ;// CONCATENATED MODULE: ../cdk8s_renderer/src/renderer/claims-render.ts
@@ -172276,16 +172940,21 @@ async function renderClaims(catalogScope, firestartrScope, data) {
172276
172940
  const variableSectionPreviousCR = claim.kind === 'OrgSettingsClaim'
172277
172941
  ? getPreviousCRfromClaim(claim, crs, 'FirestartrGithubOrganizationVariableSection')
172278
172942
  : false;
172943
+ const secretSectionPreviousCR = claim.kind === 'OrgSettingsClaim'
172944
+ ? getPreviousCRfromClaim({ kind: claim.kind, name: `${claim.name}-secret-section` }, crs, 'FirestartrGithubOrganizationSecretSection')
172945
+ : false;
172279
172946
  const patches = await extractPatches(renderClaims[claimKey], previousCR, crs);
172280
172947
  let variableSectionPatches = undefined;
172948
+ let secretSectionPatches = undefined;
172281
172949
  if (claim.kind === 'OrgSettingsClaim') {
172282
172950
  variableSectionPatches = await extractPatches(renderClaims[claimKey], variableSectionPreviousCR, crs);
172951
+ secretSectionPatches = await extractPatches(renderClaims[claimKey], secretSectionPreviousCR);
172283
172952
  }
172284
172953
  if (!previousCR) {
172285
172954
  logger.debug(`No CR found for claim ${claimKey}, it will be rendered from scratch`);
172286
172955
  }
172287
172956
  const claimPath = renderClaims[claimKey].claimPath;
172288
- const { firestartrEntity, extraCharts, catalogEntity } = await renderClaim(catalogScope, firestartrScope, claim, patches, previousCR, claimPath, variableSectionPreviousCR, variableSectionPatches, crs);
172957
+ const { firestartrEntity, extraCharts, catalogEntity } = await renderClaim(catalogScope, firestartrScope, claim, patches, previousCR, claimPath, variableSectionPreviousCR, variableSectionPatches, crs, secretSectionPreviousCR, secretSectionPatches);
172289
172958
  if (catalogEntity) {
172290
172959
  result[`${catalogEntity.kind}-${catalogEntity.metadata.name}`] =
172291
172960
  catalogEntity.toJson();
@@ -172314,7 +172983,7 @@ async function renderClaims(catalogScope, firestartrScope, data) {
172314
172983
  }
172315
172984
  return result;
172316
172985
  }
172317
- async function renderClaim(catalogScope, firestartrScope, claim, patches, previousCR = null, claimPath, variableSectionPreviousCR = false, variableSectionPatches, crs) {
172986
+ async function renderClaim(catalogScope, firestartrScope, claim, patches, previousCR = null, claimPath, variableSectionPreviousCR = false, variableSectionPatches, crs, secretSectionPreviousCR = false, secretSectionPatches) {
172318
172987
  let catalogEntity = undefined;
172319
172988
  let firestartrEntity = undefined;
172320
172989
  const extraCharts = [];
@@ -172484,6 +173153,27 @@ async function renderClaim(catalogScope, firestartrScope, claim, patches, previo
172484
173153
  },
172485
173154
  chart: variableSectionObject,
172486
173155
  });
173156
+ const secretSectionFirestartrId = secretSectionPreviousCR
173157
+ ? secretSectionPreviousCR.spec?.firestartr?.tfStateKey
173158
+ : firestartrId
173159
+ ? `${firestartrId}-secrets`
173160
+ : null;
173161
+ const ssRenderPatches = secretSectionPatches
173162
+ ? secretSectionPatches.filter((patch) => !patch.isPostPatch)
173163
+ : renderPatches;
173164
+ const ssPostPatches = secretSectionPatches
173165
+ ? secretSectionPatches.filter((patch) => patch.isPostPatch)
173166
+ : postPatches;
173167
+ const secretSectionChart = new charts.GithubOrgSecretSectionChart(firestartrScope, `github-secrets-${chartId}`, secretSectionFirestartrId, claim, ssRenderPatches);
173168
+ await secretSectionChart.render();
173169
+ const secretSectionObject = await secretSectionChart.postRenderer(ssPostPatches);
173170
+ extraCharts.push({
173171
+ claim: {
173172
+ kind: claim.kind,
173173
+ name: `${claim.name}-secret-section`,
173174
+ },
173175
+ chart: secretSectionObject,
173176
+ });
172487
173177
  }
172488
173178
  break;
172489
173179
  default:
@@ -172606,8 +173296,33 @@ function searchSecretKey(secretClaim, key) {
172606
173296
  }
172607
173297
  function validateOrgSettingsComponentRefs(ref, renderClaims) {
172608
173298
  const claim = renderClaims[ref].claim;
173299
+ validateOrgSecretsSelectedRepositories(claim, renderClaims);
172609
173300
  validateActionsVariablesSelectedRepositories(claim, renderClaims);
172610
173301
  }
173302
+ function validateOrgSecretsSelectedRepositories(claim, renderClaims) {
173303
+ const orgSecrets = claim?.providers?.github?.org_secrets;
173304
+ if (!orgSecrets || typeof orgSecrets !== 'object')
173305
+ return;
173306
+ for (const section of ['actions', 'codespaces', 'dependabot']) {
173307
+ const secrets = orgSecrets[section];
173308
+ if (!Array.isArray(secrets))
173309
+ continue;
173310
+ for (const secret of secrets) {
173311
+ if (!secret.selected_repositories)
173312
+ continue;
173313
+ for (const repoRef of secret.selected_repositories) {
173314
+ const match = repoRef.match(COMPONENT_REF_PATTERN);
173315
+ if (!match)
173316
+ continue;
173317
+ const [, componentName] = match;
173318
+ const expectedKey = `ComponentClaim-${componentName}`;
173319
+ if (!renderClaims[expectedKey]) {
173320
+ throw new Error(`CrossReference error: OrgSettingsClaim/${claim.name} references a non-existent component "${componentName}" in org_secrets.${section}.${secret.name}.selected_repositories`);
173321
+ }
173322
+ }
173323
+ }
173324
+ }
173325
+ }
172611
173326
  function validateActionsVariablesSelectedRepositories(claim, renderClaims) {
172612
173327
  const actionsVariables = claim?.providers?.github?.actions_variables;
172613
173328
  if (!Array.isArray(actionsVariables))
@@ -172738,6 +173453,116 @@ function validateActionsVariablesUniqueness(crs) {
172738
173453
  }
172739
173454
  }
172740
173455
 
173456
+ ;// CONCATENATED MODULE: ../cdk8s_renderer/src/validations/githubOrgSecretSection.ts
173457
+ const GITHUB_ORG_SECRET_SECTION_KIND = 'FirestartrGithubOrganizationSecretSection';
173458
+ const githubOrgSecretSection_FIRESTARTR_CLAIM_REF_ANNOTATION = 'firestartr.dev/claim-ref';
173459
+ const githubOrgSecretSection_CLAIM_REF_LABEL = 'claim-ref';
173460
+ const SECRETS_CLAIM_REF_PATTERN = /^ref:secretsclaim:([a-zA-Z0-9_-]+):([a-zA-Z0-9_-]+)$/;
173461
+ function githubOrgSecretSection_formatResourceRef(name, claimRef) {
173462
+ return claimRef ? `${name} (claim: ${claimRef})` : name;
173463
+ }
173464
+ function validateGithubOrgSecretSectionSingleton(crs) {
173465
+ const refsByOrg = new Map();
173466
+ const seenClaimRefs = new Map();
173467
+ for (const crKey of Object.keys(crs)) {
173468
+ const cr = crs[crKey];
173469
+ if (cr.kind !== GITHUB_ORG_SECRET_SECTION_KIND)
173470
+ continue;
173471
+ const org = cr.spec?.org;
173472
+ if (typeof org !== 'string' || !org)
173473
+ continue;
173474
+ const name = cr.metadata?.name || crKey;
173475
+ const claimRef = cr.metadata?.annotations?.[githubOrgSecretSection_FIRESTARTR_CLAIM_REF_ANNOTATION] ||
173476
+ cr.metadata?.labels?.[githubOrgSecretSection_CLAIM_REF_LABEL];
173477
+ const normalizedOrg = org.toLowerCase();
173478
+ if (claimRef) {
173479
+ const seen = seenClaimRefs.get(normalizedOrg) || new Set();
173480
+ if (seen.has(claimRef))
173481
+ continue;
173482
+ seen.add(claimRef);
173483
+ seenClaimRefs.set(normalizedOrg, seen);
173484
+ }
173485
+ const refs = refsByOrg.get(normalizedOrg) || [];
173486
+ refs.push(githubOrgSecretSection_formatResourceRef(name, claimRef));
173487
+ refsByOrg.set(normalizedOrg, refs);
173488
+ }
173489
+ for (const [org, refs] of refsByOrg.entries()) {
173490
+ if (refs.length < 2)
173491
+ continue;
173492
+ throw new Error(`Duplicate ${GITHUB_ORG_SECRET_SECTION_KIND} resources found for GitHub organization "${org}": ${refs.join(', ')}`);
173493
+ }
173494
+ }
173495
+ function validateSecretNamesUniqueness(crs) {
173496
+ for (const crKey of Object.keys(crs)) {
173497
+ const cr = crs[crKey];
173498
+ if (cr.kind !== GITHUB_ORG_SECRET_SECTION_KIND)
173499
+ continue;
173500
+ const secrets = cr.spec?.secrets;
173501
+ if (!secrets || typeof secrets !== 'object')
173502
+ continue;
173503
+ for (const section of ['actions', 'codespaces', 'dependabot']) {
173504
+ const sectionSecrets = secrets[section];
173505
+ if (!Array.isArray(sectionSecrets))
173506
+ continue;
173507
+ const names = new Set();
173508
+ for (const secret of sectionSecrets) {
173509
+ const secretName = secret?.name;
173510
+ if (!secretName)
173511
+ continue;
173512
+ if (names.has(secretName)) {
173513
+ const org = cr.spec?.org || 'unknown';
173514
+ throw new Error(`Duplicate secret name "${secretName}" found in ${section} section of ${GITHUB_ORG_SECRET_SECTION_KIND} for organization "${org}"`);
173515
+ }
173516
+ names.add(secretName);
173517
+ }
173518
+ }
173519
+ }
173520
+ }
173521
+ function validateOrgSecretsCrossReferences(renderClaims) {
173522
+ for (const claimKey of Object.keys(renderClaims)) {
173523
+ if (!claimKey.startsWith('OrgSettingsClaim-'))
173524
+ continue;
173525
+ const claimData = renderClaims[claimKey];
173526
+ const claim = claimData?.claim;
173527
+ const orgSecrets = claim?.providers?.github?.org_secrets;
173528
+ if (!orgSecrets || typeof orgSecrets !== 'object')
173529
+ continue;
173530
+ for (const section of ['actions', 'codespaces', 'dependabot']) {
173531
+ const secrets = orgSecrets[section];
173532
+ if (!Array.isArray(secrets))
173533
+ continue;
173534
+ for (const secret of secrets) {
173535
+ if (!secret.value)
173536
+ continue;
173537
+ const match = secret.value.match(SECRETS_CLAIM_REF_PATTERN);
173538
+ if (!match)
173539
+ continue;
173540
+ const [, secretClaimName, secretKey] = match;
173541
+ const expectedKey = `SecretsClaim-${secretClaimName}`;
173542
+ if (!renderClaims[expectedKey])
173543
+ continue;
173544
+ const secretClaim = renderClaims[expectedKey]?.claim;
173545
+ const externalSecrets = secretClaim?.providers?.external_secrets?.externalSecrets?.secrets;
173546
+ const pushSecrets = secretClaim?.providers?.external_secrets?.pushSecrets;
173547
+ let keyFound = false;
173548
+ if (Array.isArray(pushSecrets)) {
173549
+ keyFound =
173550
+ pushSecrets.find((s) => s.secretName === secretKey) !==
173551
+ undefined;
173552
+ }
173553
+ if (!keyFound && Array.isArray(externalSecrets)) {
173554
+ keyFound =
173555
+ externalSecrets.find((s) => s.secretName === secretKey) !==
173556
+ undefined;
173557
+ }
173558
+ if (!keyFound) {
173559
+ throw new Error(`CrossReference error: OrgSettingsClaim/${claim.name} references a non-existent secret key "${secretKey}" in SecretsClaim/${secretClaimName} via org_secrets.${section}.${secret.name}`);
173560
+ }
173561
+ }
173562
+ }
173563
+ }
173564
+ }
173565
+
172741
173566
  ;// CONCATENATED MODULE: ../cdk8s_renderer/src/renderer/renderer.ts
172742
173567
 
172743
173568
 
@@ -172750,6 +173575,7 @@ function validateActionsVariablesUniqueness(crs) {
172750
173575
 
172751
173576
 
172752
173577
 
173578
+
172753
173579
  /*
172754
173580
  * Function called when rendering but not importing
172755
173581
  *
@@ -172771,10 +173597,13 @@ async function renderer_render(catalogScope, firestartrScope, claimList) {
172771
173597
  try {
172772
173598
  validateSubReferences(data.renderClaims);
172773
173599
  validateComponentPagesPath(data.renderClaims);
173600
+ validateOrgSecretsCrossReferences(data.renderClaims);
172774
173601
  validateTfStateKeyUniqueness(result);
172775
173602
  validateGithubOrgSettingsSingleton(fullCrSet);
172776
173603
  validateGithubOrgVariableSectionSingleton(fullCrSet);
172777
173604
  validateActionsVariablesUniqueness(result);
173605
+ validateGithubOrgSecretSectionSingleton(fullCrSet);
173606
+ validateSecretNamesUniqueness(result);
172778
173607
  validateCrSizes(result);
172779
173608
  validatePermissionsUniqueness(result);
172780
173609
  validateNoBackstageAnnotationsInK8sCrs(result);
@@ -357054,6 +357883,7 @@ const kindPluralMap = {
357054
357883
  githuborgwebhooks: 'FirestartrGithubOrgWebhook',
357055
357884
  githuborganizationsettings: 'FirestartrGithubOrganizationSettings',
357056
357885
  githuborganizationvariablesections: 'FirestartrGithubOrganizationVariableSection',
357886
+ githuborganizationsecretsections: 'FirestartrGithubOrganizationSecretSection',
357057
357887
  terraformworkspaces: 'FirestartrTerraformWorkspace',
357058
357888
  terraformworkspaceplans: 'FirestartrTerraformWorkspacePlan',
357059
357889
  providerconfigs: 'FirestartrProviderConfig',
@@ -359454,6 +360284,7 @@ const kindsWithFinalizer = [
359454
360284
  'FirestartrGithubOrgWebhook',
359455
360285
  'FirestartrGithubOrganizationSettings',
359456
360286
  'FirestartrGithubOrganizationVariableSection',
360287
+ 'FirestartrGithubOrganizationSecretSection',
359457
360288
  'FirestartrGithubRepositorySecretsSection',
359458
360289
  ];
359459
360290
  const kindsWithDependants = [
@@ -362492,7 +363323,7 @@ async function configGit() {
362492
363323
  }
362493
363324
  // Import github dynamically to avoid Jest ESM issues when not specifically running this function
362494
363325
  // (see CONSTITUTION and RULES: must not change test machinery)
362495
- const githubModule = await Promise.resolve(/* import() */).then(__nccwpck_require__.bind(__nccwpck_require__, 99029));
363326
+ const githubModule = await Promise.resolve(/* import() */).then(__nccwpck_require__.bind(__nccwpck_require__, 3342));
362496
363327
  const github = githubModule.default || githubModule;
362497
363328
  if (external_fs_.existsSync(gitconfigPath)) {
362498
363329
  external_fs_.rmSync(gitconfigPath);
@@ -366338,6 +367169,11 @@ const MODULES = {
366338
367169
  // github-org-variables-section-v0.1.0
366339
367170
  ref: 'fb9c01d0a1e03e5134479da13d0faf55891dfedf',
366340
367171
  },
367172
+ FirestartrGithubOrganizationSecretSection: {
367173
+ module: 'git::https://github.com/prefapp/tfm.git//modules/github-org-secrets-section',
367174
+ // feat/1364-feat-add-github-org-secrets-section-module
367175
+ ref: '170e6cf',
367176
+ },
366341
367177
  };
366342
367178
  function getFirestartrDefaultTFM(kind) {
366343
367179
  if (kind in MODULES) {
@@ -368250,6 +369086,215 @@ class EntityGHOrgVarsSection extends base_Entity {
368250
369086
  async loadAddressesToImport() { }
368251
369087
  }
368252
369088
 
369089
+ ;// CONCATENATED MODULE: ../gh_provisioner/src/entities/ghorgsecretsection/secrets.ts
369090
+
369091
+
369092
+
369093
+
369094
+ const secrets_SECTIONS = ['actions', 'codespaces', 'dependabot'];
369095
+
369096
+ async function provisionOrgSecrets(entity, secrets) {
369097
+ gh_provisioner_src_logger.info(`[gh-provisioner] ${entity.k8sId} provisioning org secrets`);
369098
+ for (const section of secrets_SECTIONS) {
369099
+ const sectionSecrets = secrets[section] || [];
369100
+ if (sectionSecrets.length === 0)
369101
+ continue;
369102
+ let preFetchedKey;
369103
+ try {
369104
+ preFetchedKey = await fetchOrgPublicKey(entity, section);
369105
+ }
369106
+ catch (err) {
369107
+ const message = err instanceof Error ? err.message : String(err);
369108
+ throw new Error(`[gh-provisioner] ${entity.k8sId} failed to fetch ${section} org public key: ${message}`);
369109
+ }
369110
+ for (const secret of sectionSecrets) {
369111
+ await provisionOrgSecret(entity, section, secret, preFetchedKey);
369112
+ }
369113
+ }
369114
+ }
369115
+ async function fetchOrgPublicKey(entity, section) {
369116
+ return (await entity.runWithGithubProvider(async () => {
369117
+ return await github["default"].encryption.getOrgPublicKey(entity.cr.spec.org, section);
369118
+ }));
369119
+ }
369120
+ async function provisionOrgSecret(entity, section, secret, preFetchedKey) {
369121
+ gh_provisioner_src_logger.info(`[gh-provisioner] provisioning org secret ${entity.k8sId}/${section}/${secret.name}`);
369122
+ if (process.env['AVOID_PROVIDER_SECRET_ENCRYPTION']) {
369123
+ await secrets_createUnencryptedSecret(entity, section, secret);
369124
+ }
369125
+ else {
369126
+ await secrets_createEncryptedSecret(entity, section, secret, preFetchedKey);
369127
+ }
369128
+ gh_provisioner_src_logger.info(`[gh-provisioner] org secret provisioned ${section}/${secret.name}`);
369129
+ }
369130
+ async function secrets_createEncryptedSecret(entity, section, secret, preFetchedKey) {
369131
+ const plainSecret = base_Entity.refResolver(secret.ref);
369132
+ if (!plainSecret) {
369133
+ 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`);
369134
+ }
369135
+ const plainTextSecret = plainSecret.getOutput(secret.ref.key);
369136
+ const plaintextSha256 = external_crypto_default().createHash('sha256')
369137
+ .update(plainTextSecret)
369138
+ .digest('hex');
369139
+ const { encrypted_value } = (await entity.runWithGithubProvider(async () => {
369140
+ return await github["default"].encryption.encryptOrgSecret(entity.cr.spec.org, section, plainTextSecret, preFetchedKey);
369141
+ }));
369142
+ entity.patchData({
369143
+ op: PatchOperations.add,
369144
+ path: `/config/${section}/${secret.name}`,
369145
+ value: {
369146
+ value: encrypted_value,
369147
+ visibility: secret.visibility || 'all',
369148
+ ...(secret.selectedRepositories && secret.selectedRepositories.length > 0
369149
+ ? { selected_repositories: secret.selectedRepositories }
369150
+ : {}),
369151
+ },
369152
+ });
369153
+ entity.patchData({
369154
+ op: PatchOperations.add,
369155
+ path: `/config/${section}_sha256/${secret.name}`,
369156
+ value: plaintextSha256,
369157
+ });
369158
+ }
369159
+ async function secrets_createUnencryptedSecret(entity, section, secret) {
369160
+ const plainSecret = base_Entity.refResolver(secret.ref);
369161
+ const plainTextSecret = plainSecret.getOutput(secret.ref.key);
369162
+ const plaintextSha256 = external_crypto_default().createHash('sha256')
369163
+ .update(plainTextSecret)
369164
+ .digest('hex');
369165
+ entity.patchData({
369166
+ op: PatchOperations.add,
369167
+ path: `/config/${section}/${secret.name}`,
369168
+ value: {
369169
+ value: plainTextSecret,
369170
+ visibility: secret.visibility || 'all',
369171
+ ...(secret.selectedRepositories && secret.selectedRepositories.length > 0
369172
+ ? { selected_repositories: secret.selectedRepositories }
369173
+ : {}),
369174
+ },
369175
+ });
369176
+ entity.patchData({
369177
+ op: PatchOperations.add,
369178
+ path: `/config/${section}_sha256/${secret.name}`,
369179
+ value: plaintextSha256,
369180
+ });
369181
+ }
369182
+ async function adoptSecretsIfNeeded(entity, secrets) {
369183
+ const managedSecrets = entity.cr.fResolveSelfOutputs('managed_secrets') || [];
369184
+ for (const section of secrets_SECTIONS) {
369185
+ const sectionSecrets = secrets[section] || [];
369186
+ if (sectionSecrets.length === 0)
369187
+ continue;
369188
+ const declaredNames = sectionSecrets.map((s) => s.name);
369189
+ const newToModule = declaredNames.filter((name) => !managedSecrets.includes(name));
369190
+ if (newToModule.length === 0) {
369191
+ gh_provisioner_src_logger.debug(`[gh-provisioner] ${entity.k8sId} all declared ${section} secrets are already managed`);
369192
+ continue;
369193
+ }
369194
+ if (managedSecrets.length === 0) {
369195
+ gh_provisioner_src_logger.info(`[gh-provisioner] ${entity.k8sId} no managed_secrets output — first reconciliation, treating all ${newToModule.length} ${section} secret(s) as new to module`);
369196
+ }
369197
+ for (const secretName of newToModule) {
369198
+ try {
369199
+ const existing = (await entity.runWithGithubProvider(async () => {
369200
+ return await github["default"].encryption.getOrgSecret(entity.cr.spec.org, section, secretName);
369201
+ }));
369202
+ if (existing) {
369203
+ gh_provisioner_src_logger.info(`[gh-provisioner] ${entity.k8sId} adopting pre-existing ${section} secret '${secretName}' on GitHub org '${entity.cr.spec.org}'`);
369204
+ const resourceType = `github_${section}_organization_secret`;
369205
+ entity.patchImportData({
369206
+ op: PatchOperations.add,
369207
+ path: '/imports/-',
369208
+ value: {
369209
+ to: `${resourceType}.this["${secretName}"]`,
369210
+ id: secretName,
369211
+ },
369212
+ });
369213
+ const secretEntry = sectionSecrets.find((s) => s.name === secretName);
369214
+ if (secretEntry &&
369215
+ secretEntry.visibility === 'selected' &&
369216
+ (section === 'actions' || section === 'dependabot')) {
369217
+ const bindingType = `github_${section}_organization_secret_repositories`;
369218
+ entity.patchImportData({
369219
+ op: PatchOperations.add,
369220
+ path: '/imports/-',
369221
+ value: {
369222
+ to: `${bindingType}.this["${secretName}"]`,
369223
+ id: secretName,
369224
+ },
369225
+ });
369226
+ }
369227
+ }
369228
+ }
369229
+ catch (err) {
369230
+ if (err && err.status === 404) {
369231
+ 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`);
369232
+ }
369233
+ else if (err && (err.status === 401 || err.status === 403)) {
369234
+ 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`);
369235
+ }
369236
+ else {
369237
+ 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)}`);
369238
+ }
369239
+ }
369240
+ }
369241
+ }
369242
+ }
369243
+
369244
+ ;// CONCATENATED MODULE: ../gh_provisioner/src/entities/ghorgsecretsection/index.ts
369245
+
369246
+
369247
+
369248
+ class EntityGHOrgSecretSection extends base_Entity {
369249
+ constructor(artifact) {
369250
+ super(artifact, {
369251
+ config: {
369252
+ org: '',
369253
+ actions: {},
369254
+ codespaces: {},
369255
+ dependabot: {},
369256
+ actions_sha256: {},
369257
+ codespaces_sha256: {},
369258
+ dependabot_sha256: {},
369259
+ },
369260
+ });
369261
+ }
369262
+ async loadResources(tfOp) {
369263
+ gh_provisioner_src_logger.info(`[gh-provisioner] running ${tfOp} on ${this.k8sId}`);
369264
+ try {
369265
+ const cr = this.cr;
369266
+ const org = cr.spec.org;
369267
+ const secrets = cr.spec.secrets || {};
369268
+ this.patchData({
369269
+ op: PatchOperations.replace,
369270
+ path: '/config/org',
369271
+ value: org,
369272
+ });
369273
+ await provisionOrgSecrets(this, secrets);
369274
+ const redactedDoc = JSON.parse(JSON.stringify(this._document, (key, value) => {
369275
+ if (key === 'value' && typeof value === 'string')
369276
+ return '[REDACTED]';
369277
+ return typeof value === 'string' && value.length > 50
369278
+ ? '[REDACTED]'
369279
+ : value;
369280
+ }));
369281
+ this.synthMessage(`[gh-provisioner] ${this.k8sId} config:\n${JSON.stringify(redactedDoc, null, 2)}`);
369282
+ this.synthEnd(`[gh-provisioner] ${this.k8sId} loaded its data`);
369283
+ if (tfOp === 'apply') {
369284
+ await adoptSecretsIfNeeded(this, secrets);
369285
+ }
369286
+ gh_provisioner_src_logger.debug(`[gh-provisioner] ${this.k8sId} loaded its data`);
369287
+ }
369288
+ catch (err) {
369289
+ const message = err instanceof Error ? err.message : String(err);
369290
+ gh_provisioner_src_logger.error(`[gh-provisioner] ${this.k8sId} error loading resources: ${message}`);
369291
+ throw new Error(`[gh-provisioner] ${this.k8sId} error loading resources: ${message}`);
369292
+ }
369293
+ }
369294
+ async postProvision(_tfOp) { }
369295
+ async loadAddressesToImport() { }
369296
+ }
369297
+
368253
369298
  ;// CONCATENATED MODULE: ../gh_provisioner/src/entities/ghorgwebhook/index.ts
368254
369299
 
368255
369300
 
@@ -368327,6 +369372,7 @@ class EntityGHOrgWebHook extends base_Entity {
368327
369372
 
368328
369373
 
368329
369374
 
369375
+
368330
369376
  function entities_getEntity(cr) {
368331
369377
  const entityClass = getEntityClass(cr.kind);
368332
369378
  return new entityClass(cr);
@@ -368349,6 +369395,8 @@ function getEntityClass(kind) {
368349
369395
  return EntityGHOrgSettings;
368350
369396
  case 'FirestartrGithubOrganizationVariableSection':
368351
369397
  return EntityGHOrgVarsSection;
369398
+ case 'FirestartrGithubOrganizationSecretSection':
369399
+ return EntityGHOrgSecretSection;
368352
369400
  default:
368353
369401
  throw new Error(`kind ${kind} has no entity associated`);
368354
369402
  }
@@ -370176,6 +371224,7 @@ const provisionImplementations = {
370176
371224
  githuborgwebhooks: process_operation_processOperation,
370177
371225
  githuborganizationsettings: process_operation_processOperation,
370178
371226
  githuborganizationvariablesections: process_operation_processOperation,
371227
+ githuborganizationsecretsections: process_operation_processOperation,
370179
371228
  fsdummiesa: processFirestartrDummies,
370180
371229
  fsdummiesb: processFirestartrDummies,
370181
371230
  fsdummiesc: processFirestartrDummies,
@@ -714628,7 +715677,7 @@ const crsStatusSubcommand = {
714628
715677
  };
714629
715678
 
714630
715679
  ;// CONCATENATED MODULE: ./package.json
714631
- const package_namespaceObject = JSON.parse('{"i8":"2.11.0-snapshot-mco-3"}');
715680
+ const package_namespaceObject = JSON.parse('{"i8":"2.11.0-snapshot-org-secrets-00"}');
714632
715681
  ;// CONCATENATED MODULE: ../../package.json
714633
715682
  const package_namespaceObject_1 = {"i8":"2.10.0"};
714634
715683
  // EXTERNAL MODULE: ../../node_modules/semver/index.js