@firestartr/cli 1.59.0-snapshot-11 → 1.59.0-snapshot-12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.js
CHANGED
|
@@ -355410,11 +355410,11 @@ class NameNormalizer extends Normalizer {
|
|
|
355410
355410
|
const provider = helperCTX(this).provider;
|
|
355411
355411
|
const annotation = catalog_common.generic.getFirestartrAnnotation('external-name');
|
|
355412
355412
|
const providerName = claim.providers[provider].name;
|
|
355413
|
-
if (previousCR && !
|
|
355413
|
+
if (previousCR && !lodash_default().isEmpty(previousCR)) {
|
|
355414
355414
|
cr.metadata.annotations[annotation] = providerName;
|
|
355415
355415
|
cr.metadata.name = previousCR.metadata.name;
|
|
355416
355416
|
if (previousCR.writeConnectionSecretToRef &&
|
|
355417
|
-
!
|
|
355417
|
+
!lodash_default().isEmpty(previousCR.writeConnectionSecretToRef)) {
|
|
355418
355418
|
cr.writeConnectionSecretToRef.name =
|
|
355419
355419
|
previousCR.writeConnectionSecretToRef.name;
|
|
355420
355420
|
}
|
|
@@ -366091,9 +366091,93 @@ async function renderTfWorkspace(claim, firestartrId, resolveRef, namespace) {
|
|
|
366091
366091
|
return jsonObject;
|
|
366092
366092
|
}
|
|
366093
366093
|
|
|
366094
|
+
;// CONCATENATED MODULE: ../cdk8s_renderer/src/renderer/imported-refs.ts
|
|
366095
|
+
// takes a cr and walks to find
|
|
366096
|
+
// any '<type>-imported-ref' being type: user|group
|
|
366097
|
+
|
|
366098
|
+
|
|
366099
|
+
// ref must match type-imported-ref where type can be group|user and:<value>
|
|
366100
|
+
// example: user-importer-ref:My Group
|
|
366101
|
+
const REGEX_IMPORTED_REF = /(?<type>user|group)-imported-ref:(?<value>.+)/;
|
|
366102
|
+
function importedsRefsWalker(renderClaim) {
|
|
366103
|
+
// cr is an object, we want to walk through all its properties recursively
|
|
366104
|
+
// the property can be another object, an array, or a primitive value
|
|
366105
|
+
// has a function to resolve
|
|
366106
|
+
// has to be an array of functions with
|
|
366107
|
+
// the following signature: (solver: Function) => Promise<void>
|
|
366108
|
+
const symbolsToResolve = [];
|
|
366109
|
+
walk(renderClaim.claim, symbolsToResolve, renderClaim);
|
|
366110
|
+
return symbolsToResolve;
|
|
366111
|
+
}
|
|
366112
|
+
function walk(element, symbolsToResolve, renderClaim) {
|
|
366113
|
+
if (typeof element === 'string' || typeof element === 'number') {
|
|
366114
|
+
return element;
|
|
366115
|
+
}
|
|
366116
|
+
else if (Array.isArray(element)) {
|
|
366117
|
+
return walkArray(element, symbolsToResolve, renderClaim);
|
|
366118
|
+
}
|
|
366119
|
+
else if (typeof element === 'object' && element !== null) {
|
|
366120
|
+
return walkObject(element, symbolsToResolve, renderClaim);
|
|
366121
|
+
}
|
|
366122
|
+
else {
|
|
366123
|
+
return element;
|
|
366124
|
+
}
|
|
366125
|
+
}
|
|
366126
|
+
function walkObject(obj, symbolsToResolve, renderClaim) {
|
|
366127
|
+
for (const key in obj) {
|
|
366128
|
+
const value = obj[key];
|
|
366129
|
+
if (typeof value === 'string') {
|
|
366130
|
+
const match = value.match(REGEX_IMPORTED_REF);
|
|
366131
|
+
if (!match) {
|
|
366132
|
+
continue;
|
|
366133
|
+
}
|
|
366134
|
+
const type = match.groups?.type;
|
|
366135
|
+
const catchedKey = key;
|
|
366136
|
+
if (type) {
|
|
366137
|
+
cdk8s_renderer_src_logger.info(`Found an imported-ref in the claim with key ${key} and value ${value}. This will be resolved later.`);
|
|
366138
|
+
symbolsToResolve.push(async (solver) => {
|
|
366139
|
+
const resolvedValue = await solver(type, match.groups?.value);
|
|
366140
|
+
cdk8s_renderer_src_logger.info(`Resolved imported-ref with key ${key} and value ${value} to ${resolvedValue} in path ${renderClaim.claimPath}`);
|
|
366141
|
+
obj[catchedKey] = resolvedValue;
|
|
366142
|
+
await catalog_common.io.writeClaim(renderClaim.claim, renderClaim.claimPath || '');
|
|
366143
|
+
});
|
|
366144
|
+
}
|
|
366145
|
+
}
|
|
366146
|
+
else {
|
|
366147
|
+
walk(value, symbolsToResolve, renderClaim);
|
|
366148
|
+
}
|
|
366149
|
+
}
|
|
366150
|
+
}
|
|
366151
|
+
function walkArray(arr, symbolsToResolve, renderClaim) {
|
|
366152
|
+
for (let i = 0; i < arr.length; i++) {
|
|
366153
|
+
const value = arr[i];
|
|
366154
|
+
if (typeof value === 'string') {
|
|
366155
|
+
const match = value.match(REGEX_IMPORTED_REF);
|
|
366156
|
+
if (!match) {
|
|
366157
|
+
continue;
|
|
366158
|
+
}
|
|
366159
|
+
cdk8s_renderer_src_logger.info(`Found an imported-ref in the claim with value ${value}. This will be resolved later.`);
|
|
366160
|
+
const type = match.groups?.type;
|
|
366161
|
+
if (type) {
|
|
366162
|
+
const catchedIndex = i;
|
|
366163
|
+
symbolsToResolve.push(async (solver) => {
|
|
366164
|
+
const resolvedValue = await solver(type, match.groups?.value);
|
|
366165
|
+
cdk8s_renderer_src_logger.info(`Resolved imported-ref with value ${value} to ${resolvedValue} in path ${renderClaim.claimPath}`);
|
|
366166
|
+
arr[catchedIndex] = resolvedValue;
|
|
366167
|
+
await catalog_common.io.writeClaim(renderClaim.claim, renderClaim.claimPath || '');
|
|
366168
|
+
});
|
|
366169
|
+
}
|
|
366170
|
+
}
|
|
366171
|
+
else {
|
|
366172
|
+
walk(value, symbolsToResolve, renderClaim);
|
|
366173
|
+
}
|
|
366174
|
+
}
|
|
366175
|
+
}
|
|
366176
|
+
|
|
366094
366177
|
;// CONCATENATED MODULE: ../cdk8s_renderer/src/renderer/import-renderer.ts
|
|
366095
366178
|
|
|
366096
366179
|
|
|
366180
|
+
|
|
366097
366181
|
/*
|
|
366098
366182
|
* Function called when rendering from the importer class.
|
|
366099
366183
|
*
|
|
@@ -366107,6 +366191,16 @@ async function renderTfWorkspace(claim, firestartrId, resolveRef, namespace) {
|
|
|
366107
366191
|
*
|
|
366108
366192
|
*/
|
|
366109
366193
|
async function renderFromImports(rClaims, crs = {}, catalogOutputDir = '/tmp/.catalog', crOutputDir = '/tmp/.resources') {
|
|
366194
|
+
// type: is the kind of the claim
|
|
366195
|
+
// value: is the imported-ref (the name in Github, can be with special characters, spaces, etc)
|
|
366196
|
+
const fSolver = (type, value) => {
|
|
366197
|
+
return solver(type, value, rClaims);
|
|
366198
|
+
};
|
|
366199
|
+
// we need to expand the imported-refs
|
|
366200
|
+
for (const renderClaim of Object.values(rClaims)) {
|
|
366201
|
+
const symbolsToResolve = importedsRefsWalker(renderClaim);
|
|
366202
|
+
await Promise.all(symbolsToResolve.map((s) => s(fSolver)));
|
|
366203
|
+
}
|
|
366110
366204
|
const catalogScope = new lib.App({
|
|
366111
366205
|
outdir: catalogOutputDir,
|
|
366112
366206
|
outputFileExtension: '.yaml',
|
|
@@ -366121,6 +366215,19 @@ async function renderFromImports(rClaims, crs = {}, catalogOutputDir = '/tmp/.ca
|
|
|
366121
366215
|
firestartrScope.synth();
|
|
366122
366216
|
return result;
|
|
366123
366217
|
}
|
|
366218
|
+
async function solver(type, value, rClaims) {
|
|
366219
|
+
// TODO: we need to receive the claims directory as a parameter, and read all the claims to find the one that matches the imported-ref
|
|
366220
|
+
const claimKind = type === 'user' ? 'UserClaim' : 'GroupClaim';
|
|
366221
|
+
for (const key in rClaims) {
|
|
366222
|
+
if (key.startsWith(claimKind)) {
|
|
366223
|
+
const claimData = rClaims[key];
|
|
366224
|
+
if (claimData.claim.providers?.github?.name === value) {
|
|
366225
|
+
return `${type}:${claimData.claim.name}`;
|
|
366226
|
+
}
|
|
366227
|
+
}
|
|
366228
|
+
}
|
|
366229
|
+
throw new Error(`Could not resolve imported-ref of type ${type} with value ${value}`);
|
|
366230
|
+
}
|
|
366124
366231
|
|
|
366125
366232
|
;// CONCATENATED MODULE: ../cdk8s_renderer/src/renderer/last-state-pr.ts
|
|
366126
366233
|
|
|
@@ -366418,6 +366525,7 @@ class Decanter {
|
|
|
366418
366525
|
postRenderFunctions: this.postRenderFunctions,
|
|
366419
366526
|
renderClaim: {
|
|
366420
366527
|
claim: this.claim,
|
|
366528
|
+
claimPath: getClaimsPath(),
|
|
366421
366529
|
initializers,
|
|
366422
366530
|
globals: [],
|
|
366423
366531
|
overrides,
|
|
@@ -366514,7 +366622,7 @@ class GroupGithubDecanter extends GithubDecanter {
|
|
|
366514
366622
|
else {
|
|
366515
366623
|
this.__patchClaim({
|
|
366516
366624
|
op: 'add',
|
|
366517
|
-
value: this.data.members.map((member) => `user:${member.name}`),
|
|
366625
|
+
value: this.data.members.map((member) => `user-imported-ref:${member.name}`),
|
|
366518
366626
|
path: '/members',
|
|
366519
366627
|
});
|
|
366520
366628
|
}
|
|
@@ -366532,7 +366640,7 @@ class GroupGithubDecanter extends GithubDecanter {
|
|
|
366532
366640
|
if (this.data.groupDetails.parent) {
|
|
366533
366641
|
this.__patchClaim({
|
|
366534
366642
|
op: 'add',
|
|
366535
|
-
value: `group:${this.data.groupDetails.parent.
|
|
366643
|
+
value: `group-imported-ref:${this.data.groupDetails.parent.name}`,
|
|
366536
366644
|
path: '/parent',
|
|
366537
366645
|
});
|
|
366538
366646
|
}
|
|
@@ -366796,7 +366904,7 @@ class RepoGithubDecanter extends GithubDecanter {
|
|
|
366796
366904
|
const directMaintainers = this.data.teamsAndMembers.directMembers
|
|
366797
366905
|
.filter((member) => member.role === 'maintain')
|
|
366798
366906
|
.map((member) => {
|
|
366799
|
-
return `user:${member.name}`;
|
|
366907
|
+
return `user-imported-ref:${member.name}`;
|
|
366800
366908
|
});
|
|
366801
366909
|
const outsideMaintainers = this.data.teamsAndMembers.outsideMembers
|
|
366802
366910
|
.filter((member) => member.role === 'maintain')
|
|
@@ -366806,7 +366914,7 @@ class RepoGithubDecanter extends GithubDecanter {
|
|
|
366806
366914
|
const teamMaintainers = this.data.teamsAndMembers.teams
|
|
366807
366915
|
.filter((team) => team.role === 'maintain')
|
|
366808
366916
|
.map((team) => {
|
|
366809
|
-
return `group:${team.
|
|
366917
|
+
return `group-imported-ref:${team.name}`;
|
|
366810
366918
|
});
|
|
366811
366919
|
const maintainers = directMaintainers
|
|
366812
366920
|
.concat(outsideMaintainers)
|
|
@@ -366821,7 +366929,7 @@ class RepoGithubDecanter extends GithubDecanter {
|
|
|
366821
366929
|
const directAdmins = this.data.teamsAndMembers.directMembers
|
|
366822
366930
|
.filter((member) => member.role === 'admin')
|
|
366823
366931
|
.map((member) => {
|
|
366824
|
-
return `user:${member.name}`;
|
|
366932
|
+
return `user-imported-ref:${member.name}`;
|
|
366825
366933
|
});
|
|
366826
366934
|
const outsideAdmins = this.data.teamsAndMembers.outsideMembers
|
|
366827
366935
|
.filter((member) => member.role === 'admin')
|
|
@@ -366831,7 +366939,7 @@ class RepoGithubDecanter extends GithubDecanter {
|
|
|
366831
366939
|
const teamAdmins = this.data.teamsAndMembers.teams
|
|
366832
366940
|
.filter((team) => team.role === 'admin')
|
|
366833
366941
|
.map((team) => {
|
|
366834
|
-
return `group:${team.
|
|
366942
|
+
return `group-imported-ref:${team.name}`;
|
|
366835
366943
|
});
|
|
366836
366944
|
const admins = directAdmins.concat(outsideAdmins).concat(teamAdmins);
|
|
366837
366945
|
const overrides = {};
|
|
@@ -366856,7 +366964,7 @@ class RepoGithubDecanter extends GithubDecanter {
|
|
|
366856
366964
|
const directWriters = this.data.teamsAndMembers.directMembers
|
|
366857
366965
|
.filter((member) => member.role === 'push')
|
|
366858
366966
|
.map((member) => {
|
|
366859
|
-
return `user:${member.name}`;
|
|
366967
|
+
return `user-imported-ref:${member.name}`;
|
|
366860
366968
|
});
|
|
366861
366969
|
const outsideWriters = this.data.teamsAndMembers.outsideMembers
|
|
366862
366970
|
.filter((member) => member.role === 'push')
|
|
@@ -366866,7 +366974,7 @@ class RepoGithubDecanter extends GithubDecanter {
|
|
|
366866
366974
|
const teamWriters = this.data.teamsAndMembers.teams
|
|
366867
366975
|
.filter((team) => ['push', 'write'].includes(team.role))
|
|
366868
366976
|
.map((team) => {
|
|
366869
|
-
return `group:${team.
|
|
366977
|
+
return `group-imported-ref:${team.name}`;
|
|
366870
366978
|
});
|
|
366871
366979
|
const writers = directWriters.concat(outsideWriters).concat(teamWriters);
|
|
366872
366980
|
if (writers && writers.length > 0) {
|
|
@@ -366880,7 +366988,7 @@ class RepoGithubDecanter extends GithubDecanter {
|
|
|
366880
366988
|
const directReaders = this.data.teamsAndMembers.directMembers
|
|
366881
366989
|
.filter((member) => member.role === 'pull')
|
|
366882
366990
|
.map((member) => {
|
|
366883
|
-
return `user:${member.name}`;
|
|
366991
|
+
return `user-imported-ref:${member.name}`;
|
|
366884
366992
|
});
|
|
366885
366993
|
const outsideReaders = this.data.teamsAndMembers.outsideMembers
|
|
366886
366994
|
.filter((member) => member.role === 'pull')
|
|
@@ -366890,7 +366998,7 @@ class RepoGithubDecanter extends GithubDecanter {
|
|
|
366890
366998
|
const teamReaders = this.data.teamsAndMembers.teams
|
|
366891
366999
|
.filter((team) => ['pull', 'read'].includes(team.role))
|
|
366892
367000
|
.map((team) => {
|
|
366893
|
-
return `group:${team.
|
|
367001
|
+
return `group-imported-ref:${team.name}`;
|
|
366894
367002
|
});
|
|
366895
367003
|
const readers = directReaders.concat(outsideReaders).concat(teamReaders);
|
|
366896
367004
|
if (readers && readers.length > 0) {
|
|
@@ -368802,7 +368910,7 @@ class ResolverError extends Error {
|
|
|
368802
368910
|
async function resolve(cr, getItemByItemPath, getSecret, namespace = 'default') {
|
|
368803
368911
|
const deps = {};
|
|
368804
368912
|
namespace = cr['metadata']['namespace'] || namespace;
|
|
368805
|
-
const references = [...
|
|
368913
|
+
const references = [...resolver_walk(cr)];
|
|
368806
368914
|
operator_src_logger.silly(`${cr.kind}/${cr.metadata?.name}: references ${JSON.stringify(references, null, 2)}`);
|
|
368807
368915
|
// ⚠️ The references array is mutated by resolveDep, adding new references if nested dependencies are found
|
|
368808
368916
|
for (const resolve of references) {
|
|
@@ -368836,7 +368944,7 @@ async function resolveDep(namespace, resolve, deps, references, getItemByItemPat
|
|
|
368836
368944
|
throw new ResolverError(kr);
|
|
368837
368945
|
// We may have nested refs but they should not be circular
|
|
368838
368946
|
// ⚠️ This mutates the references array, but it's ok because we don't need to resolve the same ref twice
|
|
368839
|
-
for (const nestedRef of
|
|
368947
|
+
for (const nestedRef of resolver_walk(ref)) {
|
|
368840
368948
|
references.push(nestedRef);
|
|
368841
368949
|
}
|
|
368842
368950
|
const secret = resolve.apiGroup === catalog_common.types.controller.FirestartrApiGroup ||
|
|
@@ -368848,7 +368956,7 @@ async function resolveDep(namespace, resolve, deps, references, getItemByItemPat
|
|
|
368848
368956
|
secret: secret,
|
|
368849
368957
|
};
|
|
368850
368958
|
}
|
|
368851
|
-
function*
|
|
368959
|
+
function* resolver_walk(item) {
|
|
368852
368960
|
const toResolve = walkItem(item);
|
|
368853
368961
|
for (const resolve of toResolve) {
|
|
368854
368962
|
yield resolve;
|
|
@@ -368856,20 +368964,20 @@ function* walk(item) {
|
|
|
368856
368964
|
}
|
|
368857
368965
|
function walkItem(item) {
|
|
368858
368966
|
if (Array.isArray(item))
|
|
368859
|
-
return
|
|
368967
|
+
return resolver_walkArray(item);
|
|
368860
368968
|
else if (item.constructor === Object)
|
|
368861
|
-
return
|
|
368969
|
+
return resolver_walkObject(item);
|
|
368862
368970
|
else
|
|
368863
368971
|
return [];
|
|
368864
368972
|
}
|
|
368865
|
-
function
|
|
368973
|
+
function resolver_walkArray(items) {
|
|
368866
368974
|
const toResolve = [];
|
|
368867
368975
|
for (const itemN of items) {
|
|
368868
368976
|
toResolve.push(walkItem(itemN));
|
|
368869
368977
|
}
|
|
368870
368978
|
return toResolve.flat(Infinity);
|
|
368871
368979
|
}
|
|
368872
|
-
function
|
|
368980
|
+
function resolver_walkObject(item) {
|
|
368873
368981
|
const toResolve = [];
|
|
368874
368982
|
// For now we only support refs to secrets.
|
|
368875
368983
|
// We cannot make it generic because of WriteSecretConnectionToRef in our CRDs
|
|
@@ -376631,7 +376739,7 @@ const crs_analyzerSubcommand = {
|
|
|
376631
376739
|
};
|
|
376632
376740
|
|
|
376633
376741
|
;// CONCATENATED MODULE: ./package.json
|
|
376634
|
-
const package_namespaceObject = JSON.parse('{"i8":"1.59.0-snapshot-
|
|
376742
|
+
const package_namespaceObject = JSON.parse('{"i8":"1.59.0-snapshot-12"}');
|
|
376635
376743
|
;// CONCATENATED MODULE: ../../package.json
|
|
376636
376744
|
const package_namespaceObject_1 = {"i8":"1.58.0"};
|
|
376637
376745
|
;// CONCATENATED MODULE: ./src/subcommands/index.ts
|
|
@@ -36,6 +36,7 @@ export default class Decanter {
|
|
|
36
36
|
postRenderFunctions: Function[];
|
|
37
37
|
renderClaim: {
|
|
38
38
|
claim: any;
|
|
39
|
+
claimPath: string;
|
|
39
40
|
initializers: any[];
|
|
40
41
|
globals: any[];
|
|
41
42
|
overrides: any[];
|
|
@@ -55,6 +56,7 @@ export default class Decanter {
|
|
|
55
56
|
postRenderFunctions: Function[];
|
|
56
57
|
renderClaim: {
|
|
57
58
|
claim: any;
|
|
59
|
+
claimPath: string;
|
|
58
60
|
initializers: any[];
|
|
59
61
|
globals: any[];
|
|
60
62
|
overrides: any[];
|
|
@@ -80,6 +82,7 @@ export default class Decanter {
|
|
|
80
82
|
postRenderFunctions: Function[];
|
|
81
83
|
renderClaim: {
|
|
82
84
|
claim: any;
|
|
85
|
+
claimPath: string;
|
|
83
86
|
initializers: any[];
|
|
84
87
|
globals: any[];
|
|
85
88
|
overrides: any[];
|