@firestartr/cli 1.51.1-snapshot-05 → 1.52.0-snapshot-0
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 +997 -80
- package/build/packages/cdk8s_renderer/imports/firestartr.dev.d.ts +424 -0
- package/build/packages/cdk8s_renderer/src/charts/github/RepoSecretsSectionChart.d.ts +11 -0
- package/build/packages/cdk8s_renderer/src/charts/github/repositoryChart.d.ts +1 -0
- package/build/packages/cdk8s_renderer/src/claims/base/schemas/index.d.ts +4 -0
- package/build/packages/cdk8s_renderer/src/claims/tfworkspaces/index.d.ts +4 -0
- package/build/packages/cdk8s_renderer/src/claims/tfworkspaces/terraform.schema.d.ts +4 -0
- package/build/packages/operator/src/informer.d.ts +1 -0
- package/build/packages/operator/src/processItem.debug.d.ts +2 -0
- package/build/packages/operator/src/status.d.ts +2 -0
- package/build/packages/operator/src/syncCtl.d.ts +31 -0
- package/build/packages/operator/src/syncer.d.ts +6 -2
- package/build/packages/operator/src/syncer.debug.d.ts +2 -0
- package/build/packages/provisioner/src/entities/firestartrgithubrepositorysecretssection/FirestartrGithubRepositorySecretsSection.d.ts +8 -0
- package/build/packages/provisioner/src/entities/firestartrgithubrepositorysecretssection/helpers/RepositorySecret.d.ts +3 -0
- package/build/packages/provisioner/src/resources/github_repository_secrets_section/index.d.ts +5 -0
- package/build/packages/provisioner/src/resources/index.d.ts +2 -0
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -346931,6 +346931,7 @@ const DEFAULT_TIME_ZONE = 'Europe/Madrid';
|
|
|
346931
346931
|
function validateCron(cronLine, tz = DEFAULT_TIME_ZONE) {
|
|
346932
346932
|
try {
|
|
346933
346933
|
const interval = cron_parser_dist.CronExpressionParser.parse(cronLine, {
|
|
346934
|
+
// to enable the only minutes cron
|
|
346934
346935
|
strict: false,
|
|
346935
346936
|
tz,
|
|
346936
346937
|
});
|
|
@@ -355661,6 +355662,10 @@ InitializerClaimRef.applicableKinds = [
|
|
|
355661
355662
|
];
|
|
355662
355663
|
|
|
355663
355664
|
|
|
355665
|
+
;// CONCATENATED MODULE: ../cdk8s_renderer/src/logger.ts
|
|
355666
|
+
|
|
355667
|
+
/* harmony default export */ const cdk8s_renderer_src_logger = (catalog_common.logger);
|
|
355668
|
+
|
|
355664
355669
|
;// CONCATENATED MODULE: ../cdk8s_renderer/src/refresolver/index.ts
|
|
355665
355670
|
/**
|
|
355666
355671
|
* renderedClaims is a map of rendered claims
|
|
@@ -355669,8 +355674,10 @@ InitializerClaimRef.applicableKinds = [
|
|
|
355669
355674
|
* and the value is the rendered CR
|
|
355670
355675
|
*/
|
|
355671
355676
|
let renderedClaims = {};
|
|
355677
|
+
|
|
355672
355678
|
function setRenderedClaim(claim, cr) {
|
|
355673
355679
|
const claimKey = `${claim.kind}-${claim.name}`;
|
|
355680
|
+
cdk8s_renderer_src_logger.silly(`Set rendered claim with key ${claimKey}`);
|
|
355674
355681
|
if (renderedClaims[claimKey]) {
|
|
355675
355682
|
throw new Error(`Claim ${claimKey} already rendered`);
|
|
355676
355683
|
}
|
|
@@ -357181,10 +357188,6 @@ const NORMALIZERS = [
|
|
|
357181
357188
|
RevisionNormalizer,
|
|
357182
357189
|
];
|
|
357183
357190
|
|
|
357184
|
-
;// CONCATENATED MODULE: ../cdk8s_renderer/src/logger.ts
|
|
357185
|
-
|
|
357186
|
-
/* harmony default export */ const cdk8s_renderer_src_logger = (catalog_common.logger);
|
|
357187
|
-
|
|
357188
357191
|
;// CONCATENATED MODULE: ../cdk8s_renderer/src/refsSorter/refsExtractor.ts
|
|
357189
357192
|
|
|
357190
357193
|
|
|
@@ -358186,7 +358189,11 @@ const GithubSchemas = [
|
|
|
358186
358189
|
schedule_timezone: {
|
|
358187
358190
|
type: 'string',
|
|
358188
358191
|
},
|
|
358192
|
+
policy: {
|
|
358193
|
+
type: 'string',
|
|
358194
|
+
},
|
|
358189
358195
|
},
|
|
358196
|
+
additionalProperties: false,
|
|
358190
358197
|
required: ['enabled'],
|
|
358191
358198
|
oneOf: [
|
|
358192
358199
|
{
|
|
@@ -360904,6 +360911,7 @@ const KINDS_CR_MAP = {
|
|
|
360904
360911
|
user: 'FirestartrGithubMembership',
|
|
360905
360912
|
repo: 'FirestartrGithubRepository',
|
|
360906
360913
|
feat: 'FirestartrGithubRepositoryFeature',
|
|
360914
|
+
secretsSection: 'FirestartrGithubRepositorySecretsSection',
|
|
360907
360915
|
};
|
|
360908
360916
|
|
|
360909
360917
|
|
|
@@ -362649,6 +362657,361 @@ var FirestartrGithubRepositoryFeatureSpecContextProviderRefKind;
|
|
|
362649
362657
|
/** FirestartrProviderConfig */
|
|
362650
362658
|
FirestartrGithubRepositoryFeatureSpecContextProviderRefKind["FIRESTARTR_PROVIDER_CONFIG"] = "FirestartrProviderConfig";
|
|
362651
362659
|
})(FirestartrGithubRepositoryFeatureSpecContextProviderRefKind || (FirestartrGithubRepositoryFeatureSpecContextProviderRefKind = {}));
|
|
362660
|
+
/**
|
|
362661
|
+
*
|
|
362662
|
+
*
|
|
362663
|
+
* @schema FirestartrGithubRepositorySecretsSection
|
|
362664
|
+
*/
|
|
362665
|
+
class FirestartrGithubRepositorySecretsSection extends lib.ApiObject {
|
|
362666
|
+
/**
|
|
362667
|
+
* Renders a Kubernetes manifest for "FirestartrGithubRepositorySecretsSection".
|
|
362668
|
+
*
|
|
362669
|
+
* This can be used to inline resource manifests inside other objects (e.g. as templates).
|
|
362670
|
+
*
|
|
362671
|
+
* @param props initialization props
|
|
362672
|
+
*/
|
|
362673
|
+
static manifest(props = {}) {
|
|
362674
|
+
return {
|
|
362675
|
+
...FirestartrGithubRepositorySecretsSection.GVK,
|
|
362676
|
+
...toJson_FirestartrGithubRepositorySecretsSectionProps(props),
|
|
362677
|
+
};
|
|
362678
|
+
}
|
|
362679
|
+
/**
|
|
362680
|
+
* Defines a "FirestartrGithubRepositorySecretsSection" API object
|
|
362681
|
+
* @param scope the scope in which to define this object
|
|
362682
|
+
* @param id a scope-local name for the object
|
|
362683
|
+
* @param props initialization props
|
|
362684
|
+
*/
|
|
362685
|
+
constructor(scope, id, props = {}) {
|
|
362686
|
+
super(scope, id, {
|
|
362687
|
+
...FirestartrGithubRepositorySecretsSection.GVK,
|
|
362688
|
+
...props,
|
|
362689
|
+
});
|
|
362690
|
+
}
|
|
362691
|
+
/**
|
|
362692
|
+
* Renders the object to Kubernetes JSON.
|
|
362693
|
+
*/
|
|
362694
|
+
toJson() {
|
|
362695
|
+
const resolved = super.toJson();
|
|
362696
|
+
return {
|
|
362697
|
+
...FirestartrGithubRepositorySecretsSection.GVK,
|
|
362698
|
+
...toJson_FirestartrGithubRepositorySecretsSectionProps(resolved),
|
|
362699
|
+
};
|
|
362700
|
+
}
|
|
362701
|
+
}
|
|
362702
|
+
/**
|
|
362703
|
+
* Returns the apiVersion and kind for "FirestartrGithubRepositorySecretsSection"
|
|
362704
|
+
*/
|
|
362705
|
+
FirestartrGithubRepositorySecretsSection.GVK = {
|
|
362706
|
+
apiVersion: 'firestartr.dev/v1',
|
|
362707
|
+
kind: 'FirestartrGithubRepositorySecretsSection',
|
|
362708
|
+
};
|
|
362709
|
+
|
|
362710
|
+
/**
|
|
362711
|
+
* Converts an object of type 'FirestartrGithubRepositorySecretsSectionProps' to JSON representation.
|
|
362712
|
+
*/
|
|
362713
|
+
/* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
|
|
362714
|
+
function toJson_FirestartrGithubRepositorySecretsSectionProps(obj) {
|
|
362715
|
+
if (obj === undefined) {
|
|
362716
|
+
return undefined;
|
|
362717
|
+
}
|
|
362718
|
+
const result = {
|
|
362719
|
+
'metadata': obj.metadata,
|
|
362720
|
+
'spec': toJson_FirestartrGithubRepositorySecretsSectionSpec(obj.spec),
|
|
362721
|
+
};
|
|
362722
|
+
// filter undefined values
|
|
362723
|
+
return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
|
|
362724
|
+
}
|
|
362725
|
+
/**
|
|
362726
|
+
* Converts an object of type 'FirestartrGithubRepositorySecretsSectionSpec' to JSON representation.
|
|
362727
|
+
*/
|
|
362728
|
+
/* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
|
|
362729
|
+
function toJson_FirestartrGithubRepositorySecretsSectionSpec(obj) {
|
|
362730
|
+
if (obj === undefined) {
|
|
362731
|
+
return undefined;
|
|
362732
|
+
}
|
|
362733
|
+
const result = {
|
|
362734
|
+
'firestartr': toJson_FirestartrGithubRepositorySecretsSectionSpecFirestartr(obj.firestartr),
|
|
362735
|
+
'repositoryTarget': toJson_FirestartrGithubRepositorySecretsSectionSpecRepositoryTarget(obj.repositoryTarget),
|
|
362736
|
+
'secrets': toJson_FirestartrGithubRepositorySecretsSectionSpecSecrets(obj.secrets),
|
|
362737
|
+
'context': toJson_FirestartrGithubRepositorySecretsSectionSpecContext(obj.context),
|
|
362738
|
+
};
|
|
362739
|
+
// filter undefined values
|
|
362740
|
+
return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
|
|
362741
|
+
}
|
|
362742
|
+
/**
|
|
362743
|
+
* Converts an object of type 'FirestartrGithubRepositorySecretsSectionSpecFirestartr' to JSON representation.
|
|
362744
|
+
*/
|
|
362745
|
+
/* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
|
|
362746
|
+
function toJson_FirestartrGithubRepositorySecretsSectionSpecFirestartr(obj) {
|
|
362747
|
+
if (obj === undefined) {
|
|
362748
|
+
return undefined;
|
|
362749
|
+
}
|
|
362750
|
+
const result = {
|
|
362751
|
+
'tfStateKey': obj.tfStateKey,
|
|
362752
|
+
};
|
|
362753
|
+
// filter undefined values
|
|
362754
|
+
return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
|
|
362755
|
+
}
|
|
362756
|
+
/**
|
|
362757
|
+
* Converts an object of type 'FirestartrGithubRepositorySecretsSectionSpecRepositoryTarget' to JSON representation.
|
|
362758
|
+
*/
|
|
362759
|
+
/* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
|
|
362760
|
+
function toJson_FirestartrGithubRepositorySecretsSectionSpecRepositoryTarget(obj) {
|
|
362761
|
+
if (obj === undefined) {
|
|
362762
|
+
return undefined;
|
|
362763
|
+
}
|
|
362764
|
+
const result = {
|
|
362765
|
+
'ref': toJson_FirestartrGithubRepositorySecretsSectionSpecRepositoryTargetRef(obj.ref),
|
|
362766
|
+
};
|
|
362767
|
+
// filter undefined values
|
|
362768
|
+
return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
|
|
362769
|
+
}
|
|
362770
|
+
/**
|
|
362771
|
+
* Converts an object of type 'FirestartrGithubRepositorySecretsSectionSpecSecrets' to JSON representation.
|
|
362772
|
+
*/
|
|
362773
|
+
/* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
|
|
362774
|
+
function toJson_FirestartrGithubRepositorySecretsSectionSpecSecrets(obj) {
|
|
362775
|
+
if (obj === undefined) {
|
|
362776
|
+
return undefined;
|
|
362777
|
+
}
|
|
362778
|
+
const result = {
|
|
362779
|
+
'actions': obj.actions?.map(y => toJson_FirestartrGithubRepositorySecretsSectionSpecSecretsActions(y)),
|
|
362780
|
+
'codespaces': obj.codespaces?.map(y => toJson_FirestartrGithubRepositorySecretsSectionSpecSecretsCodespaces(y)),
|
|
362781
|
+
'copilot': obj.copilot?.map(y => toJson_FirestartrGithubRepositorySecretsSectionSpecSecretsCopilot(y)),
|
|
362782
|
+
};
|
|
362783
|
+
// filter undefined values
|
|
362784
|
+
return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
|
|
362785
|
+
}
|
|
362786
|
+
/**
|
|
362787
|
+
* Converts an object of type 'FirestartrGithubRepositorySecretsSectionSpecContext' to JSON representation.
|
|
362788
|
+
*/
|
|
362789
|
+
/* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
|
|
362790
|
+
function toJson_FirestartrGithubRepositorySecretsSectionSpecContext(obj) {
|
|
362791
|
+
if (obj === undefined) {
|
|
362792
|
+
return undefined;
|
|
362793
|
+
}
|
|
362794
|
+
const result = {
|
|
362795
|
+
'provider': toJson_FirestartrGithubRepositorySecretsSectionSpecContextProvider(obj.provider),
|
|
362796
|
+
'backend': toJson_FirestartrGithubRepositorySecretsSectionSpecContextBackend(obj.backend),
|
|
362797
|
+
};
|
|
362798
|
+
// filter undefined values
|
|
362799
|
+
return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
|
|
362800
|
+
}
|
|
362801
|
+
/**
|
|
362802
|
+
* Converts an object of type 'FirestartrGithubRepositorySecretsSectionSpecRepositoryTargetRef' to JSON representation.
|
|
362803
|
+
*/
|
|
362804
|
+
/* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
|
|
362805
|
+
function toJson_FirestartrGithubRepositorySecretsSectionSpecRepositoryTargetRef(obj) {
|
|
362806
|
+
if (obj === undefined) {
|
|
362807
|
+
return undefined;
|
|
362808
|
+
}
|
|
362809
|
+
const result = {
|
|
362810
|
+
'kind': obj.kind,
|
|
362811
|
+
'name': obj.name,
|
|
362812
|
+
'needsSecret': obj.needsSecret,
|
|
362813
|
+
};
|
|
362814
|
+
// filter undefined values
|
|
362815
|
+
return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
|
|
362816
|
+
}
|
|
362817
|
+
/**
|
|
362818
|
+
* Converts an object of type 'FirestartrGithubRepositorySecretsSectionSpecSecretsActions' to JSON representation.
|
|
362819
|
+
*/
|
|
362820
|
+
/* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
|
|
362821
|
+
function toJson_FirestartrGithubRepositorySecretsSectionSpecSecretsActions(obj) {
|
|
362822
|
+
if (obj === undefined) {
|
|
362823
|
+
return undefined;
|
|
362824
|
+
}
|
|
362825
|
+
const result = {
|
|
362826
|
+
'name': obj.name,
|
|
362827
|
+
'ref': toJson_FirestartrGithubRepositorySecretsSectionSpecSecretsActionsRef(obj.ref),
|
|
362828
|
+
};
|
|
362829
|
+
// filter undefined values
|
|
362830
|
+
return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
|
|
362831
|
+
}
|
|
362832
|
+
/**
|
|
362833
|
+
* Converts an object of type 'FirestartrGithubRepositorySecretsSectionSpecSecretsCodespaces' to JSON representation.
|
|
362834
|
+
*/
|
|
362835
|
+
/* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
|
|
362836
|
+
function toJson_FirestartrGithubRepositorySecretsSectionSpecSecretsCodespaces(obj) {
|
|
362837
|
+
if (obj === undefined) {
|
|
362838
|
+
return undefined;
|
|
362839
|
+
}
|
|
362840
|
+
const result = {
|
|
362841
|
+
'name': obj.name,
|
|
362842
|
+
'ref': toJson_FirestartrGithubRepositorySecretsSectionSpecSecretsCodespacesRef(obj.ref),
|
|
362843
|
+
};
|
|
362844
|
+
// filter undefined values
|
|
362845
|
+
return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
|
|
362846
|
+
}
|
|
362847
|
+
/**
|
|
362848
|
+
* Converts an object of type 'FirestartrGithubRepositorySecretsSectionSpecSecretsCopilot' to JSON representation.
|
|
362849
|
+
*/
|
|
362850
|
+
/* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
|
|
362851
|
+
function toJson_FirestartrGithubRepositorySecretsSectionSpecSecretsCopilot(obj) {
|
|
362852
|
+
if (obj === undefined) {
|
|
362853
|
+
return undefined;
|
|
362854
|
+
}
|
|
362855
|
+
const result = {
|
|
362856
|
+
'name': obj.name,
|
|
362857
|
+
'ref': toJson_FirestartrGithubRepositorySecretsSectionSpecSecretsCopilotRef(obj.ref),
|
|
362858
|
+
};
|
|
362859
|
+
// filter undefined values
|
|
362860
|
+
return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
|
|
362861
|
+
}
|
|
362862
|
+
/**
|
|
362863
|
+
* Converts an object of type 'FirestartrGithubRepositorySecretsSectionSpecContextProvider' to JSON representation.
|
|
362864
|
+
*/
|
|
362865
|
+
/* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
|
|
362866
|
+
function toJson_FirestartrGithubRepositorySecretsSectionSpecContextProvider(obj) {
|
|
362867
|
+
if (obj === undefined) {
|
|
362868
|
+
return undefined;
|
|
362869
|
+
}
|
|
362870
|
+
const result = {
|
|
362871
|
+
'ref': toJson_FirestartrGithubRepositorySecretsSectionSpecContextProviderRef(obj.ref),
|
|
362872
|
+
};
|
|
362873
|
+
// filter undefined values
|
|
362874
|
+
return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
|
|
362875
|
+
}
|
|
362876
|
+
/**
|
|
362877
|
+
* Converts an object of type 'FirestartrGithubRepositorySecretsSectionSpecContextBackend' to JSON representation.
|
|
362878
|
+
*/
|
|
362879
|
+
/* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
|
|
362880
|
+
function toJson_FirestartrGithubRepositorySecretsSectionSpecContextBackend(obj) {
|
|
362881
|
+
if (obj === undefined) {
|
|
362882
|
+
return undefined;
|
|
362883
|
+
}
|
|
362884
|
+
const result = {
|
|
362885
|
+
'ref': toJson_FirestartrGithubRepositorySecretsSectionSpecContextBackendRef(obj.ref),
|
|
362886
|
+
};
|
|
362887
|
+
// filter undefined values
|
|
362888
|
+
return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
|
|
362889
|
+
}
|
|
362890
|
+
/**
|
|
362891
|
+
* Converts an object of type 'FirestartrGithubRepositorySecretsSectionSpecSecretsActionsRef' to JSON representation.
|
|
362892
|
+
*/
|
|
362893
|
+
/* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
|
|
362894
|
+
function toJson_FirestartrGithubRepositorySecretsSectionSpecSecretsActionsRef(obj) {
|
|
362895
|
+
if (obj === undefined) {
|
|
362896
|
+
return undefined;
|
|
362897
|
+
}
|
|
362898
|
+
const result = {
|
|
362899
|
+
'kind': obj.kind,
|
|
362900
|
+
'name': obj.name,
|
|
362901
|
+
'key': obj.key,
|
|
362902
|
+
};
|
|
362903
|
+
// filter undefined values
|
|
362904
|
+
return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
|
|
362905
|
+
}
|
|
362906
|
+
/**
|
|
362907
|
+
* Converts an object of type 'FirestartrGithubRepositorySecretsSectionSpecSecretsCodespacesRef' to JSON representation.
|
|
362908
|
+
*/
|
|
362909
|
+
/* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
|
|
362910
|
+
function toJson_FirestartrGithubRepositorySecretsSectionSpecSecretsCodespacesRef(obj) {
|
|
362911
|
+
if (obj === undefined) {
|
|
362912
|
+
return undefined;
|
|
362913
|
+
}
|
|
362914
|
+
const result = {
|
|
362915
|
+
'kind': obj.kind,
|
|
362916
|
+
'name': obj.name,
|
|
362917
|
+
'key': obj.key,
|
|
362918
|
+
};
|
|
362919
|
+
// filter undefined values
|
|
362920
|
+
return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
|
|
362921
|
+
}
|
|
362922
|
+
/**
|
|
362923
|
+
* Converts an object of type 'FirestartrGithubRepositorySecretsSectionSpecSecretsCopilotRef' to JSON representation.
|
|
362924
|
+
*/
|
|
362925
|
+
/* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
|
|
362926
|
+
function toJson_FirestartrGithubRepositorySecretsSectionSpecSecretsCopilotRef(obj) {
|
|
362927
|
+
if (obj === undefined) {
|
|
362928
|
+
return undefined;
|
|
362929
|
+
}
|
|
362930
|
+
const result = {
|
|
362931
|
+
'kind': obj.kind,
|
|
362932
|
+
'name': obj.name,
|
|
362933
|
+
'key': obj.key,
|
|
362934
|
+
};
|
|
362935
|
+
// filter undefined values
|
|
362936
|
+
return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
|
|
362937
|
+
}
|
|
362938
|
+
/**
|
|
362939
|
+
* Converts an object of type 'FirestartrGithubRepositorySecretsSectionSpecContextProviderRef' to JSON representation.
|
|
362940
|
+
*/
|
|
362941
|
+
/* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
|
|
362942
|
+
function toJson_FirestartrGithubRepositorySecretsSectionSpecContextProviderRef(obj) {
|
|
362943
|
+
if (obj === undefined) {
|
|
362944
|
+
return undefined;
|
|
362945
|
+
}
|
|
362946
|
+
const result = {
|
|
362947
|
+
'kind': obj.kind,
|
|
362948
|
+
'name': obj.name,
|
|
362949
|
+
};
|
|
362950
|
+
// filter undefined values
|
|
362951
|
+
return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
|
|
362952
|
+
}
|
|
362953
|
+
/**
|
|
362954
|
+
* Converts an object of type 'FirestartrGithubRepositorySecretsSectionSpecContextBackendRef' to JSON representation.
|
|
362955
|
+
*/
|
|
362956
|
+
/* eslint-disable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
|
|
362957
|
+
function toJson_FirestartrGithubRepositorySecretsSectionSpecContextBackendRef(obj) {
|
|
362958
|
+
if (obj === undefined) {
|
|
362959
|
+
return undefined;
|
|
362960
|
+
}
|
|
362961
|
+
const result = {
|
|
362962
|
+
'kind': obj.kind,
|
|
362963
|
+
'name': obj.name,
|
|
362964
|
+
};
|
|
362965
|
+
// filter undefined values
|
|
362966
|
+
return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
|
|
362967
|
+
}
|
|
362968
|
+
/* eslint-enable max-len, @stylistic/max-len, quote-props, @stylistic/quote-props */
|
|
362969
|
+
/**
|
|
362970
|
+
* The type of Kubernetes resource to reference.
|
|
362971
|
+
*
|
|
362972
|
+
* @schema FirestartrGithubRepositorySecretsSectionSpecSecretsActionsRefKind
|
|
362973
|
+
*/
|
|
362974
|
+
var FirestartrGithubRepositorySecretsSectionSpecSecretsActionsRefKind;
|
|
362975
|
+
(function (FirestartrGithubRepositorySecretsSectionSpecSecretsActionsRefKind) {
|
|
362976
|
+
/** Secret */
|
|
362977
|
+
FirestartrGithubRepositorySecretsSectionSpecSecretsActionsRefKind["SECRET"] = "Secret";
|
|
362978
|
+
})(FirestartrGithubRepositorySecretsSectionSpecSecretsActionsRefKind || (FirestartrGithubRepositorySecretsSectionSpecSecretsActionsRefKind = {}));
|
|
362979
|
+
/**
|
|
362980
|
+
* The type of Kubernetes resource to reference.
|
|
362981
|
+
*
|
|
362982
|
+
* @schema FirestartrGithubRepositorySecretsSectionSpecSecretsCodespacesRefKind
|
|
362983
|
+
*/
|
|
362984
|
+
var FirestartrGithubRepositorySecretsSectionSpecSecretsCodespacesRefKind;
|
|
362985
|
+
(function (FirestartrGithubRepositorySecretsSectionSpecSecretsCodespacesRefKind) {
|
|
362986
|
+
/** Secret */
|
|
362987
|
+
FirestartrGithubRepositorySecretsSectionSpecSecretsCodespacesRefKind["SECRET"] = "Secret";
|
|
362988
|
+
})(FirestartrGithubRepositorySecretsSectionSpecSecretsCodespacesRefKind || (FirestartrGithubRepositorySecretsSectionSpecSecretsCodespacesRefKind = {}));
|
|
362989
|
+
/**
|
|
362990
|
+
* The type of Kubernetes resource to reference.
|
|
362991
|
+
*
|
|
362992
|
+
* @schema FirestartrGithubRepositorySecretsSectionSpecSecretsCopilotRefKind
|
|
362993
|
+
*/
|
|
362994
|
+
var FirestartrGithubRepositorySecretsSectionSpecSecretsCopilotRefKind;
|
|
362995
|
+
(function (FirestartrGithubRepositorySecretsSectionSpecSecretsCopilotRefKind) {
|
|
362996
|
+
/** Secret */
|
|
362997
|
+
FirestartrGithubRepositorySecretsSectionSpecSecretsCopilotRefKind["SECRET"] = "Secret";
|
|
362998
|
+
})(FirestartrGithubRepositorySecretsSectionSpecSecretsCopilotRefKind || (FirestartrGithubRepositorySecretsSectionSpecSecretsCopilotRefKind = {}));
|
|
362999
|
+
/**
|
|
363000
|
+
* @schema FirestartrGithubRepositorySecretsSectionSpecContextProviderRefKind
|
|
363001
|
+
*/
|
|
363002
|
+
var FirestartrGithubRepositorySecretsSectionSpecContextProviderRefKind;
|
|
363003
|
+
(function (FirestartrGithubRepositorySecretsSectionSpecContextProviderRefKind) {
|
|
363004
|
+
/** FirestartrProviderConfig */
|
|
363005
|
+
FirestartrGithubRepositorySecretsSectionSpecContextProviderRefKind["FIRESTARTR_PROVIDER_CONFIG"] = "FirestartrProviderConfig";
|
|
363006
|
+
})(FirestartrGithubRepositorySecretsSectionSpecContextProviderRefKind || (FirestartrGithubRepositorySecretsSectionSpecContextProviderRefKind = {}));
|
|
363007
|
+
/**
|
|
363008
|
+
* @schema FirestartrGithubRepositorySecretsSectionSpecContextBackendRefKind
|
|
363009
|
+
*/
|
|
363010
|
+
var FirestartrGithubRepositorySecretsSectionSpecContextBackendRefKind;
|
|
363011
|
+
(function (FirestartrGithubRepositorySecretsSectionSpecContextBackendRefKind) {
|
|
363012
|
+
/** FirestartrProviderConfig */
|
|
363013
|
+
FirestartrGithubRepositorySecretsSectionSpecContextBackendRefKind["FIRESTARTR_PROVIDER_CONFIG"] = "FirestartrProviderConfig";
|
|
363014
|
+
})(FirestartrGithubRepositorySecretsSectionSpecContextBackendRefKind || (FirestartrGithubRepositorySecretsSectionSpecContextBackendRefKind = {}));
|
|
362652
363015
|
/**
|
|
362653
363016
|
* A resource to handle backend and provider configuration.
|
|
362654
363017
|
*
|
|
@@ -363682,13 +364045,84 @@ class FeatureRepoChart extends BaseGithubChart {
|
|
|
363682
364045
|
name: this.get('repoCr').metadata.name,
|
|
363683
364046
|
needsSecret: false,
|
|
363684
364047
|
},
|
|
363685
|
-
branch: this.get('repoCr').spec.repo.defaultBranch,
|
|
364048
|
+
branch: this.get('repoCr').spec.repo.defaultBranch,
|
|
364049
|
+
};
|
|
364050
|
+
return repositoryTarget;
|
|
364051
|
+
}
|
|
364052
|
+
instanceApiObject(template) {
|
|
364053
|
+
return new FirestartrGithubRepositoryFeature(this, `${template.metadata.name}-${template.spec.firestartr.tfStateKey}-feature`, template);
|
|
364054
|
+
}
|
|
364055
|
+
}
|
|
364056
|
+
|
|
364057
|
+
;// CONCATENATED MODULE: ../cdk8s_renderer/src/charts/github/RepoSecretsSectionChart.ts
|
|
364058
|
+
|
|
364059
|
+
|
|
364060
|
+
class RepoSecretsSectionChart extends BaseGithubChart {
|
|
364061
|
+
constructor(scope, chartId, firestartrId, claim, patches = [], cr = null) {
|
|
364062
|
+
super(scope, chartId, firestartrId, claim, patches);
|
|
364063
|
+
this.set('repoCr', cr);
|
|
364064
|
+
}
|
|
364065
|
+
template() {
|
|
364066
|
+
const claim = this.get('claim');
|
|
364067
|
+
const repositoryTarget = this.resolveRepositoryTarget();
|
|
364068
|
+
const github = claim.providers?.github ?? {};
|
|
364069
|
+
const cr = {
|
|
364070
|
+
metadata: {
|
|
364071
|
+
name: this.get('repoCr').metadata.name,
|
|
364072
|
+
annotations: {
|
|
364073
|
+
'firestartr.dev/external-name': claim.name,
|
|
364074
|
+
},
|
|
364075
|
+
},
|
|
364076
|
+
spec: {
|
|
364077
|
+
context: claim.context,
|
|
364078
|
+
org: claim.org,
|
|
364079
|
+
repositoryTarget,
|
|
364080
|
+
secrets: {
|
|
364081
|
+
actions: this.renderSecrets('actions', github),
|
|
364082
|
+
codespaces: this.renderSecrets('codespaces', github),
|
|
364083
|
+
copilot: this.renderSecrets('copilot', github),
|
|
364084
|
+
},
|
|
364085
|
+
firestartr: {
|
|
364086
|
+
tfStateKey: this.get('repoCr').spec.firestartr.tfStateKey,
|
|
364087
|
+
},
|
|
364088
|
+
},
|
|
364089
|
+
};
|
|
364090
|
+
return cr;
|
|
364091
|
+
}
|
|
364092
|
+
renderSecrets(section, githubProvider) {
|
|
364093
|
+
const secrets = [];
|
|
364094
|
+
if (githubProvider?.secrets?.[section]) {
|
|
364095
|
+
const secretsSection = githubProvider.secrets[section];
|
|
364096
|
+
for (const secret of secretsSection) {
|
|
364097
|
+
const parts = secret.value.split(':');
|
|
364098
|
+
secrets.push({
|
|
364099
|
+
name: secret.name,
|
|
364100
|
+
ref: {
|
|
364101
|
+
kind: 'Secret',
|
|
364102
|
+
name: parts[2],
|
|
364103
|
+
key: parts[3],
|
|
364104
|
+
},
|
|
364105
|
+
});
|
|
364106
|
+
}
|
|
364107
|
+
}
|
|
364108
|
+
return secrets;
|
|
364109
|
+
}
|
|
364110
|
+
gvk() {
|
|
364111
|
+
return FirestartrGithubRepositorySecretsSection.GVK;
|
|
364112
|
+
}
|
|
364113
|
+
instanceApiObject(template) {
|
|
364114
|
+
return new FirestartrGithubRepositorySecretsSection(this, `${template.metadata.name}-${template.spec.firestartr.tfStateKey}-secrets-section`, template);
|
|
364115
|
+
}
|
|
364116
|
+
resolveRepositoryTarget() {
|
|
364117
|
+
const repositoryTarget = {
|
|
364118
|
+
ref: {
|
|
364119
|
+
kind: 'FirestartrGithubRepository',
|
|
364120
|
+
name: this.get('repoCr').metadata.name,
|
|
364121
|
+
needsSecret: false,
|
|
364122
|
+
},
|
|
363686
364123
|
};
|
|
363687
364124
|
return repositoryTarget;
|
|
363688
364125
|
}
|
|
363689
|
-
instanceApiObject(template) {
|
|
363690
|
-
return new FirestartrGithubRepositoryFeature(this, `${template.metadata.name}-${template.spec.firestartr.tfStateKey}-feature`, template);
|
|
363691
|
-
}
|
|
363692
364126
|
}
|
|
363693
364127
|
|
|
363694
364128
|
;// CONCATENATED MODULE: ../cdk8s_renderer/src/charts/github/repositoryChart.ts
|
|
@@ -363697,6 +364131,7 @@ class FeatureRepoChart extends BaseGithubChart {
|
|
|
363697
364131
|
|
|
363698
364132
|
|
|
363699
364133
|
|
|
364134
|
+
|
|
363700
364135
|
class GithubRepositoryChart extends BaseGithubChart {
|
|
363701
364136
|
template() {
|
|
363702
364137
|
const claim = this.get('claim');
|
|
@@ -363762,6 +364197,7 @@ class GithubRepositoryChart extends BaseGithubChart {
|
|
|
363762
364197
|
async render() {
|
|
363763
364198
|
await super.render();
|
|
363764
364199
|
await this.postRenderFeatures(this.get('rendered-cr'));
|
|
364200
|
+
await this.postRenderSecretsSection(this.get('rendered-cr'));
|
|
363765
364201
|
return this;
|
|
363766
364202
|
}
|
|
363767
364203
|
gvk() {
|
|
@@ -363783,6 +364219,20 @@ class GithubRepositoryChart extends BaseGithubChart {
|
|
|
363783
364219
|
}
|
|
363784
364220
|
this.set('features', features);
|
|
363785
364221
|
}
|
|
364222
|
+
async postRenderSecretsSection(cr) {
|
|
364223
|
+
const areThereSecrets = this.get('claim').providers?.github?.secrets ?? false;
|
|
364224
|
+
if (!areThereSecrets) {
|
|
364225
|
+
return;
|
|
364226
|
+
}
|
|
364227
|
+
const secretsSectionChart = await (await new RepoSecretsSectionChart(this, 'secrets-section', cr.spec.firestartr.tfStateKey, this.get('claim'), [], cr).render()).postRenderer([]);
|
|
364228
|
+
this.set('secrets_section', {
|
|
364229
|
+
claim: {
|
|
364230
|
+
kind: secretsSectionChart.kind,
|
|
364231
|
+
name: secretsSectionChart.name,
|
|
364232
|
+
},
|
|
364233
|
+
chart: secretsSectionChart,
|
|
364234
|
+
});
|
|
364235
|
+
}
|
|
363786
364236
|
instanceApiObject(template) {
|
|
363787
364237
|
return new FirestartrGithubRepository(this, template.metadata.name, template);
|
|
363788
364238
|
}
|
|
@@ -363887,7 +364337,10 @@ class GithubRepositoryChart extends BaseGithubChart {
|
|
|
363887
364337
|
});
|
|
363888
364338
|
}
|
|
363889
364339
|
extraCharts() {
|
|
363890
|
-
|
|
364340
|
+
const charts = [this.get('secrets_section') ?? undefined];
|
|
364341
|
+
return charts
|
|
364342
|
+
.concat(this.get('features') ?? [])
|
|
364343
|
+
.filter((chart) => chart);
|
|
363891
364344
|
}
|
|
363892
364345
|
}
|
|
363893
364346
|
|
|
@@ -366508,6 +366961,7 @@ const kindPluralMap = {
|
|
|
366508
366961
|
githubmemberships: 'FirestartrGithubMembership',
|
|
366509
366962
|
githubrepositories: 'FirestartrGithubRepository',
|
|
366510
366963
|
githubrepositoryfeatures: 'FirestartrGithubRepositoryFeature',
|
|
366964
|
+
githubrepositorysecretssections: 'FirestartrGithubRepositorySecretsSection',
|
|
366511
366965
|
terraformmodules: 'FirestartrTerraformModule',
|
|
366512
366966
|
githuborgwebhooks: 'FirestartrGithubOrgWebhook',
|
|
366513
366967
|
terraformworkspaces: 'FirestartrTerraformWorkspace',
|
|
@@ -367122,6 +367576,28 @@ async function needsProvisioningOnCreate(cr) {
|
|
|
367122
367576
|
operator_src_logger.debug(`Skipping the provisioning process for custom resource '${cr.kind}/${cr.metadata.name}' because its current state is not handled.`);
|
|
367123
367577
|
return false;
|
|
367124
367578
|
}
|
|
367579
|
+
async function updateSyncTransition(itemPath, reason, lastSyncTime, nextSyncTime, message, status) {
|
|
367580
|
+
operator_src_logger.info(`The item at '${itemPath}' transitioned to a new SYNCHRONIZED condition of '${status}'. The reason for the change is '${reason}' with the message: '${message}'.`);
|
|
367581
|
+
const k8sItem = await getItemByItemPath(itemPath);
|
|
367582
|
+
if (!('status' in k8sItem))
|
|
367583
|
+
k8sItem.status = {};
|
|
367584
|
+
if (!('conditions' in k8sItem.status))
|
|
367585
|
+
k8sItem.status.conditions = [];
|
|
367586
|
+
let conditionObject = getRelevantCondition(k8sItem.status.conditions, 'SYNCHRONIZED');
|
|
367587
|
+
conditionObject = {
|
|
367588
|
+
...conditionObject,
|
|
367589
|
+
reason,
|
|
367590
|
+
status,
|
|
367591
|
+
message,
|
|
367592
|
+
observedGeneration: k8sItem.metadata.generation,
|
|
367593
|
+
lastSyncTime,
|
|
367594
|
+
lastUpdateTime: new Date().toJSON(),
|
|
367595
|
+
nextSyncTime,
|
|
367596
|
+
};
|
|
367597
|
+
k8sItem.status.conditions = updateConditionByType(k8sItem.status.conditions, 'SYNCHRONIZED', conditionObject);
|
|
367598
|
+
const itemParameters = itemPath.split('/');
|
|
367599
|
+
await writeStatus(itemParameters[1], itemParameters[0], k8sItem);
|
|
367600
|
+
}
|
|
367125
367601
|
async function updateTransition(itemPath, reason, type, statusValue, message = '', updateStatusOnly = false) {
|
|
367126
367602
|
operator_src_logger.info(`The item at '${itemPath}' transitioned to a new status of '${statusValue}' (type: '${type}'). The reason for the change is '${reason}' with the message: '${message}'. This was a status-only update: '${updateStatusOnly}'.`);
|
|
367127
367603
|
const k8sItem = await getItemByItemPath(itemPath);
|
|
@@ -367182,12 +367658,142 @@ function updateConditionByType(conditionList, type, newCondition) {
|
|
|
367182
367658
|
return conditionList;
|
|
367183
367659
|
}
|
|
367184
367660
|
|
|
367185
|
-
;// CONCATENATED MODULE: ../operator/src/
|
|
367661
|
+
;// CONCATENATED MODULE: ../operator/src/syncCtl.ts
|
|
367662
|
+
// Machinery for syncing
|
|
367663
|
+
|
|
367664
|
+
|
|
367186
367665
|
|
|
367187
367666
|
|
|
367188
|
-
const syncWatchers = {};
|
|
367189
|
-
const FORCE_REVISION_TIME = 60 * 1000;
|
|
367190
367667
|
const DEFAULT_REVISION_TIME = '1m';
|
|
367668
|
+
async function createWatcherForItem(itemPath, itemCR) {
|
|
367669
|
+
const item = itemCR ?? (await getItemByItemPath(itemPath));
|
|
367670
|
+
const syncStatus = await getSyncStatus(itemPath, item);
|
|
367671
|
+
let nextTimeoutInMS = syncStatus.nextTimeoutInMS;
|
|
367672
|
+
// we have lapsed last interval
|
|
367673
|
+
// we calculate from the lastSyncTime
|
|
367674
|
+
if (syncStatus.intervalLapsed) {
|
|
367675
|
+
operator_src_logger.debug(`Next sync interval have been lapsed for ${itemPath}`);
|
|
367676
|
+
if (syncStatus.syncMode === 'Period') {
|
|
367677
|
+
operator_src_logger.debug(`Next sync interval have been lapsed for ${itemPath} the sync will start now`);
|
|
367678
|
+
nextTimeoutInMS = -1;
|
|
367679
|
+
}
|
|
367680
|
+
}
|
|
367681
|
+
const syncInfo = syncStatus.conditions?.[0] ?? null;
|
|
367682
|
+
const watcher = {
|
|
367683
|
+
itemPath,
|
|
367684
|
+
lastRevision: setTimeout(() => {
|
|
367685
|
+
operator_src_logger.debug(`Item ${itemPath} needs revision`);
|
|
367686
|
+
watcher.needsRevision = true;
|
|
367687
|
+
watcher.alreadyFired = true;
|
|
367688
|
+
}, nextTimeoutInMS),
|
|
367689
|
+
needsRevision: false,
|
|
367690
|
+
nextSync: syncInfo ? syncInfo?.nextSyncTime : undefined,
|
|
367691
|
+
syncMode: syncStatus.syncMode,
|
|
367692
|
+
alreadyFired: false,
|
|
367693
|
+
};
|
|
367694
|
+
return watcher;
|
|
367695
|
+
}
|
|
367696
|
+
async function destroyWatcherForItem(watcher) {
|
|
367697
|
+
clearTimeout(watcher.lastRevision);
|
|
367698
|
+
operator_src_logger.debug(`Disabled SyncWatcher for ${watcher.itemPath}`);
|
|
367699
|
+
}
|
|
367700
|
+
async function getSyncSpecs(itemPath, itemCR) {
|
|
367701
|
+
const item = itemCR ?? (await getItemByItemPath(itemPath));
|
|
367702
|
+
return {
|
|
367703
|
+
item,
|
|
367704
|
+
syncable: helperIsSyncable(item),
|
|
367705
|
+
period: item.metadata.annotations['firestartr.dev/sync-period'] ||
|
|
367706
|
+
DEFAULT_REVISION_TIME,
|
|
367707
|
+
schedule: item.metadata.annotations['firestartr.dev/sync-schedule'] || false,
|
|
367708
|
+
scheduleTZ: item.metadata.annotations['firestartr.dev/sync-schedule-timezone'] ||
|
|
367709
|
+
'Europe/Madrid',
|
|
367710
|
+
};
|
|
367711
|
+
}
|
|
367712
|
+
async function getSyncStatus(itemPath, itemCR) {
|
|
367713
|
+
const item = itemCR ?? (await getItemByItemPath(itemPath));
|
|
367714
|
+
const syncCondition = getConditionByType(item.status?.conditions ?? [], 'SYNCHRONIZED');
|
|
367715
|
+
// no sync condition present
|
|
367716
|
+
if (!syncCondition) {
|
|
367717
|
+
return {
|
|
367718
|
+
syncStatusPresent: false,
|
|
367719
|
+
};
|
|
367720
|
+
}
|
|
367721
|
+
else {
|
|
367722
|
+
const nextSyncDate = new Date(syncCondition.nextSyncTime);
|
|
367723
|
+
const isLapsed = Date.now() >= nextSyncDate.getTime();
|
|
367724
|
+
const mode = (await getSyncSpecs(itemPath, item)).schedule
|
|
367725
|
+
? 'Scheduled'
|
|
367726
|
+
: 'Period';
|
|
367727
|
+
return {
|
|
367728
|
+
itemPath,
|
|
367729
|
+
syncMode: mode,
|
|
367730
|
+
conditions: [syncCondition],
|
|
367731
|
+
syncStatusPresent: true,
|
|
367732
|
+
nextTimeoutInMS: isLapsed ? -1 : nextSyncDate.getTime() - Date.now(),
|
|
367733
|
+
intervalLapsed: isLapsed,
|
|
367734
|
+
};
|
|
367735
|
+
}
|
|
367736
|
+
}
|
|
367737
|
+
async function setSyncStatus(itemPath, reason, status, message) {
|
|
367738
|
+
const item = await getItemByItemPath(itemPath);
|
|
367739
|
+
const machinery = assessSyncCalculationMachinery(item);
|
|
367740
|
+
const syncStatus = await machinery(item, reason, status, message);
|
|
367741
|
+
syncStatus.itemPath = itemPath;
|
|
367742
|
+
syncStatus.syncStatusPresent = true;
|
|
367743
|
+
operator_src_logger.info(`Setting sync status for ${itemPath}: ${JSON.stringify(syncStatus)}`);
|
|
367744
|
+
const syncTransition = syncStatus.conditions[0];
|
|
367745
|
+
await updateSyncTransition(itemPath, syncTransition.reason, syncTransition.lastSyncTime, syncTransition.nextSyncTime, syncTransition.message, syncTransition.status);
|
|
367746
|
+
return syncStatus;
|
|
367747
|
+
}
|
|
367748
|
+
function assessSyncCalculationMachinery(item) {
|
|
367749
|
+
if (!helperIsSyncable(item)) {
|
|
367750
|
+
return processNotSyncable;
|
|
367751
|
+
}
|
|
367752
|
+
else if (item.metadata.annotations['firestartr.dev/sync-schedule'] ??
|
|
367753
|
+
false) {
|
|
367754
|
+
return processScheduledSync;
|
|
367755
|
+
}
|
|
367756
|
+
else {
|
|
367757
|
+
return processPeriodSync;
|
|
367758
|
+
}
|
|
367759
|
+
}
|
|
367760
|
+
function helperIsSyncable(item) {
|
|
367761
|
+
return (item.metadata.annotations &&
|
|
367762
|
+
item.metadata.annotations['firestartr.dev/sync-enabled'] &&
|
|
367763
|
+
item.metadata.annotations['firestartr.dev/sync-enabled'] === 'true');
|
|
367764
|
+
}
|
|
367765
|
+
async function processNotSyncable(item, reason, status, message) {
|
|
367766
|
+
return {
|
|
367767
|
+
syncMode: 'Period',
|
|
367768
|
+
conditions: [
|
|
367769
|
+
{
|
|
367770
|
+
reason,
|
|
367771
|
+
type: 'SYNCHRONIZED',
|
|
367772
|
+
message,
|
|
367773
|
+
status,
|
|
367774
|
+
lastSyncTime: new Date().toISOString(),
|
|
367775
|
+
nextSyncTime: new Date().toISOString(),
|
|
367776
|
+
},
|
|
367777
|
+
],
|
|
367778
|
+
};
|
|
367779
|
+
}
|
|
367780
|
+
async function processPeriodSync(item, reason, status, message) {
|
|
367781
|
+
const period = item.metadata.annotations['firestartr.dev/sync-period'];
|
|
367782
|
+
const periodMS = helperCalculateRevisionTime(period);
|
|
367783
|
+
return {
|
|
367784
|
+
syncMode: 'Period',
|
|
367785
|
+
conditions: [
|
|
367786
|
+
{
|
|
367787
|
+
reason,
|
|
367788
|
+
type: 'SYNCHRONIZED',
|
|
367789
|
+
message,
|
|
367790
|
+
status,
|
|
367791
|
+
lastSyncTime: new Date().toISOString(),
|
|
367792
|
+
nextSyncTime: new Date(Date.now() + periodMS).toISOString(),
|
|
367793
|
+
},
|
|
367794
|
+
],
|
|
367795
|
+
};
|
|
367796
|
+
}
|
|
367191
367797
|
function helperCalculateRevisionTime(period) {
|
|
367192
367798
|
const [_, scalar, dimension] = period.split(/(\d+)/);
|
|
367193
367799
|
const multiplier = dimension === 's'
|
|
@@ -367201,24 +367807,97 @@ function helperCalculateRevisionTime(period) {
|
|
|
367201
367807
|
: 1;
|
|
367202
367808
|
return Number(scalar) * multiplier * 1000;
|
|
367203
367809
|
}
|
|
367204
|
-
async function
|
|
367205
|
-
|
|
367206
|
-
|
|
367810
|
+
async function processScheduledSync(item, reason, status, message) {
|
|
367811
|
+
const nextPeriod = catalog_common.cron.getCronNextInterval(item.metadata.annotations['firestartr.dev/sync-schedule'], item.metadata.annotations['firestartr.dev/sync-schedule-timezone'] ||
|
|
367812
|
+
undefined);
|
|
367813
|
+
const nextPeriodDate = new Date(nextPeriod);
|
|
367207
367814
|
return {
|
|
367815
|
+
syncMode: 'Scheduled',
|
|
367816
|
+
conditions: [
|
|
367817
|
+
{
|
|
367818
|
+
reason,
|
|
367819
|
+
type: 'SYNCHRONIZED',
|
|
367820
|
+
message,
|
|
367821
|
+
status,
|
|
367822
|
+
lastSyncTime: new Date().toISOString(),
|
|
367823
|
+
nextSyncTime: nextPeriodDate.toISOString(),
|
|
367824
|
+
},
|
|
367825
|
+
],
|
|
367826
|
+
};
|
|
367827
|
+
}
|
|
367828
|
+
|
|
367829
|
+
;// CONCATENATED MODULE: ../operator/src/syncer.debug.ts
|
|
367830
|
+
|
|
367831
|
+
|
|
367832
|
+
let running = false;
|
|
367833
|
+
let waitingF = null;
|
|
367834
|
+
async function syncerDebug(syncWatchers) {
|
|
367835
|
+
if (running)
|
|
367836
|
+
return waitUntilDone(syncWatchers);
|
|
367837
|
+
running = true;
|
|
367838
|
+
try {
|
|
367839
|
+
await writeDownSyncer(syncWatchers);
|
|
367840
|
+
running = false;
|
|
367841
|
+
}
|
|
367842
|
+
catch (err) {
|
|
367843
|
+
operator_src_logger.error(`PANIC!!! sync debug could not be written ${err}`);
|
|
367844
|
+
running = false;
|
|
367845
|
+
}
|
|
367846
|
+
}
|
|
367847
|
+
async function waitUntilDone(syncWatchers) {
|
|
367848
|
+
if (waitingF)
|
|
367849
|
+
return;
|
|
367850
|
+
waitingF = setTimeout(() => {
|
|
367851
|
+
syncerDebug(syncWatchers).catch((err) => {
|
|
367852
|
+
operator_src_logger.error(`Caught error: ${err}`);
|
|
367853
|
+
throw `Caught error: ${err}`;
|
|
367854
|
+
});
|
|
367855
|
+
clearTimeout(waitingF);
|
|
367856
|
+
waitingF = null;
|
|
367857
|
+
}, 300);
|
|
367858
|
+
}
|
|
367859
|
+
async function writeDownSyncer(syncWatchers) {
|
|
367860
|
+
let output = '';
|
|
367861
|
+
for (const watcher of Object.values(syncWatchers)) {
|
|
367862
|
+
output += `${watcher.itemPath} - (${watcher.syncMode}) - next: ${watcher.nextSync} \n`;
|
|
367863
|
+
}
|
|
367864
|
+
return new Promise((ok, ko) => {
|
|
367865
|
+
external_fs_.writeFile('/tmp/syncs', output, (err) => {
|
|
367866
|
+
if (err)
|
|
367867
|
+
return ko(`Error writing the /tmp/syncs: ${err}`);
|
|
367868
|
+
else
|
|
367869
|
+
return ok();
|
|
367870
|
+
});
|
|
367871
|
+
});
|
|
367872
|
+
}
|
|
367873
|
+
|
|
367874
|
+
;// CONCATENATED MODULE: ../operator/src/syncer.ts
|
|
367875
|
+
|
|
367876
|
+
|
|
367877
|
+
|
|
367878
|
+
|
|
367879
|
+
const syncWatchers = {};
|
|
367880
|
+
const FORCE_REVISION_TIME = (/* unused pure expression or super */ null && (60 * 1000));
|
|
367881
|
+
async function syncer(enqueue) {
|
|
367882
|
+
const api = {
|
|
367208
367883
|
addItem(itemPath) {
|
|
367209
367884
|
operator_src_logger.info(`Added item of path '${itemPath}' for synchronization`);
|
|
367210
|
-
|
|
367885
|
+
getSyncSpecs(itemPath)
|
|
367886
|
+
.then(async (itemSyncInfo) => {
|
|
367211
367887
|
if (!itemSyncInfo.syncable) {
|
|
367212
367888
|
return;
|
|
367213
367889
|
}
|
|
367214
|
-
|
|
367215
|
-
|
|
367216
|
-
lastRevision: setInterval(() => {
|
|
367217
|
-
syncWatchers[itemPath].needsRevision = true;
|
|
367218
|
-
}, helperCalculateRevisionTime(itemSyncInfo.period)),
|
|
367219
|
-
needsRevision: false,
|
|
367220
|
-
};
|
|
367890
|
+
const syncCtl = await getSyncStatus(itemPath, itemSyncInfo.item);
|
|
367891
|
+
syncWatchers[itemPath] = await createWatcherForItem(itemPath, itemSyncInfo.item);
|
|
367221
367892
|
operator_src_logger.info(`Configured synchronization for item at path '${itemPath}'`);
|
|
367893
|
+
operator_src_logger.debug(`Sync information for '${itemPath}': ${JSON.stringify({ ...itemSyncInfo, item: null }, null)}`);
|
|
367894
|
+
syncerDebug(syncWatchers).catch((err) => {
|
|
367895
|
+
throw `Error syncer debug: ${err}`;
|
|
367896
|
+
});
|
|
367897
|
+
})
|
|
367898
|
+
.catch((err) => {
|
|
367899
|
+
operator_src_logger.error(`Error on sync [add item]: ${err}`);
|
|
367900
|
+
throw `Error on sync [add item]: ${err}`;
|
|
367222
367901
|
});
|
|
367223
367902
|
},
|
|
367224
367903
|
updateItem(itemPath) {
|
|
@@ -367227,27 +367906,27 @@ async function syncer(enqueue) {
|
|
|
367227
367906
|
// return
|
|
367228
367907
|
//}
|
|
367229
367908
|
operator_src_logger.debug(`Updated item of path '${itemPath}' during synchronization`);
|
|
367230
|
-
|
|
367231
|
-
|
|
367232
|
-
|
|
367233
|
-
|
|
367234
|
-
|
|
367235
|
-
operator_src_logger.info(`Removed item of path '${itemPath}' from synchronization`);
|
|
367236
|
-
}
|
|
367909
|
+
return getSyncSpecs(itemPath)
|
|
367910
|
+
.then(async (itemSyncInfo) => {
|
|
367911
|
+
if (syncWatchers[itemPath]) {
|
|
367912
|
+
await destroyWatcherForItem(syncWatchers[itemPath]);
|
|
367913
|
+
delete syncWatchers[itemPath];
|
|
367237
367914
|
}
|
|
367238
|
-
|
|
367239
|
-
|
|
367240
|
-
|
|
367241
|
-
|
|
367242
|
-
syncWatchers[itemPath] = {
|
|
367243
|
-
itemPath,
|
|
367244
|
-
lastRevision: setInterval(() => {
|
|
367245
|
-
syncWatchers[itemPath].needsRevision = true;
|
|
367246
|
-
}, helperCalculateRevisionTime(itemSyncInfo.period)),
|
|
367247
|
-
needsRevision: false,
|
|
367248
|
-
};
|
|
367249
|
-
operator_src_logger.debug(`Configured synchronization for item at path '${itemPath}' with watcher '${syncWatchers[itemPath]}'`);
|
|
367915
|
+
// we need to check if the item is not syncable anymore
|
|
367916
|
+
if (!itemSyncInfo.syncable) {
|
|
367917
|
+
operator_src_logger.info(`Removed item of path '${itemPath}' from synchronization`);
|
|
367918
|
+
return;
|
|
367250
367919
|
}
|
|
367920
|
+
// if it is syncable we need to recalculate everything
|
|
367921
|
+
syncWatchers[itemPath] = await createWatcherForItem(itemPath);
|
|
367922
|
+
operator_src_logger.info(`Configured synchronization for item at path '${itemPath}' with watcher`);
|
|
367923
|
+
syncerDebug(syncWatchers).catch((err) => {
|
|
367924
|
+
throw `Error syncer debug: ${err}`;
|
|
367925
|
+
});
|
|
367926
|
+
})
|
|
367927
|
+
.catch((err) => {
|
|
367928
|
+
operator_src_logger.error(`Error on sync [updateItem]: ${err}`);
|
|
367929
|
+
throw `Error on sync [updateItem]: ${err}`;
|
|
367251
367930
|
});
|
|
367252
367931
|
},
|
|
367253
367932
|
deleteItem(itemPath) {
|
|
@@ -367255,35 +367934,54 @@ async function syncer(enqueue) {
|
|
|
367255
367934
|
operator_src_logger.debug(`Ignored deletion attempt for item at path '${itemPath}' as it was not found during synchronization`);
|
|
367256
367935
|
return;
|
|
367257
367936
|
}
|
|
367258
|
-
|
|
367259
|
-
|
|
367260
|
-
|
|
367261
|
-
|
|
367937
|
+
destroyWatcherForItem(syncWatchers[itemPath])
|
|
367938
|
+
.then(() => {
|
|
367939
|
+
operator_src_logger.debug(`Deleted item of path '${itemPath}' during synchronization`);
|
|
367940
|
+
delete syncWatchers[itemPath];
|
|
367941
|
+
syncerDebug(syncWatchers).catch((err) => {
|
|
367942
|
+
throw `Error syncer debug: ${err}`;
|
|
367943
|
+
});
|
|
367944
|
+
})
|
|
367945
|
+
.catch((err) => {
|
|
367946
|
+
operator_src_logger.error(`Error deleting item of path ${itemPath} for synchronization: ${err}`);
|
|
367947
|
+
throw `Error deleting item of path ${itemPath} for synchronization: ${err}`;
|
|
367948
|
+
});
|
|
367262
367949
|
},
|
|
367263
367950
|
};
|
|
367951
|
+
// fork
|
|
367952
|
+
void loop(enqueue, api);
|
|
367953
|
+
return api;
|
|
367264
367954
|
}
|
|
367265
|
-
async function loop(enqueueIfNeeded) {
|
|
367955
|
+
async function loop(enqueueIfNeeded, api) {
|
|
367956
|
+
void loopKeeper(api);
|
|
367266
367957
|
while (1) {
|
|
367267
367958
|
await fWait();
|
|
367268
367959
|
const needRevisionItems = Object.values(syncWatchers).filter((watcher) => watcher.needsRevision);
|
|
367269
367960
|
for (const watcher of needRevisionItems) {
|
|
367270
367961
|
const item = await getItemIfNeededSync(watcher);
|
|
367962
|
+
operator_src_logger.debug(`Item needs revision ${watcher.itemPath}`);
|
|
367271
367963
|
if (item !== null) {
|
|
367272
367964
|
enqueueIfNeeded(item);
|
|
367273
|
-
watcher.needsRevision = false;
|
|
367274
367965
|
}
|
|
367966
|
+
watcher.needsRevision = false;
|
|
367275
367967
|
}
|
|
367276
367968
|
}
|
|
367277
367969
|
}
|
|
367278
|
-
async function
|
|
367279
|
-
|
|
367280
|
-
|
|
367281
|
-
|
|
367282
|
-
|
|
367283
|
-
|
|
367284
|
-
|
|
367285
|
-
|
|
367286
|
-
|
|
367970
|
+
async function loopKeeper(api) {
|
|
367971
|
+
try {
|
|
367972
|
+
while (1) {
|
|
367973
|
+
await fWait(5);
|
|
367974
|
+
for (const watcher of Object.values(syncWatchers)) {
|
|
367975
|
+
if (watcher.alreadyFired) {
|
|
367976
|
+
await api.updateItem(watcher.itemPath);
|
|
367977
|
+
}
|
|
367978
|
+
}
|
|
367979
|
+
}
|
|
367980
|
+
}
|
|
367981
|
+
catch (err) {
|
|
367982
|
+
operator_src_logger.error(`PANIC!: loopKeeper has failed: ${err}`);
|
|
367983
|
+
process.exit(1);
|
|
367984
|
+
}
|
|
367287
367985
|
}
|
|
367288
367986
|
async function getItemIfNeededSync(watcher) {
|
|
367289
367987
|
const item = await getItemByItemPath(watcher.itemPath);
|
|
@@ -367293,13 +367991,7 @@ async function getItemIfNeededSync(watcher) {
|
|
|
367293
367991
|
const isDeleting = item.status?.conditions?.find((condition) => condition.type === 'DELETING' && condition.status === 'True');
|
|
367294
367992
|
if (isDeleting)
|
|
367295
367993
|
return null;
|
|
367296
|
-
|
|
367297
|
-
if (!synchronizedCondition)
|
|
367298
|
-
return item;
|
|
367299
|
-
const lastSync = new Date(synchronizedCondition.lastUpdateTime).getTime();
|
|
367300
|
-
if (lastSync <= Date.now() - FORCE_REVISION_TIME)
|
|
367301
|
-
return item;
|
|
367302
|
-
return null;
|
|
367994
|
+
return item;
|
|
367303
367995
|
}
|
|
367304
367996
|
function fWait(segs = 1) {
|
|
367305
367997
|
return new Promise((ok) => {
|
|
@@ -367555,6 +368247,7 @@ var WorkStatus;
|
|
|
367555
368247
|
|
|
367556
368248
|
|
|
367557
368249
|
|
|
368250
|
+
|
|
367558
368251
|
const kindsWithFinalizer = [
|
|
367559
368252
|
'FirestartrTerraformWorkspace',
|
|
367560
368253
|
'FirestartrGithubGroup',
|
|
@@ -367562,6 +368255,7 @@ const kindsWithFinalizer = [
|
|
|
367562
368255
|
'FirestartrGithubRepository',
|
|
367563
368256
|
'FirestartrGithubRepositoryFeature',
|
|
367564
368257
|
'FirestartrGithubOrgWebhook',
|
|
368258
|
+
'FirestartrGithubRepositorySecretsSection',
|
|
367565
368259
|
];
|
|
367566
368260
|
/**
|
|
367567
368261
|
* Observe whenever a new item is added, modified or deleted in a given kind
|
|
@@ -367674,15 +368368,18 @@ function enqueue(pluralKind, workItem, queue, compute, syncCtl, retryCtl) {
|
|
|
367674
368368
|
success: () => retryCtl.successReconciling(informer_itemPath(pluralKind, workItem.item)),
|
|
367675
368369
|
};
|
|
367676
368370
|
workItem.process = async function* (item, operation, handler) {
|
|
367677
|
-
|
|
367678
|
-
yield transition;
|
|
367679
|
-
}
|
|
367680
|
-
if (operation === OperationType.RENAMED ||
|
|
368371
|
+
const needsUpdateSyncConditions = operation === OperationType.RENAMED ||
|
|
367681
368372
|
operation === OperationType.UPDATED ||
|
|
367682
368373
|
operation === OperationType.SYNC ||
|
|
367683
368374
|
operation === OperationType.CREATED ||
|
|
367684
|
-
operation === OperationType.RETRY
|
|
367685
|
-
|
|
368375
|
+
operation === OperationType.RETRY;
|
|
368376
|
+
await setSyncStatus(workItem.handler.itemPath(), operation, 'False', 'Sync process started');
|
|
368377
|
+
for await (const transition of compute(item, operation, handler)) {
|
|
368378
|
+
yield transition;
|
|
368379
|
+
}
|
|
368380
|
+
if (needsUpdateSyncConditions) {
|
|
368381
|
+
await setSyncStatus(workItem.handler.itemPath(), operation, operation === OperationType.SYNC ? 'True' : 'False', 'Sync process finished');
|
|
368382
|
+
void syncCtl.updateItem(informer_itemPath(pluralKind, item));
|
|
367686
368383
|
}
|
|
367687
368384
|
else {
|
|
367688
368385
|
operator_src_logger.debug(`The informer received an item with an operation type of '${operation}', which is not a specific operation.`);
|
|
@@ -367724,6 +368421,7 @@ async function inform(pluralKind, item, op, lastWorkItem = null) {
|
|
|
367724
368421
|
item,
|
|
367725
368422
|
workStatus: WorkStatus.PENDING,
|
|
367726
368423
|
onDelete: function () { },
|
|
368424
|
+
upsertTime: Date.now(),
|
|
367727
368425
|
};
|
|
367728
368426
|
return workItem;
|
|
367729
368427
|
case 'onRename':
|
|
@@ -367734,6 +368432,7 @@ async function inform(pluralKind, item, op, lastWorkItem = null) {
|
|
|
367734
368432
|
item,
|
|
367735
368433
|
workStatus: WorkStatus.PENDING,
|
|
367736
368434
|
onDelete: function () { },
|
|
368435
|
+
upsertTime: Date.now(),
|
|
367737
368436
|
};
|
|
367738
368437
|
return workItem;
|
|
367739
368438
|
}
|
|
@@ -367747,6 +368446,7 @@ async function inform(pluralKind, item, op, lastWorkItem = null) {
|
|
|
367747
368446
|
item,
|
|
367748
368447
|
workStatus: WorkStatus.PENDING,
|
|
367749
368448
|
onDelete: function () { },
|
|
368449
|
+
upsertTime: Date.now(),
|
|
367750
368450
|
};
|
|
367751
368451
|
return workItem;
|
|
367752
368452
|
case 'onAdd':
|
|
@@ -367756,6 +368456,7 @@ async function inform(pluralKind, item, op, lastWorkItem = null) {
|
|
|
367756
368456
|
item,
|
|
367757
368457
|
workStatus: WorkStatus.PENDING,
|
|
367758
368458
|
onDelete: function () { },
|
|
368459
|
+
upsertTime: Date.now(),
|
|
367759
368460
|
};
|
|
367760
368461
|
return workItem;
|
|
367761
368462
|
}
|
|
@@ -367763,6 +368464,7 @@ async function inform(pluralKind, item, op, lastWorkItem = null) {
|
|
|
367763
368464
|
case 'onMarkedToDeletion':
|
|
367764
368465
|
if (workItem !== null && workItem.workStatus === WorkStatus.PENDING) {
|
|
367765
368466
|
workItem.operation = OperationType.MARKED_TO_DELETION;
|
|
368467
|
+
workItem.upsertTime = Date.now();
|
|
367766
368468
|
return null;
|
|
367767
368469
|
}
|
|
367768
368470
|
else {
|
|
@@ -367771,6 +368473,7 @@ async function inform(pluralKind, item, op, lastWorkItem = null) {
|
|
|
367771
368473
|
item,
|
|
367772
368474
|
workStatus: WorkStatus.PENDING,
|
|
367773
368475
|
onDelete: function () { },
|
|
368476
|
+
upsertTime: Date.now(),
|
|
367774
368477
|
};
|
|
367775
368478
|
return workItem;
|
|
367776
368479
|
}
|
|
@@ -367785,6 +368488,7 @@ async function inform(pluralKind, item, op, lastWorkItem = null) {
|
|
|
367785
368488
|
item,
|
|
367786
368489
|
workStatus: WorkStatus.PENDING,
|
|
367787
368490
|
onDelete: function () { },
|
|
368491
|
+
upsertTime: Date.now(),
|
|
367788
368492
|
};
|
|
367789
368493
|
return workItem;
|
|
367790
368494
|
}
|
|
@@ -367904,11 +368608,89 @@ function dummy_fWait(ms) {
|
|
|
367904
368608
|
});
|
|
367905
368609
|
}
|
|
367906
368610
|
|
|
368611
|
+
;// CONCATENATED MODULE: ../operator/src/processItem.debug.ts
|
|
368612
|
+
|
|
368613
|
+
|
|
368614
|
+
function loopWorkItemDebug(queue) {
|
|
368615
|
+
let running = false;
|
|
368616
|
+
setInterval(() => {
|
|
368617
|
+
if (running)
|
|
368618
|
+
return;
|
|
368619
|
+
running = true;
|
|
368620
|
+
writeDownQueueStatus(queue)
|
|
368621
|
+
.then(() => {
|
|
368622
|
+
running = false;
|
|
368623
|
+
})
|
|
368624
|
+
.catch((err) => {
|
|
368625
|
+
operator_src_logger.error(`PANIC cannot evaluate the queue for debug!!!: ${err}`);
|
|
368626
|
+
});
|
|
368627
|
+
}, 5 * 1000);
|
|
368628
|
+
}
|
|
368629
|
+
async function writeDownQueueStatus(queue) {
|
|
368630
|
+
let output = '';
|
|
368631
|
+
for (const workItem of queue) {
|
|
368632
|
+
const item = workItem.item;
|
|
368633
|
+
output += `${item.kind}/${item.metadata.name} - ${workItem.workStatus} - ${workItem.operation} - (upsert ${formatElapsedTimeWithDate(workItem.upsertTime)})\n`;
|
|
368634
|
+
}
|
|
368635
|
+
return new Promise((ok, ko) => {
|
|
368636
|
+
external_fs_.writeFile('/tmp/queue', output, (err) => {
|
|
368637
|
+
if (err)
|
|
368638
|
+
ko(`Writing /tmp/queue: ${err}`);
|
|
368639
|
+
else
|
|
368640
|
+
ok();
|
|
368641
|
+
});
|
|
368642
|
+
});
|
|
368643
|
+
}
|
|
368644
|
+
function formatElapsedTimeWithDate(upsertTime) {
|
|
368645
|
+
const now = new Date();
|
|
368646
|
+
const diffMs = now.getTime() - upsertTime;
|
|
368647
|
+
if (diffMs < 0) {
|
|
368648
|
+
return 'Future time (Error)';
|
|
368649
|
+
}
|
|
368650
|
+
if (diffMs < 1000) {
|
|
368651
|
+
return 'Just now';
|
|
368652
|
+
}
|
|
368653
|
+
const MS_PER_SECOND = 1000;
|
|
368654
|
+
const MS_PER_MINUTE = 60 * MS_PER_SECOND;
|
|
368655
|
+
const MS_PER_HOUR = 60 * MS_PER_MINUTE;
|
|
368656
|
+
const MS_PER_DAY = 24 * MS_PER_HOUR;
|
|
368657
|
+
const parts = [];
|
|
368658
|
+
let remainingMs = diffMs;
|
|
368659
|
+
// 1. Calculate Days
|
|
368660
|
+
const days = Math.floor(remainingMs / MS_PER_DAY);
|
|
368661
|
+
if (days > 0) {
|
|
368662
|
+
parts.push(`${days} day${days !== 1 ? 's' : ''}`);
|
|
368663
|
+
remainingMs %= MS_PER_DAY;
|
|
368664
|
+
}
|
|
368665
|
+
// 2. Calculate Hours
|
|
368666
|
+
const hours = Math.floor(remainingMs / MS_PER_HOUR);
|
|
368667
|
+
if (hours > 0) {
|
|
368668
|
+
parts.push(`${hours} hour${hours !== 1 ? 's' : ''}`);
|
|
368669
|
+
remainingMs %= MS_PER_HOUR;
|
|
368670
|
+
}
|
|
368671
|
+
// 3. Calculate Minutes
|
|
368672
|
+
const minutes = Math.floor(remainingMs / MS_PER_MINUTE);
|
|
368673
|
+
if (minutes > 0) {
|
|
368674
|
+
parts.push(`${minutes} minute${minutes !== 1 ? 's' : ''}`);
|
|
368675
|
+
remainingMs %= MS_PER_MINUTE;
|
|
368676
|
+
}
|
|
368677
|
+
// 4. Calculate Seconds (added logic for seconds)
|
|
368678
|
+
const seconds = Math.floor(remainingMs / MS_PER_SECOND);
|
|
368679
|
+
if (seconds > 0 && parts.length < 2) {
|
|
368680
|
+
parts.push(`${seconds} second${seconds !== 1 ? 's' : ''}`);
|
|
368681
|
+
}
|
|
368682
|
+
if (parts.length === 0 && seconds > 0) {
|
|
368683
|
+
return `${seconds} second${seconds !== 1 ? 's' : ''} ago`;
|
|
368684
|
+
}
|
|
368685
|
+
return `${parts.slice(0, 2).join(', ')} ago`;
|
|
368686
|
+
}
|
|
368687
|
+
|
|
367907
368688
|
;// CONCATENATED MODULE: ../operator/src/processItem.ts
|
|
367908
368689
|
|
|
367909
368690
|
|
|
367910
368691
|
|
|
367911
368692
|
|
|
368693
|
+
|
|
367912
368694
|
const queue = [];
|
|
367913
368695
|
const WEIGHTS = {
|
|
367914
368696
|
RENAMED: 15,
|
|
@@ -368014,6 +368796,7 @@ async function processItem(workItem) {
|
|
|
368014
368796
|
*/
|
|
368015
368797
|
async function processItem_loop() {
|
|
368016
368798
|
const nextWorkItem = () => sortQueue(queue).find((w) => w.workStatus === WorkStatus.PENDING);
|
|
368799
|
+
loopWorkItemDebug(queue);
|
|
368017
368800
|
while (1) {
|
|
368018
368801
|
const w = nextWorkItem();
|
|
368019
368802
|
if (w) {
|
|
@@ -368047,9 +368830,18 @@ function createTimeout(w) {
|
|
|
368047
368830
|
*/
|
|
368048
368831
|
function sortQueue(queue) {
|
|
368049
368832
|
const sortedQueue = queue.sort((wa, wb) => {
|
|
368050
|
-
|
|
368051
|
-
const
|
|
368052
|
-
|
|
368833
|
+
// --- PRIMARY SORT: By Weight (Descending) ---
|
|
368834
|
+
const weightA = WEIGHTS[wa.operation];
|
|
368835
|
+
const weightB = WEIGHTS[wb.operation];
|
|
368836
|
+
// Check if weights are different
|
|
368837
|
+
if (weightA !== weightB) {
|
|
368838
|
+
// Sort in descending order (higher weight first)
|
|
368839
|
+
// If weightA is larger, return -1 (a comes before b)
|
|
368840
|
+
return weightB - weightA;
|
|
368841
|
+
}
|
|
368842
|
+
// --- SECONDARY SORT: By upsertTime (Ascending) ---
|
|
368843
|
+
// If weights are equal, sort by the oldest upsertTime (ascending)
|
|
368844
|
+
return wa.upsertTime - wb.upsertTime;
|
|
368053
368845
|
});
|
|
368054
368846
|
return sortedQueue;
|
|
368055
368847
|
}
|
|
@@ -368882,6 +369674,106 @@ class FirestartrTerraformModuleEntity extends Entity {
|
|
|
368882
369674
|
}
|
|
368883
369675
|
}
|
|
368884
369676
|
|
|
369677
|
+
;// CONCATENATED MODULE: ../provisioner/src/entities/firestartrgithubrepositorysecretssection/helpers/RepositorySecret.ts
|
|
369678
|
+
|
|
369679
|
+
|
|
369680
|
+
|
|
369681
|
+
|
|
369682
|
+
|
|
369683
|
+
|
|
369684
|
+
async function RepositorySecret_provisionRepositorySecrets(scope, fsGithubRepositorySecretsSection, repo) {
|
|
369685
|
+
const sections = ['actions', 'codespaces', 'dependabot'];
|
|
369686
|
+
if ('secrets' in fsGithubRepositorySecretsSection.spec) {
|
|
369687
|
+
const secrets = fsGithubRepositorySecretsSection.spec.secrets;
|
|
369688
|
+
for (const section of sections) {
|
|
369689
|
+
if (section in secrets) {
|
|
369690
|
+
for (const secret of secrets[section]) {
|
|
369691
|
+
await RepositorySecret_provisionRepositorySecret(scope, fsGithubRepositorySecretsSection, section, secret.name, secret.ref, repo);
|
|
369692
|
+
}
|
|
369693
|
+
}
|
|
369694
|
+
}
|
|
369695
|
+
}
|
|
369696
|
+
else {
|
|
369697
|
+
provisioner_src_logger.info(`FirestartrGithubRepository ${fsGithubRepositorySecretsSection.metadata.name} does not have a secrets section`);
|
|
369698
|
+
}
|
|
369699
|
+
}
|
|
369700
|
+
async function RepositorySecret_provisionRepositorySecret(scope, rss, section, repoSecretName, secretRef, repoResource) {
|
|
369701
|
+
provisioner_src_logger.info(`Provisioning repo secret ${rss.metadata.name}/${section}/${repoSecretName}`);
|
|
369702
|
+
const secretClass = section === 'actions'
|
|
369703
|
+
? actions_secret/* ActionsSecret */.N
|
|
369704
|
+
: section === 'codespaces'
|
|
369705
|
+
? codespaces_secret/* CodespacesSecret */.k
|
|
369706
|
+
: section === 'dependabot'
|
|
369707
|
+
? dependabot_secret/* DependabotSecret */.c
|
|
369708
|
+
: null;
|
|
369709
|
+
if (secretClass) {
|
|
369710
|
+
const fSecretCreation = process.env['AVOID_PROVIDER_SECRET_ENCRYPTION']
|
|
369711
|
+
? RepositorySecret_createUnencryptedSecret
|
|
369712
|
+
: RepositorySecret_createEncryptedSecrect;
|
|
369713
|
+
await fSecretCreation(scope, rss, secretRef, secretClass, section, repoSecretName, repoResource);
|
|
369714
|
+
provisioner_src_logger.info(`RepoSecret provisioned ${section}-${repoSecretName.toLowerCase()}-secret`);
|
|
369715
|
+
}
|
|
369716
|
+
}
|
|
369717
|
+
async function RepositorySecret_createEncryptedSecrect(scope, rss, secretRef, secretClass, section, repoSecretName, repo) {
|
|
369718
|
+
const { key_id, encrypted_value } = await RepositorySecret_encryptSecret(rss, secretRef);
|
|
369719
|
+
const resourceKey = `${section}-${repoSecretName.toLowerCase()}-secret`;
|
|
369720
|
+
const plainTextSecret = rss.resolveSecretRef({
|
|
369721
|
+
name: secretRef.name,
|
|
369722
|
+
key: secretRef.key,
|
|
369723
|
+
});
|
|
369724
|
+
const sha256 = external_crypto_default().createHash('sha256')
|
|
369725
|
+
.update(plainTextSecret)
|
|
369726
|
+
.digest('hex');
|
|
369727
|
+
const secretResourceName = `_${section}-${repoSecretName.toLowerCase()}-${sha256.slice(0, 12)}`;
|
|
369728
|
+
const instanceLifecycle = {
|
|
369729
|
+
ignoreChanges: ['encrypted_value'],
|
|
369730
|
+
};
|
|
369731
|
+
const sc = new secretClass(scope, secretResourceName, {
|
|
369732
|
+
secretName: repoSecretName,
|
|
369733
|
+
repository: repo,
|
|
369734
|
+
encryptedValue: encrypted_value,
|
|
369735
|
+
lifecycle: instanceLifecycle,
|
|
369736
|
+
});
|
|
369737
|
+
rss.addResourceToStack(resourceKey, sc);
|
|
369738
|
+
}
|
|
369739
|
+
async function RepositorySecret_createUnencryptedSecret(scope, rss, secretRef, secretClass, section, repoSecretName, repo) {
|
|
369740
|
+
const plainTextSecret = rss.resolveSecretRef({
|
|
369741
|
+
name: secretRef.name,
|
|
369742
|
+
key: secretRef.key,
|
|
369743
|
+
});
|
|
369744
|
+
const resourceKey = `${section}-${repoSecretName.toLowerCase()}-secret`;
|
|
369745
|
+
const tfStateKey = `_${rss.getTfStateKey()}-${resourceKey}`;
|
|
369746
|
+
const sc = new secretClass(scope, tfStateKey, {
|
|
369747
|
+
secretName: repoSecretName,
|
|
369748
|
+
plaintextValue: plainTextSecret,
|
|
369749
|
+
repository: repo,
|
|
369750
|
+
});
|
|
369751
|
+
provisioner_src_logger.info(tfStateKey);
|
|
369752
|
+
rss.addResourceToStack(resourceKey, sc);
|
|
369753
|
+
}
|
|
369754
|
+
async function RepositorySecret_encryptSecret(rss, secretRef) {
|
|
369755
|
+
const plainTextSecret = rss.resolveSecretRef({
|
|
369756
|
+
name: secretRef.name,
|
|
369757
|
+
key: secretRef.key,
|
|
369758
|
+
});
|
|
369759
|
+
const v = await github_0.encryption.encryptRepoSecret(process.env.ORG, rss.metadata.name, plainTextSecret);
|
|
369760
|
+
return v;
|
|
369761
|
+
}
|
|
369762
|
+
|
|
369763
|
+
;// CONCATENATED MODULE: ../provisioner/src/entities/firestartrgithubrepositorysecretssection/FirestartrGithubRepositorySecretsSection.ts
|
|
369764
|
+
|
|
369765
|
+
|
|
369766
|
+
class FirestartrGithubRepositorySecretsSection_FirestartrGithubRepositorySecretsSection extends Entity {
|
|
369767
|
+
constructor(artifact, deps) {
|
|
369768
|
+
super(artifact, deps);
|
|
369769
|
+
}
|
|
369770
|
+
async loadResources(data) {
|
|
369771
|
+
const { scope } = data;
|
|
369772
|
+
const repo = this.resolveRef(this.spec.repositoryTarget.ref);
|
|
369773
|
+
await RepositorySecret_provisionRepositorySecrets(scope, this, repo);
|
|
369774
|
+
}
|
|
369775
|
+
}
|
|
369776
|
+
|
|
368885
369777
|
;// CONCATENATED MODULE: ../provisioner/src/entities/index.ts
|
|
368886
369778
|
|
|
368887
369779
|
|
|
@@ -368889,6 +369781,7 @@ class FirestartrTerraformModuleEntity extends Entity {
|
|
|
368889
369781
|
|
|
368890
369782
|
|
|
368891
369783
|
|
|
369784
|
+
|
|
368892
369785
|
function getEntityInstance(entity, deps) {
|
|
368893
369786
|
let instance = null;
|
|
368894
369787
|
switch (entity.kind) {
|
|
@@ -368910,6 +369803,9 @@ function getEntityInstance(entity, deps) {
|
|
|
368910
369803
|
case 'FirestartrGithubOrgWebhook':
|
|
368911
369804
|
instance = new FirestartrGithubOrgWebhook_FirestartrGithubOrgWebhook(entity, deps);
|
|
368912
369805
|
break;
|
|
369806
|
+
case 'FirestartrGithubRepositorySecretsSection':
|
|
369807
|
+
instance = new FirestartrGithubRepositorySecretsSection_FirestartrGithubRepositorySecretsSection(entity, deps);
|
|
369808
|
+
break;
|
|
368913
369809
|
default:
|
|
368914
369810
|
break;
|
|
368915
369811
|
}
|
|
@@ -369149,6 +370045,7 @@ function getStackByEntity(entity) {
|
|
|
369149
370045
|
case 'FirestartrGithubMembership':
|
|
369150
370046
|
case 'FirestartrGithubRepositoryFeature':
|
|
369151
370047
|
case 'FirestartrGithubOrgWebhook':
|
|
370048
|
+
case 'FirestartrGithubRepositorySecretsSection':
|
|
369152
370049
|
return GithubStack;
|
|
369153
370050
|
case 'FirestartrTerraformModule':
|
|
369154
370051
|
return TerraformModuleStack;
|
|
@@ -369900,6 +370797,30 @@ class github_orgWebhook_FirestartrGithubOrgWebhook extends Resource {
|
|
|
369900
370797
|
}
|
|
369901
370798
|
}
|
|
369902
370799
|
|
|
370800
|
+
;// CONCATENATED MODULE: ../provisioner/src/resources/github_repository_secrets_section/index.ts
|
|
370801
|
+
|
|
370802
|
+
|
|
370803
|
+
class github_repository_secrets_section_FirestartrGithubRepositorySecretsSection extends Resource {
|
|
370804
|
+
static kind() {
|
|
370805
|
+
return 'FirestartrGithubRepositorySecretsSection';
|
|
370806
|
+
}
|
|
370807
|
+
async preprocess() {
|
|
370808
|
+
switch (this.get('operation')) {
|
|
370809
|
+
case 'CREATE':
|
|
370810
|
+
provisioner_src_logger.debug('Creating FirestartrGithubRepositorySecretsSection');
|
|
370811
|
+
break;
|
|
370812
|
+
case 'UPDATE':
|
|
370813
|
+
provisioner_src_logger.debug('Updating FirestartrGithubRepositorySecretsSection');
|
|
370814
|
+
break;
|
|
370815
|
+
case 'DELETE':
|
|
370816
|
+
provisioner_src_logger.debug('Deleting FirestartrGithubRepositorySecretsSection');
|
|
370817
|
+
break;
|
|
370818
|
+
default:
|
|
370819
|
+
provisioner_src_logger.debug(`Unknown operation '${this.get('operation')}' for FirestartrGithubRepositorySecretsSection`);
|
|
370820
|
+
}
|
|
370821
|
+
}
|
|
370822
|
+
}
|
|
370823
|
+
|
|
369903
370824
|
;// CONCATENATED MODULE: ../provisioner/src/resources/index.ts
|
|
369904
370825
|
|
|
369905
370826
|
|
|
@@ -369907,6 +370828,7 @@ class github_orgWebhook_FirestartrGithubOrgWebhook extends Resource {
|
|
|
369907
370828
|
|
|
369908
370829
|
|
|
369909
370830
|
|
|
370831
|
+
|
|
369910
370832
|
/* harmony default export */ const resources = ({
|
|
369911
370833
|
FirestartrGithubRepositoryFeature: github_feature_FirestartrGithubRepositoryFeature,
|
|
369912
370834
|
FirestartrGithubRepository: github_repository_FirestartrGithubRepository,
|
|
@@ -369914,6 +370836,7 @@ class github_orgWebhook_FirestartrGithubOrgWebhook extends Resource {
|
|
|
369914
370836
|
FirestartrGithubGroup: github_group_FirestartrGithubGroup,
|
|
369915
370837
|
FirestartrTerraformModule: FirestartrTerraformModule,
|
|
369916
370838
|
FirestartrGithubOrgWebhook: github_orgWebhook_FirestartrGithubOrgWebhook,
|
|
370839
|
+
FirestartrGithubRepositorySecretsSection: github_repository_secrets_section_FirestartrGithubRepositorySecretsSection,
|
|
369917
370840
|
});
|
|
369918
370841
|
|
|
369919
370842
|
;// CONCATENATED MODULE: ../provisioner/init.ts
|
|
@@ -371807,13 +372730,6 @@ function isDestroyRetry(item) {
|
|
|
371807
372730
|
return false;
|
|
371808
372731
|
}
|
|
371809
372732
|
async function* process_operation_sync(item, op, handler, syncPolicy, generalPolicy) {
|
|
371810
|
-
yield {
|
|
371811
|
-
item,
|
|
371812
|
-
reason: op,
|
|
371813
|
-
type: 'SYNCHRONIZED',
|
|
371814
|
-
status: 'False',
|
|
371815
|
-
message: 'Sync process started',
|
|
371816
|
-
};
|
|
371817
372733
|
if (!syncPolicy) {
|
|
371818
372734
|
operator_src_logger.debug(`The Terraform processor is only observing item '${item.kind}/${item.metadata.name}' because no sync policy was found for operation '${op}'.`);
|
|
371819
372735
|
yield* doPlanJSONFormat(item, op, handler);
|
|
@@ -373636,6 +374552,7 @@ function getProvisionImplementation(plural) {
|
|
|
373636
374552
|
case 'githubrepositoryfeatures':
|
|
373637
374553
|
case 'githubgroups':
|
|
373638
374554
|
case 'githuborgwebhooks':
|
|
374555
|
+
case 'githubrepositorysecretssections':
|
|
373639
374556
|
implementation = processOperation;
|
|
373640
374557
|
break;
|
|
373641
374558
|
}
|