@firestartr/cli 1.56.0-snapshot-1 → 1.56.1-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 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,13 @@ 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
+ const postRenderFunctions = data.postRender[`${cr.kind}-${claimName}`] || [];
367013
+ for (const postRenderFunction of postRenderFunctions) {
367014
+ cr = postRenderFunction(cr);
367015
+ }
367016
+ });
366981
367017
  await moveCRsAndClaims(crs, org, claimsPath, resourcesPath);
366982
367018
  }
366983
367019
  async function moveCRsAndClaims(crs, org, claimsPath, resourcesPath) {
@@ -367033,24 +367069,30 @@ async function getDataFromKinds(org, filters = []) {
367033
367069
  ]);
367034
367070
  const renderClaims = {};
367035
367071
  const deps = {};
367072
+ const postRender = {};
367036
367073
  for (const repo of data['repos']) {
367037
367074
  renderClaims[`ComponentClaim-${repo.renderClaim.claim.name}`] =
367038
367075
  repo.renderClaim;
367039
367076
  deps[`FirestartrGithubRepository-${repo.renderClaim.claim.name}`] =
367040
367077
  repo.deps;
367078
+ postRender[`FirestartrGithubRepository-${repo.renderClaim.claim.name}`] =
367079
+ repo.postRenderFunctions;
367041
367080
  }
367042
367081
  for (const group of data['groups']) {
367043
367082
  renderClaims[`GroupClaim-${group.renderClaim.claim.name}`] =
367044
367083
  group.renderClaim;
367045
367084
  deps[`FirestartrGithubGroup-${group.renderClaim.claim.name}`] = group.deps;
367085
+ postRender[`FirestartrGithubGroup-${group.renderClaim.claim.name}`] =
367086
+ group.postRenderFunctions;
367046
367087
  }
367047
367088
  for (const membership of data['memberships']) {
367048
367089
  renderClaims[`UserClaim-${membership.renderClaim.claim.name}`] =
367049
367090
  membership.renderClaim;
367050
367091
  deps[`FirestartrGithubMembership-${membership.renderClaim.claim.name}`] =
367051
367092
  membership.deps;
367093
+ postRender[`FirestartrGithubMembership-${membership.renderClaim.claim.name}`] = membership.postRenderFunctions;
367052
367094
  }
367053
- return { renderClaims, deps: deps };
367095
+ return { renderClaims, deps: deps, postRender: postRender };
367054
367096
  }
367055
367097
  async function importGithubGroups(org, filters = []) {
367056
367098
  const groups = [];
@@ -367061,6 +367103,7 @@ async function importGithubGroups(org, filters = []) {
367061
367103
  await group.decant();
367062
367104
  groups.push(await group.adapt());
367063
367105
  group.render();
367106
+ group.postRender();
367064
367107
  }
367065
367108
  return groups;
367066
367109
  }
@@ -368828,6 +368871,7 @@ var WorkStatus;
368828
368871
 
368829
368872
 
368830
368873
 
368874
+
368831
368875
  const kindsWithFinalizer = [
368832
368876
  'FirestartrDummyA',
368833
368877
  'FirestartrDummyB',
@@ -368952,6 +368996,9 @@ function enqueue(pluralKind, workItem, queue, compute, syncCtl, retryCtl) {
368952
368996
  writeTerraformOutputInTfResult: writeTerraformOuputInTFResult,
368953
368997
  writeConnectionSecret: writeConnectionSecret,
368954
368998
  resolveReferences: () => resolve(workItem.item, getItemByItemPath, getSecret),
368999
+ resolveOwnOutputs: () => {
369000
+ return resolveSecretRef(workItem.item.metadata.namespace, workItem.item, getSecret);
369001
+ },
368955
369002
  deleteSecret: () => deleteSecret(workItem.item.spec.writeConnectionSecretToRef.name, workItem.item.metadata.namespace),
368956
369003
  itemPath: () => informer_itemPath(pluralKind, workItem.item),
368957
369004
  error: () => retryCtl.errorReconciling(informer_itemPath(pluralKind, workItem.item)),
@@ -369965,10 +370012,13 @@ var lib_provider = __nccwpck_require__(85791);
369965
370012
  ;// CONCATENATED MODULE: ../provisioner/src/entities/base/Entity.ts
369966
370013
 
369967
370014
  const EXTERNAL_NAME_ANNOTATION = 'firestartr.dev/external-name';
370015
+ const IMPORT_SLUG_ANNOTATION = 'firestartr.dev/github-slug';
370016
+ const IMPORT_ID_ANNOTATION = 'firestartr.dev/github-id';
369968
370017
 
369969
370018
  class Metadata {
369970
- constructor(metadata) {
370019
+ constructor(metadata, resolveOutputs) {
369971
370020
  this._metadata = metadata;
370021
+ this._resolveOutputs = resolveOutputs;
369972
370022
  }
369973
370023
  get name() {
369974
370024
  if (EXTERNAL_NAME_ANNOTATION in this.annotations) {
@@ -369978,19 +370028,56 @@ class Metadata {
369978
370028
  return this._metadata.name;
369979
370029
  }
369980
370030
  }
370031
+ get slug() {
370032
+ // buscar el slug en los outputs
370033
+ const slug = this._resolveOutputs('slug');
370034
+ if (IMPORT_SLUG_ANNOTATION in this.annotations) {
370035
+ return this.annotations[IMPORT_SLUG_ANNOTATION];
370036
+ }
370037
+ else if (slug) {
370038
+ // hay outputs?
370039
+ return slug;
370040
+ }
370041
+ else {
370042
+ return undefined;
370043
+ }
370044
+ }
369981
370045
  get annotations() {
369982
370046
  return this._metadata.annotations || {};
369983
370047
  }
369984
370048
  get labels() {
369985
370049
  return this._metadata.labels || {};
369986
370050
  }
370051
+ get id() {
370052
+ // buscar el id en los outputs
370053
+ const id = this._resolveOutputs('id');
370054
+ if (IMPORT_ID_ANNOTATION in this.annotations) {
370055
+ return this.annotations[IMPORT_ID_ANNOTATION];
370056
+ }
370057
+ else if (id) {
370058
+ // hay outputs?
370059
+ return id;
370060
+ }
370061
+ else {
370062
+ return undefined;
370063
+ }
370064
+ }
369987
370065
  }
369988
370066
  class Entity {
369989
370067
  constructor(artifact, deps) {
369990
370068
  this.importStack = [];
369991
370069
  this.kind = artifact.kind;
369992
370070
  this.apiVersion = artifact.apiVersion;
369993
- this.metadata = new Metadata(artifact.metadata);
370071
+ this.metadata = new Metadata(artifact.metadata, (key) => {
370072
+ if (this.deps && 'self-outputs' in this.deps) {
370073
+ const cr = this.deps['self-outputs'].cr;
370074
+ if (cr && typeof cr.data === 'object') {
370075
+ if (key in cr.data) {
370076
+ return Buffer.from(cr.data[key], 'base64').toString('utf-8');
370077
+ }
370078
+ }
370079
+ }
370080
+ });
369994
370081
  this.spec = artifact.spec;
369995
370082
  if (deps) {
369996
370083
  this.deps = deps;
@@ -370140,14 +370227,15 @@ function provisionPermissions(scope, repo, fsGithubRepository) {
370140
370227
  if ('ref' in permission) {
370141
370228
  const tfStateKey = `_${fsGithubRepository.getTfStateKey()}-${permission.ref.kind}-${permission.ref.name}-tr`;
370142
370229
  if (permission.ref.kind === 'FirestartrGithubGroup') {
370230
+ const teamSlug = fsGithubRepository.resolveRef(permission.ref, 'slug');
370143
370231
  const teamId = fsGithubRepository.resolveRef(permission.ref, 'id');
370144
370232
  const config = {
370145
370233
  repository: repo.name,
370146
- teamId,
370234
+ teamId: teamId,
370147
370235
  permission: permission.role,
370148
370236
  };
370149
370237
  const teamsRepository = new team_repository/* TeamRepository */.C(scope, tfStateKey, config);
370150
- fsGithubRepository.addResourceToStack(`${teamId}:${fsGithubRepository.metadata.name}`, teamsRepository);
370238
+ fsGithubRepository.addResourceToStack(`${teamSlug}:${fsGithubRepository.metadata.name}`, teamsRepository);
370151
370239
  }
370152
370240
  else if (permission.ref.kind === 'FirestartrGithubMembership') {
370153
370241
  const username = fsGithubRepository.resolveRef(permission.ref);
@@ -370507,7 +370595,7 @@ function provisionGroup(scope, fsGithubGroup) {
370507
370595
  };
370508
370596
  const tfStateKey = `_${fsGithubGroup.getTfStateKey()}`;
370509
370597
  const group = new lib_team/* Team */.S(scope, tfStateKey, config);
370510
- fsGithubGroup.addResourceToStack(fsGithubGroup.metadata.name, group);
370598
+ fsGithubGroup.addResourceToStack(fsGithubGroup.metadata.id || fsGithubGroup.metadata.name, group);
370511
370599
  return group;
370512
370600
  }
370513
370601
 
@@ -370524,11 +370612,11 @@ function provisionMembers(scope, team, fsGithubGroup) {
370524
370612
  const config = {
370525
370613
  dependsOn: [team],
370526
370614
  username,
370527
- teamId: team.id,
370615
+ teamId: fsGithubGroup.metadata.slug || team.id,
370528
370616
  role: member.role,
370529
370617
  };
370530
370618
  const membership = new team_membership/* TeamMembership */.E(scope, tfStateKey, config);
370531
- fsGithubGroup.addResourceToStack(`${team.id}:${username}`, membership);
370619
+ fsGithubGroup.addResourceToStack(`${fsGithubGroup.metadata.slug || team.id}:${username}`, membership);
370532
370620
  }
370533
370621
  }
370534
370622
  }
@@ -372409,7 +372497,10 @@ async function* doApply(item, op, handler) {
372409
372497
  opts['create'] = true;
372410
372498
  }
372411
372499
  const deps = await handler.resolveReferences();
372412
- operator_src_logger.info(`Item ${item.metadata.name} has the following dependencies: ${deps}`);
372500
+ deps['self-outputs'] = {
372501
+ cr: await handler.resolveOwnOutputs(),
372502
+ };
372503
+ operator_src_logger.info(`Item ${item.metadata.name} has the following dependencies: ${Object.keys(deps)}`);
372413
372504
  const annotation = 'firestartr.dev/last-state-pr';
372414
372505
  const statePr = item?.metadata?.annotations?.[annotation];
372415
372506
  const hasStatePr = typeof statePr === 'string' && statePr.trim().length > 0;
@@ -376325,7 +376416,7 @@ const crs_analyzerSubcommand = {
376325
376416
  };
376326
376417
 
376327
376418
  ;// CONCATENATED MODULE: ./package.json
376328
- const package_namespaceObject = JSON.parse('{"i8":"1.56.0-snapshot-1"}');
376419
+ const package_namespaceObject = JSON.parse('{"i8":"1.56.1-snapshot-1"}');
376329
376420
  ;// CONCATENATED MODULE: ../../package.json
376330
376421
  const package_namespaceObject_1 = {"i8":"1.56.0"};
376331
376422
  ;// 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.56.0-snapshot-1",
3
+ "version": "1.56.1-snapshot-1",
4
4
  "private": false,
5
5
  "description": "Commandline tool",
6
6
  "main": "build/main.js",