@firestartr/cli 1.39.0-SNAPSHOT → 1.39.1-SNAPSHOT

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
@@ -276807,8 +276807,12 @@ const validate = uuid_dist/* validate */.Gu;
276807
276807
  const stringify = uuid_dist/* stringify */.Pz;
276808
276808
  const parse = uuid_dist/* parse */.Qc;
276809
276809
 
276810
+ // EXTERNAL MODULE: external "crypto"
276811
+ var external_crypto_ = __nccwpck_require__(6113);
276812
+ var external_crypto_default = /*#__PURE__*/__nccwpck_require__.n(external_crypto_);
276810
276813
  ;// CONCATENATED MODULE: ../catalog_common/src/generic/nomicon.ts
276811
276814
 
276815
+
276812
276816
  const UUID_ANNOTATION = 'fire-starter.dev/uuid';
276813
276817
  /*
276814
276818
  *
@@ -276836,6 +276840,12 @@ function calculateStoregeKey(artifact, storageType) {
276836
276840
  return `${artifact['kind'].toLowerCase()}-${helperlGetArtifactUUID(artifact)}`;
276837
276841
  }
276838
276842
  }
276843
+ /*
276844
+ * String to md5
276845
+ */
276846
+ function toMd5(text) {
276847
+ return external_crypto_default().createHash('md5').update(text).digest('hex');
276848
+ }
276839
276849
 
276840
276850
  // EXTERNAL MODULE: external "stream"
276841
276851
  var external_stream_ = __nccwpck_require__(12781);
@@ -277829,6 +277839,7 @@ function removeRepeatedObjectsFromArrayByProp(array, propiedad) {
277829
277839
  getFirestartrLabel: getFirestartrLabel,
277830
277840
  normalizeLabel: normalizeLabel,
277831
277841
  removeRepeatedObjectsFromArrayByProp: removeRepeatedObjectsFromArrayByProp,
277842
+ toMd5: toMd5,
277832
277843
  });
277833
277844
 
277834
277845
  ;// CONCATENATED MODULE: ../catalog_common/src/types/envvars.ts
@@ -286971,7 +286982,7 @@ async function replaceReferencesValues(contents, references, resolveRef) {
286971
286982
  class RevisionNormalizer extends Normalizer {
286972
286983
  constructor() {
286973
286984
  super(...arguments);
286974
- this.applicableProviders = ['all'];
286985
+ this.applicableProviders = ['terraform', 'github'];
286975
286986
  }
286976
286987
  async __validate(_schema) {
286977
286988
  return true;
@@ -287004,11 +287015,6 @@ class RevisionNormalizer extends Normalizer {
287004
287015
  identify() {
287005
287016
  return 'normalizer/revision';
287006
287017
  },
287007
- applicable() {
287008
- return {
287009
- applicableProviders: ['terraform'],
287010
- };
287011
- },
287012
287018
  },
287013
287019
  ];
287014
287020
  }
@@ -291497,11 +291503,10 @@ class FeatureRepoChart extends BaseGithubChart {
291497
291503
  template() {
291498
291504
  const claim = this.get('claim');
291499
291505
  const repositoryTarget = this.resolveRepositoryTarget();
291500
- return {
291506
+ const cr = {
291501
291507
  metadata: {
291502
291508
  name: claim.name,
291503
291509
  annotations: {
291504
- 'firestartr.dev/claim-ref': `${this.get('repoCr').metadata.annotations['firestartr.dev/claim-ref']}`,
291505
291510
  'firestartr.dev/external-name': claim.name,
291506
291511
  'firestartr.dev/feature-name': claim.feature.name,
291507
291512
  },
@@ -291518,10 +291523,31 @@ class FeatureRepoChart extends BaseGithubChart {
291518
291523
  },
291519
291524
  },
291520
291525
  };
291526
+ const annotations = this.getAnnotationsFromRepo(this.get('repoCr'), [
291527
+ 'claim-ref',
291528
+ 'revision',
291529
+ 'sync-enabled',
291530
+ 'sync-period',
291531
+ ]);
291532
+ cr.metadata.annotations = {
291533
+ ...cr.metadata.annotations,
291534
+ ...annotations,
291535
+ };
291536
+ return cr;
291521
291537
  }
291522
291538
  gvk() {
291523
291539
  return FirestartrGithubRepositoryFeature.GVK;
291524
291540
  }
291541
+ getAnnotationsFromRepo(repoCr, inheritedAnnotations) {
291542
+ const annotations = {};
291543
+ for (const annotation of inheritedAnnotations) {
291544
+ const fsAnnotation = `firestartr.dev/${annotation}`;
291545
+ if (fsAnnotation in repoCr.metadata.annotations) {
291546
+ annotations[fsAnnotation] = repoCr.metadata.annotations[fsAnnotation];
291547
+ }
291548
+ }
291549
+ return annotations;
291550
+ }
291525
291551
  resolveRepositoryTarget() {
291526
291552
  const repositoryTarget = {
291527
291553
  ref: {
@@ -292749,7 +292775,8 @@ function compareCRs(crV1, crV2) {
292749
292775
  */
292750
292776
  (op) => op.path !== '/spec/firestartr/tfStateKey' &&
292751
292777
  op.path !== '/metadata/name' &&
292752
- op.path !== '/spec/writeConnectionSecretToRef/name');
292778
+ op.path !== '/spec/writeConnectionSecretToRef/name' &&
292779
+ op.path !== '/metadata/annotations/firestartr.dev~1revision');
292753
292780
  return {
292754
292781
  changed: compareResult.length !== 0,
292755
292782
  changes: compareResult,
@@ -296746,6 +296773,9 @@ class GithubStack extends BaseStack {
296746
296773
  async provisionEntity(isImport, entity, deps, tfStatePath, orgConfig) {
296747
296774
  try {
296748
296775
  const { backendConfig, providerConfig } = this.getRefContextConfigs(entity, deps);
296776
+ if (backendConfig.spec.type === 'kubernetes') {
296777
+ tfStatePath = catalog_common.generic.toMd5(tfStatePath);
296778
+ }
296749
296779
  this.initProviders(this, tfStatePath, backendConfig, providerConfig, deps);
296750
296780
  const instance = getEntityInstance(entity, deps);
296751
296781
  await instance.provision({ scope: this });
@@ -297267,6 +297297,7 @@ class github_feature_FirestartrGithubRepositoryFeature extends Resource {
297267
297297
  break;
297268
297298
  case 'UPDATE':
297269
297299
  github_feature_log('UPDATED');
297300
+ await this._updateManagedFiles();
297270
297301
  break;
297271
297302
  case 'DELETE':
297272
297303
  github_feature_log('DELETE');
@@ -301102,8 +301133,8 @@ class Analyzer {
301102
301133
  }
301103
301134
  }
301104
301135
 
301105
- ;// CONCATENATED MODULE: ../crs_analyzer/src/models/workspace.ts
301106
- class Workspace {
301136
+ ;// CONCATENATED MODULE: ../crs_analyzer/src/models/cr.ts
301137
+ class Cr {
301107
301138
  constructor(kind, metadata, conditions) {
301108
301139
  this.kind = kind;
301109
301140
  this.metadata = metadata;
@@ -301133,23 +301164,23 @@ class Workspace {
301133
301164
  }
301134
301165
  }
301135
301166
 
301136
- ;// CONCATENATED MODULE: ../crs_analyzer/src/analyzers/workspaces.ts
301167
+ ;// CONCATENATED MODULE: ../crs_analyzer/src/analyzers/crs-analyzer.ts
301137
301168
 
301138
301169
 
301139
- class WorkspacesAnalyzer extends Analyzer {
301170
+ class CrsAnalyzer extends Analyzer {
301140
301171
  constructor(context, cli) {
301141
301172
  super(context, cli);
301142
301173
  this.drifted = [];
301143
301174
  this.failed = [];
301144
301175
  }
301145
301176
  async analyze() {
301146
- const workspaces = await this.listWorkspaces();
301147
- this.drifted = this.filterByDrifted(workspaces);
301148
- this.failed = this.filterByFailed(workspaces);
301177
+ const crs = await this.listCrs();
301178
+ this.drifted = this.filterByDrifted(crs);
301179
+ this.failed = this.filterByFailed(crs);
301149
301180
  }
301150
- async listWorkspaces() {
301181
+ async listCrs() {
301151
301182
  const list = await this.cli.listKind(this.ctx.apiGroup, this.ctx.apiVersion, this.ctx.namespace, this.ctx.plural);
301152
- return list.map((item) => new Workspace(item.kind, item.metadata, item.status.conditions));
301183
+ return list.map((item) => new Cr(item.kind, item.metadata, item.status.conditions));
301153
301184
  }
301154
301185
  filterByFailed(workspaces) {
301155
301186
  return workspaces.filter((ws) => ws.hasError());
@@ -301224,10 +301255,10 @@ function sanitize(str) {
301224
301255
  return str;
301225
301256
  }
301226
301257
 
301227
- ;// CONCATENATED MODULE: ../crs_analyzer/src/publishers/workspaces.ts
301258
+ ;// CONCATENATED MODULE: ../crs_analyzer/src/publishers/crs.ts
301228
301259
 
301229
301260
 
301230
- class WorkspacesPublisher extends Publisher {
301261
+ class CrsPublisher extends Publisher {
301231
301262
  constructor(analyzer, githubCli, context) {
301232
301263
  super();
301233
301264
  this.output = '';
@@ -301251,35 +301282,35 @@ class WorkspacesPublisher extends Publisher {
301251
301282
  for (const issue of errorIssues || []) {
301252
301283
  if (!this.analyzer.failed.find((wp) => issue.title.includes(wp.claimName) && issue.title.includes('error'))) {
301253
301284
  await this.githubCli.closeIssue(this.context.githubOwner, this.context.githubRepo, issue.number);
301254
- this.writeLnOutput(`✅ No errors detected for TFWorkspace on issue ${issue.title}. Issue has been closed.`);
301285
+ this.writeLnOutput(`✅ No errors detected on issue ${issue.title}. Issue has been closed.`);
301255
301286
  }
301256
301287
  }
301257
301288
  }
301258
301289
  async closeOldDriftIssues(driftIssues) {
301259
301290
  for (const issue of driftIssues || []) {
301260
- if (!this.analyzer.drifted.find((wp) => issue.title.includes(wp.claimName) && issue.title.includes('drift'))) {
301291
+ if (!this.analyzer.drifted.find((cr) => issue.title.includes(cr.claimName) && issue.title.includes('drift'))) {
301261
301292
  await this.githubCli.closeIssue(this.context.githubOwner, this.context.githubRepo, issue.number);
301262
- this.writeLnOutput(`✅ No drift detected for TFWorkspace on issue ${issue.title}. Issue has been closed.`);
301293
+ this.writeLnOutput(`✅ No drift detected on issue ${issue.title}. Issue has been closed.`);
301263
301294
  }
301264
301295
  }
301265
301296
  }
301266
- async publishError(wp) {
301267
- const body = this.buildErrorsBody(wp);
301268
- const resp = await this.githubCli.upsertIssue(this.context.githubOwner, this.context.githubRepo, `Claim '${wp.claimName}' has an error`, body, [wp.claimKind, 'error']);
301269
- this.writeLnOutput(`❌ Error detected for TFWorkspace: ${wp.claimName}. Issue has been created or updated: ${resp.data.html_url}`);
301297
+ async publishError(cr) {
301298
+ const body = this.buildErrorsBody(cr);
301299
+ const resp = await this.githubCli.upsertIssue(this.context.githubOwner, this.context.githubRepo, `Claim '${cr.claimName}' has an error`, body, [cr.claimKind, 'error']);
301300
+ this.writeLnOutput(`❌ Error detected for ${cr.claimKind}: ${cr.claimName}. Issue has been created or updated: ${resp.data.html_url}`);
301270
301301
  return resp;
301271
301302
  }
301272
- async publishDrift(wp) {
301273
- const body = this.buildDriftBody(wp);
301274
- const resp = await this.githubCli.upsertIssue(this.context.githubOwner, this.context.githubRepo, `Claim '${wp.claimName}' has a drift`, body, [wp.claimKind, 'drift']);
301275
- this.writeLnOutput(`⚠️ Drift detected for TFWorkspace: ${wp.claimName}. Issue has been created or updated: ${resp.data.html_url}`);
301303
+ async publishDrift(cr) {
301304
+ const body = this.buildDriftBody(cr);
301305
+ const resp = await this.githubCli.upsertIssue(this.context.githubOwner, this.context.githubRepo, `Claim '${cr.claimName}' has a drift`, body, [cr.claimKind, 'drift']);
301306
+ this.writeLnOutput(`⚠️ Drift detected for ${cr.claimKind}: ${cr.claimName}. Issue has been created or updated: ${resp.data.html_url}`);
301276
301307
  return resp;
301277
301308
  }
301278
- buildErrorsBody(wp) {
301309
+ buildErrorsBody(cr) {
301279
301310
  return `
301280
- The claim '${wp.claimName}' with kind: ${wp.claimKind} has an error.
301311
+ The claim '${cr.claimName}' with kind: ${cr.claimKind} has an error.
301281
301312
 
301282
- ${this.buildErrorForWs(wp)}
301313
+ ${this.buildErrorForWs(cr)}
301283
301314
  `;
301284
301315
  }
301285
301316
  buildErrorForWs(ws) {
@@ -301331,19 +301362,11 @@ class GithubClient {
301331
301362
 
301332
301363
 
301333
301364
 
301334
- async function runCrsAnalyzer(analyzerType, namespace, org, repo) {
301335
- switch (analyzerType) {
301336
- case 'tfworkspaces':
301337
- await tfWorkspacesAnalyze(namespace, org, repo);
301338
- break;
301339
- default:
301340
- }
301341
- }
301342
- async function tfWorkspacesAnalyze(namespace, org, repo) {
301343
- const context = new context_Context('firestartr.dev', 'v1', 'terraformworkspaces', namespace, org, repo);
301344
- const analyzer = new WorkspacesAnalyzer(context, new KubernetesClient());
301365
+ async function runCrsAnalyzer(plural, namespace, org, repo) {
301366
+ const context = new context_Context('firestartr.dev', 'v1', plural, namespace, org, repo);
301367
+ const analyzer = new CrsAnalyzer(context, new KubernetesClient());
301345
301368
  await analyzer.analyze();
301346
- const publisher = new WorkspacesPublisher(analyzer, new GithubClient(), context);
301369
+ const publisher = new CrsPublisher(analyzer, new GithubClient(), context);
301347
301370
  await publisher.publish();
301348
301371
  if (publisher.output !== '') {
301349
301372
  console.log(publisher.output);
@@ -38,6 +38,7 @@ declare const _default: {
38
38
  getFirestartrLabel: typeof import("./src/generic/labels").getFirestartrLabel;
39
39
  normalizeLabel: typeof import("./src/generic/labels").normalizeLabel;
40
40
  removeRepeatedObjectsFromArrayByProp: typeof import("./src/generic/arrays").removeRepeatedObjectsFromArrayByProp;
41
+ toMd5: typeof import("./src/generic/nomicon").toMd5;
41
42
  };
42
43
  types: {
43
44
  ArtifactStatuses: typeof import("./src/types/catalog").ArtifactStatuses;
@@ -1,5 +1,5 @@
1
1
  import { randomString, shuffleArray, shuffleObject } from './random';
2
- import { annotateWithUUID, calculateStoregeKey } from './nomicon';
2
+ import { annotateWithUUID, calculateStoregeKey, toMd5 } from './nomicon';
3
3
  import CsvWriter from './csv_generator';
4
4
  import { getLogger } from './logger';
5
5
  import { sleep } from './time';
@@ -24,5 +24,6 @@ declare const _default: {
24
24
  getFirestartrLabel: typeof getFirestartrLabel;
25
25
  normalizeLabel: typeof normalizeLabel;
26
26
  removeRepeatedObjectsFromArrayByProp: typeof removeRepeatedObjectsFromArrayByProp;
27
+ toMd5: typeof toMd5;
27
28
  };
28
29
  export default _default;
@@ -4,3 +4,4 @@ export interface Artifact {
4
4
  export declare function annotateWithUUID(artifact: Artifact): Artifact;
5
5
  export declare function helperlGetArtifactUUID(artifact: Artifact): string;
6
6
  export declare function calculateStoregeKey(artifact: Artifact, storageType: string): string;
7
+ export declare function toMd5(text: string): string;
@@ -5,6 +5,7 @@ export declare class FeatureRepoChart extends BaseGithubChart {
5
5
  constructor(scope: any, chartId: string, firestartrId: string | null, claim: any, patches?: any[], cr?: any);
6
6
  template(): FirestartrGithubRepositoryFeatureProps;
7
7
  gvk(): GroupVersionKind;
8
+ private getAnnotationsFromRepo;
8
9
  private resolveRepositoryTarget;
9
10
  instanceApiObject(template: any): FirestartrGithubRepositoryFeature;
10
11
  }
@@ -1,4 +1,4 @@
1
- declare function runCrsAnalyzer(analyzerType: string, namespace: string, org: string, repo: string): Promise<void>;
1
+ declare function runCrsAnalyzer(plural: string, namespace: string, org: string, repo: string): Promise<void>;
2
2
  declare const _default: {
3
3
  runCrsAnalyzer: typeof runCrsAnalyzer;
4
4
  };
@@ -0,0 +1,13 @@
1
+ import { Context } from '../context';
2
+ import { Analyzer } from './base';
3
+ import { Cr } from '../models/cr';
4
+ import { KubernetesClient } from '../kubernetes-client';
5
+ export declare class CrsAnalyzer extends Analyzer {
6
+ drifted: Cr[];
7
+ failed: Cr[];
8
+ constructor(context: Context, cli: KubernetesClient);
9
+ analyze(): Promise<void>;
10
+ listCrs(): Promise<Cr[]>;
11
+ filterByFailed(workspaces: Cr[]): Cr[];
12
+ filterByDrifted(workspaces: Cr[]): Cr[];
13
+ }
@@ -1,4 +1,4 @@
1
- export declare class Workspace {
1
+ export declare class Cr {
2
2
  kind: string;
3
3
  metadata: {
4
4
  name: string;
@@ -0,0 +1,23 @@
1
+ import { CrsAnalyzer } from '../analyzers/crs-analyzer';
2
+ import { Context } from '../context';
3
+ import { GithubClient } from '../github-client';
4
+ import { Cr } from '../models/cr';
5
+ import { Publisher } from './base';
6
+ export declare class CrsPublisher extends Publisher {
7
+ githubCli: GithubClient;
8
+ analyzer: CrsAnalyzer;
9
+ context: Context;
10
+ output: string;
11
+ constructor(analyzer: CrsAnalyzer, githubCli: GithubClient, context: Context);
12
+ publish(): Promise<void>;
13
+ closeOldErrorIssues(errorIssues: any): Promise<void>;
14
+ closeOldDriftIssues(driftIssues: any): Promise<void>;
15
+ publishError(cr: Cr): Promise<any>;
16
+ publishDrift(cr: Cr): Promise<any>;
17
+ buildErrorsBody(cr: Cr): string;
18
+ buildErrorForWs(ws: Cr): string;
19
+ buildDriftBody(wp: Cr): string;
20
+ buildDriftForWs(ws: Cr): string;
21
+ writeLnOutput(line: string): void;
22
+ filterIssuesBy(type: 'error' | 'drift'): Promise<any>;
23
+ }
@@ -428,7 +428,7 @@ export declare function getBranch(repo: string, branch: string, owner?: string):
428
428
  verified_at: string;
429
429
  };
430
430
  };
431
- author: {
431
+ author: Record<string, never> | {
432
432
  name?: string;
433
433
  email?: string;
434
434
  login: string;
@@ -451,8 +451,8 @@ export declare function getBranch(repo: string, branch: string, owner?: string):
451
451
  site_admin: boolean;
452
452
  starred_at?: string;
453
453
  user_view_type?: string;
454
- } | Record<string, never>;
455
- committer: {
454
+ };
455
+ committer: Record<string, never> | {
456
456
  name?: string;
457
457
  email?: string;
458
458
  login: string;
@@ -475,7 +475,7 @@ export declare function getBranch(repo: string, branch: string, owner?: string):
475
475
  site_admin: boolean;
476
476
  starred_at?: string;
477
477
  user_view_type?: string;
478
- } | Record<string, never>;
478
+ };
479
479
  parents: {
480
480
  sha: string;
481
481
  url: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firestartr/cli",
3
- "version": "1.39.0-SNAPSHOT",
3
+ "version": "1.39.1-SNAPSHOT+PR934",
4
4
  "private": false,
5
5
  "description": "Commandline tool",
6
6
  "main": "build/main.js",
@@ -1,13 +0,0 @@
1
- import { Context } from '../context';
2
- import { Analyzer } from './base';
3
- import { Workspace } from '../models/workspace';
4
- import { KubernetesClient } from '../kubernetes-client';
5
- export declare class WorkspacesAnalyzer extends Analyzer {
6
- drifted: Workspace[];
7
- failed: Workspace[];
8
- constructor(context: Context, cli: KubernetesClient);
9
- analyze(): Promise<void>;
10
- listWorkspaces(): Promise<Workspace[]>;
11
- filterByFailed(workspaces: Workspace[]): Workspace[];
12
- filterByDrifted(workspaces: Workspace[]): Workspace[];
13
- }
@@ -1,23 +0,0 @@
1
- import { WorkspacesAnalyzer } from '../analyzers/workspaces';
2
- import { Context } from '../context';
3
- import { GithubClient } from '../github-client';
4
- import { Workspace } from '../models/workspace';
5
- import { Publisher } from './base';
6
- export declare class WorkspacesPublisher extends Publisher {
7
- githubCli: GithubClient;
8
- analyzer: WorkspacesAnalyzer;
9
- context: Context;
10
- output: string;
11
- constructor(analyzer: WorkspacesAnalyzer, githubCli: GithubClient, context: Context);
12
- publish(): Promise<void>;
13
- closeOldErrorIssues(errorIssues: any): Promise<void>;
14
- closeOldDriftIssues(driftIssues: any): Promise<void>;
15
- publishError(wp: Workspace): Promise<any>;
16
- publishDrift(wp: Workspace): Promise<any>;
17
- buildErrorsBody(wp: Workspace): string;
18
- buildErrorForWs(ws: Workspace): string;
19
- buildDriftBody(wp: Workspace): string;
20
- buildDriftForWs(ws: Workspace): string;
21
- writeLnOutput(line: string): void;
22
- filterIssuesBy(type: 'error' | 'drift'): Promise<any>;
23
- }