@firestartr/cli 2.11.0-snapshot-objects-in-patches → 2.11.0-snapshot-orgsettings-nullguard-1

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
@@ -280314,7 +280314,7 @@ function getCronNextInterval(cronLine, tz) {
280314
280314
 
280315
280315
  /***/ }),
280316
280316
 
280317
- /***/ 99029:
280317
+ /***/ 3342:
280318
280318
  /***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => {
280319
280319
 
280320
280320
  // ESM COMPAT FLAG
@@ -285979,6 +285979,66 @@ async function encryptRepoSecret(owner, repo, section, plaintextValue, octokit)
285979
285979
  }
285980
285980
  }
285981
285981
 
285982
+ ;// CONCATENATED MODULE: ../github/src/orgSecrets.ts
285983
+
285984
+
285985
+
285986
+ async function getOrgPublicKey(org, section, octokit) {
285987
+ logger.info(`Retrieving org public key for ${org} (${section})`);
285988
+ try {
285989
+ if (!octokit) {
285990
+ octokit = await getOctokitForOrg(org);
285991
+ }
285992
+ const { data } = await octokit.rest[`${section}`].getOrgPublicKey({
285993
+ org,
285994
+ });
285995
+ return data;
285996
+ }
285997
+ catch (error) {
285998
+ logger.error(`Error retrieving org public key (${section}) for ${org}: ${error}`);
285999
+ throw error;
286000
+ }
286001
+ }
286002
+ async function encryptOrgSecret(org, section, plaintextValue, preFetchedKey, octokit) {
286003
+ try {
286004
+ const { key_id, key } = preFetchedKey
286005
+ ? preFetchedKey
286006
+ : await getOrgPublicKey(org, section, octokit);
286007
+ await libsodium_wrappers.ready;
286008
+ const publicKey = libsodium_wrappers.from_base64(key, libsodium_wrappers.base64_variants.ORIGINAL);
286009
+ const secretBytes = libsodium_wrappers.from_string(plaintextValue);
286010
+ const encryptedBytes = libsodium_wrappers.crypto_box_seal(secretBytes, publicKey);
286011
+ const encryptedValue = libsodium_wrappers.to_base64(encryptedBytes, libsodium_wrappers.base64_variants.ORIGINAL);
286012
+ return {
286013
+ key_id,
286014
+ encrypted_value: encryptedValue,
286015
+ };
286016
+ }
286017
+ catch (err) {
286018
+ logger.error(`Error encrypting org secret (${section}) for ${org}: ${err}`);
286019
+ throw err;
286020
+ }
286021
+ }
286022
+ async function getOrgSecret(org, section, name, octokit) {
286023
+ logger.info(`Checking org secret ${name} (${section}) for ${org}`);
286024
+ try {
286025
+ if (!octokit) {
286026
+ octokit = await getOctokitForOrg(org);
286027
+ }
286028
+ const response = await octokit.rest[`${section}`].getOrgSecret({
286029
+ org,
286030
+ secret_name: name,
286031
+ });
286032
+ return response.data;
286033
+ }
286034
+ catch (err) {
286035
+ if (err && err.status === 404) {
286036
+ return null;
286037
+ }
286038
+ throw err;
286039
+ }
286040
+ }
286041
+
285982
286042
  ;// CONCATENATED MODULE: ../github/src/profile.ts
285983
286043
  // Profile definitions and store for github package (immutable and ambient profiles)
285984
286044
  const profileStore = new Map();
@@ -286412,6 +286472,7 @@ function withProfile(profileName) {
286412
286472
 
286413
286473
 
286414
286474
 
286475
+
286415
286476
  /* harmony default export */ const github = ({
286416
286477
  org: organization,
286417
286478
  repo: repository,
@@ -286434,6 +286495,9 @@ function withProfile(profileName) {
286434
286495
  encryption: {
286435
286496
  encryptRepoSecret: encryptRepoSecret,
286436
286497
  getRepoPublicKey: getRepoPublicKey,
286498
+ getOrgPublicKey: getOrgPublicKey,
286499
+ encryptOrgSecret: encryptOrgSecret,
286500
+ getOrgSecret: getOrgSecret,
286437
286501
  },
286438
286502
  withProfile: withProfile,
286439
286503
  createProfile: createProfile,
@@ -319334,8 +319398,8 @@ var dist = __nccwpck_require__(44516);
319334
319398
  var dist_default = /*#__PURE__*/__nccwpck_require__.n(dist);
319335
319399
  // EXTERNAL MODULE: ../catalog_common/index.ts + 44 modules
319336
319400
  var catalog_common = __nccwpck_require__(78542);
319337
- // EXTERNAL MODULE: ../github/index.ts + 37 modules
319338
- var github = __nccwpck_require__(99029);
319401
+ // EXTERNAL MODULE: ../github/index.ts + 38 modules
319402
+ var github = __nccwpck_require__(3342);
319339
319403
  ;// CONCATENATED MODULE: ../cdk8s_renderer/src/patches/base.ts
319340
319404
  class BasePatches {
319341
319405
  constructor() { }
@@ -322103,6 +322167,31 @@ function extractAllRefs(claimData) {
322103
322167
  }
322104
322168
  }
322105
322169
  }
322170
+ const orgSecrets = parsedClaim.providers?.github?.org_secrets;
322171
+ if (orgSecrets && typeof orgSecrets === 'object') {
322172
+ const secretRefRegex = /^ref:secretsclaim:([a-zA-Z0-9_-]+):([a-zA-Z0-9_-]+)$/;
322173
+ for (const section of ['actions', 'codespaces', 'dependabot']) {
322174
+ const secrets = orgSecrets[section];
322175
+ if (!Array.isArray(secrets))
322176
+ continue;
322177
+ for (const secret of secrets) {
322178
+ if (secret.value) {
322179
+ const match = secret.value.match(secretRefRegex);
322180
+ if (match) {
322181
+ refs.push(`SecretsClaim-${match[1]}`);
322182
+ }
322183
+ }
322184
+ if (Array.isArray(secret.selected_repositories)) {
322185
+ for (const repoRef of secret.selected_repositories) {
322186
+ const compMatch = repoRef.match(/^component:(.+)$/);
322187
+ if (compMatch) {
322188
+ refs.push(`ComponentClaim-${compMatch[1]}`);
322189
+ }
322190
+ }
322191
+ }
322192
+ }
322193
+ }
322194
+ }
322106
322195
  break;
322107
322196
  }
322108
322197
  }
@@ -323274,6 +323363,30 @@ const organizationSettingsProperties = {
323274
323363
  ],
323275
323364
  },
323276
323365
  },
323366
+ org_secrets: {
323367
+ type: 'object',
323368
+ properties: {
323369
+ actions: {
323370
+ type: 'array',
323371
+ items: {
323372
+ $ref: 'firestartr.dev://github/GithubOrgClaimSecret',
323373
+ },
323374
+ },
323375
+ codespaces: {
323376
+ type: 'array',
323377
+ items: {
323378
+ $ref: 'firestartr.dev://github/GithubOrgClaimSecret',
323379
+ },
323380
+ },
323381
+ dependabot: {
323382
+ type: 'array',
323383
+ items: {
323384
+ $ref: 'firestartr.dev://github/GithubOrgClaimSecret',
323385
+ },
323386
+ },
323387
+ },
323388
+ additionalProperties: false,
323389
+ },
323277
323390
  };
323278
323391
  /* harmony default export */ const github_orgsettings_schema = ({
323279
323392
  $schema: SCHEMA,
@@ -323461,6 +323574,75 @@ const organizationSettingsProperties = {
323461
323574
  },
323462
323575
  });
323463
323576
 
323577
+ ;// CONCATENATED MODULE: ../cdk8s_renderer/src/claims/github/orgSecrets.schema.ts
323578
+
323579
+ /* harmony default export */ const orgSecrets_schema = ({
323580
+ $schema: SCHEMA,
323581
+ $id: 'GithubOrgClaimSecrets',
323582
+ definitions: {
323583
+ GithubOrgClaimSecrets: {
323584
+ $id: 'firestartr.dev://github/GithubOrgClaimSecrets',
323585
+ type: 'object',
323586
+ description: 'Organization-level GitHub Actions secrets',
323587
+ properties: {
323588
+ actions: {
323589
+ type: 'array',
323590
+ items: {
323591
+ $ref: 'firestartr.dev://github/GithubOrgClaimSecret',
323592
+ },
323593
+ },
323594
+ codespaces: {
323595
+ type: 'array',
323596
+ items: {
323597
+ $ref: 'firestartr.dev://github/GithubOrgClaimSecret',
323598
+ },
323599
+ },
323600
+ dependabot: {
323601
+ type: 'array',
323602
+ items: {
323603
+ $ref: 'firestartr.dev://github/GithubOrgClaimSecret',
323604
+ },
323605
+ },
323606
+ },
323607
+ additionalProperties: false,
323608
+ },
323609
+ GithubOrgClaimSecretRef: {
323610
+ $id: 'firestartr.dev://github/GithubOrgClaimSecretRef',
323611
+ type: 'string',
323612
+ description: 'the reference of the secret',
323613
+ pattern: '^ref:secretsclaim:([a-zA-Z0-9_-]+):([a-zA-Z0-9_-]+)$',
323614
+ },
323615
+ GithubOrgClaimSecret: {
323616
+ $id: 'firestartr.dev://github/GithubOrgClaimSecret',
323617
+ type: 'object',
323618
+ description: 'An organization-level secret for GitHub Actions',
323619
+ properties: {
323620
+ name: {
323621
+ type: 'string',
323622
+ description: 'the name of the secret',
323623
+ },
323624
+ value: {
323625
+ $ref: 'firestartr.dev://github/GithubOrgClaimSecretRef',
323626
+ },
323627
+ visibility: {
323628
+ type: 'string',
323629
+ enum: ['all', 'selected', 'private'],
323630
+ description: 'which repositories can access the secret',
323631
+ },
323632
+ selected_repositories: {
323633
+ type: 'array',
323634
+ items: {
323635
+ type: 'string',
323636
+ },
323637
+ description: 'list of repository refs when visibility is selected',
323638
+ },
323639
+ },
323640
+ required: ['name', 'value'],
323641
+ additionalProperties: false,
323642
+ },
323643
+ },
323644
+ });
323645
+
323464
323646
  ;// CONCATENATED MODULE: ../cdk8s_renderer/src/claims/github/index.ts
323465
323647
 
323466
323648
 
@@ -323470,6 +323652,7 @@ const organizationSettingsProperties = {
323470
323652
 
323471
323653
 
323472
323654
 
323655
+
323473
323656
  const GithubSchemas = [
323474
323657
  github_group_schema,
323475
323658
  github_user_schema,
@@ -323479,6 +323662,7 @@ const GithubSchemas = [
323479
323662
  github_orgsettings_schema,
323480
323663
  component_secrets_vars_schema,
323481
323664
  component_labels_schema,
323665
+ orgSecrets_schema,
323482
323666
  ];
323483
323667
 
323484
323668
  ;// CONCATENATED MODULE: ../cdk8s_renderer/src/claims/tfworkspaces/terraform.schema.ts
@@ -327490,6 +327674,382 @@ var FirestartrGithubMembershipSpecContextProviderRefKind;
327490
327674
  /** FirestartrProviderConfig */
327491
327675
  FirestartrGithubMembershipSpecContextProviderRefKind["FIRESTARTR_PROVIDER_CONFIG"] = "FirestartrProviderConfig";
327492
327676
  })(FirestartrGithubMembershipSpecContextProviderRefKind || (FirestartrGithubMembershipSpecContextProviderRefKind = {}));
327677
+ /**
327678
+ * A resource to handle GitHub Organization Actions Secrets.
327679
+ *
327680
+ * @schema FirestartrGithubOrganizationSecretSection
327681
+ */
327682
+ class FirestartrGithubOrganizationSecretSection extends lib.ApiObject {
327683
+ /**
327684
+ * Renders a Kubernetes manifest for "FirestartrGithubOrganizationSecretSection".
327685
+ *
327686
+ * This can be used to inline resource manifests inside other objects (e.g. as templates).
327687
+ *
327688
+ * @param props initialization props
327689
+ */
327690
+ static manifest(props) {
327691
+ return {
327692
+ ...FirestartrGithubOrganizationSecretSection.GVK,
327693
+ ...toJson_FirestartrGithubOrganizationSecretSectionProps(props),
327694
+ };
327695
+ }
327696
+ /**
327697
+ * Defines a "FirestartrGithubOrganizationSecretSection" API object
327698
+ * @param scope the scope in which to define this object
327699
+ * @param id a scope-local name for the object
327700
+ * @param props initialization props
327701
+ */
327702
+ constructor(scope, id, props) {
327703
+ super(scope, id, {
327704
+ ...FirestartrGithubOrganizationSecretSection.GVK,
327705
+ ...props,
327706
+ });
327707
+ }
327708
+ /**
327709
+ * Renders the object to Kubernetes JSON.
327710
+ */
327711
+ toJson() {
327712
+ const resolved = super.toJson();
327713
+ return {
327714
+ ...FirestartrGithubOrganizationSecretSection.GVK,
327715
+ ...toJson_FirestartrGithubOrganizationSecretSectionProps(resolved),
327716
+ };
327717
+ }
327718
+ }
327719
+ /**
327720
+ * Returns the apiVersion and kind for "FirestartrGithubOrganizationSecretSection"
327721
+ */
327722
+ FirestartrGithubOrganizationSecretSection.GVK = {
327723
+ apiVersion: 'firestartr.dev/v1',
327724
+ kind: 'FirestartrGithubOrganizationSecretSection',
327725
+ };
327726
+
327727
+ /**
327728
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionProps' to JSON representation.
327729
+ */
327730
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
327731
+ function toJson_FirestartrGithubOrganizationSecretSectionProps(obj) {
327732
+ if (obj === undefined) {
327733
+ return undefined;
327734
+ }
327735
+ const result = {
327736
+ 'metadata': obj.metadata,
327737
+ 'spec': toJson_FirestartrGithubOrganizationSecretSectionSpec(obj.spec),
327738
+ };
327739
+ // filter undefined values
327740
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
327741
+ }
327742
+ /**
327743
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpec' to JSON representation.
327744
+ */
327745
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
327746
+ function toJson_FirestartrGithubOrganizationSecretSectionSpec(obj) {
327747
+ if (obj === undefined) {
327748
+ return undefined;
327749
+ }
327750
+ const result = {
327751
+ 'org': obj.org,
327752
+ 'secrets': toJson_FirestartrGithubOrganizationSecretSectionSpecSecrets(obj.secrets),
327753
+ 'context': toJson_FirestartrGithubOrganizationSecretSectionSpecContext(obj.context),
327754
+ 'firestartr': toJson_FirestartrGithubOrganizationSecretSectionSpecFirestartr(obj.firestartr),
327755
+ };
327756
+ // filter undefined values
327757
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
327758
+ }
327759
+ /**
327760
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecSecrets' to JSON representation.
327761
+ */
327762
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
327763
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecSecrets(obj) {
327764
+ if (obj === undefined) {
327765
+ return undefined;
327766
+ }
327767
+ const result = {
327768
+ 'actions': obj.actions?.map(y => toJson_FirestartrGithubOrganizationSecretSectionSpecSecretsActions(y)),
327769
+ 'codespaces': obj.codespaces?.map(y => toJson_FirestartrGithubOrganizationSecretSectionSpecSecretsCodespaces(y)),
327770
+ 'dependabot': obj.dependabot?.map(y => toJson_FirestartrGithubOrganizationSecretSectionSpecSecretsDependabot(y)),
327771
+ };
327772
+ // filter undefined values
327773
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
327774
+ }
327775
+ /**
327776
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecContext' to JSON representation.
327777
+ */
327778
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
327779
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecContext(obj) {
327780
+ if (obj === undefined) {
327781
+ return undefined;
327782
+ }
327783
+ const result = {
327784
+ 'backend': toJson_FirestartrGithubOrganizationSecretSectionSpecContextBackend(obj.backend),
327785
+ 'provider': toJson_FirestartrGithubOrganizationSecretSectionSpecContextProvider(obj.provider),
327786
+ };
327787
+ // filter undefined values
327788
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
327789
+ }
327790
+ /**
327791
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecFirestartr' to JSON representation.
327792
+ */
327793
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
327794
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecFirestartr(obj) {
327795
+ if (obj === undefined) {
327796
+ return undefined;
327797
+ }
327798
+ const result = {
327799
+ 'tfStateKey': obj.tfStateKey,
327800
+ };
327801
+ // filter undefined values
327802
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
327803
+ }
327804
+ /**
327805
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecSecretsActions' to JSON representation.
327806
+ */
327807
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
327808
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecSecretsActions(obj) {
327809
+ if (obj === undefined) {
327810
+ return undefined;
327811
+ }
327812
+ const result = {
327813
+ 'name': obj.name,
327814
+ 'ref': toJson_FirestartrGithubOrganizationSecretSectionSpecSecretsActionsRef(obj.ref),
327815
+ 'visibility': obj.visibility,
327816
+ 'selectedRepositories': obj.selectedRepositories?.map(y => y),
327817
+ };
327818
+ // filter undefined values
327819
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
327820
+ }
327821
+ /**
327822
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecSecretsCodespaces' to JSON representation.
327823
+ */
327824
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
327825
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecSecretsCodespaces(obj) {
327826
+ if (obj === undefined) {
327827
+ return undefined;
327828
+ }
327829
+ const result = {
327830
+ 'name': obj.name,
327831
+ 'ref': toJson_FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesRef(obj.ref),
327832
+ 'visibility': obj.visibility,
327833
+ 'selectedRepositories': obj.selectedRepositories?.map(y => y),
327834
+ };
327835
+ // filter undefined values
327836
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
327837
+ }
327838
+ /**
327839
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecSecretsDependabot' to JSON representation.
327840
+ */
327841
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
327842
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecSecretsDependabot(obj) {
327843
+ if (obj === undefined) {
327844
+ return undefined;
327845
+ }
327846
+ const result = {
327847
+ 'name': obj.name,
327848
+ 'ref': toJson_FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotRef(obj.ref),
327849
+ 'visibility': obj.visibility,
327850
+ 'selectedRepositories': obj.selectedRepositories?.map(y => y),
327851
+ };
327852
+ // filter undefined values
327853
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
327854
+ }
327855
+ /**
327856
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecContextBackend' to JSON representation.
327857
+ */
327858
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
327859
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecContextBackend(obj) {
327860
+ if (obj === undefined) {
327861
+ return undefined;
327862
+ }
327863
+ const result = {
327864
+ 'ref': toJson_FirestartrGithubOrganizationSecretSectionSpecContextBackendRef(obj.ref),
327865
+ };
327866
+ // filter undefined values
327867
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
327868
+ }
327869
+ /**
327870
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecContextProvider' to JSON representation.
327871
+ */
327872
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
327873
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecContextProvider(obj) {
327874
+ if (obj === undefined) {
327875
+ return undefined;
327876
+ }
327877
+ const result = {
327878
+ 'ref': toJson_FirestartrGithubOrganizationSecretSectionSpecContextProviderRef(obj.ref),
327879
+ };
327880
+ // filter undefined values
327881
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
327882
+ }
327883
+ /**
327884
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecSecretsActionsRef' to JSON representation.
327885
+ */
327886
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
327887
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecSecretsActionsRef(obj) {
327888
+ if (obj === undefined) {
327889
+ return undefined;
327890
+ }
327891
+ const result = {
327892
+ 'kind': obj.kind,
327893
+ 'name': obj.name,
327894
+ 'key': obj.key,
327895
+ };
327896
+ // filter undefined values
327897
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
327898
+ }
327899
+ /* eslint-enable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
327900
+ /**
327901
+ * Which repositories can access the secret.
327902
+ *
327903
+ * @schema FirestartrGithubOrganizationSecretSectionSpecSecretsActionsVisibility
327904
+ */
327905
+ var FirestartrGithubOrganizationSecretSectionSpecSecretsActionsVisibility;
327906
+ (function (FirestartrGithubOrganizationSecretSectionSpecSecretsActionsVisibility) {
327907
+ /** all */
327908
+ FirestartrGithubOrganizationSecretSectionSpecSecretsActionsVisibility["ALL"] = "all";
327909
+ /** selected */
327910
+ FirestartrGithubOrganizationSecretSectionSpecSecretsActionsVisibility["SELECTED"] = "selected";
327911
+ /** private */
327912
+ FirestartrGithubOrganizationSecretSectionSpecSecretsActionsVisibility["PRIVATE"] = "private";
327913
+ })(FirestartrGithubOrganizationSecretSectionSpecSecretsActionsVisibility || (FirestartrGithubOrganizationSecretSectionSpecSecretsActionsVisibility = {}));
327914
+ /**
327915
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesRef' to JSON representation.
327916
+ */
327917
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
327918
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesRef(obj) {
327919
+ if (obj === undefined) {
327920
+ return undefined;
327921
+ }
327922
+ const result = {
327923
+ 'kind': obj.kind,
327924
+ 'name': obj.name,
327925
+ 'key': obj.key,
327926
+ };
327927
+ // filter undefined values
327928
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
327929
+ }
327930
+ /* eslint-enable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
327931
+ /**
327932
+ * Which repositories can access the secret.
327933
+ *
327934
+ * @schema FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesVisibility
327935
+ */
327936
+ var FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesVisibility;
327937
+ (function (FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesVisibility) {
327938
+ /** all */
327939
+ FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesVisibility["ALL"] = "all";
327940
+ /** selected */
327941
+ FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesVisibility["SELECTED"] = "selected";
327942
+ /** private */
327943
+ FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesVisibility["PRIVATE"] = "private";
327944
+ })(FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesVisibility || (FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesVisibility = {}));
327945
+ /**
327946
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotRef' to JSON representation.
327947
+ */
327948
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
327949
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotRef(obj) {
327950
+ if (obj === undefined) {
327951
+ return undefined;
327952
+ }
327953
+ const result = {
327954
+ 'kind': obj.kind,
327955
+ 'name': obj.name,
327956
+ 'key': obj.key,
327957
+ };
327958
+ // filter undefined values
327959
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
327960
+ }
327961
+ /* eslint-enable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
327962
+ /**
327963
+ * Which repositories can access the secret.
327964
+ *
327965
+ * @schema FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotVisibility
327966
+ */
327967
+ var FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotVisibility;
327968
+ (function (FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotVisibility) {
327969
+ /** all */
327970
+ FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotVisibility["ALL"] = "all";
327971
+ /** selected */
327972
+ FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotVisibility["SELECTED"] = "selected";
327973
+ /** private */
327974
+ FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotVisibility["PRIVATE"] = "private";
327975
+ })(FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotVisibility || (FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotVisibility = {}));
327976
+ /**
327977
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecContextBackendRef' to JSON representation.
327978
+ */
327979
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
327980
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecContextBackendRef(obj) {
327981
+ if (obj === undefined) {
327982
+ return undefined;
327983
+ }
327984
+ const result = {
327985
+ 'kind': obj.kind,
327986
+ 'name': obj.name,
327987
+ };
327988
+ // filter undefined values
327989
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
327990
+ }
327991
+ /**
327992
+ * Converts an object of type 'FirestartrGithubOrganizationSecretSectionSpecContextProviderRef' to JSON representation.
327993
+ */
327994
+ /* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
327995
+ function toJson_FirestartrGithubOrganizationSecretSectionSpecContextProviderRef(obj) {
327996
+ if (obj === undefined) {
327997
+ return undefined;
327998
+ }
327999
+ const result = {
328000
+ 'kind': obj.kind,
328001
+ 'name': obj.name,
328002
+ };
328003
+ // filter undefined values
328004
+ return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
328005
+ }
328006
+ /* eslint-enable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
328007
+ /**
328008
+ * The type of Kubernetes resource to reference.
328009
+ *
328010
+ * @schema FirestartrGithubOrganizationSecretSectionSpecSecretsActionsRefKind
328011
+ */
328012
+ var FirestartrGithubOrganizationSecretSectionSpecSecretsActionsRefKind;
328013
+ (function (FirestartrGithubOrganizationSecretSectionSpecSecretsActionsRefKind) {
328014
+ /** Secret */
328015
+ FirestartrGithubOrganizationSecretSectionSpecSecretsActionsRefKind["SECRET"] = "Secret";
328016
+ })(FirestartrGithubOrganizationSecretSectionSpecSecretsActionsRefKind || (FirestartrGithubOrganizationSecretSectionSpecSecretsActionsRefKind = {}));
328017
+ /**
328018
+ * The type of Kubernetes resource to reference.
328019
+ *
328020
+ * @schema FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesRefKind
328021
+ */
328022
+ var FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesRefKind;
328023
+ (function (FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesRefKind) {
328024
+ /** Secret */
328025
+ FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesRefKind["SECRET"] = "Secret";
328026
+ })(FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesRefKind || (FirestartrGithubOrganizationSecretSectionSpecSecretsCodespacesRefKind = {}));
328027
+ /**
328028
+ * The type of Kubernetes resource to reference.
328029
+ *
328030
+ * @schema FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotRefKind
328031
+ */
328032
+ var FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotRefKind;
328033
+ (function (FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotRefKind) {
328034
+ /** Secret */
328035
+ FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotRefKind["SECRET"] = "Secret";
328036
+ })(FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotRefKind || (FirestartrGithubOrganizationSecretSectionSpecSecretsDependabotRefKind = {}));
328037
+ /**
328038
+ * @schema FirestartrGithubOrganizationSecretSectionSpecContextBackendRefKind
328039
+ */
328040
+ var FirestartrGithubOrganizationSecretSectionSpecContextBackendRefKind;
328041
+ (function (FirestartrGithubOrganizationSecretSectionSpecContextBackendRefKind) {
328042
+ /** FirestartrProviderConfig */
328043
+ FirestartrGithubOrganizationSecretSectionSpecContextBackendRefKind["FIRESTARTR_PROVIDER_CONFIG"] = "FirestartrProviderConfig";
328044
+ })(FirestartrGithubOrganizationSecretSectionSpecContextBackendRefKind || (FirestartrGithubOrganizationSecretSectionSpecContextBackendRefKind = {}));
328045
+ /**
328046
+ * @schema FirestartrGithubOrganizationSecretSectionSpecContextProviderRefKind
328047
+ */
328048
+ var FirestartrGithubOrganizationSecretSectionSpecContextProviderRefKind;
328049
+ (function (FirestartrGithubOrganizationSecretSectionSpecContextProviderRefKind) {
328050
+ /** FirestartrProviderConfig */
328051
+ FirestartrGithubOrganizationSecretSectionSpecContextProviderRefKind["FIRESTARTR_PROVIDER_CONFIG"] = "FirestartrProviderConfig";
328052
+ })(FirestartrGithubOrganizationSecretSectionSpecContextProviderRefKind || (FirestartrGithubOrganizationSecretSectionSpecContextProviderRefKind = {}));
327493
328053
  /**
327494
328054
  * A resource to handle GitHub Organization Settings.
327495
328055
  *
@@ -330904,6 +331464,78 @@ class GithubOrgVariableSectionChart extends BaseGithubChart {
330904
331464
  }
330905
331465
  }
330906
331466
 
331467
+ ;// CONCATENATED MODULE: ../cdk8s_renderer/src/charts/github/orgSecretSectionChart.ts
331468
+
331469
+
331470
+
331471
+ class GithubOrgSecretSectionChart extends BaseGithubChart {
331472
+ template() {
331473
+ const claim = this.get('claim');
331474
+ const firestartrId = this.get('firestartrId');
331475
+ const githubProvider = claim.providers.github;
331476
+ const orgSecrets = githubProvider.org_secrets || {};
331477
+ const renderSecrets = (section) => {
331478
+ const secrets = orgSecrets[section];
331479
+ if (!Array.isArray(secrets))
331480
+ return [];
331481
+ return secrets.map((secret) => {
331482
+ const parts = secret.value.split(':');
331483
+ const selectedRepositories = (secret.selected_repositories || []).map((ref) => {
331484
+ const match = ref.match(/^component:(.+)$/);
331485
+ if (!match) {
331486
+ throw new ChartRenderError('OrgSettingsClaim', claim.name, `Invalid component ref "${ref}" in selected_repositories. Expected format: component:<name>`);
331487
+ }
331488
+ const componentName = match[1];
331489
+ const resolvedCr = this.refResolver('ComponentClaim', componentName);
331490
+ const org = resolvedCr?.spec?.org;
331491
+ const repoName = resolvedCr?.metadata?.annotations?.['firestartr.dev/external-name'] || resolvedCr?.metadata?.name?.replace(/-[0-9a-f-]{36}$/, '');
331492
+ if (!org || !repoName) {
331493
+ throw new ChartRenderError('OrgSettingsClaim', claim.name, `Referenced component "${componentName}" has no GitHub provider configured`);
331494
+ }
331495
+ return `${org}/${repoName}`;
331496
+ });
331497
+ return {
331498
+ name: secret.name,
331499
+ ref: {
331500
+ kind: 'Secret',
331501
+ name: parts[2],
331502
+ key: parts[3],
331503
+ },
331504
+ visibility: secret.visibility || 'all',
331505
+ selectedRepositories,
331506
+ };
331507
+ });
331508
+ };
331509
+ const template = {
331510
+ metadata: {
331511
+ name: `${githubProvider.name}-secrets`,
331512
+ },
331513
+ spec: {
331514
+ org: githubProvider.org,
331515
+ secrets: {
331516
+ actions: renderSecrets('actions'),
331517
+ codespaces: renderSecrets('codespaces'),
331518
+ dependabot: renderSecrets('dependabot'),
331519
+ },
331520
+ firestartr: {
331521
+ tfStateKey: firestartrId ? `${firestartrId}-secrets` : firestartrId,
331522
+ },
331523
+ writeConnectionSecretToRef: {
331524
+ name: `firestartrgithuborganizationsecretsection-${githubProvider.name}-secrets-outputs`.toLowerCase(),
331525
+ outputs: [{ key: 'managed_secrets' }, { key: 'secret_ids' }],
331526
+ },
331527
+ },
331528
+ };
331529
+ return JSON.parse(JSON.stringify(template));
331530
+ }
331531
+ gvk() {
331532
+ return FirestartrGithubOrganizationSecretSection.GVK;
331533
+ }
331534
+ instanceApiObject(template) {
331535
+ return new FirestartrGithubOrganizationSecretSection(this, template.metadata.name, template);
331536
+ }
331537
+ }
331538
+
330907
331539
  ;// CONCATENATED MODULE: ../cdk8s_renderer/src/charts/github/index.ts
330908
331540
 
330909
331541
 
@@ -330912,6 +331544,7 @@ class GithubOrgVariableSectionChart extends BaseGithubChart {
330912
331544
 
330913
331545
 
330914
331546
 
331547
+
330915
331548
  ;// CONCATENATED MODULE: ../cdk8s_renderer/src/charts/catalog/base.ts
330916
331549
 
330917
331550
  class BaseCatalogChart extends BaseChart {
@@ -331660,6 +332293,7 @@ class SecretsChart extends BaseSecretsChart {
331660
332293
  GithubOrgWebhookChart: GithubOrgWebhookChart,
331661
332294
  GithubOrgSettingsChart: GithubOrgSettingsChart,
331662
332295
  GithubOrgVariableSectionChart: GithubOrgVariableSectionChart,
332296
+ GithubOrgSecretSectionChart: GithubOrgSecretSectionChart,
331663
332297
  });
331664
332298
 
331665
332299
  ;// CONCATENATED MODULE: ../cdk8s_renderer/src/renderer/claims-render.ts
@@ -331711,16 +332345,21 @@ async function renderClaims(catalogScope, firestartrScope, data) {
331711
332345
  const variableSectionPreviousCR = claim.kind === 'OrgSettingsClaim'
331712
332346
  ? getPreviousCRfromClaim({ kind: claim.kind, name: `${claim.name}-variable-section` }, crs, 'FirestartrGithubOrganizationVariableSection')
331713
332347
  : false;
332348
+ const secretSectionPreviousCR = claim.kind === 'OrgSettingsClaim'
332349
+ ? getPreviousCRfromClaim({ kind: claim.kind, name: `${claim.name}-secret-section` }, crs, 'FirestartrGithubOrganizationSecretSection')
332350
+ : false;
331714
332351
  const patches = await extractPatches(renderClaims[claimKey], previousCR);
331715
332352
  let variableSectionPatches = undefined;
332353
+ let secretSectionPatches = undefined;
331716
332354
  if (claim.kind === 'OrgSettingsClaim') {
331717
332355
  variableSectionPatches = await extractPatches(renderClaims[claimKey], variableSectionPreviousCR);
332356
+ secretSectionPatches = await extractPatches(renderClaims[claimKey], secretSectionPreviousCR);
331718
332357
  }
331719
332358
  if (!previousCR) {
331720
332359
  logger.debug(`No CR found for claim ${claimKey}, it will be rendered from scratch`);
331721
332360
  }
331722
332361
  const claimPath = renderClaims[claimKey].claimPath;
331723
- const { firestartrEntity, extraCharts, catalogEntity } = await renderClaim(catalogScope, firestartrScope, claim, patches, previousCR, claimPath, variableSectionPreviousCR, variableSectionPatches);
332362
+ const { firestartrEntity, extraCharts, catalogEntity } = await renderClaim(catalogScope, firestartrScope, claim, patches, previousCR, claimPath, variableSectionPreviousCR, variableSectionPatches, secretSectionPreviousCR, secretSectionPatches);
331724
332363
  if (catalogEntity) {
331725
332364
  result[`${catalogEntity.kind}-${catalogEntity.metadata.name}`] =
331726
332365
  catalogEntity.toJson();
@@ -331749,7 +332388,7 @@ async function renderClaims(catalogScope, firestartrScope, data) {
331749
332388
  }
331750
332389
  return result;
331751
332390
  }
331752
- async function renderClaim(catalogScope, firestartrScope, claim, patches, previousCR = null, claimPath, variableSectionPreviousCR = false, variableSectionPatches) {
332391
+ async function renderClaim(catalogScope, firestartrScope, claim, patches, previousCR = null, claimPath, variableSectionPreviousCR = false, variableSectionPatches, secretSectionPreviousCR = false, secretSectionPatches) {
331753
332392
  let catalogEntity = undefined;
331754
332393
  let firestartrEntity = undefined;
331755
332394
  const extraCharts = [];
@@ -331918,6 +332557,27 @@ async function renderClaim(catalogScope, firestartrScope, claim, patches, previo
331918
332557
  },
331919
332558
  chart: variableSectionObject,
331920
332559
  });
332560
+ const secretSectionFirestartrId = secretSectionPreviousCR
332561
+ ? secretSectionPreviousCR.spec?.firestartr?.tfStateKey
332562
+ : firestartrId
332563
+ ? `${firestartrId}-secrets`
332564
+ : null;
332565
+ const ssRenderPatches = secretSectionPatches
332566
+ ? secretSectionPatches.filter((patch) => !patch.isPostPatch)
332567
+ : renderPatches;
332568
+ const ssPostPatches = secretSectionPatches
332569
+ ? secretSectionPatches.filter((patch) => patch.isPostPatch)
332570
+ : postPatches;
332571
+ const secretSectionChart = new charts.GithubOrgSecretSectionChart(firestartrScope, `github-secrets-${chartId}`, secretSectionFirestartrId, claim, ssRenderPatches);
332572
+ await secretSectionChart.render();
332573
+ const secretSectionObject = await secretSectionChart.postRenderer(ssPostPatches);
332574
+ extraCharts.push({
332575
+ claim: {
332576
+ kind: claim.kind,
332577
+ name: `${claim.name}-secret-section`,
332578
+ },
332579
+ chart: secretSectionObject,
332580
+ });
331921
332581
  }
331922
332582
  break;
331923
332583
  default:
@@ -332040,8 +332700,33 @@ function searchSecretKey(secretClaim, key) {
332040
332700
  }
332041
332701
  function validateOrgSettingsComponentRefs(ref, renderClaims) {
332042
332702
  const claim = renderClaims[ref].claim;
332703
+ validateOrgSecretsSelectedRepositories(claim, renderClaims);
332043
332704
  validateActionsVariablesSelectedRepositories(claim, renderClaims);
332044
332705
  }
332706
+ function validateOrgSecretsSelectedRepositories(claim, renderClaims) {
332707
+ const orgSecrets = claim?.providers?.github?.org_secrets;
332708
+ if (!orgSecrets || typeof orgSecrets !== 'object')
332709
+ return;
332710
+ for (const section of ['actions', 'codespaces', 'dependabot']) {
332711
+ const secrets = orgSecrets[section];
332712
+ if (!Array.isArray(secrets))
332713
+ continue;
332714
+ for (const secret of secrets) {
332715
+ if (!secret.selected_repositories)
332716
+ continue;
332717
+ for (const repoRef of secret.selected_repositories) {
332718
+ const match = repoRef.match(COMPONENT_REF_PATTERN);
332719
+ if (!match)
332720
+ continue;
332721
+ const [, componentName] = match;
332722
+ const expectedKey = `ComponentClaim-${componentName}`;
332723
+ if (!renderClaims[expectedKey]) {
332724
+ throw new Error(`CrossReference error: OrgSettingsClaim/${claim.name} references a non-existent component "${componentName}" in org_secrets.${section}.${secret.name}.selected_repositories`);
332725
+ }
332726
+ }
332727
+ }
332728
+ }
332729
+ }
332045
332730
  function validateActionsVariablesSelectedRepositories(claim, renderClaims) {
332046
332731
  const actionsVariables = claim?.providers?.github?.actions_variables;
332047
332732
  if (!Array.isArray(actionsVariables))
@@ -332172,6 +332857,116 @@ function validateActionsVariablesUniqueness(crs) {
332172
332857
  }
332173
332858
  }
332174
332859
 
332860
+ ;// CONCATENATED MODULE: ../cdk8s_renderer/src/validations/githubOrgSecretSection.ts
332861
+ const GITHUB_ORG_SECRET_SECTION_KIND = 'FirestartrGithubOrganizationSecretSection';
332862
+ const githubOrgSecretSection_FIRESTARTR_CLAIM_REF_ANNOTATION = 'firestartr.dev/claim-ref';
332863
+ const githubOrgSecretSection_CLAIM_REF_LABEL = 'claim-ref';
332864
+ const SECRETS_CLAIM_REF_PATTERN = /^ref:secretsclaim:([a-zA-Z0-9_-]+):([a-zA-Z0-9_-]+)$/;
332865
+ function githubOrgSecretSection_formatResourceRef(name, claimRef) {
332866
+ return claimRef ? `${name} (claim: ${claimRef})` : name;
332867
+ }
332868
+ function validateGithubOrgSecretSectionSingleton(crs) {
332869
+ const refsByOrg = new Map();
332870
+ const seenClaimRefs = new Map();
332871
+ for (const crKey of Object.keys(crs)) {
332872
+ const cr = crs[crKey];
332873
+ if (cr.kind !== GITHUB_ORG_SECRET_SECTION_KIND)
332874
+ continue;
332875
+ const org = cr.spec?.org;
332876
+ if (typeof org !== 'string' || !org)
332877
+ continue;
332878
+ const name = cr.metadata?.name || crKey;
332879
+ const claimRef = cr.metadata?.annotations?.[githubOrgSecretSection_FIRESTARTR_CLAIM_REF_ANNOTATION] ||
332880
+ cr.metadata?.labels?.[githubOrgSecretSection_CLAIM_REF_LABEL];
332881
+ const normalizedOrg = org.toLowerCase();
332882
+ if (claimRef) {
332883
+ const seen = seenClaimRefs.get(normalizedOrg) || new Set();
332884
+ if (seen.has(claimRef))
332885
+ continue;
332886
+ seen.add(claimRef);
332887
+ seenClaimRefs.set(normalizedOrg, seen);
332888
+ }
332889
+ const refs = refsByOrg.get(normalizedOrg) || [];
332890
+ refs.push(githubOrgSecretSection_formatResourceRef(name, claimRef));
332891
+ refsByOrg.set(normalizedOrg, refs);
332892
+ }
332893
+ for (const [org, refs] of refsByOrg.entries()) {
332894
+ if (refs.length < 2)
332895
+ continue;
332896
+ throw new Error(`Duplicate ${GITHUB_ORG_SECRET_SECTION_KIND} resources found for GitHub organization "${org}": ${refs.join(', ')}`);
332897
+ }
332898
+ }
332899
+ function validateSecretNamesUniqueness(crs) {
332900
+ for (const crKey of Object.keys(crs)) {
332901
+ const cr = crs[crKey];
332902
+ if (cr.kind !== GITHUB_ORG_SECRET_SECTION_KIND)
332903
+ continue;
332904
+ const secrets = cr.spec?.secrets;
332905
+ if (!secrets || typeof secrets !== 'object')
332906
+ continue;
332907
+ for (const section of ['actions', 'codespaces', 'dependabot']) {
332908
+ const sectionSecrets = secrets[section];
332909
+ if (!Array.isArray(sectionSecrets))
332910
+ continue;
332911
+ const names = new Set();
332912
+ for (const secret of sectionSecrets) {
332913
+ const secretName = secret?.name;
332914
+ if (!secretName)
332915
+ continue;
332916
+ if (names.has(secretName)) {
332917
+ const org = cr.spec?.org || 'unknown';
332918
+ throw new Error(`Duplicate secret name "${secretName}" found in ${section} section of ${GITHUB_ORG_SECRET_SECTION_KIND} for organization "${org}"`);
332919
+ }
332920
+ names.add(secretName);
332921
+ }
332922
+ }
332923
+ }
332924
+ }
332925
+ function validateOrgSecretsCrossReferences(renderClaims) {
332926
+ for (const claimKey of Object.keys(renderClaims)) {
332927
+ if (!claimKey.startsWith('OrgSettingsClaim-'))
332928
+ continue;
332929
+ const claimData = renderClaims[claimKey];
332930
+ const claim = claimData?.claim;
332931
+ const orgSecrets = claim?.providers?.github?.org_secrets;
332932
+ if (!orgSecrets || typeof orgSecrets !== 'object')
332933
+ continue;
332934
+ for (const section of ['actions', 'codespaces', 'dependabot']) {
332935
+ const secrets = orgSecrets[section];
332936
+ if (!Array.isArray(secrets))
332937
+ continue;
332938
+ for (const secret of secrets) {
332939
+ if (!secret.value)
332940
+ continue;
332941
+ const match = secret.value.match(SECRETS_CLAIM_REF_PATTERN);
332942
+ if (!match)
332943
+ continue;
332944
+ const [, secretClaimName, secretKey] = match;
332945
+ const expectedKey = `SecretsClaim-${secretClaimName}`;
332946
+ if (!renderClaims[expectedKey])
332947
+ continue;
332948
+ const secretClaim = renderClaims[expectedKey]?.claim;
332949
+ const externalSecrets = secretClaim?.providers?.external_secrets?.externalSecrets?.secrets;
332950
+ const pushSecrets = secretClaim?.providers?.external_secrets?.pushSecrets;
332951
+ let keyFound = false;
332952
+ if (Array.isArray(pushSecrets)) {
332953
+ keyFound =
332954
+ pushSecrets.find((s) => s.secretName === secretKey) !==
332955
+ undefined;
332956
+ }
332957
+ if (!keyFound && Array.isArray(externalSecrets)) {
332958
+ keyFound =
332959
+ externalSecrets.find((s) => s.secretName === secretKey) !==
332960
+ undefined;
332961
+ }
332962
+ if (!keyFound) {
332963
+ throw new Error(`CrossReference error: OrgSettingsClaim/${claim.name} references a non-existent secret key "${secretKey}" in SecretsClaim/${secretClaimName} via org_secrets.${section}.${secret.name}`);
332964
+ }
332965
+ }
332966
+ }
332967
+ }
332968
+ }
332969
+
332175
332970
  ;// CONCATENATED MODULE: ../cdk8s_renderer/src/renderer/renderer.ts
332176
332971
 
332177
332972
 
@@ -332183,6 +332978,7 @@ function validateActionsVariablesUniqueness(crs) {
332183
332978
 
332184
332979
 
332185
332980
 
332981
+
332186
332982
  /*
332187
332983
  * Function called when rendering but not importing
332188
332984
  *
@@ -332204,10 +333000,13 @@ async function renderer_render(catalogScope, firestartrScope, claimList) {
332204
333000
  try {
332205
333001
  validateSubReferences(data.renderClaims);
332206
333002
  validateComponentPagesPath(data.renderClaims);
333003
+ validateOrgSecretsCrossReferences(data.renderClaims);
332207
333004
  validateTfStateKeyUniqueness(result);
332208
333005
  validateGithubOrgSettingsSingleton(fullCrSet);
332209
333006
  validateGithubOrgVariableSectionSingleton(fullCrSet);
332210
333007
  validateActionsVariablesUniqueness(result);
333008
+ validateGithubOrgSecretSectionSingleton(fullCrSet);
333009
+ validateSecretNamesUniqueness(result);
332211
333010
  validateCrSizes(result);
332212
333011
  validatePermissionsUniqueness(result);
332213
333012
  }
@@ -334540,6 +335339,7 @@ const kindPluralMap = {
334540
335339
  githuborgwebhooks: 'FirestartrGithubOrgWebhook',
334541
335340
  githuborganizationsettings: 'FirestartrGithubOrganizationSettings',
334542
335341
  githuborganizationvariablesections: 'FirestartrGithubOrganizationVariableSection',
335342
+ githuborganizationsecretsections: 'FirestartrGithubOrganizationSecretSection',
334543
335343
  terraformworkspaces: 'FirestartrTerraformWorkspace',
334544
335344
  terraformworkspaceplans: 'FirestartrTerraformWorkspacePlan',
334545
335345
  providerconfigs: 'FirestartrProviderConfig',
@@ -336518,6 +337318,7 @@ const kindsWithFinalizer = [
336518
337318
  'FirestartrGithubOrgWebhook',
336519
337319
  'FirestartrGithubOrganizationSettings',
336520
337320
  'FirestartrGithubOrganizationVariableSection',
337321
+ 'FirestartrGithubOrganizationSecretSection',
336521
337322
  'FirestartrGithubRepositorySecretsSection',
336522
337323
  ];
336523
337324
  const kindsWithDependants = [
@@ -339467,7 +340268,7 @@ async function configGit() {
339467
340268
  }
339468
340269
  // Import github dynamically to avoid Jest ESM issues when not specifically running this function
339469
340270
  // (see CONSTITUTION and RULES: must not change test machinery)
339470
- const githubModule = await Promise.resolve(/* import() */).then(__nccwpck_require__.bind(__nccwpck_require__, 99029));
340271
+ const githubModule = await Promise.resolve(/* import() */).then(__nccwpck_require__.bind(__nccwpck_require__, 3342));
339471
340272
  const github = githubModule.default || githubModule;
339472
340273
  if (external_fs_.existsSync(gitconfigPath)) {
339473
340274
  external_fs_.rmSync(gitconfigPath);
@@ -343064,6 +343865,11 @@ const MODULES = {
343064
343865
  // github-org-variables-section-v0.1.0
343065
343866
  ref: 'fb9c01d0a1e03e5134479da13d0faf55891dfedf',
343066
343867
  },
343868
+ FirestartrGithubOrganizationSecretSection: {
343869
+ module: 'git::https://github.com/prefapp/tfm.git//modules/github-org-secrets-section',
343870
+ // feat/1364-feat-add-github-org-secrets-section-module
343871
+ ref: '170e6cf',
343872
+ },
343067
343873
  };
343068
343874
  function getFirestartrDefaultTFM(kind) {
343069
343875
  if (kind in MODULES) {
@@ -344954,6 +345760,206 @@ class EntityGHOrgVarsSection extends base_Entity {
344954
345760
  async loadAddressesToImport() { }
344955
345761
  }
344956
345762
 
345763
+ ;// CONCATENATED MODULE: ../gh_provisioner/src/entities/ghorgsecretsection/secrets.ts
345764
+
345765
+
345766
+
345767
+
345768
+ const secrets_SECTIONS = ['actions', 'codespaces', 'dependabot'];
345769
+
345770
+ async function provisionOrgSecrets(entity, secrets) {
345771
+ gh_provisioner_src_logger.info(`[gh-provisioner] ${entity.k8sId} provisioning org secrets`);
345772
+ for (const section of secrets_SECTIONS) {
345773
+ const sectionSecrets = secrets[section] || [];
345774
+ if (sectionSecrets.length === 0)
345775
+ continue;
345776
+ let preFetchedKey;
345777
+ try {
345778
+ preFetchedKey = await fetchOrgPublicKey(entity, section);
345779
+ }
345780
+ catch (err) {
345781
+ const message = err instanceof Error ? err.message : String(err);
345782
+ throw new Error(`[gh-provisioner] ${entity.k8sId} failed to fetch ${section} org public key: ${message}`);
345783
+ }
345784
+ for (const secret of sectionSecrets) {
345785
+ await provisionOrgSecret(entity, section, secret, preFetchedKey);
345786
+ }
345787
+ }
345788
+ }
345789
+ async function fetchOrgPublicKey(entity, section) {
345790
+ return (await entity.runWithGithubProvider(async () => {
345791
+ return await github["default"].encryption.getOrgPublicKey(entity.cr.spec.org, section);
345792
+ }));
345793
+ }
345794
+ async function provisionOrgSecret(entity, section, secret, preFetchedKey) {
345795
+ gh_provisioner_src_logger.info(`[gh-provisioner] provisioning org secret ${entity.k8sId}/${section}/${secret.name}`);
345796
+ if (process.env['AVOID_PROVIDER_SECRET_ENCRYPTION']) {
345797
+ await secrets_createUnencryptedSecret(entity, section, secret);
345798
+ }
345799
+ else {
345800
+ await secrets_createEncryptedSecret(entity, section, secret, preFetchedKey);
345801
+ }
345802
+ gh_provisioner_src_logger.info(`[gh-provisioner] org secret provisioned ${section}/${secret.name}`);
345803
+ }
345804
+ async function secrets_createEncryptedSecret(entity, section, secret, preFetchedKey) {
345805
+ const plainSecret = base_Entity.refResolver(secret.ref);
345806
+ const plainTextSecret = plainSecret.getOutput(secret.ref.key);
345807
+ const plaintextSha256 = external_crypto_default().createHash('sha256')
345808
+ .update(plainTextSecret)
345809
+ .digest('hex');
345810
+ const { encrypted_value } = (await entity.runWithGithubProvider(async () => {
345811
+ return await github["default"].encryption.encryptOrgSecret(entity.cr.spec.org, section, plainTextSecret, preFetchedKey);
345812
+ }));
345813
+ entity.patchData({
345814
+ op: PatchOperations.add,
345815
+ path: `/config/${section}/${secret.name}`,
345816
+ value: {
345817
+ value: encrypted_value,
345818
+ visibility: secret.visibility || 'all',
345819
+ ...(secret.selectedRepositories && secret.selectedRepositories.length > 0
345820
+ ? { selected_repositories: secret.selectedRepositories }
345821
+ : {}),
345822
+ },
345823
+ });
345824
+ entity.patchData({
345825
+ op: PatchOperations.add,
345826
+ path: `/config/${section}_sha256/${secret.name}`,
345827
+ value: plaintextSha256,
345828
+ });
345829
+ }
345830
+ async function secrets_createUnencryptedSecret(entity, section, secret) {
345831
+ const plainSecret = base_Entity.refResolver(secret.ref);
345832
+ const plainTextSecret = plainSecret.getOutput(secret.ref.key);
345833
+ const plaintextSha256 = external_crypto_default().createHash('sha256')
345834
+ .update(plainTextSecret)
345835
+ .digest('hex');
345836
+ entity.patchData({
345837
+ op: PatchOperations.add,
345838
+ path: `/config/${section}/${secret.name}`,
345839
+ value: {
345840
+ value: plainTextSecret,
345841
+ visibility: secret.visibility || 'all',
345842
+ ...(secret.selectedRepositories && secret.selectedRepositories.length > 0
345843
+ ? { selected_repositories: secret.selectedRepositories }
345844
+ : {}),
345845
+ },
345846
+ });
345847
+ entity.patchData({
345848
+ op: PatchOperations.add,
345849
+ path: `/config/${section}_sha256/${secret.name}`,
345850
+ value: plaintextSha256,
345851
+ });
345852
+ }
345853
+ async function adoptSecretsIfNeeded(entity, secrets) {
345854
+ const managedSecrets = entity.cr.fResolveSelfOutputs('managed_secrets') || [];
345855
+ for (const section of secrets_SECTIONS) {
345856
+ const sectionSecrets = secrets[section] || [];
345857
+ if (sectionSecrets.length === 0)
345858
+ continue;
345859
+ const declaredNames = sectionSecrets.map((s) => s.name);
345860
+ const newToModule = declaredNames.filter((name) => !managedSecrets.includes(name));
345861
+ if (newToModule.length === 0) {
345862
+ gh_provisioner_src_logger.debug(`[gh-provisioner] ${entity.k8sId} all declared ${section} secrets are already managed`);
345863
+ continue;
345864
+ }
345865
+ if (managedSecrets.length === 0) {
345866
+ 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`);
345867
+ }
345868
+ for (const secretName of newToModule) {
345869
+ try {
345870
+ const existing = (await entity.runWithGithubProvider(async () => {
345871
+ return await github["default"].encryption.getOrgSecret(entity.cr.spec.org, section, secretName);
345872
+ }));
345873
+ if (existing) {
345874
+ gh_provisioner_src_logger.info(`[gh-provisioner] ${entity.k8sId} adopting pre-existing ${section} secret '${secretName}' on GitHub org '${entity.cr.spec.org}'`);
345875
+ const resourceType = `github_${section}_organization_secret`;
345876
+ entity.patchImportData({
345877
+ op: PatchOperations.add,
345878
+ path: '/imports/-',
345879
+ value: {
345880
+ to: `${resourceType}.this["${secretName}"]`,
345881
+ id: secretName,
345882
+ },
345883
+ });
345884
+ const secretEntry = sectionSecrets.find((s) => s.name === secretName);
345885
+ if (secretEntry &&
345886
+ secretEntry.visibility === 'selected' &&
345887
+ (section === 'actions' || section === 'dependabot')) {
345888
+ const bindingType = `github_${section}_organization_secret_repositories`;
345889
+ entity.patchImportData({
345890
+ op: PatchOperations.add,
345891
+ path: '/imports/-',
345892
+ value: {
345893
+ to: `${bindingType}.this["${secretName}"]`,
345894
+ id: secretName,
345895
+ },
345896
+ });
345897
+ }
345898
+ }
345899
+ }
345900
+ catch (err) {
345901
+ if (err && err.status === 404) {
345902
+ 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`);
345903
+ }
345904
+ else if (err && (err.status === 401 || err.status === 403)) {
345905
+ 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`);
345906
+ }
345907
+ else {
345908
+ 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)}`);
345909
+ }
345910
+ }
345911
+ }
345912
+ }
345913
+ }
345914
+
345915
+ ;// CONCATENATED MODULE: ../gh_provisioner/src/entities/ghorgsecretsection/index.ts
345916
+
345917
+
345918
+
345919
+ class EntityGHOrgSecretSection extends base_Entity {
345920
+ constructor(artifact) {
345921
+ super(artifact, {
345922
+ config: {
345923
+ org: '',
345924
+ actions: {},
345925
+ codespaces: {},
345926
+ dependabot: {},
345927
+ actions_sha256: {},
345928
+ codespaces_sha256: {},
345929
+ dependabot_sha256: {},
345930
+ },
345931
+ });
345932
+ }
345933
+ async loadResources(tfOp) {
345934
+ gh_provisioner_src_logger.info(`[gh-provisioner] running ${tfOp} on ${this.k8sId}`);
345935
+ try {
345936
+ const cr = this.cr;
345937
+ const org = cr.spec.org;
345938
+ const secrets = cr.spec.secrets || {};
345939
+ this.patchData({
345940
+ op: PatchOperations.replace,
345941
+ path: '/config/org',
345942
+ value: org,
345943
+ });
345944
+ await provisionOrgSecrets(this, secrets);
345945
+ const redactedDoc = JSON.parse(JSON.stringify(this._document, (key, value) => typeof value === 'string' && value.length > 50 ? '[REDACTED]' : value));
345946
+ this.synthMessage(`[gh-provisioner] ${this.k8sId} config:\n${JSON.stringify(redactedDoc, null, 2)}`);
345947
+ this.synthEnd(`[gh-provisioner] ${this.k8sId} loaded its data`);
345948
+ if (tfOp === 'apply') {
345949
+ await adoptSecretsIfNeeded(this, secrets);
345950
+ }
345951
+ gh_provisioner_src_logger.debug(`[gh-provisioner] ${this.k8sId} loaded its data`);
345952
+ }
345953
+ catch (err) {
345954
+ const message = err instanceof Error ? err.message : String(err);
345955
+ gh_provisioner_src_logger.error(`[gh-provisioner] ${this.k8sId} error loading resources: ${message}`);
345956
+ throw new Error(`[gh-provisioner] ${this.k8sId} error loading resources: ${message}`);
345957
+ }
345958
+ }
345959
+ async postProvision(_tfOp) { }
345960
+ async loadAddressesToImport() { }
345961
+ }
345962
+
344957
345963
  ;// CONCATENATED MODULE: ../gh_provisioner/src/entities/ghorgwebhook/index.ts
344958
345964
 
344959
345965
 
@@ -345031,6 +346037,7 @@ class EntityGHOrgWebHook extends base_Entity {
345031
346037
 
345032
346038
 
345033
346039
 
346040
+
345034
346041
  function entities_getEntity(cr) {
345035
346042
  const entityClass = getEntityClass(cr.kind);
345036
346043
  return new entityClass(cr);
@@ -345053,6 +346060,8 @@ function getEntityClass(kind) {
345053
346060
  return EntityGHOrgSettings;
345054
346061
  case 'FirestartrGithubOrganizationVariableSection':
345055
346062
  return EntityGHOrgVarsSection;
346063
+ case 'FirestartrGithubOrganizationSecretSection':
346064
+ return EntityGHOrgSecretSection;
345056
346065
  default:
345057
346066
  throw new Error(`kind ${kind} has no entity associated`);
345058
346067
  }
@@ -346802,6 +347811,7 @@ const provisionImplementations = {
346802
347811
  githuborgwebhooks: process_operation_processOperation,
346803
347812
  githuborganizationsettings: process_operation_processOperation,
346804
347813
  githuborganizationvariablesections: process_operation_processOperation,
347814
+ githuborganizationsecretsections: process_operation_processOperation,
346805
347815
  fsdummiesa: processFirestartrDummies,
346806
347816
  fsdummiesb: processFirestartrDummies,
346807
347817
  fsdummiesc: processFirestartrDummies,
@@ -525620,7 +526630,7 @@ const crsStatusSubcommand = {
525620
526630
  };
525621
526631
 
525622
526632
  ;// CONCATENATED MODULE: ./package.json
525623
- const package_namespaceObject = JSON.parse('{"i8":"2.11.0-snapshot-objects-in-patches"}');
526633
+ const package_namespaceObject = JSON.parse('{"i8":"2.11.0-snapshot-orgsettings-nullguard-1"}');
525624
526634
  ;// CONCATENATED MODULE: ../../package.json
525625
526635
  const package_namespaceObject_1 = {"i8":"2.10.0"};
525626
526636
  // EXTERNAL MODULE: ../../node_modules/semver/index.js