@firestartr/cli 1.56.1-snapshot-2 → 1.56.1-snapshot-4

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
  }
@@ -370020,7 +370047,6 @@ var lib_provider = __nccwpck_require__(85791);
370020
370047
  ;// CONCATENATED MODULE: ../provisioner/src/entities/base/Entity.ts
370021
370048
 
370022
370049
  const EXTERNAL_NAME_ANNOTATION = 'firestartr.dev/external-name';
370023
- const IMPORT_SLUG_ANNOTATION = 'firestartr.dev/github-slug';
370024
370050
  const IMPORT_ID_ANNOTATION = 'firestartr.dev/github-id';
370025
370051
 
370026
370052
  class Metadata {
@@ -370037,13 +370063,10 @@ class Metadata {
370037
370063
  }
370038
370064
  }
370039
370065
  get slug() {
370040
- // buscar el slug en los outputs
370066
+ // we search the slug in the outputs
370041
370067
  const slug = this._resolveOutputs('slug');
370042
- if (IMPORT_SLUG_ANNOTATION in this.annotations) {
370043
- return this.annotations[IMPORT_SLUG_ANNOTATION];
370044
- }
370045
- else if (slug) {
370046
- // hay outputs?
370068
+ if (slug) {
370069
+ // is the slug in the outputs?
370047
370070
  return slug;
370048
370071
  }
370049
370072
  else {
@@ -370057,13 +370080,16 @@ class Metadata {
370057
370080
  return this._metadata.labels || {};
370058
370081
  }
370059
370082
  get id() {
370060
- // buscar el id en los outputs
370083
+ // we search the id in the outputs
370061
370084
  const id = this._resolveOutputs('id');
370085
+ // if we are in an import process
370086
+ // there should be an id annotation
370087
+ // it takes always precedence
370062
370088
  if (IMPORT_ID_ANNOTATION in this.annotations) {
370063
370089
  return this.annotations[IMPORT_ID_ANNOTATION];
370064
370090
  }
370065
370091
  else if (id) {
370066
- // hay outputs?
370092
+ // is the ID in the outputs?
370067
370093
  return id;
370068
370094
  }
370069
370095
  else {
@@ -370615,16 +370641,17 @@ function provisionMembers(scope, team, fsGithubGroup) {
370615
370641
  for (const member of fsGithubGroup.spec.members) {
370616
370642
  provisioner_src_logger.info(`Provisioning user ${member.ref.name} for group ${fsGithubGroup.metadata.name}`);
370617
370643
  const tfStateKey = `_${fsGithubGroup.getTfStateKey()}-${member.ref.kind}-${member.ref.name}-tr`;
370644
+ const teamId = team.id || fsGithubGroup.metadata.id;
370618
370645
  if (member.ref.kind === 'FirestartrGithubMembership') {
370619
370646
  const username = fsGithubGroup.resolveRef(member.ref);
370620
370647
  const config = {
370621
370648
  dependsOn: [team],
370622
370649
  username,
370623
- teamId: fsGithubGroup.metadata.slug || team.id,
370650
+ teamId: teamId,
370624
370651
  role: member.role,
370625
370652
  };
370626
370653
  const membership = new team_membership/* TeamMembership */.E(scope, tfStateKey, config);
370627
- fsGithubGroup.addResourceToStack(`${fsGithubGroup.metadata.slug || team.id}:${username}`, membership);
370654
+ fsGithubGroup.addResourceToStack(`${teamId}:${username}`, membership);
370628
370655
  }
370629
370656
  }
370630
370657
  }
@@ -371162,6 +371189,7 @@ async function runCDKTF(entityPath, action, depsPath, stream) {
371162
371189
  FORCE_COLOR: '0',
371163
371190
  DEBUG: process.env.DEBUG,
371164
371191
  DEBUG_DEPTH: '0',
371192
+ AVOID_PAT: process.env.AVOID_PAT,
371165
371193
  },
371166
371194
  });
371167
371195
  let output = '';
@@ -376424,7 +376452,7 @@ const crs_analyzerSubcommand = {
376424
376452
  };
376425
376453
 
376426
376454
  ;// CONCATENATED MODULE: ./package.json
376427
- const package_namespaceObject = JSON.parse('{"i8":"1.56.1-snapshot-2"}');
376455
+ const package_namespaceObject = JSON.parse('{"i8":"1.56.1-snapshot-4"}');
376428
376456
  ;// CONCATENATED MODULE: ../../package.json
376429
376457
  const package_namespaceObject_1 = {"i8":"1.56.0"};
376430
376458
  ;// 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",
@@ -42,7 +42,7 @@ export type WorkItemHandler = {
42
42
  writeTerraformOutputInTfResult: WriteTerraformOutputInTfResultFn;
43
43
  writeConnectionSecret: WriteConnectionSecretFn;
44
44
  resolveReferences: ResolveReferencesFn;
45
- resolveOwnOutputs: Function;
45
+ resolveOwnOutputs: () => Promise<any | undefined>;
46
46
  deleteSecret: DeleteSecretFn;
47
47
  itemPath: ItemPathFn;
48
48
  error: ErrorFn;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firestartr/cli",
3
- "version": "1.56.1-snapshot-2",
3
+ "version": "1.56.1-snapshot-4",
4
4
  "private": false,
5
5
  "description": "Commandline tool",
6
6
  "main": "build/main.js",