@firestartr/cli 1.55.1-snapshot-4 → 1.55.1-snapshot-5

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
@@ -366252,11 +366252,15 @@ class Decanter {
366252
366252
  get github() {
366253
366253
  return this._github;
366254
366254
  }
366255
+ get postRenderFunctions() {
366256
+ return this._postRenderFunctions;
366257
+ }
366255
366258
  constructor(data) {
366256
366259
  this.data = {};
366257
366260
  this.initializerInstances = [];
366258
366261
  this.claim = {};
366259
366262
  this.deps = {};
366263
+ this._postRenderFunctions = [];
366260
366264
  this._github = github_0;
366261
366265
  this.data = data;
366262
366266
  }
@@ -366270,10 +366274,14 @@ class Decanter {
366270
366274
  return new ImportInitializer();
366271
366275
  }
366272
366276
  __patchClaim(patch) {
366273
- this.claim = fast_json_patch.applyPatch(this.claim, [patch]).newDocument;
366277
+ this.claim = fast_json_patch_default().applyPatch(this.claim, [patch]).newDocument;
366278
+ }
366279
+ __patchCr(cr, patches) {
366280
+ patches = Array.isArray(patches) ? patches : [patches];
366281
+ return fast_json_patch_default().applyPatch(cr, patches).newDocument;
366274
366282
  }
366275
366283
  __validateEqual(a, b) {
366276
- return fast_json_patch.compare(a, b).length === 0;
366284
+ return fast_json_patch_default().compare(a, b).length === 0;
366277
366285
  }
366278
366286
  __decantStart() { }
366279
366287
  __getMethods(check) {
@@ -366323,6 +366331,14 @@ class Decanter {
366323
366331
  catalog_common.io.writeClaim(this.claim, claimsPath);
366324
366332
  return yaml;
366325
366333
  }
366334
+ postRender() {
366335
+ for (const method of this.__getMethods(this)) {
366336
+ if (method.match(/^__postRender/) &&
366337
+ typeof this[method] === 'function') {
366338
+ this[method]();
366339
+ }
366340
+ }
366341
+ }
366326
366342
  async _adapt() {
366327
366343
  const initializers = [];
366328
366344
  const overrides = [];
@@ -366343,6 +366359,7 @@ class Decanter {
366343
366359
  }
366344
366360
  const adapted = {
366345
366361
  deps: this.getDeps(),
366362
+ postRenderFunctions: this.postRenderFunctions,
366346
366363
  renderClaim: {
366347
366364
  claim: this.claim,
366348
366365
  initializers,
@@ -366357,6 +366374,9 @@ class Decanter {
366357
366374
  if (!this.deps[key])
366358
366375
  this.deps[key] = { cr, secret };
366359
366376
  }
366377
+ setPostRenderF(f) {
366378
+ this._postRenderFunctions.push(f);
366379
+ }
366360
366380
  getDeps() {
366361
366381
  return this.deps;
366362
366382
  }
@@ -366473,6 +366493,15 @@ class GroupGithubDecanter extends GithubDecanter {
366473
366493
  async __adaptInitializerBase(_claim) {
366474
366494
  return await this.__loadInitializer('defaults_github_group.yaml');
366475
366495
  }
366496
+ __postRenderAnnotateGithubId() {
366497
+ this.setPostRenderF((cr) => {
366498
+ return this.__patchCr(cr, {
366499
+ op: 'add',
366500
+ path: '/metadata/annotations/firestartr.dev~1github-id',
366501
+ value: `${this.data.groupDetails.id}`,
366502
+ });
366503
+ });
366504
+ }
366476
366505
  __validateKind(cr) {
366477
366506
  return true;
366478
366507
  }
@@ -366978,6 +367007,12 @@ async function importGithubGitopsRepository(org, skipPlan, claimsPath, resources
366978
367007
  previousCRs[k];
366979
367008
  }
366980
367009
  const crs = await renderCRs(data);
367010
+ Object.values(crs).forEach((cr) => {
367011
+ const claimName = cr.metadata.labels['claim-ref'];
367012
+ for (const postRenderFunction of data.postRender[`${cr.kind}-${claimName}`]) {
367013
+ cr = postRenderFunction(cr);
367014
+ }
367015
+ });
366981
367016
  await moveCRsAndClaims(crs, org, claimsPath, resourcesPath);
366982
367017
  }
366983
367018
  async function moveCRsAndClaims(crs, org, claimsPath, resourcesPath) {
@@ -367033,24 +367068,30 @@ async function getDataFromKinds(org, filters = []) {
367033
367068
  ]);
367034
367069
  const renderClaims = {};
367035
367070
  const deps = {};
367071
+ const postRender = {};
367036
367072
  for (const repo of data['repos']) {
367037
367073
  renderClaims[`ComponentClaim-${repo.renderClaim.claim.name}`] =
367038
367074
  repo.renderClaim;
367039
367075
  deps[`FirestartrGithubRepository-${repo.renderClaim.claim.name}`] =
367040
367076
  repo.deps;
367077
+ postRender[`FirestartrGithubRepository-${repo.renderClaim.claim.name}`] =
367078
+ repo.postRenderFunctions;
367041
367079
  }
367042
367080
  for (const group of data['groups']) {
367043
367081
  renderClaims[`GroupClaim-${group.renderClaim.claim.name}`] =
367044
367082
  group.renderClaim;
367045
367083
  deps[`FirestartrGithubGroup-${group.renderClaim.claim.name}`] = group.deps;
367084
+ postRender[`FirestartrGithubGroup-${group.renderClaim.claim.name}`] =
367085
+ group.postRenderFunctions;
367046
367086
  }
367047
367087
  for (const membership of data['memberships']) {
367048
367088
  renderClaims[`UserClaim-${membership.renderClaim.claim.name}`] =
367049
367089
  membership.renderClaim;
367050
367090
  deps[`FirestartrGithubMembership-${membership.renderClaim.claim.name}`] =
367051
367091
  membership.deps;
367092
+ postRender[`FirestartrGithubMembership-${membership.renderClaim.claim.name}`] = membership.postRenderFunctions;
367052
367093
  }
367053
- return { renderClaims, deps: deps };
367094
+ return { renderClaims, deps: deps, postRender: postRender };
367054
367095
  }
367055
367096
  async function importGithubGroups(org, filters = []) {
367056
367097
  const groups = [];
@@ -367061,6 +367102,7 @@ async function importGithubGroups(org, filters = []) {
367061
367102
  await group.decant();
367062
367103
  groups.push(await group.adapt());
367063
367104
  group.render();
367105
+ group.postRender();
367064
367106
  }
367065
367107
  return groups;
367066
367108
  }
@@ -368828,6 +368870,7 @@ var WorkStatus;
368828
368870
 
368829
368871
 
368830
368872
 
368873
+
368831
368874
  const kindsWithFinalizer = [
368832
368875
  'FirestartrDummyA',
368833
368876
  'FirestartrDummyB',
@@ -368952,6 +368995,9 @@ function enqueue(pluralKind, workItem, queue, compute, syncCtl, retryCtl) {
368952
368995
  writeTerraformOutputInTfResult: writeTerraformOuputInTFResult,
368953
368996
  writeConnectionSecret: writeConnectionSecret,
368954
368997
  resolveReferences: () => resolve(workItem.item, getItemByItemPath, getSecret),
368998
+ resolveOwnOutputs: () => {
368999
+ return resolveSecretRef(workItem.item.metadata.namespace, workItem.item, getSecret);
369000
+ },
368955
369001
  deleteSecret: () => deleteSecret(workItem.item.spec.writeConnectionSecretToRef.name, workItem.item.metadata.namespace),
368956
369002
  itemPath: () => informer_itemPath(pluralKind, workItem.item),
368957
369003
  error: () => retryCtl.errorReconciling(informer_itemPath(pluralKind, workItem.item)),
@@ -369965,10 +370011,13 @@ var lib_provider = __nccwpck_require__(85791);
369965
370011
  ;// CONCATENATED MODULE: ../provisioner/src/entities/base/Entity.ts
369966
370012
 
369967
370013
  const EXTERNAL_NAME_ANNOTATION = 'firestartr.dev/external-name';
370014
+ const IMPORT_SLUG_ANNOTATION = 'firestartr.dev/github-slug';
370015
+ const IMPORT_ID_ANNOTATION = 'firestartr.dev/github-id';
369968
370016
 
369969
370017
  class Metadata {
369970
- constructor(metadata) {
370018
+ constructor(metadata, resolveOutputs) {
369971
370019
  this._metadata = metadata;
370020
+ this._resolveOutputs = resolveOutputs;
369972
370021
  }
369973
370022
  get name() {
369974
370023
  if (EXTERNAL_NAME_ANNOTATION in this.annotations) {
@@ -369978,19 +370027,56 @@ class Metadata {
369978
370027
  return this._metadata.name;
369979
370028
  }
369980
370029
  }
370030
+ get slug() {
370031
+ // buscar el slug en los outputs
370032
+ const slug = this._resolveOutputs('slug');
370033
+ if (IMPORT_SLUG_ANNOTATION in this.annotations) {
370034
+ return this.annotations[IMPORT_SLUG_ANNOTATION];
370035
+ }
370036
+ else if (slug) {
370037
+ // hay outputs?
370038
+ return slug;
370039
+ }
370040
+ else {
370041
+ return undefined;
370042
+ }
370043
+ }
369981
370044
  get annotations() {
369982
370045
  return this._metadata.annotations || {};
369983
370046
  }
369984
370047
  get labels() {
369985
370048
  return this._metadata.labels || {};
369986
370049
  }
370050
+ get id() {
370051
+ // buscar el id en los outputs
370052
+ const id = this._resolveOutputs('id');
370053
+ if (IMPORT_ID_ANNOTATION in this.annotations) {
370054
+ return this.annotations[IMPORT_ID_ANNOTATION];
370055
+ }
370056
+ else if (id) {
370057
+ // hay outputs?
370058
+ return id;
370059
+ }
370060
+ else {
370061
+ return undefined;
370062
+ }
370063
+ }
369987
370064
  }
369988
370065
  class Entity {
369989
370066
  constructor(artifact, deps) {
369990
370067
  this.importStack = [];
369991
370068
  this.kind = artifact.kind;
369992
370069
  this.apiVersion = artifact.apiVersion;
369993
- this.metadata = new Metadata(artifact.metadata);
370070
+ this.metadata = new Metadata(artifact.metadata, (key) => {
370071
+ if (this.deps && 'self-outputs' in this.deps) {
370072
+ const cr = this.deps['self-outputs'].cr;
370073
+ if (cr && typeof cr.data === 'object') {
370074
+ if (key in cr.data) {
370075
+ return Buffer.from(cr.data[key], 'base64').toString('utf-8');
370076
+ }
370077
+ }
370078
+ }
370079
+ });
369994
370080
  this.spec = artifact.spec;
369995
370081
  if (deps) {
369996
370082
  this.deps = deps;
@@ -370140,14 +370226,14 @@ function provisionPermissions(scope, repo, fsGithubRepository) {
370140
370226
  if ('ref' in permission) {
370141
370227
  const tfStateKey = `_${fsGithubRepository.getTfStateKey()}-${permission.ref.kind}-${permission.ref.name}-tr`;
370142
370228
  if (permission.ref.kind === 'FirestartrGithubGroup') {
370143
- const teamId = fsGithubRepository.resolveRef(permission.ref, 'id');
370229
+ const teamSlug = fsGithubRepository.resolveRef(permission.ref, 'slug');
370144
370230
  const config = {
370145
370231
  repository: repo.name,
370146
- teamId,
370232
+ teamId: teamSlug,
370147
370233
  permission: permission.role,
370148
370234
  };
370149
370235
  const teamsRepository = new team_repository/* TeamRepository */.C(scope, tfStateKey, config);
370150
- fsGithubRepository.addResourceToStack(`${teamId}:${fsGithubRepository.metadata.name}`, teamsRepository);
370236
+ fsGithubRepository.addResourceToStack(`${teamSlug}:${fsGithubRepository.metadata.name}`, teamsRepository);
370151
370237
  }
370152
370238
  else if (permission.ref.kind === 'FirestartrGithubMembership') {
370153
370239
  const username = fsGithubRepository.resolveRef(permission.ref);
@@ -370507,7 +370593,7 @@ function provisionGroup(scope, fsGithubGroup) {
370507
370593
  };
370508
370594
  const tfStateKey = `_${fsGithubGroup.getTfStateKey()}`;
370509
370595
  const group = new lib_team/* Team */.S(scope, tfStateKey, config);
370510
- fsGithubGroup.addResourceToStack(fsGithubGroup.metadata.name, group);
370596
+ fsGithubGroup.addResourceToStack(fsGithubGroup.metadata.id || fsGithubGroup.metadata.name, group);
370511
370597
  return group;
370512
370598
  }
370513
370599
 
@@ -370524,11 +370610,11 @@ function provisionMembers(scope, team, fsGithubGroup) {
370524
370610
  const config = {
370525
370611
  dependsOn: [team],
370526
370612
  username,
370527
- teamId: team.id,
370613
+ teamId: fsGithubGroup.metadata.slug || team.id,
370528
370614
  role: member.role,
370529
370615
  };
370530
370616
  const membership = new team_membership/* TeamMembership */.E(scope, tfStateKey, config);
370531
- fsGithubGroup.addResourceToStack(`${team.id}:${username}`, membership);
370617
+ fsGithubGroup.addResourceToStack(`${fsGithubGroup.metadata.slug || team.id}:${username}`, membership);
370532
370618
  }
370533
370619
  }
370534
370620
  }
@@ -372404,7 +372490,10 @@ async function* doApply(item, op, handler) {
372404
372490
  opts['create'] = true;
372405
372491
  }
372406
372492
  const deps = await handler.resolveReferences();
372407
- operator_src_logger.info(`Item ${item.metadata.name} has the following dependencies: ${deps}`);
372493
+ deps['self-outputs'] = {
372494
+ cr: await handler.resolveOwnOutputs(),
372495
+ };
372496
+ operator_src_logger.info(`Item ${item.metadata.name} has the following dependencies: ${Object.keys(deps)}`);
372408
372497
  const annotation = 'firestartr.dev/last-state-pr';
372409
372498
  const statePr = item?.metadata?.annotations?.[annotation];
372410
372499
  const hasStatePr = typeof statePr === 'string' && statePr.trim().length > 0;
@@ -376320,7 +376409,7 @@ const crs_analyzerSubcommand = {
376320
376409
  };
376321
376410
 
376322
376411
  ;// CONCATENATED MODULE: ./package.json
376323
- const package_namespaceObject = JSON.parse('{"i8":"1.55.1-snapshot-4"}');
376412
+ const package_namespaceObject = JSON.parse('{"i8":"1.55.1-snapshot-5"}');
376324
376413
  ;// CONCATENATED MODULE: ../../package.json
376325
376414
  const package_namespaceObject_1 = {"i8":"1.55.0"};
376326
376415
  ;// CONCATENATED MODULE: ./src/subcommands/index.ts
@@ -1,5 +1,5 @@
1
1
  import { importGithubGitopsRepository } from './src/decanter';
2
- import { CollectionFilter } from './src/decanter/collections';
2
+ import type { CollectionFilter } from './src/decanter/collections';
3
3
  export { CollectionFilter };
4
4
  declare const _default: {
5
5
  importGithubGitopsRepository: typeof importGithubGitopsRepository;
@@ -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: Function;
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.55.1-snapshot-4",
3
+ "version": "1.55.1-snapshot-5",
4
4
  "private": false,
5
5
  "description": "Commandline tool",
6
6
  "main": "build/main.js",