@firestartr/cli 1.56.1-snapshot-3 → 1.56.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
@@ -346571,7 +346571,6 @@ var envVars;
346571
346571
  envVars["githubAppInstallationIdPrefapp"] = "GITHUB_APP_INSTALLATION_ID_PREFAPP";
346572
346572
  envVars["githubAppPemFile"] = "GITHUB_APP_PEM_FILE";
346573
346573
  // ---- PREFAPP BOT VARIABLES -----------------------------------------------
346574
- envVars["avoidPAT"] = "AVOID_PAT";
346575
346574
  envVars["githubAppPatPrefapp"] = "PREFAPP_BOT_PAT";
346576
346575
  // ---- GENERAL CLI VARIABLES -----------------------------------------------
346577
346576
  envVars["firestartrImageKind"] = "FIRESTARTR_IMAGE_KIND";
@@ -353658,6 +353657,7 @@ async function checkIfInstalledForOrg(org = 'default') {
353658
353657
 
353659
353658
 
353660
353659
 
353660
+ const REPOS_WITH_PAT = ['prefapp/features'];
353661
353661
  const generateGithubAppToken = async (config) => {
353662
353662
  try {
353663
353663
  const { appId, privateKey, installationOrgId } = config;
@@ -353691,17 +353691,44 @@ async function getOctokitForOrg(org, paginated = false, genGithubAppToken = gene
353691
353691
  if (org === '') {
353692
353692
  throw 'getOctokitForOrg: "org" has to be passed';
353693
353693
  }
353694
- if (org === 'prefapp' && !process.env[catalog_common.types.envVars.avoidPAT]) {
353695
- github_src_logger.info("Using Prefapp's PAT token");
353696
- return getOctokitFromPat(catalog_common.types.envVars.githubAppPatPrefapp);
353697
- }
353698
- github_src_logger.info('Using GitHub App token');
353699
- const auth = await genGithubAppToken({
353700
- appId: catalog_common.environment.getFromEnvironment(catalog_common.types.envVars.githubAppId),
353701
- privateKey: catalog_common.environment.getFromEnvironment(catalog_common.types.envVars.githubAppPemFile),
353702
- installationOrgId: await getInstallationID(org),
353703
- });
353704
- const options = { auth: auth };
353694
+ const createRepoSwitchAuth = (options) => {
353695
+ // Auth strategy factory that switches between PAT and GitHub App tokens based on the repository
353696
+ const generateTokenFromGithubApp = async () => {
353697
+ github_src_logger.info(`Using GitHub App token for org ${org}`);
353698
+ let auth = null;
353699
+ auth = await genGithubAppToken({
353700
+ appId: catalog_common.environment.getFromEnvironment(catalog_common.types.envVars.githubAppId),
353701
+ privateKey: catalog_common.environment.getFromEnvironment(catalog_common.types.envVars.githubAppPemFile),
353702
+ installationOrgId: await getInstallationID(org),
353703
+ });
353704
+ return auth;
353705
+ };
353706
+ return {
353707
+ async hook(request, requestOptions) {
353708
+ let isRepoWithPat = REPOS_WITH_PAT.find((repo) => {
353709
+ return requestOptions.url.includes(`repos/${repo}`);
353710
+ }) !== undefined;
353711
+ if (!isRepoWithPat && 'repo' in requestOptions) {
353712
+ const checkOrg = requestOptions['owner'] || '';
353713
+ // prefapp/features
353714
+ isRepoWithPat =
353715
+ REPOS_WITH_PAT.indexOf(`${checkOrg}/${requestOptions['repo']}`) !==
353716
+ -1;
353717
+ }
353718
+ github_src_logger.debug(`Requested ${JSON.stringify(requestOptions)}`);
353719
+ requestOptions.headers = requestOptions.headers || {};
353720
+ if (isRepoWithPat) {
353721
+ github_src_logger.info('Using GitHub PAT token');
353722
+ requestOptions.headers.authorization = `token ${process.env[catalog_common.types.envVars.githubAppPatPrefapp]}`;
353723
+ }
353724
+ else {
353725
+ requestOptions.headers.authorization = `token ${await generateTokenFromGithubApp()}`;
353726
+ }
353727
+ return request(requestOptions);
353728
+ },
353729
+ };
353730
+ };
353731
+ const options = { authStrategy: createRepoSwitchAuth };
353705
353732
  if (paginated) {
353706
353733
  options.plugins = [dist_bundle_paginateRest, paginateGraphQL];
353707
353734
  }
@@ -367009,7 +367036,7 @@ async function importGithubGitopsRepository(org, skipPlan, claimsPath, resources
367009
367036
  const crs = await renderCRs(data);
367010
367037
  for (const key in crs) {
367011
367038
  let cr = crs[key];
367012
- const claimName = cr.metadata?.annotations?.[catalog_common.generic.getFirestartrAnnotation('external-name')];
367039
+ const claimName = cr.metadata?.annotations?.[catalog_common.generic.getFirestartrAnnotation('claim-ref')]?.split('/')[1];
367013
367040
  const postRenderFunctions = data.postRender[`${cr.kind}-${claimName}`] || [];
367014
367041
  let crModified = false;
367015
367042
  for (const postRenderFunction of postRenderFunctions) {
@@ -367109,9 +367136,9 @@ async function importGithubGroups(org, filters = []) {
367109
367136
  for (const group of collection) {
367110
367137
  await group.gather();
367111
367138
  await group.decant();
367112
- groups.push(await group.adapt());
367113
367139
  group.render();
367114
367140
  group.postRender();
367141
+ groups.push(await group.adapt());
367115
367142
  }
367116
367143
  return groups;
367117
367144
  }
@@ -376424,7 +376451,7 @@ const crs_analyzerSubcommand = {
376424
376451
  };
376425
376452
 
376426
376453
  ;// CONCATENATED MODULE: ./package.json
376427
- const package_namespaceObject = JSON.parse('{"i8":" v1.56.1-snapshot-3"}');
376454
+ const package_namespaceObject = JSON.parse('{"i8":"1.56.1-snapshot-5"}');
376428
376455
  ;// CONCATENATED MODULE: ../../package.json
376429
376456
  const package_namespaceObject_1 = {"i8":"1.56.0"};
376430
376457
  ;// CONCATENATED MODULE: ./src/subcommands/index.ts
@@ -34,7 +34,6 @@ export declare enum envVars {
34
34
  githubAppInstallationId = "GITHUB_APP_INSTALLATION_ID",
35
35
  githubAppInstallationIdPrefapp = "GITHUB_APP_INSTALLATION_ID_PREFAPP",
36
36
  githubAppPemFile = "GITHUB_APP_PEM_FILE",
37
- avoidPAT = "AVOID_PAT",
38
37
  githubAppPatPrefapp = "PREFAPP_BOT_PAT",
39
38
  firestartrImageKind = "FIRESTARTR_IMAGE_KIND",
40
39
  operatorNamespace = "OPERATOR_NAMESPACE",
@@ -1,6 +1,6 @@
1
1
  import { importGithubGitopsRepository } from './src/decanter';
2
2
  import type { CollectionFilter } from './src/decanter/collections';
3
- export { CollectionFilter };
3
+ export type { CollectionFilter };
4
4
  declare const _default: {
5
5
  importGithubGitopsRepository: typeof importGithubGitopsRepository;
6
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firestartr/cli",
3
- "version": " v1.56.1-snapshot-3",
3
+ "version": "1.56.1-snapshot-5",
4
4
  "private": false,
5
5
  "description": "Commandline tool",
6
6
  "main": "build/main.js",