@firestartr/cli 1.51.1-snapshot-04 → 1.51.1-snapshot-06

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
@@ -358995,7 +358995,14 @@ async function loadInitializers(claim, initializersPath = config_getPath('initia
358995
358995
  return loadedInitializers;
358996
358996
  }
358997
358997
  function loadClaimDefaults() {
358998
- return catalog_common.io.fromYaml(external_fs_.readFileSync(`${config_getPath('claimsDefaults')}/claims_defaults.yaml`, 'utf-8'));
358998
+ try {
358999
+ return catalog_common.io.fromYaml(external_fs_.readFileSync(`${config_getPath('claimsDefaults')}/claims_defaults.yaml`, 'utf-8'));
359000
+ }
359001
+ catch (error) {
359002
+ const errMsg = `Could not read claims defaults file in path ${config_getPath('claimsDefaults')}/claims_defaults.yaml: ${error}`;
359003
+ cdk8s_renderer_src_logger.error(errMsg);
359004
+ throw new Error(errMsg);
359005
+ }
358999
359006
  }
359000
359007
  /*
359001
359008
  * Using fast-json-patch, compares a claim to its kind's defaults, then patches it.
@@ -365288,12 +365295,19 @@ function getConfigPath() {
365288
365295
  getConfigPath,
365289
365296
  });
365290
365297
 
365298
+ ;// CONCATENATED MODULE: ../importer/src/logger.ts
365299
+
365300
+ /* harmony default export */ const importer_src_logger = (catalog_common.logger);
365301
+
365291
365302
  ;// CONCATENATED MODULE: ../importer/src/decanter/base.ts
365292
365303
 
365293
365304
 
365294
365305
 
365295
365306
 
365296
365307
 
365308
+
365309
+
365310
+
365297
365311
  class Decanter {
365298
365312
  set github(githubInstance) {
365299
365313
  this._github = githubInstance;
@@ -365415,6 +365429,27 @@ class Decanter {
365415
365429
  adapt() {
365416
365430
  return this._adapt();
365417
365431
  }
365432
+ async __loadInitializer(initDefaultPath, isAbsolute = false) {
365433
+ let initPath = initDefaultPath;
365434
+ try {
365435
+ if (!isAbsolute) {
365436
+ // Path construction may throw, so handle it separately
365437
+ try {
365438
+ initPath = external_path_.join(getConfigPath(), 'resources', initDefaultPath);
365439
+ }
365440
+ catch (err) {
365441
+ importer_src_logger.error('Error constructing initializer path:', err);
365442
+ throw new Error(`Failed to construct initializer path for ${initDefaultPath}`);
365443
+ }
365444
+ }
365445
+ const adapter = catalog_common.io.fromYaml(external_fs_.readFileSync(initPath, 'utf-8'));
365446
+ return new InitializerDefault(adapter);
365447
+ }
365448
+ catch (e) {
365449
+ importer_src_logger.error(`Error loading initializer at ${initPath}:`, e);
365450
+ throw new Error(`Failed to load initializer at ${initPath}`);
365451
+ }
365452
+ }
365418
365453
  }
365419
365454
  Decanter.collectionKind = '';
365420
365455
  /* harmony default export */ const decanter_base = (Decanter);
@@ -365432,19 +365467,10 @@ class GithubDecanter extends decanter_base {
365432
365467
  }
365433
365468
  }
365434
365469
 
365435
- ;// CONCATENATED MODULE: ../importer/src/logger.ts
365436
-
365437
- /* harmony default export */ const importer_src_logger = (catalog_common.logger);
365438
-
365439
365470
  ;// CONCATENATED MODULE: ../importer/src/decanter/gh/github_group.ts
365440
365471
 
365441
365472
 
365442
365473
 
365443
-
365444
-
365445
-
365446
-
365447
-
365448
365474
  class GroupGithubDecanter extends GithubDecanter {
365449
365475
  constructor() {
365450
365476
  super(...arguments);
@@ -365469,7 +365495,7 @@ class GroupGithubDecanter extends GithubDecanter {
365469
365495
  });
365470
365496
  }
365471
365497
  __decantMembers() {
365472
- if (this.data.groupDetails.name.includes(`${this.org}-all`)) {
365498
+ if (this.data.groupDetails.name === `${this.org}-all`) {
365473
365499
  importer_src_logger.debug(`Skipping adding members for virtual ${this.data.groupDetails.name} group`);
365474
365500
  }
365475
365501
  else {
@@ -365508,43 +365534,7 @@ class GroupGithubDecanter extends GithubDecanter {
365508
365534
  return this.__validateEqual(members, this.data.members);
365509
365535
  }
365510
365536
  async __adaptInitializerBase(_claim) {
365511
- let githubGroupDefaultsFilePath;
365512
- try {
365513
- githubGroupDefaultsFilePath = external_path_.join(getConfigPath(), 'resources', 'defaults_github_group.yaml');
365514
- }
365515
- catch (e) {
365516
- importer_src_logger.warn('No config path set, using built-in defaults');
365517
- githubGroupDefaultsFilePath = '';
365518
- }
365519
- let adapter;
365520
- if (githubGroupDefaultsFilePath &&
365521
- external_fs_.existsSync(githubGroupDefaultsFilePath)) {
365522
- adapter = catalog_common.io.fromYaml(external_fs_.readFileSync(githubGroupDefaultsFilePath, 'utf-8'));
365523
- }
365524
- else {
365525
- adapter = {
365526
- name: 'base',
365527
- apiVersion: 'firestartr.dev/v1',
365528
- kind: 'FirestartrGithubGroup',
365529
- defaultValues: {
365530
- context: {
365531
- backend: {
365532
- ref: {
365533
- kind: 'FirestartrProviderConfig',
365534
- name: 'firestartr-terraform-state',
365535
- },
365536
- },
365537
- provider: {
365538
- ref: {
365539
- kind: 'FirestartrProviderConfig',
365540
- name: 'github-app',
365541
- },
365542
- },
365543
- },
365544
- },
365545
- };
365546
- }
365547
- return new InitializerDefault(adapter);
365537
+ return await this.__loadInitializer('defaults_github_group.yaml');
365548
365538
  }
365549
365539
  __validateKind(cr) {
365550
365540
  return true;
@@ -365640,12 +365630,6 @@ applyCollectionMixins(GroupCollectionGithubDecanter);
365640
365630
  ;// CONCATENATED MODULE: ../importer/src/decanter/gh/github_member.ts
365641
365631
 
365642
365632
 
365643
-
365644
-
365645
-
365646
-
365647
-
365648
-
365649
365633
  class MemberGithubDecanter extends GithubDecanter {
365650
365634
  constructor() {
365651
365635
  super(...arguments);
@@ -365683,43 +365667,7 @@ class MemberGithubDecanter extends GithubDecanter {
365683
365667
  });
365684
365668
  }
365685
365669
  async __adaptInitializerBase(_claim) {
365686
- let githubMemberDefaultsFilePath;
365687
- try {
365688
- githubMemberDefaultsFilePath = external_path_.join(getConfigPath(), 'resources', 'defaults_github_membership.yaml');
365689
- }
365690
- catch (e) {
365691
- importer_src_logger.warn('No config path set, using built-in defaults');
365692
- githubMemberDefaultsFilePath = '';
365693
- }
365694
- let adapter;
365695
- if (githubMemberDefaultsFilePath &&
365696
- external_fs_.existsSync(githubMemberDefaultsFilePath)) {
365697
- adapter = catalog_common.io.fromYaml(external_fs_.readFileSync(githubMemberDefaultsFilePath, 'utf-8'));
365698
- }
365699
- else {
365700
- adapter = {
365701
- name: 'base',
365702
- apiVersion: 'firestartr.dev/v1',
365703
- kind: 'FirestartrGithubMembership',
365704
- defaultValues: {
365705
- context: {
365706
- backend: {
365707
- ref: {
365708
- kind: 'FirestartrProviderConfig',
365709
- name: 'firestartr-terraform-state',
365710
- },
365711
- },
365712
- provider: {
365713
- ref: {
365714
- kind: 'FirestartrProviderConfig',
365715
- name: 'github-app',
365716
- },
365717
- },
365718
- },
365719
- },
365720
- };
365721
- }
365722
- return new InitializerDefault(adapter);
365670
+ return await this.__loadInitializer('defaults_github_membership.yaml');
365723
365671
  }
365724
365672
  }
365725
365673
 
@@ -365752,11 +365700,6 @@ applyCollectionMixins(MemberCollectionGithubDecanter);
365752
365700
 
365753
365701
 
365754
365702
 
365755
-
365756
-
365757
-
365758
-
365759
-
365760
365703
  const TYPE_MAP = {
365761
365704
  User: 'user',
365762
365705
  Team: 'group',
@@ -366014,74 +365957,7 @@ class RepoGithubDecanter extends GithubDecanter {
366014
365957
  return null;
366015
365958
  }
366016
365959
  async __adaptInitializerBase(_claim) {
366017
- let githubRepoDefaultsFilePath;
366018
- try {
366019
- githubRepoDefaultsFilePath = external_path_.join(getConfigPath(), 'resources', 'defaults_github_repository.yaml');
366020
- }
366021
- catch (e) {
366022
- importer_src_logger.warn('No config path set, using built-in defaults');
366023
- githubRepoDefaultsFilePath = '';
366024
- }
366025
- let adapter;
366026
- if (githubRepoDefaultsFilePath &&
366027
- external_fs_.existsSync(githubRepoDefaultsFilePath)) {
366028
- adapter = catalog_common.io.fromYaml(external_fs_.readFileSync(githubRepoDefaultsFilePath, 'utf-8'));
366029
- }
366030
- else {
366031
- adapter = {
366032
- name: 'base',
366033
- apiVersion: 'firestartr.dev/v1',
366034
- kind: 'FirestartrGithubRepository',
366035
- defaultValues: {
366036
- context: {
366037
- backend: {
366038
- ref: {
366039
- kind: 'FirestartrProviderConfig',
366040
- name: 'firestartr-terraform-state',
366041
- },
366042
- },
366043
- provider: {
366044
- ref: {
366045
- kind: 'FirestartrProviderConfig',
366046
- name: 'github-app',
366047
- },
366048
- },
366049
- },
366050
- name: this.data.repoDetails.name,
366051
- description: this.data.repoDetails.description,
366052
- org: this.org,
366053
- firestartr: {
366054
- technology: { stack: 'none', version: 'none' },
366055
- },
366056
- repo: {
366057
- description: this.data.repoDetails.description,
366058
- allowMergeCommit: this.data.repoDetails.allow_merge_commit,
366059
- allowSquashMerge: this.data.repoDetails.allow_squash_merge,
366060
- allowRebaseMerge: this.data.repoDetails.allow_rebase_merge,
366061
- allowAutoMerge: this.data.repoDetails.allow_auto_merge,
366062
- deleteBranchOnMerge: this.data.repoDetails.delete_branch_on_merge,
366063
- autoInit: true,
366064
- archiveOnDestroy: true,
366065
- allowUpdateBranch: this.data.repoDetails.allow_update_branch,
366066
- hasIssues: this.data.repoDetails.has_issues,
366067
- visibility: this.data.repoDetails.visibility,
366068
- defaultBranch: this.data.repoDetails.default_branch,
366069
- },
366070
- permissions: [],
366071
- actions: {
366072
- oidc: this.data.oidc.use_default
366073
- ? undefined
366074
- : {
366075
- useDefault: this.data.oidc.use_default,
366076
- includeClaimKeys: this.data.oidc.include_claim_keys
366077
- ? this.data.oidc.include_claim_keys
366078
- : [],
366079
- },
366080
- },
366081
- },
366082
- };
366083
- }
366084
- return new InitializerDefault(adapter);
365960
+ return await this.__loadInitializer('defaults_github_repository.yaml');
366085
365961
  }
366086
365962
  async __adaptOverriderRepo(_claim) {
366087
365963
  return new GithubRepositoryOverrider();
@@ -366325,22 +366201,17 @@ function compileReg(value) {
366325
366201
  });
366326
366202
 
366327
366203
 
366328
-
366329
366204
  // const MAP_COLLECTION_KIND_CR_KIND: any = {
366330
366205
  // gh-members: 'FirestartrGithubMembership',
366331
366206
  // gh-group: 'FirestartrGithubGroup',
366332
366207
  // gh-repo: 'FirestartrGithubRepository',
366333
366208
  // }
366334
- async function runImporter(force, generateDefaults, skipPlan, claimsPath, crsPath, configPath, claimsDefaultsPath, org, filters, provider = AllowedProviders.all) {
366209
+ async function runImporter(force, skipPlan, claimsPath, crsPath, configPath, claimsDefaultsPath, org, filters, provider = AllowedProviders.all) {
366335
366210
  configureProvider(provider);
366336
366211
  let generatedFilters = [];
366337
366212
  //gh-repo,REGEXP=.*vite.*
366338
366213
  cdk8s_renderer.setPath('claimsDefaults', claimsDefaultsPath);
366339
366214
  generatedFilters = buildFilters(filters, force, crsPath, generatedFilters);
366340
- if (generateDefaults) {
366341
- generateClaimsDefaults(org, claimsDefaultsPath);
366342
- generateDefaultsFn(org, configPath);
366343
- }
366344
366215
  await importGithubGitopsRepository(org, skipPlan, claimsPath, crsPath, configPath, generatedFilters);
366345
366216
  }
366346
366217
  function buildFilters(filters, force, crsPath, generatedFilters) {
@@ -366376,97 +366247,6 @@ function createSkipFilters(filters) {
366376
366247
  }
366377
366248
  return filters;
366378
366249
  }
366379
- function generateDefaultsFn(org, defaultsPath) {
366380
- generateDefaultsForGithubGroups(org, defaultsPath);
366381
- generateDefaultsForGithubRepos(org, defaultsPath);
366382
- generateDefaultsForGithubRepos(org, defaultsPath);
366383
- }
366384
- function generateDefaultsForGithubGroups(org, defaultsPath) {
366385
- const defaultGroups = {
366386
- name: 'group_base',
366387
- apiVersion: 'firestartr.dev/v1',
366388
- kind: 'FirestartrGithubGroup',
366389
- defaultValues: {
366390
- org: org,
366391
- },
366392
- };
366393
- catalog_common.io.writeYamlFile('defaults_github_group', defaultGroups, defaultsPath);
366394
- }
366395
- function generateDefaultsForGithubRepos(org, defaultsPath) {
366396
- const defaultRepos = {
366397
- name: 'repo_base',
366398
- apiVersion: 'firestartr.dev/v1',
366399
- kind: 'FirestartrGithubRepository',
366400
- defaultValues: {
366401
- firestartr: {
366402
- technology: {
366403
- stack: 'none',
366404
- version: 'none',
366405
- },
366406
- },
366407
- repo: {
366408
- allowAutoMerge: true,
366409
- codeowners: ' - ',
366410
- allowMergeCommit: true,
366411
- allowSquashMerge: true,
366412
- allowRebaseMerge: true,
366413
- deleteBranchOnMerge: true,
366414
- autoInit: true,
366415
- archiveOnDestroy: true,
366416
- allowUpdateBranch: true,
366417
- hasIssues: true,
366418
- },
366419
- },
366420
- };
366421
- catalog_common.io.writeYamlFile('defaults_github_repository', defaultRepos, defaultsPath);
366422
- }
366423
- function generateClaimsDefaults(org, defaultsPath) {
366424
- const defaultClaims = {
366425
- ComponentClaim: {
366426
- version: '1.0',
366427
- type: 'service',
366428
- lifecycle: 'production',
366429
- system: 'system:firestartr-test-system',
366430
- maintainedBy: [],
366431
- platformOwner: `group:${org}-all`,
366432
- providers: {
366433
- github: {
366434
- org: org,
366435
- branchStrategy: {
366436
- name: 'trunkBasedDevelopment',
366437
- defaultBranch: 'main',
366438
- },
366439
- orgPermissions: 'none',
366440
- visibility: 'private',
366441
- technology: {
366442
- stack: 'none',
366443
- version: 'none',
366444
- },
366445
- features: [],
366446
- },
366447
- },
366448
- },
366449
- GroupClaim: {
366450
- providers: {
366451
- github: {
366452
- org: org,
366453
- privacy: 'closed',
366454
- },
366455
- },
366456
- },
366457
- SystemClaim: {
366458
- providers: {
366459
- catalog: null,
366460
- },
366461
- },
366462
- DomainClaim: {
366463
- providers: {
366464
- catalog: null,
366465
- },
366466
- },
366467
- };
366468
- catalog_common.io.writeYamlFile('claims_defaults', defaultClaims, defaultsPath);
366469
- }
366470
366250
 
366471
366251
  ;// CONCATENATED MODULE: ./src/subcommands/importer-subcommands.ts
366472
366252
 
@@ -366475,7 +366255,6 @@ const importSubcommand = {
366475
366255
  requiredEnv: [],
366476
366256
  subparameters: [
366477
366257
  { name: 'force', type: Boolean },
366478
- { name: 'generateDefaults', type: Boolean },
366479
366258
  { name: 'skipPlan', type: Boolean },
366480
366259
  { name: 'claims', type: String },
366481
366260
  { name: 'crs', type: String },
@@ -366486,7 +366265,7 @@ const importSubcommand = {
366486
366265
  ],
366487
366266
  run: async (options) => {
366488
366267
  console.table(options);
366489
- await runImporter(options.force, options.generateDefaults, options.skipPlan, options.claims, options.crs, options.config, options.claimsDefaults, options.org, options.filters);
366268
+ await runImporter(options.force, options.skipPlan, options.claims, options.crs, options.config, options.claimsDefaults, options.org, options.filters);
366490
366269
  },
366491
366270
  };
366492
366271
 
@@ -368401,21 +368180,28 @@ class Entity {
368401
368180
  throw new Error(ErrorMessage);
368402
368181
  }
368403
368182
  const { kind, name, needsSecret } = ref;
368404
- if (!needsSecret) {
368405
- const cr = this.deps[`${kind}-${name}`].cr;
368406
- return (cr.metadata?.annotations?.[EXTERNAL_NAME_ANNOTATION] || cr.metadata.name);
368407
- }
368408
- else {
368409
- if (!propertyRef) {
368410
- const ErrorMessage = `resolveRef:
368183
+ try {
368184
+ if (!needsSecret) {
368185
+ const cr = this.deps[`${kind}-${name}`].cr;
368186
+ return (cr.metadata?.annotations?.[EXTERNAL_NAME_ANNOTATION] ||
368187
+ cr.metadata.name);
368188
+ }
368189
+ else {
368190
+ if (!propertyRef) {
368191
+ const ErrorMessage = `resolveRef:
368411
368192
 
368412
- Entity with kind ${this.kind} ${this.metadata.name}
368193
+ Entity with kind ${this.kind} ${this.metadata.name}
368413
368194
 
368414
- needs a propertyRef to resolve the secret`;
368415
- provisioner_src_logger.error(ErrorMessage);
368416
- throw new Error(ErrorMessage);
368195
+ needs a propertyRef to resolve the secret`;
368196
+ provisioner_src_logger.error(ErrorMessage);
368197
+ throw new Error(ErrorMessage);
368198
+ }
368199
+ return Buffer.from(this.deps[`${kind}-${name}`].secret.data[propertyRef], 'base64').toString('utf8');
368417
368200
  }
368418
- return Buffer.from(this.deps[`${kind}-${name}`].secret.data[propertyRef], 'base64').toString('utf8');
368201
+ }
368202
+ catch (error) {
368203
+ const errorMsg = `Error resolving ref for ${kind}-${name}: ${error}`;
368204
+ throw new Error(errorMsg);
368419
368205
  }
368420
368206
  }
368421
368207
  resolveSecretRef(ref) {
@@ -6,4 +6,4 @@ declare const _default: {
6
6
  };
7
7
  export default _default;
8
8
  import { AllowedProviders } from 'cdk8s_renderer';
9
- export declare function runImporter(force: boolean, generateDefaults: boolean, skipPlan: boolean, claimsPath: string, crsPath: string, configPath: string, claimsDefaultsPath: string, org: string, filters: string[], provider?: AllowedProviders): Promise<void>;
9
+ export declare function runImporter(force: boolean, skipPlan: boolean, claimsPath: string, crsPath: string, configPath: string, claimsDefaultsPath: string, org: string, filters: string[], provider?: AllowedProviders): Promise<void>;
@@ -1,4 +1,4 @@
1
- import { ImportInitializer, UUIDInitializer, NameNormalizer, InitializerClaimRef } from 'cdk8s_renderer';
1
+ import { ImportInitializer, UUIDInitializer, NameNormalizer, InitializerClaimRef, InitializerDefault } from 'cdk8s_renderer';
2
2
  export default class Decanter {
3
3
  data: any;
4
4
  claimKind: string | undefined;
@@ -78,4 +78,5 @@ export default class Decanter {
78
78
  normalizers: NameNormalizer[];
79
79
  };
80
80
  }>;
81
+ __loadInitializer(initDefaultPath: string, isAbsolute?: boolean): Promise<InitializerDefault>;
81
82
  }
@@ -1,9 +1,8 @@
1
1
  import { GithubDecanter } from './base';
2
- import { InitializerDefault } from 'cdk8s_renderer';
3
2
  export default class MemberGithubDecanter extends GithubDecanter {
4
3
  claimKind: string;
5
4
  __decantStart(): void;
6
5
  __gatherRoleInOrg(): Promise<void>;
7
6
  __decantProviders(): void;
8
- __adaptInitializerBase(_claim: any): Promise<InitializerDefault>;
7
+ __adaptInitializerBase(_claim: any): Promise<import("../../../../cdk8s_renderer").InitializerDefault>;
9
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firestartr/cli",
3
- "version": "1.51.1-snapshot-04",
3
+ "version": "1.51.1-snapshot-06",
4
4
  "private": false,
5
5
  "description": "Commandline tool",
6
6
  "main": "build/main.js",