@backstage/integration 1.0.1-next.0 → 1.1.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 +35 -0
- package/dist/index.cjs.js +66 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +46 -1
- package/dist/index.esm.js +64 -4
- package/dist/index.esm.js.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# @backstage/integration
|
|
2
2
|
|
|
3
|
+
## 1.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- b7436743cb: Gerrit integration: Added an optional configuration to set the Gitiles base url.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 1691c6c5c2: Clarify that config locations that emit User and Group kinds now need to declare so in the `catalog.locations.[].rules`
|
|
12
|
+
- 3ef123bbf0: Support external ID when assuming roles in S3 integration
|
|
13
|
+
|
|
14
|
+
In order to assume a role created by a 3rd party as external
|
|
15
|
+
ID is needed. This change adds an optional field to the s3
|
|
16
|
+
integration configuration and consumes that in the AwsS3UrlReader.
|
|
17
|
+
|
|
18
|
+
- d26e1b0146: Exported `replaceGitLabUrlType` from package
|
|
19
|
+
|
|
20
|
+
## 1.1.0-next.2
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- d26e1b0146: Exported `replaceGitLabUrlType` from package
|
|
25
|
+
|
|
26
|
+
## 1.1.0-next.1
|
|
27
|
+
|
|
28
|
+
### Minor Changes
|
|
29
|
+
|
|
30
|
+
- b7436743cb: Gerrit integration: Added an optional configuration to set the Gitiles base url.
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- 1691c6c5c2: Clarify that config locations that emit User and Group kinds now need to declare so in the `catalog.locations.[].rules`
|
|
35
|
+
|
|
3
36
|
## 1.0.1-next.0
|
|
4
37
|
|
|
5
38
|
### Patch Changes
|
|
@@ -237,6 +270,8 @@
|
|
|
237
270
|
locations:
|
|
238
271
|
- type: github-multi-org
|
|
239
272
|
target: https://github.myorg.com
|
|
273
|
+
rules:
|
|
274
|
+
- allow: [User, Group]
|
|
240
275
|
|
|
241
276
|
processors:
|
|
242
277
|
githubMultiOrg:
|
package/dist/index.cjs.js
CHANGED
|
@@ -454,21 +454,30 @@ function getBitbucketRequestOptions(config) {
|
|
|
454
454
|
function readGerritIntegrationConfig(config) {
|
|
455
455
|
const host = config.getString("host");
|
|
456
456
|
let baseUrl = config.getOptionalString("baseUrl");
|
|
457
|
+
let gitilesBaseUrl = config.getOptionalString("gitilesBaseUrl");
|
|
457
458
|
const username = config.getOptionalString("username");
|
|
458
459
|
const password = config.getOptionalString("password");
|
|
459
460
|
if (!isValidHost(host)) {
|
|
460
461
|
throw new Error(`Invalid Gerrit integration config, '${host}' is not a valid host`);
|
|
461
462
|
} else if (baseUrl && !isValidUrl(baseUrl)) {
|
|
462
463
|
throw new Error(`Invalid Gerrit integration config, '${baseUrl}' is not a valid baseUrl`);
|
|
464
|
+
} else if (gitilesBaseUrl && !isValidUrl(gitilesBaseUrl)) {
|
|
465
|
+
throw new Error(`Invalid Gerrit integration config, '${gitilesBaseUrl}' is not a valid gitilesBaseUrl`);
|
|
463
466
|
}
|
|
464
467
|
if (baseUrl) {
|
|
465
468
|
baseUrl = lodash.trimEnd(baseUrl, "/");
|
|
466
469
|
} else {
|
|
467
470
|
baseUrl = `https://${host}`;
|
|
468
471
|
}
|
|
472
|
+
if (gitilesBaseUrl) {
|
|
473
|
+
gitilesBaseUrl = lodash.trimEnd(gitilesBaseUrl, "/");
|
|
474
|
+
} else {
|
|
475
|
+
gitilesBaseUrl = `https://${host}`;
|
|
476
|
+
}
|
|
469
477
|
return {
|
|
470
478
|
host,
|
|
471
479
|
baseUrl,
|
|
480
|
+
gitilesBaseUrl,
|
|
472
481
|
username,
|
|
473
482
|
password
|
|
474
483
|
};
|
|
@@ -514,6 +523,57 @@ GerritIntegration.factory = ({ config }) => {
|
|
|
514
523
|
return basicIntegrations(configs.map((c) => new _GerritIntegration(c)), (i) => i.config.host);
|
|
515
524
|
};
|
|
516
525
|
|
|
526
|
+
const GERRIT_BODY_PREFIX = ")]}'";
|
|
527
|
+
function parseGitilesUrl(config, url) {
|
|
528
|
+
const urlPath = url.replace(config.gitilesBaseUrl, "");
|
|
529
|
+
const parts = urlPath.split("/").filter((p) => !!p);
|
|
530
|
+
const projectEndIndex = parts.indexOf("+");
|
|
531
|
+
if (projectEndIndex <= 0) {
|
|
532
|
+
throw new Error(`Unable to parse project from url: ${url}`);
|
|
533
|
+
}
|
|
534
|
+
const project = lodash.trimStart(parts.slice(0, projectEndIndex).join("/"), "/");
|
|
535
|
+
const branchIndex = parts.indexOf("heads");
|
|
536
|
+
if (branchIndex <= 0) {
|
|
537
|
+
throw new Error(`Unable to parse branch from url: ${url}`);
|
|
538
|
+
}
|
|
539
|
+
const branch = parts[branchIndex + 1];
|
|
540
|
+
const filePath = parts.slice(branchIndex + 2).join("/");
|
|
541
|
+
return {
|
|
542
|
+
branch,
|
|
543
|
+
filePath: filePath === "" ? "/" : filePath,
|
|
544
|
+
project
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
function getAuthenticationPrefix(config) {
|
|
548
|
+
return config.password ? "/a/" : "/";
|
|
549
|
+
}
|
|
550
|
+
function getGerritFileContentsApiUrl(config, url) {
|
|
551
|
+
const { branch, filePath, project } = parseGitilesUrl(config, url);
|
|
552
|
+
return `${config.baseUrl}${getAuthenticationPrefix(config)}projects/${encodeURIComponent(project)}/branches/${branch}/files/${encodeURIComponent(filePath)}/content`;
|
|
553
|
+
}
|
|
554
|
+
function getGerritRequestOptions(config) {
|
|
555
|
+
const headers = {};
|
|
556
|
+
if (!config.password) {
|
|
557
|
+
return headers;
|
|
558
|
+
}
|
|
559
|
+
const buffer = Buffer.from(`${config.username}:${config.password}`, "utf8");
|
|
560
|
+
headers.Authorization = `Basic ${buffer.toString("base64")}`;
|
|
561
|
+
return {
|
|
562
|
+
headers
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
async function parseGerritJsonResponse(response) {
|
|
566
|
+
const responseBody = await response.text();
|
|
567
|
+
if (responseBody.startsWith(GERRIT_BODY_PREFIX)) {
|
|
568
|
+
try {
|
|
569
|
+
return JSON.parse(responseBody.slice(GERRIT_BODY_PREFIX.length));
|
|
570
|
+
} catch (ex) {
|
|
571
|
+
throw new Error(`Invalid response from Gerrit: ${responseBody.slice(0, 10)} - ${ex}`);
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
throw new Error(`Gerrit JSON body prefix missing. Found: ${responseBody.slice(0, 10)}`);
|
|
575
|
+
}
|
|
576
|
+
|
|
517
577
|
const GITHUB_HOST = "github.com";
|
|
518
578
|
const GITHUB_API_BASE_URL = "https://api.github.com";
|
|
519
579
|
const GITHUB_RAW_BASE_URL = "https://raw.githubusercontent.com";
|
|
@@ -910,7 +970,7 @@ const _GitLabIntegration = class {
|
|
|
910
970
|
return defaultScmResolveUrl(options);
|
|
911
971
|
}
|
|
912
972
|
resolveEditUrl(url) {
|
|
913
|
-
return
|
|
973
|
+
return replaceGitLabUrlType(url, "edit");
|
|
914
974
|
}
|
|
915
975
|
};
|
|
916
976
|
let GitLabIntegration = _GitLabIntegration;
|
|
@@ -919,7 +979,7 @@ GitLabIntegration.factory = ({ config }) => {
|
|
|
919
979
|
const configs = readGitLabIntegrationConfigs((_a = config.getOptionalConfigArray("integrations.gitlab")) != null ? _a : []);
|
|
920
980
|
return basicIntegrations(configs.map((c) => new _GitLabIntegration(c)), (i) => i.config.host);
|
|
921
981
|
};
|
|
922
|
-
function
|
|
982
|
+
function replaceGitLabUrlType(url, type) {
|
|
923
983
|
return url.replace(/\/\-\/(blob|tree|edit)\//, `/-/${type}/`);
|
|
924
984
|
}
|
|
925
985
|
|
|
@@ -1084,10 +1144,13 @@ exports.getBitbucketDefaultBranch = getBitbucketDefaultBranch;
|
|
|
1084
1144
|
exports.getBitbucketDownloadUrl = getBitbucketDownloadUrl;
|
|
1085
1145
|
exports.getBitbucketFileFetchUrl = getBitbucketFileFetchUrl;
|
|
1086
1146
|
exports.getBitbucketRequestOptions = getBitbucketRequestOptions;
|
|
1147
|
+
exports.getGerritFileContentsApiUrl = getGerritFileContentsApiUrl;
|
|
1148
|
+
exports.getGerritRequestOptions = getGerritRequestOptions;
|
|
1087
1149
|
exports.getGitHubFileFetchUrl = getGitHubFileFetchUrl;
|
|
1088
1150
|
exports.getGitHubRequestOptions = getGitHubRequestOptions;
|
|
1089
1151
|
exports.getGitLabFileFetchUrl = getGitLabFileFetchUrl;
|
|
1090
1152
|
exports.getGitLabRequestOptions = getGitLabRequestOptions;
|
|
1153
|
+
exports.parseGerritJsonResponse = parseGerritJsonResponse;
|
|
1091
1154
|
exports.readAwsS3IntegrationConfig = readAwsS3IntegrationConfig;
|
|
1092
1155
|
exports.readAwsS3IntegrationConfigs = readAwsS3IntegrationConfigs;
|
|
1093
1156
|
exports.readAzureIntegrationConfig = readAzureIntegrationConfig;
|
|
@@ -1102,4 +1165,5 @@ exports.readGitLabIntegrationConfig = readGitLabIntegrationConfig;
|
|
|
1102
1165
|
exports.readGitLabIntegrationConfigs = readGitLabIntegrationConfigs;
|
|
1103
1166
|
exports.readGoogleGcsIntegrationConfig = readGoogleGcsIntegrationConfig;
|
|
1104
1167
|
exports.replaceGitHubUrlType = replaceGitHubUrlType;
|
|
1168
|
+
exports.replaceGitLabUrlType = replaceGitLabUrlType;
|
|
1105
1169
|
//# sourceMappingURL=index.cjs.js.map
|