@backstage/integration 0.7.5 → 1.0.1-next.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,37 @@
1
1
  # @backstage/integration
2
2
 
3
+ ## 1.0.1-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 3ef123bbf0: Support external ID when assuming roles in S3 integration
8
+
9
+ In order to assume a role created by a 3rd party as external
10
+ ID is needed. This change adds an optional field to the s3
11
+ integration configuration and consumes that in the AwsS3UrlReader.
12
+
13
+ ## 1.0.0
14
+
15
+ ### Major Changes
16
+
17
+ - b58c70c223: This package has been promoted to v1.0! To understand how this change affects the package, please check out our [versioning policy](https://backstage.io/docs/overview/versioning-policy).
18
+
19
+ ### Patch Changes
20
+
21
+ - 403837cbac: Added an integration for Gerrit
22
+ - Updated dependencies
23
+ - @backstage/config@1.0.0
24
+
25
+ ## 0.8.0
26
+
27
+ ### Minor Changes
28
+
29
+ - 34af86517c: ensure `apiBaseUrl` being set for Bitbucket integrations, replace hardcoded defaults
30
+
31
+ ### Patch Changes
32
+
33
+ - 33d5e79822: Fix Bitbucket Cloud and Bitbucket Server line number reference.
34
+
3
35
  ## 0.7.5
4
36
 
5
37
  ### Patch Changes
package/config.d.ts CHANGED
@@ -60,6 +60,31 @@ export interface Config {
60
60
  appPassword?: string;
61
61
  }>;
62
62
 
63
+ /** Integration configuration for Gerrit */
64
+ gerrit?: Array<{
65
+ /**
66
+ * The hostname of the given Gerrit instance
67
+ * @visibility frontend
68
+ */
69
+ host: string;
70
+ /**
71
+ * The base url for the Gerrit instance.
72
+ * @visibility frontend
73
+ */
74
+ baseUrl?: string;
75
+ /**
76
+ * The username to use for authenticated requests.
77
+ * @visibility secret
78
+ */
79
+ username?: string;
80
+ /**
81
+ * Gerrit password used to authenticate requests. This can be either a password
82
+ * or a generated access token.
83
+ * @visibility secret
84
+ */
85
+ password?: string;
86
+ }>;
87
+
63
88
  /** Integration configuration for GitHub */
64
89
  github?: Array<{
65
90
  /**
@@ -200,6 +225,12 @@ export interface Config {
200
225
  * @visibility backend
201
226
  */
202
227
  roleArn?: string;
228
+
229
+ /**
230
+ * External ID to use when assuming role
231
+ * @visibility backend
232
+ */
233
+ externalId?: string;
203
234
  }>;
204
235
  };
205
236
  }
package/dist/index.cjs.js CHANGED
@@ -310,6 +310,8 @@ function readBitbucketIntegrationConfig(config) {
310
310
  apiBaseUrl = lodash.trimEnd(apiBaseUrl, "/");
311
311
  } else if (host === BITBUCKET_HOST) {
312
312
  apiBaseUrl = BITBUCKET_API_BASE_URL;
313
+ } else {
314
+ apiBaseUrl = `https://${host}/rest/api/1.0`;
313
315
  }
314
316
  return {
315
317
  host,
@@ -345,13 +347,16 @@ const _BitbucketIntegration = class {
345
347
  }
346
348
  resolveUrl(options) {
347
349
  const resolved = defaultScmResolveUrl(options);
348
- if (options.lineNumber) {
349
- const url = new URL(resolved);
350
- const filename = url.pathname.split("/").slice(-1)[0];
351
- url.hash = `${filename}-${options.lineNumber}`;
352
- return url.toString();
350
+ if (!options.lineNumber) {
351
+ return resolved;
353
352
  }
354
- return resolved;
353
+ const url = new URL(resolved);
354
+ if (this.integrationConfig.host === "bitbucket.org") {
355
+ url.hash = `lines-${options.lineNumber}`;
356
+ } else {
357
+ url.hash = `${options.lineNumber}`;
358
+ }
359
+ return url.toString();
355
360
  }
356
361
  resolveEditUrl(url) {
357
362
  const urlData = parseGitUrl__default["default"](url);
@@ -446,6 +451,69 @@ function getBitbucketRequestOptions(config) {
446
451
  };
447
452
  }
448
453
 
454
+ function readGerritIntegrationConfig(config) {
455
+ const host = config.getString("host");
456
+ let baseUrl = config.getOptionalString("baseUrl");
457
+ const username = config.getOptionalString("username");
458
+ const password = config.getOptionalString("password");
459
+ if (!isValidHost(host)) {
460
+ throw new Error(`Invalid Gerrit integration config, '${host}' is not a valid host`);
461
+ } else if (baseUrl && !isValidUrl(baseUrl)) {
462
+ throw new Error(`Invalid Gerrit integration config, '${baseUrl}' is not a valid baseUrl`);
463
+ }
464
+ if (baseUrl) {
465
+ baseUrl = lodash.trimEnd(baseUrl, "/");
466
+ } else {
467
+ baseUrl = `https://${host}`;
468
+ }
469
+ return {
470
+ host,
471
+ baseUrl,
472
+ username,
473
+ password
474
+ };
475
+ }
476
+ function readGerritIntegrationConfigs(configs) {
477
+ return configs.map(readGerritIntegrationConfig);
478
+ }
479
+
480
+ const _GerritIntegration = class {
481
+ constructor(integrationConfig) {
482
+ this.integrationConfig = integrationConfig;
483
+ }
484
+ get type() {
485
+ return "gerrit";
486
+ }
487
+ get title() {
488
+ return this.integrationConfig.host;
489
+ }
490
+ get config() {
491
+ return this.integrationConfig;
492
+ }
493
+ resolveUrl(options) {
494
+ const { url, base, lineNumber } = options;
495
+ let updated;
496
+ if (url) {
497
+ updated = new URL(url, base);
498
+ } else {
499
+ updated = new URL(base);
500
+ }
501
+ if (lineNumber) {
502
+ updated.hash = lineNumber.toString();
503
+ }
504
+ return updated.toString();
505
+ }
506
+ resolveEditUrl(url) {
507
+ return url;
508
+ }
509
+ };
510
+ let GerritIntegration = _GerritIntegration;
511
+ GerritIntegration.factory = ({ config }) => {
512
+ var _a;
513
+ const configs = readGerritIntegrationConfigs((_a = config.getOptionalConfigArray("integrations.gerrit")) != null ? _a : []);
514
+ return basicIntegrations(configs.map((c) => new _GerritIntegration(c)), (i) => i.config.host);
515
+ };
516
+
449
517
  const GITHUB_HOST = "github.com";
450
518
  const GITHUB_API_BASE_URL = "https://api.github.com";
451
519
  const GITHUB_RAW_BASE_URL = "https://raw.githubusercontent.com";
@@ -891,13 +959,15 @@ function readAwsS3IntegrationConfig(config) {
891
959
  const accessKeyId = config.getOptionalString("accessKeyId");
892
960
  const secretAccessKey = config.getOptionalString("secretAccessKey");
893
961
  const roleArn = config.getOptionalString("roleArn");
962
+ const externalId = config.getOptionalString("externalId");
894
963
  return {
895
964
  host,
896
965
  endpoint,
897
966
  s3ForcePathStyle,
898
967
  accessKeyId,
899
968
  secretAccessKey,
900
- roleArn
969
+ roleArn,
970
+ externalId
901
971
  };
902
972
  }
903
973
  function readAwsS3IntegrationConfigs(configs) {
@@ -944,6 +1014,7 @@ class ScmIntegrations {
944
1014
  awsS3: AwsS3Integration.factory({ config }),
945
1015
  azure: AzureIntegration.factory({ config }),
946
1016
  bitbucket: BitbucketIntegration.factory({ config }),
1017
+ gerrit: GerritIntegration.factory({ config }),
947
1018
  github: GitHubIntegration.factory({ config }),
948
1019
  gitlab: GitLabIntegration.factory({ config })
949
1020
  });
@@ -960,6 +1031,9 @@ class ScmIntegrations {
960
1031
  get bitbucket() {
961
1032
  return this.byType.bitbucket;
962
1033
  }
1034
+ get gerrit() {
1035
+ return this.byType.gerrit;
1036
+ }
963
1037
  get github() {
964
1038
  return this.byType.github;
965
1039
  }
@@ -995,6 +1069,7 @@ exports.AwsS3Integration = AwsS3Integration;
995
1069
  exports.AzureIntegration = AzureIntegration;
996
1070
  exports.BitbucketIntegration = BitbucketIntegration;
997
1071
  exports.DefaultGithubCredentialsProvider = DefaultGithubCredentialsProvider;
1072
+ exports.GerritIntegration = GerritIntegration;
998
1073
  exports.GitHubIntegration = GitHubIntegration;
999
1074
  exports.GitLabIntegration = GitLabIntegration;
1000
1075
  exports.GithubAppCredentialsMux = GithubAppCredentialsMux;
@@ -1019,6 +1094,8 @@ exports.readAzureIntegrationConfig = readAzureIntegrationConfig;
1019
1094
  exports.readAzureIntegrationConfigs = readAzureIntegrationConfigs;
1020
1095
  exports.readBitbucketIntegrationConfig = readBitbucketIntegrationConfig;
1021
1096
  exports.readBitbucketIntegrationConfigs = readBitbucketIntegrationConfigs;
1097
+ exports.readGerritIntegrationConfig = readGerritIntegrationConfig;
1098
+ exports.readGerritIntegrationConfigs = readGerritIntegrationConfigs;
1022
1099
  exports.readGitHubIntegrationConfig = readGitHubIntegrationConfig;
1023
1100
  exports.readGitHubIntegrationConfigs = readGitHubIntegrationConfigs;
1024
1101
  exports.readGitLabIntegrationConfig = readGitLabIntegrationConfig;