@firestartr/cli 1.56.1-snapshot-7 → 1.56.1-snapshot-9

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
@@ -366279,11 +366279,15 @@ class Decanter {
366279
366279
  get github() {
366280
366280
  return this._github;
366281
366281
  }
366282
+ get postRenderFunctions() {
366283
+ return this._postRenderFunctions;
366284
+ }
366282
366285
  constructor(data) {
366283
366286
  this.data = {};
366284
366287
  this.initializerInstances = [];
366285
366288
  this.claim = {};
366286
366289
  this.deps = {};
366290
+ this._postRenderFunctions = [];
366287
366291
  this._github = github_0;
366288
366292
  this.data = data;
366289
366293
  }
@@ -366297,10 +366301,14 @@ class Decanter {
366297
366301
  return new ImportInitializer();
366298
366302
  }
366299
366303
  __patchClaim(patch) {
366300
- this.claim = fast_json_patch.applyPatch(this.claim, [patch]).newDocument;
366304
+ this.claim = fast_json_patch_default().applyPatch(this.claim, [patch]).newDocument;
366305
+ }
366306
+ __patchCr(cr, patches) {
366307
+ patches = Array.isArray(patches) ? patches : [patches];
366308
+ return fast_json_patch_default().applyPatch(cr, patches).newDocument;
366301
366309
  }
366302
366310
  __validateEqual(a, b) {
366303
- return fast_json_patch.compare(a, b).length === 0;
366311
+ return fast_json_patch_default().compare(a, b).length === 0;
366304
366312
  }
366305
366313
  __decantStart() { }
366306
366314
  __getMethods(check) {
@@ -366350,6 +366358,14 @@ class Decanter {
366350
366358
  catalog_common.io.writeClaim(this.claim, claimsPath);
366351
366359
  return yaml;
366352
366360
  }
366361
+ postRender() {
366362
+ for (const method of this.__getMethods(this)) {
366363
+ if (method.match(/^__postRender/) &&
366364
+ typeof this[method] === 'function') {
366365
+ this[method]();
366366
+ }
366367
+ }
366368
+ }
366353
366369
  async _adapt() {
366354
366370
  const initializers = [];
366355
366371
  const overrides = [];
@@ -366370,6 +366386,7 @@ class Decanter {
366370
366386
  }
366371
366387
  const adapted = {
366372
366388
  deps: this.getDeps(),
366389
+ postRenderFunctions: this.postRenderFunctions,
366373
366390
  renderClaim: {
366374
366391
  claim: this.claim,
366375
366392
  initializers,
@@ -366384,6 +366401,9 @@ class Decanter {
366384
366401
  if (!this.deps[key])
366385
366402
  this.deps[key] = { cr, secret };
366386
366403
  }
366404
+ setPostRenderF(f) {
366405
+ this._postRenderFunctions.push(f);
366406
+ }
366387
366407
  getDeps() {
366388
366408
  return this.deps;
366389
366409
  }
@@ -366445,7 +366465,7 @@ class GroupGithubDecanter extends GithubDecanter {
366445
366465
  kind: this.claimKind,
366446
366466
  version: this.VERSION(),
366447
366467
  name: this.data.groupDetails.slug,
366448
- description: this.data.groupDetails.description,
366468
+ description: this.data.groupDetails.description || '',
366449
366469
  type: 'business-unit',
366450
366470
  };
366451
366471
  }
@@ -366500,6 +366520,15 @@ class GroupGithubDecanter extends GithubDecanter {
366500
366520
  async __adaptInitializerBase(_claim) {
366501
366521
  return await this.__loadInitializer('defaults_github_group.yaml');
366502
366522
  }
366523
+ __postRenderAnnotateGithubId() {
366524
+ this.setPostRenderF((cr) => {
366525
+ return this.__patchCr(cr, {
366526
+ op: 'add',
366527
+ path: '/metadata/annotations/firestartr.dev~1github-id',
366528
+ value: `${this.data.groupDetails.id}`,
366529
+ });
366530
+ });
366531
+ }
366503
366532
  __validateKind(cr) {
366504
366533
  return true;
366505
366534
  }
@@ -367005,6 +367034,21 @@ async function importGithubGitopsRepository(org, skipPlan, claimsPath, resources
367005
367034
  previousCRs[k];
367006
367035
  }
367007
367036
  const crs = await renderCRs(data);
367037
+ for (const key in crs) {
367038
+ let cr = crs[key];
367039
+ const claimName = cr.metadata?.annotations?.[catalog_common.generic.getFirestartrAnnotation('claim-ref')]?.split('/')[1];
367040
+ const postRenderFunctions = data.postRender[`${cr.kind}-${claimName}`] || [];
367041
+ let crModified = false;
367042
+ for (const postRenderFunction of postRenderFunctions) {
367043
+ cr = postRenderFunction(cr);
367044
+ crModified = true;
367045
+ }
367046
+ if (crModified) {
367047
+ const crPath = getCrPath(tmpRenderedCrsPath, cr);
367048
+ catalog_common.io.writeYamlFile(external_path_.basename(crPath), cr, external_path_.dirname(crPath));
367049
+ crs[key] = cr;
367050
+ }
367051
+ }
367008
367052
  await moveCRsAndClaims(crs, org, claimsPath, resourcesPath);
367009
367053
  }
367010
367054
  async function moveCRsAndClaims(crs, org, claimsPath, resourcesPath) {
@@ -367046,7 +367090,8 @@ function getClaimPathFromCR(claimsBasePath, cr) {
367046
367090
  FirestartrGithubRepository: 'components',
367047
367091
  FirestartrGithubMembership: 'users',
367048
367092
  };
367049
- return external_path_.join(claimsBasePath, `${cr.metadata.annotations[catalog_common.generic.getFirestartrAnnotation('claim-ref')]}.yaml`.toLowerCase());
367093
+ const claimRef = `${cr.metadata.annotations['firestartr.dev/claim-ref']}.yaml`.toLowerCase();
367094
+ return external_path_.join(claimsBasePath, mapCrsToClaims[cr.kind], claimRef.replace(/^[^/]+/, ''));
367050
367095
  }
367051
367096
  function getCrPath(crsBasePath, cr) {
367052
367097
  return external_path_.join(crsBasePath, `${cr.kind}.${cr.metadata.name}.yaml`);
@@ -367060,24 +367105,30 @@ async function getDataFromKinds(org, filters = []) {
367060
367105
  ]);
367061
367106
  const renderClaims = {};
367062
367107
  const deps = {};
367108
+ const postRender = {};
367063
367109
  for (const repo of data['repos']) {
367064
367110
  renderClaims[`ComponentClaim-${repo.renderClaim.claim.name}`] =
367065
367111
  repo.renderClaim;
367066
367112
  deps[`FirestartrGithubRepository-${repo.renderClaim.claim.name}`] =
367067
367113
  repo.deps;
367114
+ postRender[`FirestartrGithubRepository-${repo.renderClaim.claim.name}`] =
367115
+ repo.postRenderFunctions;
367068
367116
  }
367069
367117
  for (const group of data['groups']) {
367070
367118
  renderClaims[`GroupClaim-${group.renderClaim.claim.name}`] =
367071
367119
  group.renderClaim;
367072
367120
  deps[`FirestartrGithubGroup-${group.renderClaim.claim.name}`] = group.deps;
367121
+ postRender[`FirestartrGithubGroup-${group.renderClaim.claim.name}`] =
367122
+ group.postRenderFunctions;
367073
367123
  }
367074
367124
  for (const membership of data['memberships']) {
367075
367125
  renderClaims[`UserClaim-${membership.renderClaim.claim.name}`] =
367076
367126
  membership.renderClaim;
367077
367127
  deps[`FirestartrGithubMembership-${membership.renderClaim.claim.name}`] =
367078
367128
  membership.deps;
367129
+ postRender[`FirestartrGithubMembership-${membership.renderClaim.claim.name}`] = membership.postRenderFunctions;
367079
367130
  }
367080
- return { renderClaims, deps: deps };
367131
+ return { renderClaims, deps: deps, postRender: postRender };
367081
367132
  }
367082
367133
  async function importGithubGroups(org, filters = []) {
367083
367134
  const groups = [];
@@ -367086,8 +367137,9 @@ async function importGithubGroups(org, filters = []) {
367086
367137
  for (const group of collection) {
367087
367138
  await group.gather();
367088
367139
  await group.decant();
367089
- groups.push(await group.adapt());
367090
367140
  group.render();
367141
+ group.postRender();
367142
+ groups.push(await group.adapt());
367091
367143
  }
367092
367144
  return groups;
367093
367145
  }
@@ -368855,6 +368907,7 @@ var WorkStatus;
368855
368907
 
368856
368908
 
368857
368909
 
368910
+
368858
368911
  const kindsWithFinalizer = [
368859
368912
  'FirestartrDummyA',
368860
368913
  'FirestartrDummyB',
@@ -368979,6 +369032,9 @@ function enqueue(pluralKind, workItem, queue, compute, syncCtl, retryCtl) {
368979
369032
  writeTerraformOutputInTfResult: writeTerraformOuputInTFResult,
368980
369033
  writeConnectionSecret: writeConnectionSecret,
368981
369034
  resolveReferences: () => resolve(workItem.item, getItemByItemPath, getSecret),
369035
+ resolveOwnOutputs: () => {
369036
+ return resolveSecretRef(workItem.item.metadata.namespace, workItem.item, getSecret);
369037
+ },
368982
369038
  deleteSecret: () => deleteSecret(workItem.item.spec.writeConnectionSecretToRef.name, workItem.item.metadata.namespace),
368983
369039
  itemPath: () => informer_itemPath(pluralKind, workItem.item),
368984
369040
  error: () => retryCtl.errorReconciling(informer_itemPath(pluralKind, workItem.item)),
@@ -369992,10 +370048,12 @@ var lib_provider = __nccwpck_require__(85791);
369992
370048
  ;// CONCATENATED MODULE: ../provisioner/src/entities/base/Entity.ts
369993
370049
 
369994
370050
  const EXTERNAL_NAME_ANNOTATION = 'firestartr.dev/external-name';
370051
+ const IMPORT_ID_ANNOTATION = 'firestartr.dev/github-id';
369995
370052
 
369996
370053
  class Metadata {
369997
- constructor(metadata) {
370054
+ constructor(metadata, resolveOutputs) {
369998
370055
  this._metadata = metadata;
370056
+ this._resolveOutputs = resolveOutputs;
369999
370057
  }
370000
370058
  get name() {
370001
370059
  if (EXTERNAL_NAME_ANNOTATION in this.annotations) {
@@ -370005,19 +370063,56 @@ class Metadata {
370005
370063
  return this._metadata.name;
370006
370064
  }
370007
370065
  }
370066
+ get slug() {
370067
+ // we search the slug in the outputs
370068
+ const slug = this._resolveOutputs('slug');
370069
+ if (slug) {
370070
+ // is the slug in the outputs?
370071
+ return slug;
370072
+ }
370073
+ else {
370074
+ return undefined;
370075
+ }
370076
+ }
370008
370077
  get annotations() {
370009
370078
  return this._metadata.annotations || {};
370010
370079
  }
370011
370080
  get labels() {
370012
370081
  return this._metadata.labels || {};
370013
370082
  }
370083
+ get id() {
370084
+ // we search the id in the outputs
370085
+ const id = this._resolveOutputs('id');
370086
+ // if we are in an import process
370087
+ // there should be an id annotation
370088
+ // it takes always precedence
370089
+ if (IMPORT_ID_ANNOTATION in this.annotations) {
370090
+ return this.annotations[IMPORT_ID_ANNOTATION];
370091
+ }
370092
+ else if (id) {
370093
+ // is the ID in the outputs?
370094
+ return id;
370095
+ }
370096
+ else {
370097
+ return undefined;
370098
+ }
370099
+ }
370014
370100
  }
370015
370101
  class Entity {
370016
370102
  constructor(artifact, deps) {
370017
370103
  this.importStack = [];
370018
370104
  this.kind = artifact.kind;
370019
370105
  this.apiVersion = artifact.apiVersion;
370020
- this.metadata = new Metadata(artifact.metadata);
370106
+ this.metadata = new Metadata(artifact.metadata, (key) => {
370107
+ if (this.deps && 'self-outputs' in this.deps) {
370108
+ const cr = this.deps['self-outputs'].cr;
370109
+ if (cr && typeof cr.data === 'object') {
370110
+ if (key in cr.data) {
370111
+ return Buffer.from(cr.data[key], 'base64').toString('utf-8');
370112
+ }
370113
+ }
370114
+ }
370115
+ });
370021
370116
  this.spec = artifact.spec;
370022
370117
  if (deps) {
370023
370118
  this.deps = deps;
@@ -370167,14 +370262,15 @@ function provisionPermissions(scope, repo, fsGithubRepository) {
370167
370262
  if ('ref' in permission) {
370168
370263
  const tfStateKey = `_${fsGithubRepository.getTfStateKey()}-${permission.ref.kind}-${permission.ref.name}-tr`;
370169
370264
  if (permission.ref.kind === 'FirestartrGithubGroup') {
370265
+ const teamSlug = fsGithubRepository.resolveRef(permission.ref, 'slug');
370170
370266
  const teamId = fsGithubRepository.resolveRef(permission.ref, 'id');
370171
370267
  const config = {
370172
370268
  repository: repo.name,
370173
- teamId,
370269
+ teamId: teamId,
370174
370270
  permission: permission.role,
370175
370271
  };
370176
370272
  const teamsRepository = new team_repository/* TeamRepository */.C(scope, tfStateKey, config);
370177
- fsGithubRepository.addResourceToStack(`${teamId}:${fsGithubRepository.metadata.name}`, teamsRepository);
370273
+ fsGithubRepository.addResourceToStack(`${teamSlug}:${fsGithubRepository.metadata.name}`, teamsRepository);
370178
370274
  }
370179
370275
  else if (permission.ref.kind === 'FirestartrGithubMembership') {
370180
370276
  const username = fsGithubRepository.resolveRef(permission.ref);
@@ -370534,7 +370630,7 @@ function provisionGroup(scope, fsGithubGroup) {
370534
370630
  };
370535
370631
  const tfStateKey = `_${fsGithubGroup.getTfStateKey()}`;
370536
370632
  const group = new lib_team/* Team */.S(scope, tfStateKey, config);
370537
- fsGithubGroup.addResourceToStack(fsGithubGroup.metadata.name, group);
370633
+ fsGithubGroup.addResourceToStack(fsGithubGroup.metadata.id || fsGithubGroup.metadata.name, group);
370538
370634
  return group;
370539
370635
  }
370540
370636
 
@@ -370546,16 +370642,17 @@ function provisionMembers(scope, team, fsGithubGroup) {
370546
370642
  for (const member of fsGithubGroup.spec.members) {
370547
370643
  provisioner_src_logger.info(`Provisioning user ${member.ref.name} for group ${fsGithubGroup.metadata.name}`);
370548
370644
  const tfStateKey = `_${fsGithubGroup.getTfStateKey()}-${member.ref.kind}-${member.ref.name}-tr`;
370645
+ const teamId = team.id || fsGithubGroup.metadata.id;
370549
370646
  if (member.ref.kind === 'FirestartrGithubMembership') {
370550
370647
  const username = fsGithubGroup.resolveRef(member.ref);
370551
370648
  const config = {
370552
370649
  dependsOn: [team],
370553
370650
  username,
370554
- teamId: team.id,
370651
+ teamId: teamId,
370555
370652
  role: member.role,
370556
370653
  };
370557
370654
  const membership = new team_membership/* TeamMembership */.E(scope, tfStateKey, config);
370558
- fsGithubGroup.addResourceToStack(`${team.id}:${username}`, membership);
370655
+ fsGithubGroup.addResourceToStack(`${teamId}:${username}`, membership);
370559
370656
  }
370560
370657
  }
370561
370658
  }
@@ -372436,7 +372533,10 @@ async function* doApply(item, op, handler) {
372436
372533
  opts['create'] = true;
372437
372534
  }
372438
372535
  const deps = await handler.resolveReferences();
372439
- operator_src_logger.info(`Item ${item.metadata.name} has the following dependencies: ${deps}`);
372536
+ deps['self-outputs'] = {
372537
+ cr: await handler.resolveOwnOutputs(),
372538
+ };
372539
+ operator_src_logger.info(`Item ${item.metadata.name} has the following dependencies: ${Object.keys(deps)}`);
372440
372540
  const annotation = 'firestartr.dev/last-state-pr';
372441
372541
  const statePr = item?.metadata?.annotations?.[annotation];
372442
372542
  const hasStatePr = typeof statePr === 'string' && statePr.trim().length > 0;
@@ -376352,7 +376452,7 @@ const crs_analyzerSubcommand = {
376352
376452
  };
376353
376453
 
376354
376454
  ;// CONCATENATED MODULE: ./package.json
376355
- const package_namespaceObject = JSON.parse('{"i8":"1.56.1-snapshot-7"}');
376455
+ const package_namespaceObject = JSON.parse('{"i8":"1.56.1-snapshot-9"}');
376356
376456
  ;// CONCATENATED MODULE: ../../package.json
376357
376457
  const package_namespaceObject_1 = {"i8":"1.56.0"};
376358
376458
  ;// CONCATENATED MODULE: ./src/subcommands/index.ts
@@ -1,6 +1,6 @@
1
1
  import { importGithubGitopsRepository } from './src/decanter';
2
- import { CollectionFilter } from './src/decanter/collections';
3
- export { CollectionFilter };
2
+ import type { CollectionFilter } from './src/decanter/collections';
3
+ export type { CollectionFilter };
4
4
  declare const _default: {
5
5
  importGithubGitopsRepository: typeof importGithubGitopsRepository;
6
6
  };
@@ -11,14 +11,17 @@ export default class Decanter {
11
11
  secret: any;
12
12
  };
13
13
  };
14
+ _postRenderFunctions: Function[];
14
15
  _github: any;
15
16
  set github(githubInstance: any);
16
17
  get github(): any;
18
+ get postRenderFunctions(): Function[];
17
19
  constructor(data: any);
18
20
  __adaptInitializerTfStateKey(): Promise<UUIDInitializer>;
19
21
  __adaptInitializerClaimRef(): Promise<InitializerClaimRef>;
20
22
  __adaptInitializerImport(): Promise<ImportInitializer>;
21
23
  __patchClaim(patch: any): void;
24
+ __patchCr(cr: any, patches: any): any;
22
25
  __validateEqual(a: any, b: any): boolean;
23
26
  __decantStart(): void;
24
27
  __getMethods(check: any): any[];
@@ -30,6 +33,7 @@ export default class Decanter {
30
33
  secret: any;
31
34
  };
32
35
  };
36
+ postRenderFunctions: Function[];
33
37
  renderClaim: {
34
38
  claim: any;
35
39
  initializers: any[];
@@ -40,6 +44,7 @@ export default class Decanter {
40
44
  }>;
41
45
  validateCR(cr: any): boolean;
42
46
  render(): string;
47
+ postRender(): void;
43
48
  _adapt(): Promise<{
44
49
  deps: {
45
50
  [key: string]: {
@@ -47,6 +52,7 @@ export default class Decanter {
47
52
  secret: any;
48
53
  };
49
54
  };
55
+ postRenderFunctions: Function[];
50
56
  renderClaim: {
51
57
  claim: any;
52
58
  initializers: any[];
@@ -56,6 +62,7 @@ export default class Decanter {
56
62
  };
57
63
  }>;
58
64
  setDep(key: string, cr: any, secret: any): void;
65
+ setPostRenderF(f: Function): void;
59
66
  getDeps(): {
60
67
  [key: string]: {
61
68
  cr: any;
@@ -70,6 +77,7 @@ export default class Decanter {
70
77
  secret: any;
71
78
  };
72
79
  };
80
+ postRenderFunctions: Function[];
73
81
  renderClaim: {
74
82
  claim: any;
75
83
  initializers: any[];
@@ -1,5 +1,5 @@
1
+ export type { CollectionFilter } from './filters';
1
2
  export declare function applyCollectionMixins(derivedCtor: any): void;
2
- export { CollectionFilter } from './filters';
3
3
  export declare class CollectionMixins {
4
4
  IS_FILTER_BY_NAME_SET(filters: any[], kind: string): boolean;
5
5
  IS_SKIP_SET(filters: any[], kind: string): boolean;
@@ -10,6 +10,7 @@ export default class GroupGithubDecanter extends GithubDecanter {
10
10
  __gatherMembers(): Promise<void>;
11
11
  __validateMembers(cr: any): Promise<boolean>;
12
12
  __adaptInitializerBase(_claim: any): Promise<InitializerDefault>;
13
+ __postRenderAnnotateGithubId(): void;
13
14
  __validateKind(cr: any): boolean;
14
15
  KO__validateKind(): void;
15
16
  }
@@ -1,5 +1,5 @@
1
- export { CollectionFilter } from './collections';
2
- import { CollectionFilter } from './collections';
1
+ export type { CollectionFilter } from './collections';
2
+ import type { CollectionFilter } from './collections';
3
3
  import GroupCollectionGithubDecanter from './gh/github_group_collection';
4
4
  import MemberCollectionGithubDecanter from './gh/github_member_collection';
5
5
  import RepoCollectionGithubDecanter from './gh/github_repo_collection';
@@ -42,6 +42,7 @@ export type WorkItemHandler = {
42
42
  writeTerraformOutputInTfResult: WriteTerraformOutputInTfResultFn;
43
43
  writeConnectionSecret: WriteConnectionSecretFn;
44
44
  resolveReferences: ResolveReferencesFn;
45
+ resolveOwnOutputs: () => Promise<any | undefined>;
45
46
  deleteSecret: DeleteSecretFn;
46
47
  itemPath: ItemPathFn;
47
48
  error: ErrorFn;
@@ -2,10 +2,13 @@ import { Construct } from 'constructs';
2
2
  import { TerraformModule, TerraformResource } from 'cdktf';
3
3
  declare class Metadata {
4
4
  _metadata: any;
5
- constructor(metadata: any);
5
+ _resolveOutputs: Function;
6
+ constructor(metadata: any, resolveOutputs: Function);
6
7
  get name(): any;
8
+ get slug(): any;
7
9
  get annotations(): any;
8
10
  get labels(): any;
11
+ get id(): any;
9
12
  }
10
13
  export declare abstract class Entity {
11
14
  kind: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firestartr/cli",
3
- "version": "1.56.1-snapshot-7",
3
+ "version": "1.56.1-snapshot-9",
4
4
  "private": false,
5
5
  "description": "Commandline tool",
6
6
  "main": "build/main.js",