@firestartr/cli 1.51.1-snapshot-03 → 1.51.1-snapshot-05

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,11 +365495,16 @@ class GroupGithubDecanter extends GithubDecanter {
365469
365495
  });
365470
365496
  }
365471
365497
  __decantMembers() {
365472
- this.__patchClaim({
365473
- op: 'add',
365474
- value: this.data.members.map((member) => `user:${member.name}`),
365475
- path: '/members',
365476
- });
365498
+ if (this.data.groupDetails.name === `${this.org}-all`) {
365499
+ importer_src_logger.debug(`Skipping adding members for virtual ${this.data.groupDetails.name} group`);
365500
+ }
365501
+ else {
365502
+ this.__patchClaim({
365503
+ op: 'add',
365504
+ value: this.data.members.map((member) => `user:${member.name}`),
365505
+ path: '/members',
365506
+ });
365507
+ }
365477
365508
  }
365478
365509
  __decantProviders() {
365479
365510
  this.__patchClaim({
@@ -365503,43 +365534,7 @@ class GroupGithubDecanter extends GithubDecanter {
365503
365534
  return this.__validateEqual(members, this.data.members);
365504
365535
  }
365505
365536
  async __adaptInitializerBase(_claim) {
365506
- let githubGroupDefaultsFilePath;
365507
- try {
365508
- githubGroupDefaultsFilePath = external_path_.join(getConfigPath(), 'resources', 'defaults_github_group.yaml');
365509
- }
365510
- catch (e) {
365511
- importer_src_logger.warn('No config path set, using built-in defaults');
365512
- githubGroupDefaultsFilePath = '';
365513
- }
365514
- let adapter;
365515
- if (githubGroupDefaultsFilePath &&
365516
- external_fs_.existsSync(githubGroupDefaultsFilePath)) {
365517
- adapter = catalog_common.io.fromYaml(external_fs_.readFileSync(githubGroupDefaultsFilePath, 'utf-8'));
365518
- }
365519
- else {
365520
- adapter = {
365521
- name: 'base',
365522
- apiVersion: 'firestartr.dev/v1',
365523
- kind: 'FirestartrGithubGroup',
365524
- defaultValues: {
365525
- context: {
365526
- backend: {
365527
- ref: {
365528
- kind: 'FirestartrProviderConfig',
365529
- name: 'firestartr-terraform-state',
365530
- },
365531
- },
365532
- provider: {
365533
- ref: {
365534
- kind: 'FirestartrProviderConfig',
365535
- name: 'github-app',
365536
- },
365537
- },
365538
- },
365539
- },
365540
- };
365541
- }
365542
- return new InitializerDefault(adapter);
365537
+ return await this.__loadInitializer('defaults_github_group.yaml');
365543
365538
  }
365544
365539
  __validateKind(cr) {
365545
365540
  return true;
@@ -365635,12 +365630,6 @@ applyCollectionMixins(GroupCollectionGithubDecanter);
365635
365630
  ;// CONCATENATED MODULE: ../importer/src/decanter/gh/github_member.ts
365636
365631
 
365637
365632
 
365638
-
365639
-
365640
-
365641
-
365642
-
365643
-
365644
365633
  class MemberGithubDecanter extends GithubDecanter {
365645
365634
  constructor() {
365646
365635
  super(...arguments);
@@ -365678,43 +365667,7 @@ class MemberGithubDecanter extends GithubDecanter {
365678
365667
  });
365679
365668
  }
365680
365669
  async __adaptInitializerBase(_claim) {
365681
- let githubMemberDefaultsFilePath;
365682
- try {
365683
- githubMemberDefaultsFilePath = external_path_.join(getConfigPath(), 'resources', 'defaults_github_membership.yaml');
365684
- }
365685
- catch (e) {
365686
- importer_src_logger.warn('No config path set, using built-in defaults');
365687
- githubMemberDefaultsFilePath = '';
365688
- }
365689
- let adapter;
365690
- if (githubMemberDefaultsFilePath &&
365691
- external_fs_.existsSync(githubMemberDefaultsFilePath)) {
365692
- adapter = catalog_common.io.fromYaml(external_fs_.readFileSync(githubMemberDefaultsFilePath, 'utf-8'));
365693
- }
365694
- else {
365695
- adapter = {
365696
- name: 'base',
365697
- apiVersion: 'firestartr.dev/v1',
365698
- kind: 'FirestartrGithubMembership',
365699
- defaultValues: {
365700
- context: {
365701
- backend: {
365702
- ref: {
365703
- kind: 'FirestartrProviderConfig',
365704
- name: 'firestartr-terraform-state',
365705
- },
365706
- },
365707
- provider: {
365708
- ref: {
365709
- kind: 'FirestartrProviderConfig',
365710
- name: 'github-app',
365711
- },
365712
- },
365713
- },
365714
- },
365715
- };
365716
- }
365717
- return new InitializerDefault(adapter);
365670
+ return await this.__loadInitializer('defaults_github_membership.yaml');
365718
365671
  }
365719
365672
  }
365720
365673
 
@@ -365747,11 +365700,6 @@ applyCollectionMixins(MemberCollectionGithubDecanter);
365747
365700
 
365748
365701
 
365749
365702
 
365750
-
365751
-
365752
-
365753
-
365754
-
365755
365703
  const TYPE_MAP = {
365756
365704
  User: 'user',
365757
365705
  Team: 'group',
@@ -366009,74 +365957,7 @@ class RepoGithubDecanter extends GithubDecanter {
366009
365957
  return null;
366010
365958
  }
366011
365959
  async __adaptInitializerBase(_claim) {
366012
- let githubRepoDefaultsFilePath;
366013
- try {
366014
- githubRepoDefaultsFilePath = external_path_.join(getConfigPath(), 'resources', 'defaults_github_repository.yaml');
366015
- }
366016
- catch (e) {
366017
- importer_src_logger.warn('No config path set, using built-in defaults');
366018
- githubRepoDefaultsFilePath = '';
366019
- }
366020
- let adapter;
366021
- if (githubRepoDefaultsFilePath &&
366022
- external_fs_.existsSync(githubRepoDefaultsFilePath)) {
366023
- adapter = catalog_common.io.fromYaml(external_fs_.readFileSync(githubRepoDefaultsFilePath, 'utf-8'));
366024
- }
366025
- else {
366026
- adapter = {
366027
- name: 'base',
366028
- apiVersion: 'firestartr.dev/v1',
366029
- kind: 'FirestartrGithubRepository',
366030
- defaultValues: {
366031
- context: {
366032
- backend: {
366033
- ref: {
366034
- kind: 'FirestartrProviderConfig',
366035
- name: 'firestartr-terraform-state',
366036
- },
366037
- },
366038
- provider: {
366039
- ref: {
366040
- kind: 'FirestartrProviderConfig',
366041
- name: 'github-app',
366042
- },
366043
- },
366044
- },
366045
- name: this.data.repoDetails.name,
366046
- description: this.data.repoDetails.description,
366047
- org: this.org,
366048
- firestartr: {
366049
- technology: { stack: 'none', version: 'none' },
366050
- },
366051
- repo: {
366052
- description: this.data.repoDetails.description,
366053
- allowMergeCommit: this.data.repoDetails.allow_merge_commit,
366054
- allowSquashMerge: this.data.repoDetails.allow_squash_merge,
366055
- allowRebaseMerge: this.data.repoDetails.allow_rebase_merge,
366056
- allowAutoMerge: this.data.repoDetails.allow_auto_merge,
366057
- deleteBranchOnMerge: this.data.repoDetails.delete_branch_on_merge,
366058
- autoInit: true,
366059
- archiveOnDestroy: true,
366060
- allowUpdateBranch: this.data.repoDetails.allow_update_branch,
366061
- hasIssues: this.data.repoDetails.has_issues,
366062
- visibility: this.data.repoDetails.visibility,
366063
- defaultBranch: this.data.repoDetails.default_branch,
366064
- },
366065
- permissions: [],
366066
- actions: {
366067
- oidc: this.data.oidc.use_default
366068
- ? undefined
366069
- : {
366070
- useDefault: this.data.oidc.use_default,
366071
- includeClaimKeys: this.data.oidc.include_claim_keys
366072
- ? this.data.oidc.include_claim_keys
366073
- : [],
366074
- },
366075
- },
366076
- },
366077
- };
366078
- }
366079
- return new InitializerDefault(adapter);
365960
+ return await this.__loadInitializer('defaults_github_repository.yaml');
366080
365961
  }
366081
365962
  async __adaptOverriderRepo(_claim) {
366082
365963
  return new GithubRepositoryOverrider();
@@ -366166,7 +366047,7 @@ async function moveCRsAndClaims(crs, org, claimsPath, resourcesPath) {
366166
366047
  const failedImportedResources = [];
366167
366048
  for (const k of Object.keys(crs)) {
366168
366049
  if (crs[k].kind === 'FirestartrGithubGroup' &&
366169
- crs[k].metadata.name.includes(`${org}-all-`)) {
366050
+ crs[k].metadata.name === `${org}-all`) {
366170
366051
  importer_src_logger.info(`⚡ SKIP IMPORT: CR is the all group, skipping import with kind: ${crs[k].kind} and name: ${crs[k].metadata.name}`);
366171
366052
  continue;
366172
366053
  }
@@ -366320,22 +366201,17 @@ function compileReg(value) {
366320
366201
  });
366321
366202
 
366322
366203
 
366323
-
366324
366204
  // const MAP_COLLECTION_KIND_CR_KIND: any = {
366325
366205
  // gh-members: 'FirestartrGithubMembership',
366326
366206
  // gh-group: 'FirestartrGithubGroup',
366327
366207
  // gh-repo: 'FirestartrGithubRepository',
366328
366208
  // }
366329
- 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) {
366330
366210
  configureProvider(provider);
366331
366211
  let generatedFilters = [];
366332
366212
  //gh-repo,REGEXP=.*vite.*
366333
366213
  cdk8s_renderer.setPath('claimsDefaults', claimsDefaultsPath);
366334
366214
  generatedFilters = buildFilters(filters, force, crsPath, generatedFilters);
366335
- if (generateDefaults) {
366336
- generateClaimsDefaults(org, claimsDefaultsPath);
366337
- generateDefaultsFn(org, configPath);
366338
- }
366339
366215
  await importGithubGitopsRepository(org, skipPlan, claimsPath, crsPath, configPath, generatedFilters);
366340
366216
  }
366341
366217
  function buildFilters(filters, force, crsPath, generatedFilters) {
@@ -366371,97 +366247,6 @@ function createSkipFilters(filters) {
366371
366247
  }
366372
366248
  return filters;
366373
366249
  }
366374
- function generateDefaultsFn(org, defaultsPath) {
366375
- generateDefaultsForGithubGroups(org, defaultsPath);
366376
- generateDefaultsForGithubRepos(org, defaultsPath);
366377
- generateDefaultsForGithubRepos(org, defaultsPath);
366378
- }
366379
- function generateDefaultsForGithubGroups(org, defaultsPath) {
366380
- const defaultGroups = {
366381
- name: 'group_base',
366382
- apiVersion: 'firestartr.dev/v1',
366383
- kind: 'FirestartrGithubGroup',
366384
- defaultValues: {
366385
- org: org,
366386
- },
366387
- };
366388
- catalog_common.io.writeYamlFile('defaults_github_group', defaultGroups, defaultsPath);
366389
- }
366390
- function generateDefaultsForGithubRepos(org, defaultsPath) {
366391
- const defaultRepos = {
366392
- name: 'repo_base',
366393
- apiVersion: 'firestartr.dev/v1',
366394
- kind: 'FirestartrGithubRepository',
366395
- defaultValues: {
366396
- firestartr: {
366397
- technology: {
366398
- stack: 'none',
366399
- version: 'none',
366400
- },
366401
- },
366402
- repo: {
366403
- allowAutoMerge: true,
366404
- codeowners: ' - ',
366405
- allowMergeCommit: true,
366406
- allowSquashMerge: true,
366407
- allowRebaseMerge: true,
366408
- deleteBranchOnMerge: true,
366409
- autoInit: true,
366410
- archiveOnDestroy: true,
366411
- allowUpdateBranch: true,
366412
- hasIssues: true,
366413
- },
366414
- },
366415
- };
366416
- catalog_common.io.writeYamlFile('defaults_github_repository', defaultRepos, defaultsPath);
366417
- }
366418
- function generateClaimsDefaults(org, defaultsPath) {
366419
- const defaultClaims = {
366420
- ComponentClaim: {
366421
- version: '1.0',
366422
- type: 'service',
366423
- lifecycle: 'production',
366424
- system: 'system:firestartr-test-system',
366425
- maintainedBy: [],
366426
- platformOwner: `group:${org}-all`,
366427
- providers: {
366428
- github: {
366429
- org: org,
366430
- branchStrategy: {
366431
- name: 'trunkBasedDevelopment',
366432
- defaultBranch: 'main',
366433
- },
366434
- orgPermissions: 'none',
366435
- visibility: 'private',
366436
- technology: {
366437
- stack: 'none',
366438
- version: 'none',
366439
- },
366440
- features: [],
366441
- },
366442
- },
366443
- },
366444
- GroupClaim: {
366445
- providers: {
366446
- github: {
366447
- org: org,
366448
- privacy: 'closed',
366449
- },
366450
- },
366451
- },
366452
- SystemClaim: {
366453
- providers: {
366454
- catalog: null,
366455
- },
366456
- },
366457
- DomainClaim: {
366458
- providers: {
366459
- catalog: null,
366460
- },
366461
- },
366462
- };
366463
- catalog_common.io.writeYamlFile('claims_defaults', defaultClaims, defaultsPath);
366464
- }
366465
366250
 
366466
366251
  ;// CONCATENATED MODULE: ./src/subcommands/importer-subcommands.ts
366467
366252
 
@@ -366470,7 +366255,6 @@ const importSubcommand = {
366470
366255
  requiredEnv: [],
366471
366256
  subparameters: [
366472
366257
  { name: 'force', type: Boolean },
366473
- { name: 'generateDefaults', type: Boolean },
366474
366258
  { name: 'skipPlan', type: Boolean },
366475
366259
  { name: 'claims', type: String },
366476
366260
  { name: 'crs', type: String },
@@ -366481,7 +366265,7 @@ const importSubcommand = {
366481
366265
  ],
366482
366266
  run: async (options) => {
366483
366267
  console.table(options);
366484
- 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);
366485
366269
  },
366486
366270
  };
366487
366271
 
@@ -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-03",
3
+ "version": "1.51.1-snapshot-05",
4
4
  "private": false,
5
5
  "description": "Commandline tool",
6
6
  "main": "build/main.js",