@firestartr/cli 1.51.1-snapshot-06 → 1.52.0-snapshot-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 +1025 -95
- package/build/packages/cdk8s_renderer/imports/firestartr.dev.d.ts +424 -0
- package/build/packages/cdk8s_renderer/src/charts/github/RepoSecretsSectionChart.d.ts +12 -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
|
*
|
|
@@ -363691,12 +364054,104 @@ class FeatureRepoChart extends BaseGithubChart {
|
|
|
363691
364054
|
}
|
|
363692
364055
|
}
|
|
363693
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
|
+
const annotations = this.getAnnotationsFromRepo(this.get('repoCr'), [
|
|
364091
|
+
'claim-ref',
|
|
364092
|
+
'revision',
|
|
364093
|
+
'sync-enabled',
|
|
364094
|
+
'sync-period',
|
|
364095
|
+
]);
|
|
364096
|
+
cr.metadata.annotations = {
|
|
364097
|
+
...cr.metadata.annotations,
|
|
364098
|
+
...annotations,
|
|
364099
|
+
};
|
|
364100
|
+
return cr;
|
|
364101
|
+
}
|
|
364102
|
+
getAnnotationsFromRepo(repoCr, inheritedAnnotations) {
|
|
364103
|
+
const annotations = {};
|
|
364104
|
+
for (const annotation of inheritedAnnotations) {
|
|
364105
|
+
const fsAnnotation = `firestartr.dev/${annotation}`;
|
|
364106
|
+
if (fsAnnotation in repoCr.metadata.annotations) {
|
|
364107
|
+
annotations[fsAnnotation] = repoCr.metadata.annotations[fsAnnotation];
|
|
364108
|
+
}
|
|
364109
|
+
}
|
|
364110
|
+
return annotations;
|
|
364111
|
+
}
|
|
364112
|
+
renderSecrets(section, githubProvider) {
|
|
364113
|
+
const secrets = [];
|
|
364114
|
+
if (githubProvider?.secrets?.[section]) {
|
|
364115
|
+
const secretsSection = githubProvider.secrets[section];
|
|
364116
|
+
for (const secret of secretsSection) {
|
|
364117
|
+
const parts = secret.value.split(':');
|
|
364118
|
+
secrets.push({
|
|
364119
|
+
name: secret.name,
|
|
364120
|
+
ref: {
|
|
364121
|
+
kind: 'Secret',
|
|
364122
|
+
name: parts[2],
|
|
364123
|
+
key: parts[3],
|
|
364124
|
+
},
|
|
364125
|
+
});
|
|
364126
|
+
}
|
|
364127
|
+
}
|
|
364128
|
+
return secrets;
|
|
364129
|
+
}
|
|
364130
|
+
gvk() {
|
|
364131
|
+
return FirestartrGithubRepositorySecretsSection.GVK;
|
|
364132
|
+
}
|
|
364133
|
+
instanceApiObject(template) {
|
|
364134
|
+
return new FirestartrGithubRepositorySecretsSection(this, `${template.metadata.name}-${template.spec.firestartr.tfStateKey}-secrets-section`, template);
|
|
364135
|
+
}
|
|
364136
|
+
resolveRepositoryTarget() {
|
|
364137
|
+
const repositoryTarget = {
|
|
364138
|
+
ref: {
|
|
364139
|
+
kind: 'FirestartrGithubRepository',
|
|
364140
|
+
name: this.get('repoCr').metadata.name,
|
|
364141
|
+
needsSecret: false,
|
|
364142
|
+
},
|
|
364143
|
+
};
|
|
364144
|
+
return repositoryTarget;
|
|
364145
|
+
}
|
|
364146
|
+
}
|
|
364147
|
+
|
|
363694
364148
|
;// CONCATENATED MODULE: ../cdk8s_renderer/src/charts/github/repositoryChart.ts
|
|
363695
364149
|
|
|
363696
364150
|
|
|
363697
364151
|
|
|
363698
364152
|
|
|
363699
364153
|
|
|
364154
|
+
|
|
363700
364155
|
class GithubRepositoryChart extends BaseGithubChart {
|
|
363701
364156
|
template() {
|
|
363702
364157
|
const claim = this.get('claim');
|
|
@@ -363762,6 +364217,7 @@ class GithubRepositoryChart extends BaseGithubChart {
|
|
|
363762
364217
|
async render() {
|
|
363763
364218
|
await super.render();
|
|
363764
364219
|
await this.postRenderFeatures(this.get('rendered-cr'));
|
|
364220
|
+
await this.postRenderSecretsSection(this.get('rendered-cr'));
|
|
363765
364221
|
return this;
|
|
363766
364222
|
}
|
|
363767
364223
|
gvk() {
|
|
@@ -363783,6 +364239,20 @@ class GithubRepositoryChart extends BaseGithubChart {
|
|
|
363783
364239
|
}
|
|
363784
364240
|
this.set('features', features);
|
|
363785
364241
|
}
|
|
364242
|
+
async postRenderSecretsSection(cr) {
|
|
364243
|
+
const areThereSecrets = this.get('claim').providers?.github?.secrets ?? false;
|
|
364244
|
+
if (!areThereSecrets) {
|
|
364245
|
+
return;
|
|
364246
|
+
}
|
|
364247
|
+
const secretsSectionChart = await (await new RepoSecretsSectionChart(this, 'secrets-section', cr.spec.firestartr.tfStateKey, this.get('claim'), [], cr).render()).postRenderer([]);
|
|
364248
|
+
this.set('secrets_section', {
|
|
364249
|
+
claim: {
|
|
364250
|
+
kind: secretsSectionChart.kind,
|
|
364251
|
+
name: secretsSectionChart.name,
|
|
364252
|
+
},
|
|
364253
|
+
chart: secretsSectionChart,
|
|
364254
|
+
});
|
|
364255
|
+
}
|
|
363786
364256
|
instanceApiObject(template) {
|
|
363787
364257
|
return new FirestartrGithubRepository(this, template.metadata.name, template);
|
|
363788
364258
|
}
|
|
@@ -363887,7 +364357,10 @@ class GithubRepositoryChart extends BaseGithubChart {
|
|
|
363887
364357
|
});
|
|
363888
364358
|
}
|
|
363889
364359
|
extraCharts() {
|
|
363890
|
-
|
|
364360
|
+
const charts = [this.get('secrets_section') ?? undefined];
|
|
364361
|
+
return charts
|
|
364362
|
+
.concat(this.get('features') ?? [])
|
|
364363
|
+
.filter((chart) => chart);
|
|
363891
364364
|
}
|
|
363892
364365
|
}
|
|
363893
364366
|
|
|
@@ -366508,6 +366981,7 @@ const kindPluralMap = {
|
|
|
366508
366981
|
githubmemberships: 'FirestartrGithubMembership',
|
|
366509
366982
|
githubrepositories: 'FirestartrGithubRepository',
|
|
366510
366983
|
githubrepositoryfeatures: 'FirestartrGithubRepositoryFeature',
|
|
366984
|
+
githubrepositorysecretssections: 'FirestartrGithubRepositorySecretsSection',
|
|
366511
366985
|
terraformmodules: 'FirestartrTerraformModule',
|
|
366512
366986
|
githuborgwebhooks: 'FirestartrGithubOrgWebhook',
|
|
366513
366987
|
terraformworkspaces: 'FirestartrTerraformWorkspace',
|
|
@@ -367122,6 +367596,28 @@ async function needsProvisioningOnCreate(cr) {
|
|
|
367122
367596
|
operator_src_logger.debug(`Skipping the provisioning process for custom resource '${cr.kind}/${cr.metadata.name}' because its current state is not handled.`);
|
|
367123
367597
|
return false;
|
|
367124
367598
|
}
|
|
367599
|
+
async function updateSyncTransition(itemPath, reason, lastSyncTime, nextSyncTime, message, status) {
|
|
367600
|
+
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}'.`);
|
|
367601
|
+
const k8sItem = await getItemByItemPath(itemPath);
|
|
367602
|
+
if (!('status' in k8sItem))
|
|
367603
|
+
k8sItem.status = {};
|
|
367604
|
+
if (!('conditions' in k8sItem.status))
|
|
367605
|
+
k8sItem.status.conditions = [];
|
|
367606
|
+
let conditionObject = getRelevantCondition(k8sItem.status.conditions, 'SYNCHRONIZED');
|
|
367607
|
+
conditionObject = {
|
|
367608
|
+
...conditionObject,
|
|
367609
|
+
reason,
|
|
367610
|
+
status,
|
|
367611
|
+
message,
|
|
367612
|
+
observedGeneration: k8sItem.metadata.generation,
|
|
367613
|
+
lastSyncTime,
|
|
367614
|
+
lastUpdateTime: new Date().toJSON(),
|
|
367615
|
+
nextSyncTime,
|
|
367616
|
+
};
|
|
367617
|
+
k8sItem.status.conditions = updateConditionByType(k8sItem.status.conditions, 'SYNCHRONIZED', conditionObject);
|
|
367618
|
+
const itemParameters = itemPath.split('/');
|
|
367619
|
+
await writeStatus(itemParameters[1], itemParameters[0], k8sItem);
|
|
367620
|
+
}
|
|
367125
367621
|
async function updateTransition(itemPath, reason, type, statusValue, message = '', updateStatusOnly = false) {
|
|
367126
367622
|
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
367623
|
const k8sItem = await getItemByItemPath(itemPath);
|
|
@@ -367182,12 +367678,142 @@ function updateConditionByType(conditionList, type, newCondition) {
|
|
|
367182
367678
|
return conditionList;
|
|
367183
367679
|
}
|
|
367184
367680
|
|
|
367185
|
-
;// CONCATENATED MODULE: ../operator/src/
|
|
367681
|
+
;// CONCATENATED MODULE: ../operator/src/syncCtl.ts
|
|
367682
|
+
// Machinery for syncing
|
|
367683
|
+
|
|
367684
|
+
|
|
367186
367685
|
|
|
367187
367686
|
|
|
367188
|
-
const syncWatchers = {};
|
|
367189
|
-
const FORCE_REVISION_TIME = 60 * 1000;
|
|
367190
367687
|
const DEFAULT_REVISION_TIME = '1m';
|
|
367688
|
+
async function createWatcherForItem(itemPath, itemCR) {
|
|
367689
|
+
const item = itemCR ?? (await getItemByItemPath(itemPath));
|
|
367690
|
+
const syncStatus = await getSyncStatus(itemPath, item);
|
|
367691
|
+
let nextTimeoutInMS = syncStatus.nextTimeoutInMS;
|
|
367692
|
+
// we have lapsed last interval
|
|
367693
|
+
// we calculate from the lastSyncTime
|
|
367694
|
+
if (syncStatus.intervalLapsed) {
|
|
367695
|
+
operator_src_logger.debug(`Next sync interval have been lapsed for ${itemPath}`);
|
|
367696
|
+
if (syncStatus.syncMode === 'Period') {
|
|
367697
|
+
operator_src_logger.debug(`Next sync interval have been lapsed for ${itemPath} the sync will start now`);
|
|
367698
|
+
nextTimeoutInMS = -1;
|
|
367699
|
+
}
|
|
367700
|
+
}
|
|
367701
|
+
const syncInfo = syncStatus.conditions?.[0] ?? null;
|
|
367702
|
+
const watcher = {
|
|
367703
|
+
itemPath,
|
|
367704
|
+
lastRevision: setTimeout(() => {
|
|
367705
|
+
operator_src_logger.debug(`Item ${itemPath} needs revision`);
|
|
367706
|
+
watcher.needsRevision = true;
|
|
367707
|
+
watcher.alreadyFired = true;
|
|
367708
|
+
}, nextTimeoutInMS),
|
|
367709
|
+
needsRevision: false,
|
|
367710
|
+
nextSync: syncInfo ? syncInfo?.nextSyncTime : undefined,
|
|
367711
|
+
syncMode: syncStatus.syncMode,
|
|
367712
|
+
alreadyFired: false,
|
|
367713
|
+
};
|
|
367714
|
+
return watcher;
|
|
367715
|
+
}
|
|
367716
|
+
async function destroyWatcherForItem(watcher) {
|
|
367717
|
+
clearTimeout(watcher.lastRevision);
|
|
367718
|
+
operator_src_logger.debug(`Disabled SyncWatcher for ${watcher.itemPath}`);
|
|
367719
|
+
}
|
|
367720
|
+
async function getSyncSpecs(itemPath, itemCR) {
|
|
367721
|
+
const item = itemCR ?? (await getItemByItemPath(itemPath));
|
|
367722
|
+
return {
|
|
367723
|
+
item,
|
|
367724
|
+
syncable: helperIsSyncable(item),
|
|
367725
|
+
period: item.metadata.annotations['firestartr.dev/sync-period'] ||
|
|
367726
|
+
DEFAULT_REVISION_TIME,
|
|
367727
|
+
schedule: item.metadata.annotations['firestartr.dev/sync-schedule'] || false,
|
|
367728
|
+
scheduleTZ: item.metadata.annotations['firestartr.dev/sync-schedule-timezone'] ||
|
|
367729
|
+
'Europe/Madrid',
|
|
367730
|
+
};
|
|
367731
|
+
}
|
|
367732
|
+
async function getSyncStatus(itemPath, itemCR) {
|
|
367733
|
+
const item = itemCR ?? (await getItemByItemPath(itemPath));
|
|
367734
|
+
const syncCondition = getConditionByType(item.status?.conditions ?? [], 'SYNCHRONIZED');
|
|
367735
|
+
// no sync condition present
|
|
367736
|
+
if (!syncCondition) {
|
|
367737
|
+
return {
|
|
367738
|
+
syncStatusPresent: false,
|
|
367739
|
+
};
|
|
367740
|
+
}
|
|
367741
|
+
else {
|
|
367742
|
+
const nextSyncDate = new Date(syncCondition.nextSyncTime);
|
|
367743
|
+
const isLapsed = Date.now() >= nextSyncDate.getTime();
|
|
367744
|
+
const mode = (await getSyncSpecs(itemPath, item)).schedule
|
|
367745
|
+
? 'Scheduled'
|
|
367746
|
+
: 'Period';
|
|
367747
|
+
return {
|
|
367748
|
+
itemPath,
|
|
367749
|
+
syncMode: mode,
|
|
367750
|
+
conditions: [syncCondition],
|
|
367751
|
+
syncStatusPresent: true,
|
|
367752
|
+
nextTimeoutInMS: isLapsed ? -1 : nextSyncDate.getTime() - Date.now(),
|
|
367753
|
+
intervalLapsed: isLapsed,
|
|
367754
|
+
};
|
|
367755
|
+
}
|
|
367756
|
+
}
|
|
367757
|
+
async function setSyncStatus(itemPath, reason, status, message) {
|
|
367758
|
+
const item = await getItemByItemPath(itemPath);
|
|
367759
|
+
const machinery = assessSyncCalculationMachinery(item);
|
|
367760
|
+
const syncStatus = await machinery(item, reason, status, message);
|
|
367761
|
+
syncStatus.itemPath = itemPath;
|
|
367762
|
+
syncStatus.syncStatusPresent = true;
|
|
367763
|
+
operator_src_logger.info(`Setting sync status for ${itemPath}: ${JSON.stringify(syncStatus)}`);
|
|
367764
|
+
const syncTransition = syncStatus.conditions[0];
|
|
367765
|
+
await updateSyncTransition(itemPath, syncTransition.reason, syncTransition.lastSyncTime, syncTransition.nextSyncTime, syncTransition.message, syncTransition.status);
|
|
367766
|
+
return syncStatus;
|
|
367767
|
+
}
|
|
367768
|
+
function assessSyncCalculationMachinery(item) {
|
|
367769
|
+
if (!helperIsSyncable(item)) {
|
|
367770
|
+
return processNotSyncable;
|
|
367771
|
+
}
|
|
367772
|
+
else if (item.metadata.annotations['firestartr.dev/sync-schedule'] ??
|
|
367773
|
+
false) {
|
|
367774
|
+
return processScheduledSync;
|
|
367775
|
+
}
|
|
367776
|
+
else {
|
|
367777
|
+
return processPeriodSync;
|
|
367778
|
+
}
|
|
367779
|
+
}
|
|
367780
|
+
function helperIsSyncable(item) {
|
|
367781
|
+
return (item.metadata.annotations &&
|
|
367782
|
+
item.metadata.annotations['firestartr.dev/sync-enabled'] &&
|
|
367783
|
+
item.metadata.annotations['firestartr.dev/sync-enabled'] === 'true');
|
|
367784
|
+
}
|
|
367785
|
+
async function processNotSyncable(item, reason, status, message) {
|
|
367786
|
+
return {
|
|
367787
|
+
syncMode: 'Period',
|
|
367788
|
+
conditions: [
|
|
367789
|
+
{
|
|
367790
|
+
reason,
|
|
367791
|
+
type: 'SYNCHRONIZED',
|
|
367792
|
+
message,
|
|
367793
|
+
status,
|
|
367794
|
+
lastSyncTime: new Date().toISOString(),
|
|
367795
|
+
nextSyncTime: new Date().toISOString(),
|
|
367796
|
+
},
|
|
367797
|
+
],
|
|
367798
|
+
};
|
|
367799
|
+
}
|
|
367800
|
+
async function processPeriodSync(item, reason, status, message) {
|
|
367801
|
+
const period = item.metadata.annotations['firestartr.dev/sync-period'];
|
|
367802
|
+
const periodMS = helperCalculateRevisionTime(period);
|
|
367803
|
+
return {
|
|
367804
|
+
syncMode: 'Period',
|
|
367805
|
+
conditions: [
|
|
367806
|
+
{
|
|
367807
|
+
reason,
|
|
367808
|
+
type: 'SYNCHRONIZED',
|
|
367809
|
+
message,
|
|
367810
|
+
status,
|
|
367811
|
+
lastSyncTime: new Date().toISOString(),
|
|
367812
|
+
nextSyncTime: new Date(Date.now() + periodMS).toISOString(),
|
|
367813
|
+
},
|
|
367814
|
+
],
|
|
367815
|
+
};
|
|
367816
|
+
}
|
|
367191
367817
|
function helperCalculateRevisionTime(period) {
|
|
367192
367818
|
const [_, scalar, dimension] = period.split(/(\d+)/);
|
|
367193
367819
|
const multiplier = dimension === 's'
|
|
@@ -367201,24 +367827,97 @@ function helperCalculateRevisionTime(period) {
|
|
|
367201
367827
|
: 1;
|
|
367202
367828
|
return Number(scalar) * multiplier * 1000;
|
|
367203
367829
|
}
|
|
367204
|
-
async function
|
|
367205
|
-
|
|
367206
|
-
|
|
367830
|
+
async function processScheduledSync(item, reason, status, message) {
|
|
367831
|
+
const nextPeriod = catalog_common.cron.getCronNextInterval(item.metadata.annotations['firestartr.dev/sync-schedule'], item.metadata.annotations['firestartr.dev/sync-schedule-timezone'] ||
|
|
367832
|
+
undefined);
|
|
367833
|
+
const nextPeriodDate = new Date(nextPeriod);
|
|
367207
367834
|
return {
|
|
367835
|
+
syncMode: 'Scheduled',
|
|
367836
|
+
conditions: [
|
|
367837
|
+
{
|
|
367838
|
+
reason,
|
|
367839
|
+
type: 'SYNCHRONIZED',
|
|
367840
|
+
message,
|
|
367841
|
+
status,
|
|
367842
|
+
lastSyncTime: new Date().toISOString(),
|
|
367843
|
+
nextSyncTime: nextPeriodDate.toISOString(),
|
|
367844
|
+
},
|
|
367845
|
+
],
|
|
367846
|
+
};
|
|
367847
|
+
}
|
|
367848
|
+
|
|
367849
|
+
;// CONCATENATED MODULE: ../operator/src/syncer.debug.ts
|
|
367850
|
+
|
|
367851
|
+
|
|
367852
|
+
let running = false;
|
|
367853
|
+
let waitingF = null;
|
|
367854
|
+
async function syncerDebug(syncWatchers) {
|
|
367855
|
+
if (running)
|
|
367856
|
+
return waitUntilDone(syncWatchers);
|
|
367857
|
+
running = true;
|
|
367858
|
+
try {
|
|
367859
|
+
await writeDownSyncer(syncWatchers);
|
|
367860
|
+
running = false;
|
|
367861
|
+
}
|
|
367862
|
+
catch (err) {
|
|
367863
|
+
operator_src_logger.error(`PANIC!!! sync debug could not be written ${err}`);
|
|
367864
|
+
running = false;
|
|
367865
|
+
}
|
|
367866
|
+
}
|
|
367867
|
+
async function waitUntilDone(syncWatchers) {
|
|
367868
|
+
if (waitingF)
|
|
367869
|
+
return;
|
|
367870
|
+
waitingF = setTimeout(() => {
|
|
367871
|
+
syncerDebug(syncWatchers).catch((err) => {
|
|
367872
|
+
operator_src_logger.error(`Caught error: ${err}`);
|
|
367873
|
+
throw `Caught error: ${err}`;
|
|
367874
|
+
});
|
|
367875
|
+
clearTimeout(waitingF);
|
|
367876
|
+
waitingF = null;
|
|
367877
|
+
}, 300);
|
|
367878
|
+
}
|
|
367879
|
+
async function writeDownSyncer(syncWatchers) {
|
|
367880
|
+
let output = '';
|
|
367881
|
+
for (const watcher of Object.values(syncWatchers)) {
|
|
367882
|
+
output += `${watcher.itemPath} - (${watcher.syncMode}) - next: ${watcher.nextSync} \n`;
|
|
367883
|
+
}
|
|
367884
|
+
return new Promise((ok, ko) => {
|
|
367885
|
+
external_fs_.writeFile('/tmp/syncs', output, (err) => {
|
|
367886
|
+
if (err)
|
|
367887
|
+
return ko(`Error writing the /tmp/syncs: ${err}`);
|
|
367888
|
+
else
|
|
367889
|
+
return ok();
|
|
367890
|
+
});
|
|
367891
|
+
});
|
|
367892
|
+
}
|
|
367893
|
+
|
|
367894
|
+
;// CONCATENATED MODULE: ../operator/src/syncer.ts
|
|
367895
|
+
|
|
367896
|
+
|
|
367897
|
+
|
|
367898
|
+
|
|
367899
|
+
const syncWatchers = {};
|
|
367900
|
+
const FORCE_REVISION_TIME = (/* unused pure expression or super */ null && (60 * 1000));
|
|
367901
|
+
async function syncer(enqueue) {
|
|
367902
|
+
const api = {
|
|
367208
367903
|
addItem(itemPath) {
|
|
367209
367904
|
operator_src_logger.info(`Added item of path '${itemPath}' for synchronization`);
|
|
367210
|
-
|
|
367905
|
+
getSyncSpecs(itemPath)
|
|
367906
|
+
.then(async (itemSyncInfo) => {
|
|
367211
367907
|
if (!itemSyncInfo.syncable) {
|
|
367212
367908
|
return;
|
|
367213
367909
|
}
|
|
367214
|
-
|
|
367215
|
-
|
|
367216
|
-
lastRevision: setInterval(() => {
|
|
367217
|
-
syncWatchers[itemPath].needsRevision = true;
|
|
367218
|
-
}, helperCalculateRevisionTime(itemSyncInfo.period)),
|
|
367219
|
-
needsRevision: false,
|
|
367220
|
-
};
|
|
367910
|
+
const syncCtl = await getSyncStatus(itemPath, itemSyncInfo.item);
|
|
367911
|
+
syncWatchers[itemPath] = await createWatcherForItem(itemPath, itemSyncInfo.item);
|
|
367221
367912
|
operator_src_logger.info(`Configured synchronization for item at path '${itemPath}'`);
|
|
367913
|
+
operator_src_logger.debug(`Sync information for '${itemPath}': ${JSON.stringify({ ...itemSyncInfo, item: null }, null)}`);
|
|
367914
|
+
syncerDebug(syncWatchers).catch((err) => {
|
|
367915
|
+
throw `Error syncer debug: ${err}`;
|
|
367916
|
+
});
|
|
367917
|
+
})
|
|
367918
|
+
.catch((err) => {
|
|
367919
|
+
operator_src_logger.error(`Error on sync [add item]: ${err}`);
|
|
367920
|
+
throw `Error on sync [add item]: ${err}`;
|
|
367222
367921
|
});
|
|
367223
367922
|
},
|
|
367224
367923
|
updateItem(itemPath) {
|
|
@@ -367227,27 +367926,27 @@ async function syncer(enqueue) {
|
|
|
367227
367926
|
// return
|
|
367228
367927
|
//}
|
|
367229
367928
|
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
|
-
}
|
|
367929
|
+
return getSyncSpecs(itemPath)
|
|
367930
|
+
.then(async (itemSyncInfo) => {
|
|
367931
|
+
if (syncWatchers[itemPath]) {
|
|
367932
|
+
await destroyWatcherForItem(syncWatchers[itemPath]);
|
|
367933
|
+
delete syncWatchers[itemPath];
|
|
367237
367934
|
}
|
|
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]}'`);
|
|
367935
|
+
// we need to check if the item is not syncable anymore
|
|
367936
|
+
if (!itemSyncInfo.syncable) {
|
|
367937
|
+
operator_src_logger.info(`Removed item of path '${itemPath}' from synchronization`);
|
|
367938
|
+
return;
|
|
367250
367939
|
}
|
|
367940
|
+
// if it is syncable we need to recalculate everything
|
|
367941
|
+
syncWatchers[itemPath] = await createWatcherForItem(itemPath);
|
|
367942
|
+
operator_src_logger.info(`Configured synchronization for item at path '${itemPath}' with watcher`);
|
|
367943
|
+
syncerDebug(syncWatchers).catch((err) => {
|
|
367944
|
+
throw `Error syncer debug: ${err}`;
|
|
367945
|
+
});
|
|
367946
|
+
})
|
|
367947
|
+
.catch((err) => {
|
|
367948
|
+
operator_src_logger.error(`Error on sync [updateItem]: ${err}`);
|
|
367949
|
+
throw `Error on sync [updateItem]: ${err}`;
|
|
367251
367950
|
});
|
|
367252
367951
|
},
|
|
367253
367952
|
deleteItem(itemPath) {
|
|
@@ -367255,35 +367954,54 @@ async function syncer(enqueue) {
|
|
|
367255
367954
|
operator_src_logger.debug(`Ignored deletion attempt for item at path '${itemPath}' as it was not found during synchronization`);
|
|
367256
367955
|
return;
|
|
367257
367956
|
}
|
|
367258
|
-
|
|
367259
|
-
|
|
367260
|
-
|
|
367261
|
-
|
|
367957
|
+
destroyWatcherForItem(syncWatchers[itemPath])
|
|
367958
|
+
.then(() => {
|
|
367959
|
+
operator_src_logger.debug(`Deleted item of path '${itemPath}' during synchronization`);
|
|
367960
|
+
delete syncWatchers[itemPath];
|
|
367961
|
+
syncerDebug(syncWatchers).catch((err) => {
|
|
367962
|
+
throw `Error syncer debug: ${err}`;
|
|
367963
|
+
});
|
|
367964
|
+
})
|
|
367965
|
+
.catch((err) => {
|
|
367966
|
+
operator_src_logger.error(`Error deleting item of path ${itemPath} for synchronization: ${err}`);
|
|
367967
|
+
throw `Error deleting item of path ${itemPath} for synchronization: ${err}`;
|
|
367968
|
+
});
|
|
367262
367969
|
},
|
|
367263
367970
|
};
|
|
367971
|
+
// fork
|
|
367972
|
+
void loop(enqueue, api);
|
|
367973
|
+
return api;
|
|
367264
367974
|
}
|
|
367265
|
-
async function loop(enqueueIfNeeded) {
|
|
367975
|
+
async function loop(enqueueIfNeeded, api) {
|
|
367976
|
+
void loopKeeper(api);
|
|
367266
367977
|
while (1) {
|
|
367267
367978
|
await fWait();
|
|
367268
367979
|
const needRevisionItems = Object.values(syncWatchers).filter((watcher) => watcher.needsRevision);
|
|
367269
367980
|
for (const watcher of needRevisionItems) {
|
|
367270
367981
|
const item = await getItemIfNeededSync(watcher);
|
|
367982
|
+
operator_src_logger.debug(`Item needs revision ${watcher.itemPath}`);
|
|
367271
367983
|
if (item !== null) {
|
|
367272
367984
|
enqueueIfNeeded(item);
|
|
367273
|
-
watcher.needsRevision = false;
|
|
367274
367985
|
}
|
|
367986
|
+
watcher.needsRevision = false;
|
|
367275
367987
|
}
|
|
367276
367988
|
}
|
|
367277
367989
|
}
|
|
367278
|
-
async function
|
|
367279
|
-
|
|
367280
|
-
|
|
367281
|
-
|
|
367282
|
-
|
|
367283
|
-
|
|
367284
|
-
|
|
367285
|
-
|
|
367286
|
-
|
|
367990
|
+
async function loopKeeper(api) {
|
|
367991
|
+
try {
|
|
367992
|
+
while (1) {
|
|
367993
|
+
await fWait(5);
|
|
367994
|
+
for (const watcher of Object.values(syncWatchers)) {
|
|
367995
|
+
if (watcher.alreadyFired) {
|
|
367996
|
+
await api.updateItem(watcher.itemPath);
|
|
367997
|
+
}
|
|
367998
|
+
}
|
|
367999
|
+
}
|
|
368000
|
+
}
|
|
368001
|
+
catch (err) {
|
|
368002
|
+
operator_src_logger.error(`PANIC!: loopKeeper has failed: ${err}`);
|
|
368003
|
+
process.exit(1);
|
|
368004
|
+
}
|
|
367287
368005
|
}
|
|
367288
368006
|
async function getItemIfNeededSync(watcher) {
|
|
367289
368007
|
const item = await getItemByItemPath(watcher.itemPath);
|
|
@@ -367293,13 +368011,7 @@ async function getItemIfNeededSync(watcher) {
|
|
|
367293
368011
|
const isDeleting = item.status?.conditions?.find((condition) => condition.type === 'DELETING' && condition.status === 'True');
|
|
367294
368012
|
if (isDeleting)
|
|
367295
368013
|
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;
|
|
368014
|
+
return item;
|
|
367303
368015
|
}
|
|
367304
368016
|
function fWait(segs = 1) {
|
|
367305
368017
|
return new Promise((ok) => {
|
|
@@ -367555,6 +368267,7 @@ var WorkStatus;
|
|
|
367555
368267
|
|
|
367556
368268
|
|
|
367557
368269
|
|
|
368270
|
+
|
|
367558
368271
|
const kindsWithFinalizer = [
|
|
367559
368272
|
'FirestartrTerraformWorkspace',
|
|
367560
368273
|
'FirestartrGithubGroup',
|
|
@@ -367562,6 +368275,7 @@ const kindsWithFinalizer = [
|
|
|
367562
368275
|
'FirestartrGithubRepository',
|
|
367563
368276
|
'FirestartrGithubRepositoryFeature',
|
|
367564
368277
|
'FirestartrGithubOrgWebhook',
|
|
368278
|
+
'FirestartrGithubRepositorySecretsSection',
|
|
367565
368279
|
];
|
|
367566
368280
|
/**
|
|
367567
368281
|
* Observe whenever a new item is added, modified or deleted in a given kind
|
|
@@ -367674,15 +368388,18 @@ function enqueue(pluralKind, workItem, queue, compute, syncCtl, retryCtl) {
|
|
|
367674
368388
|
success: () => retryCtl.successReconciling(informer_itemPath(pluralKind, workItem.item)),
|
|
367675
368389
|
};
|
|
367676
368390
|
workItem.process = async function* (item, operation, handler) {
|
|
367677
|
-
|
|
367678
|
-
yield transition;
|
|
367679
|
-
}
|
|
367680
|
-
if (operation === OperationType.RENAMED ||
|
|
368391
|
+
const needsUpdateSyncConditions = operation === OperationType.RENAMED ||
|
|
367681
368392
|
operation === OperationType.UPDATED ||
|
|
367682
368393
|
operation === OperationType.SYNC ||
|
|
367683
368394
|
operation === OperationType.CREATED ||
|
|
367684
|
-
operation === OperationType.RETRY
|
|
367685
|
-
|
|
368395
|
+
operation === OperationType.RETRY;
|
|
368396
|
+
await setSyncStatus(workItem.handler.itemPath(), operation, 'False', 'Sync process started');
|
|
368397
|
+
for await (const transition of compute(item, operation, handler)) {
|
|
368398
|
+
yield transition;
|
|
368399
|
+
}
|
|
368400
|
+
if (needsUpdateSyncConditions) {
|
|
368401
|
+
await setSyncStatus(workItem.handler.itemPath(), operation, operation === OperationType.SYNC ? 'True' : 'False', 'Sync process finished');
|
|
368402
|
+
void syncCtl.updateItem(informer_itemPath(pluralKind, item));
|
|
367686
368403
|
}
|
|
367687
368404
|
else {
|
|
367688
368405
|
operator_src_logger.debug(`The informer received an item with an operation type of '${operation}', which is not a specific operation.`);
|
|
@@ -367724,6 +368441,7 @@ async function inform(pluralKind, item, op, lastWorkItem = null) {
|
|
|
367724
368441
|
item,
|
|
367725
368442
|
workStatus: WorkStatus.PENDING,
|
|
367726
368443
|
onDelete: function () { },
|
|
368444
|
+
upsertTime: Date.now(),
|
|
367727
368445
|
};
|
|
367728
368446
|
return workItem;
|
|
367729
368447
|
case 'onRename':
|
|
@@ -367734,6 +368452,7 @@ async function inform(pluralKind, item, op, lastWorkItem = null) {
|
|
|
367734
368452
|
item,
|
|
367735
368453
|
workStatus: WorkStatus.PENDING,
|
|
367736
368454
|
onDelete: function () { },
|
|
368455
|
+
upsertTime: Date.now(),
|
|
367737
368456
|
};
|
|
367738
368457
|
return workItem;
|
|
367739
368458
|
}
|
|
@@ -367747,6 +368466,7 @@ async function inform(pluralKind, item, op, lastWorkItem = null) {
|
|
|
367747
368466
|
item,
|
|
367748
368467
|
workStatus: WorkStatus.PENDING,
|
|
367749
368468
|
onDelete: function () { },
|
|
368469
|
+
upsertTime: Date.now(),
|
|
367750
368470
|
};
|
|
367751
368471
|
return workItem;
|
|
367752
368472
|
case 'onAdd':
|
|
@@ -367756,6 +368476,7 @@ async function inform(pluralKind, item, op, lastWorkItem = null) {
|
|
|
367756
368476
|
item,
|
|
367757
368477
|
workStatus: WorkStatus.PENDING,
|
|
367758
368478
|
onDelete: function () { },
|
|
368479
|
+
upsertTime: Date.now(),
|
|
367759
368480
|
};
|
|
367760
368481
|
return workItem;
|
|
367761
368482
|
}
|
|
@@ -367763,6 +368484,7 @@ async function inform(pluralKind, item, op, lastWorkItem = null) {
|
|
|
367763
368484
|
case 'onMarkedToDeletion':
|
|
367764
368485
|
if (workItem !== null && workItem.workStatus === WorkStatus.PENDING) {
|
|
367765
368486
|
workItem.operation = OperationType.MARKED_TO_DELETION;
|
|
368487
|
+
workItem.upsertTime = Date.now();
|
|
367766
368488
|
return null;
|
|
367767
368489
|
}
|
|
367768
368490
|
else {
|
|
@@ -367771,6 +368493,7 @@ async function inform(pluralKind, item, op, lastWorkItem = null) {
|
|
|
367771
368493
|
item,
|
|
367772
368494
|
workStatus: WorkStatus.PENDING,
|
|
367773
368495
|
onDelete: function () { },
|
|
368496
|
+
upsertTime: Date.now(),
|
|
367774
368497
|
};
|
|
367775
368498
|
return workItem;
|
|
367776
368499
|
}
|
|
@@ -367785,6 +368508,7 @@ async function inform(pluralKind, item, op, lastWorkItem = null) {
|
|
|
367785
368508
|
item,
|
|
367786
368509
|
workStatus: WorkStatus.PENDING,
|
|
367787
368510
|
onDelete: function () { },
|
|
368511
|
+
upsertTime: Date.now(),
|
|
367788
368512
|
};
|
|
367789
368513
|
return workItem;
|
|
367790
368514
|
}
|
|
@@ -367904,11 +368628,89 @@ function dummy_fWait(ms) {
|
|
|
367904
368628
|
});
|
|
367905
368629
|
}
|
|
367906
368630
|
|
|
368631
|
+
;// CONCATENATED MODULE: ../operator/src/processItem.debug.ts
|
|
368632
|
+
|
|
368633
|
+
|
|
368634
|
+
function loopWorkItemDebug(queue) {
|
|
368635
|
+
let running = false;
|
|
368636
|
+
setInterval(() => {
|
|
368637
|
+
if (running)
|
|
368638
|
+
return;
|
|
368639
|
+
running = true;
|
|
368640
|
+
writeDownQueueStatus(queue)
|
|
368641
|
+
.then(() => {
|
|
368642
|
+
running = false;
|
|
368643
|
+
})
|
|
368644
|
+
.catch((err) => {
|
|
368645
|
+
operator_src_logger.error(`PANIC cannot evaluate the queue for debug!!!: ${err}`);
|
|
368646
|
+
});
|
|
368647
|
+
}, 5 * 1000);
|
|
368648
|
+
}
|
|
368649
|
+
async function writeDownQueueStatus(queue) {
|
|
368650
|
+
let output = '';
|
|
368651
|
+
for (const workItem of queue) {
|
|
368652
|
+
const item = workItem.item;
|
|
368653
|
+
output += `${item.kind}/${item.metadata.name} - ${workItem.workStatus} - ${workItem.operation} - (upsert ${formatElapsedTimeWithDate(workItem.upsertTime)})\n`;
|
|
368654
|
+
}
|
|
368655
|
+
return new Promise((ok, ko) => {
|
|
368656
|
+
external_fs_.writeFile('/tmp/queue', output, (err) => {
|
|
368657
|
+
if (err)
|
|
368658
|
+
ko(`Writing /tmp/queue: ${err}`);
|
|
368659
|
+
else
|
|
368660
|
+
ok();
|
|
368661
|
+
});
|
|
368662
|
+
});
|
|
368663
|
+
}
|
|
368664
|
+
function formatElapsedTimeWithDate(upsertTime) {
|
|
368665
|
+
const now = new Date();
|
|
368666
|
+
const diffMs = now.getTime() - upsertTime;
|
|
368667
|
+
if (diffMs < 0) {
|
|
368668
|
+
return 'Future time (Error)';
|
|
368669
|
+
}
|
|
368670
|
+
if (diffMs < 1000) {
|
|
368671
|
+
return 'Just now';
|
|
368672
|
+
}
|
|
368673
|
+
const MS_PER_SECOND = 1000;
|
|
368674
|
+
const MS_PER_MINUTE = 60 * MS_PER_SECOND;
|
|
368675
|
+
const MS_PER_HOUR = 60 * MS_PER_MINUTE;
|
|
368676
|
+
const MS_PER_DAY = 24 * MS_PER_HOUR;
|
|
368677
|
+
const parts = [];
|
|
368678
|
+
let remainingMs = diffMs;
|
|
368679
|
+
// 1. Calculate Days
|
|
368680
|
+
const days = Math.floor(remainingMs / MS_PER_DAY);
|
|
368681
|
+
if (days > 0) {
|
|
368682
|
+
parts.push(`${days} day${days !== 1 ? 's' : ''}`);
|
|
368683
|
+
remainingMs %= MS_PER_DAY;
|
|
368684
|
+
}
|
|
368685
|
+
// 2. Calculate Hours
|
|
368686
|
+
const hours = Math.floor(remainingMs / MS_PER_HOUR);
|
|
368687
|
+
if (hours > 0) {
|
|
368688
|
+
parts.push(`${hours} hour${hours !== 1 ? 's' : ''}`);
|
|
368689
|
+
remainingMs %= MS_PER_HOUR;
|
|
368690
|
+
}
|
|
368691
|
+
// 3. Calculate Minutes
|
|
368692
|
+
const minutes = Math.floor(remainingMs / MS_PER_MINUTE);
|
|
368693
|
+
if (minutes > 0) {
|
|
368694
|
+
parts.push(`${minutes} minute${minutes !== 1 ? 's' : ''}`);
|
|
368695
|
+
remainingMs %= MS_PER_MINUTE;
|
|
368696
|
+
}
|
|
368697
|
+
// 4. Calculate Seconds (added logic for seconds)
|
|
368698
|
+
const seconds = Math.floor(remainingMs / MS_PER_SECOND);
|
|
368699
|
+
if (seconds > 0 && parts.length < 2) {
|
|
368700
|
+
parts.push(`${seconds} second${seconds !== 1 ? 's' : ''}`);
|
|
368701
|
+
}
|
|
368702
|
+
if (parts.length === 0 && seconds > 0) {
|
|
368703
|
+
return `${seconds} second${seconds !== 1 ? 's' : ''} ago`;
|
|
368704
|
+
}
|
|
368705
|
+
return `${parts.slice(0, 2).join(', ')} ago`;
|
|
368706
|
+
}
|
|
368707
|
+
|
|
367907
368708
|
;// CONCATENATED MODULE: ../operator/src/processItem.ts
|
|
367908
368709
|
|
|
367909
368710
|
|
|
367910
368711
|
|
|
367911
368712
|
|
|
368713
|
+
|
|
367912
368714
|
const queue = [];
|
|
367913
368715
|
const WEIGHTS = {
|
|
367914
368716
|
RENAMED: 15,
|
|
@@ -368014,6 +368816,7 @@ async function processItem(workItem) {
|
|
|
368014
368816
|
*/
|
|
368015
368817
|
async function processItem_loop() {
|
|
368016
368818
|
const nextWorkItem = () => sortQueue(queue).find((w) => w.workStatus === WorkStatus.PENDING);
|
|
368819
|
+
loopWorkItemDebug(queue);
|
|
368017
368820
|
while (1) {
|
|
368018
368821
|
const w = nextWorkItem();
|
|
368019
368822
|
if (w) {
|
|
@@ -368047,9 +368850,18 @@ function createTimeout(w) {
|
|
|
368047
368850
|
*/
|
|
368048
368851
|
function sortQueue(queue) {
|
|
368049
368852
|
const sortedQueue = queue.sort((wa, wb) => {
|
|
368050
|
-
|
|
368051
|
-
const
|
|
368052
|
-
|
|
368853
|
+
// --- PRIMARY SORT: By Weight (Descending) ---
|
|
368854
|
+
const weightA = WEIGHTS[wa.operation];
|
|
368855
|
+
const weightB = WEIGHTS[wb.operation];
|
|
368856
|
+
// Check if weights are different
|
|
368857
|
+
if (weightA !== weightB) {
|
|
368858
|
+
// Sort in descending order (higher weight first)
|
|
368859
|
+
// If weightA is larger, return -1 (a comes before b)
|
|
368860
|
+
return weightB - weightA;
|
|
368861
|
+
}
|
|
368862
|
+
// --- SECONDARY SORT: By upsertTime (Ascending) ---
|
|
368863
|
+
// If weights are equal, sort by the oldest upsertTime (ascending)
|
|
368864
|
+
return wa.upsertTime - wb.upsertTime;
|
|
368053
368865
|
});
|
|
368054
368866
|
return sortedQueue;
|
|
368055
368867
|
}
|
|
@@ -368180,28 +368992,21 @@ class Entity {
|
|
|
368180
368992
|
throw new Error(ErrorMessage);
|
|
368181
368993
|
}
|
|
368182
368994
|
const { kind, name, needsSecret } = ref;
|
|
368183
|
-
|
|
368184
|
-
|
|
368185
|
-
|
|
368186
|
-
|
|
368187
|
-
|
|
368188
|
-
|
|
368189
|
-
|
|
368190
|
-
if (!propertyRef) {
|
|
368191
|
-
const ErrorMessage = `resolveRef:
|
|
368995
|
+
if (!needsSecret) {
|
|
368996
|
+
const cr = this.deps[`${kind}-${name}`].cr;
|
|
368997
|
+
return (cr.metadata?.annotations?.[EXTERNAL_NAME_ANNOTATION] || cr.metadata.name);
|
|
368998
|
+
}
|
|
368999
|
+
else {
|
|
369000
|
+
if (!propertyRef) {
|
|
369001
|
+
const ErrorMessage = `resolveRef:
|
|
368192
369002
|
|
|
368193
|
-
|
|
369003
|
+
Entity with kind ${this.kind} ${this.metadata.name}
|
|
368194
369004
|
|
|
368195
|
-
|
|
368196
|
-
|
|
368197
|
-
|
|
368198
|
-
}
|
|
368199
|
-
return Buffer.from(this.deps[`${kind}-${name}`].secret.data[propertyRef], 'base64').toString('utf8');
|
|
369005
|
+
needs a propertyRef to resolve the secret`;
|
|
369006
|
+
provisioner_src_logger.error(ErrorMessage);
|
|
369007
|
+
throw new Error(ErrorMessage);
|
|
368200
369008
|
}
|
|
368201
|
-
|
|
368202
|
-
catch (error) {
|
|
368203
|
-
const errorMsg = `Error resolving ref for ${kind}-${name}: ${error}`;
|
|
368204
|
-
throw new Error(errorMsg);
|
|
369009
|
+
return Buffer.from(this.deps[`${kind}-${name}`].secret.data[propertyRef], 'base64').toString('utf8');
|
|
368205
369010
|
}
|
|
368206
369011
|
}
|
|
368207
369012
|
resolveSecretRef(ref) {
|
|
@@ -368889,6 +369694,106 @@ class FirestartrTerraformModuleEntity extends Entity {
|
|
|
368889
369694
|
}
|
|
368890
369695
|
}
|
|
368891
369696
|
|
|
369697
|
+
;// CONCATENATED MODULE: ../provisioner/src/entities/firestartrgithubrepositorysecretssection/helpers/RepositorySecret.ts
|
|
369698
|
+
|
|
369699
|
+
|
|
369700
|
+
|
|
369701
|
+
|
|
369702
|
+
|
|
369703
|
+
|
|
369704
|
+
async function RepositorySecret_provisionRepositorySecrets(scope, fsGithubRepositorySecretsSection, repo) {
|
|
369705
|
+
const sections = ['actions', 'codespaces', 'dependabot'];
|
|
369706
|
+
if ('secrets' in fsGithubRepositorySecretsSection.spec) {
|
|
369707
|
+
const secrets = fsGithubRepositorySecretsSection.spec.secrets;
|
|
369708
|
+
for (const section of sections) {
|
|
369709
|
+
if (section in secrets) {
|
|
369710
|
+
for (const secret of secrets[section]) {
|
|
369711
|
+
await RepositorySecret_provisionRepositorySecret(scope, fsGithubRepositorySecretsSection, section, secret.name, secret.ref, repo);
|
|
369712
|
+
}
|
|
369713
|
+
}
|
|
369714
|
+
}
|
|
369715
|
+
}
|
|
369716
|
+
else {
|
|
369717
|
+
provisioner_src_logger.info(`FirestartrGithubRepository ${fsGithubRepositorySecretsSection.metadata.name} does not have a secrets section`);
|
|
369718
|
+
}
|
|
369719
|
+
}
|
|
369720
|
+
async function RepositorySecret_provisionRepositorySecret(scope, rss, section, repoSecretName, secretRef, repoResource) {
|
|
369721
|
+
provisioner_src_logger.info(`Provisioning repo secret ${rss.metadata.name}/${section}/${repoSecretName}`);
|
|
369722
|
+
const secretClass = section === 'actions'
|
|
369723
|
+
? actions_secret/* ActionsSecret */.N
|
|
369724
|
+
: section === 'codespaces'
|
|
369725
|
+
? codespaces_secret/* CodespacesSecret */.k
|
|
369726
|
+
: section === 'dependabot'
|
|
369727
|
+
? dependabot_secret/* DependabotSecret */.c
|
|
369728
|
+
: null;
|
|
369729
|
+
if (secretClass) {
|
|
369730
|
+
const fSecretCreation = process.env['AVOID_PROVIDER_SECRET_ENCRYPTION']
|
|
369731
|
+
? RepositorySecret_createUnencryptedSecret
|
|
369732
|
+
: RepositorySecret_createEncryptedSecrect;
|
|
369733
|
+
await fSecretCreation(scope, rss, secretRef, secretClass, section, repoSecretName, repoResource);
|
|
369734
|
+
provisioner_src_logger.info(`RepoSecret provisioned ${section}-${repoSecretName.toLowerCase()}-secret`);
|
|
369735
|
+
}
|
|
369736
|
+
}
|
|
369737
|
+
async function RepositorySecret_createEncryptedSecrect(scope, rss, secretRef, secretClass, section, repoSecretName, repo) {
|
|
369738
|
+
const { key_id, encrypted_value } = await RepositorySecret_encryptSecret(rss, secretRef);
|
|
369739
|
+
const resourceKey = `${section}-${repoSecretName.toLowerCase()}-secret`;
|
|
369740
|
+
const plainTextSecret = rss.resolveSecretRef({
|
|
369741
|
+
name: secretRef.name,
|
|
369742
|
+
key: secretRef.key,
|
|
369743
|
+
});
|
|
369744
|
+
const sha256 = external_crypto_default().createHash('sha256')
|
|
369745
|
+
.update(plainTextSecret)
|
|
369746
|
+
.digest('hex');
|
|
369747
|
+
const secretResourceName = `_${section}-${repoSecretName.toLowerCase()}-${sha256.slice(0, 12)}`;
|
|
369748
|
+
const instanceLifecycle = {
|
|
369749
|
+
ignoreChanges: ['encrypted_value'],
|
|
369750
|
+
};
|
|
369751
|
+
const sc = new secretClass(scope, secretResourceName, {
|
|
369752
|
+
secretName: repoSecretName,
|
|
369753
|
+
repository: repo,
|
|
369754
|
+
encryptedValue: encrypted_value,
|
|
369755
|
+
lifecycle: instanceLifecycle,
|
|
369756
|
+
});
|
|
369757
|
+
rss.addResourceToStack(resourceKey, sc);
|
|
369758
|
+
}
|
|
369759
|
+
async function RepositorySecret_createUnencryptedSecret(scope, rss, secretRef, secretClass, section, repoSecretName, repo) {
|
|
369760
|
+
const plainTextSecret = rss.resolveSecretRef({
|
|
369761
|
+
name: secretRef.name,
|
|
369762
|
+
key: secretRef.key,
|
|
369763
|
+
});
|
|
369764
|
+
const resourceKey = `${section}-${repoSecretName.toLowerCase()}-secret`;
|
|
369765
|
+
const tfStateKey = `_${rss.getTfStateKey()}-${resourceKey}`;
|
|
369766
|
+
const sc = new secretClass(scope, tfStateKey, {
|
|
369767
|
+
secretName: repoSecretName,
|
|
369768
|
+
plaintextValue: plainTextSecret,
|
|
369769
|
+
repository: repo,
|
|
369770
|
+
});
|
|
369771
|
+
provisioner_src_logger.info(tfStateKey);
|
|
369772
|
+
rss.addResourceToStack(resourceKey, sc);
|
|
369773
|
+
}
|
|
369774
|
+
async function RepositorySecret_encryptSecret(rss, secretRef) {
|
|
369775
|
+
const plainTextSecret = rss.resolveSecretRef({
|
|
369776
|
+
name: secretRef.name,
|
|
369777
|
+
key: secretRef.key,
|
|
369778
|
+
});
|
|
369779
|
+
const v = await github_0.encryption.encryptRepoSecret(process.env.ORG, rss.metadata.name, plainTextSecret);
|
|
369780
|
+
return v;
|
|
369781
|
+
}
|
|
369782
|
+
|
|
369783
|
+
;// CONCATENATED MODULE: ../provisioner/src/entities/firestartrgithubrepositorysecretssection/FirestartrGithubRepositorySecretsSection.ts
|
|
369784
|
+
|
|
369785
|
+
|
|
369786
|
+
class FirestartrGithubRepositorySecretsSection_FirestartrGithubRepositorySecretsSection extends Entity {
|
|
369787
|
+
constructor(artifact, deps) {
|
|
369788
|
+
super(artifact, deps);
|
|
369789
|
+
}
|
|
369790
|
+
async loadResources(data) {
|
|
369791
|
+
const { scope } = data;
|
|
369792
|
+
const repo = this.resolveRef(this.spec.repositoryTarget.ref);
|
|
369793
|
+
await RepositorySecret_provisionRepositorySecrets(scope, this, repo);
|
|
369794
|
+
}
|
|
369795
|
+
}
|
|
369796
|
+
|
|
368892
369797
|
;// CONCATENATED MODULE: ../provisioner/src/entities/index.ts
|
|
368893
369798
|
|
|
368894
369799
|
|
|
@@ -368896,6 +369801,7 @@ class FirestartrTerraformModuleEntity extends Entity {
|
|
|
368896
369801
|
|
|
368897
369802
|
|
|
368898
369803
|
|
|
369804
|
+
|
|
368899
369805
|
function getEntityInstance(entity, deps) {
|
|
368900
369806
|
let instance = null;
|
|
368901
369807
|
switch (entity.kind) {
|
|
@@ -368917,6 +369823,9 @@ function getEntityInstance(entity, deps) {
|
|
|
368917
369823
|
case 'FirestartrGithubOrgWebhook':
|
|
368918
369824
|
instance = new FirestartrGithubOrgWebhook_FirestartrGithubOrgWebhook(entity, deps);
|
|
368919
369825
|
break;
|
|
369826
|
+
case 'FirestartrGithubRepositorySecretsSection':
|
|
369827
|
+
instance = new FirestartrGithubRepositorySecretsSection_FirestartrGithubRepositorySecretsSection(entity, deps);
|
|
369828
|
+
break;
|
|
368920
369829
|
default:
|
|
368921
369830
|
break;
|
|
368922
369831
|
}
|
|
@@ -369156,6 +370065,7 @@ function getStackByEntity(entity) {
|
|
|
369156
370065
|
case 'FirestartrGithubMembership':
|
|
369157
370066
|
case 'FirestartrGithubRepositoryFeature':
|
|
369158
370067
|
case 'FirestartrGithubOrgWebhook':
|
|
370068
|
+
case 'FirestartrGithubRepositorySecretsSection':
|
|
369159
370069
|
return GithubStack;
|
|
369160
370070
|
case 'FirestartrTerraformModule':
|
|
369161
370071
|
return TerraformModuleStack;
|
|
@@ -369907,6 +370817,30 @@ class github_orgWebhook_FirestartrGithubOrgWebhook extends Resource {
|
|
|
369907
370817
|
}
|
|
369908
370818
|
}
|
|
369909
370819
|
|
|
370820
|
+
;// CONCATENATED MODULE: ../provisioner/src/resources/github_repository_secrets_section/index.ts
|
|
370821
|
+
|
|
370822
|
+
|
|
370823
|
+
class github_repository_secrets_section_FirestartrGithubRepositorySecretsSection extends Resource {
|
|
370824
|
+
static kind() {
|
|
370825
|
+
return 'FirestartrGithubRepositorySecretsSection';
|
|
370826
|
+
}
|
|
370827
|
+
async preprocess() {
|
|
370828
|
+
switch (this.get('operation')) {
|
|
370829
|
+
case 'CREATE':
|
|
370830
|
+
provisioner_src_logger.debug('Creating FirestartrGithubRepositorySecretsSection');
|
|
370831
|
+
break;
|
|
370832
|
+
case 'UPDATE':
|
|
370833
|
+
provisioner_src_logger.debug('Updating FirestartrGithubRepositorySecretsSection');
|
|
370834
|
+
break;
|
|
370835
|
+
case 'DELETE':
|
|
370836
|
+
provisioner_src_logger.debug('Deleting FirestartrGithubRepositorySecretsSection');
|
|
370837
|
+
break;
|
|
370838
|
+
default:
|
|
370839
|
+
provisioner_src_logger.debug(`Unknown operation '${this.get('operation')}' for FirestartrGithubRepositorySecretsSection`);
|
|
370840
|
+
}
|
|
370841
|
+
}
|
|
370842
|
+
}
|
|
370843
|
+
|
|
369910
370844
|
;// CONCATENATED MODULE: ../provisioner/src/resources/index.ts
|
|
369911
370845
|
|
|
369912
370846
|
|
|
@@ -369914,6 +370848,7 @@ class github_orgWebhook_FirestartrGithubOrgWebhook extends Resource {
|
|
|
369914
370848
|
|
|
369915
370849
|
|
|
369916
370850
|
|
|
370851
|
+
|
|
369917
370852
|
/* harmony default export */ const resources = ({
|
|
369918
370853
|
FirestartrGithubRepositoryFeature: github_feature_FirestartrGithubRepositoryFeature,
|
|
369919
370854
|
FirestartrGithubRepository: github_repository_FirestartrGithubRepository,
|
|
@@ -369921,6 +370856,7 @@ class github_orgWebhook_FirestartrGithubOrgWebhook extends Resource {
|
|
|
369921
370856
|
FirestartrGithubGroup: github_group_FirestartrGithubGroup,
|
|
369922
370857
|
FirestartrTerraformModule: FirestartrTerraformModule,
|
|
369923
370858
|
FirestartrGithubOrgWebhook: github_orgWebhook_FirestartrGithubOrgWebhook,
|
|
370859
|
+
FirestartrGithubRepositorySecretsSection: github_repository_secrets_section_FirestartrGithubRepositorySecretsSection,
|
|
369924
370860
|
});
|
|
369925
370861
|
|
|
369926
370862
|
;// CONCATENATED MODULE: ../provisioner/init.ts
|
|
@@ -371814,13 +372750,6 @@ function isDestroyRetry(item) {
|
|
|
371814
372750
|
return false;
|
|
371815
372751
|
}
|
|
371816
372752
|
async function* process_operation_sync(item, op, handler, syncPolicy, generalPolicy) {
|
|
371817
|
-
yield {
|
|
371818
|
-
item,
|
|
371819
|
-
reason: op,
|
|
371820
|
-
type: 'SYNCHRONIZED',
|
|
371821
|
-
status: 'False',
|
|
371822
|
-
message: 'Sync process started',
|
|
371823
|
-
};
|
|
371824
372753
|
if (!syncPolicy) {
|
|
371825
372754
|
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}'.`);
|
|
371826
372755
|
yield* doPlanJSONFormat(item, op, handler);
|
|
@@ -373643,6 +374572,7 @@ function getProvisionImplementation(plural) {
|
|
|
373643
374572
|
case 'githubrepositoryfeatures':
|
|
373644
374573
|
case 'githubgroups':
|
|
373645
374574
|
case 'githuborgwebhooks':
|
|
374575
|
+
case 'githubrepositorysecretssections':
|
|
373646
374576
|
implementation = processOperation;
|
|
373647
374577
|
break;
|
|
373648
374578
|
}
|