@backstage/integration
Version:
Helpers for managing integrations towards external systems
45 lines (43 loc) • 1.57 kB
JavaScript
const BITBUCKET_CLOUD_HOST = "bitbucket.org";
const BITBUCKET_CLOUD_API_BASE_URL = "https://api.bitbucket.org/2.0";
function readBitbucketCloudIntegrationConfig(config) {
const host = BITBUCKET_CLOUD_HOST;
const apiBaseUrl = BITBUCKET_CLOUD_API_BASE_URL;
const username = config.getOptionalString("username");
const appPassword = config.getOptionalString("appPassword")?.trim();
const token = config.getOptionalString("token");
const clientId = config.getOptionalString("clientId")?.trim();
const clientSecret = config.getOptionalString("clientSecret")?.trim();
if (username && !token && !appPassword) {
throw new Error(
`Bitbucket Cloud integration must be configured with as username and either a token or an appPassword.`
);
}
if (clientId && !clientSecret || clientSecret && !clientId) {
throw new Error(
`Bitbucket Cloud integration has incomplete OAuth configuration. Both clientId and clientSecret are required.`
);
}
return {
host,
apiBaseUrl,
username,
appPassword,
token,
clientId,
clientSecret,
commitSigningKey: config.getOptionalString("commitSigningKey")
};
}
function readBitbucketCloudIntegrationConfigs(configs) {
const result = configs.map(readBitbucketCloudIntegrationConfig);
if (result.length === 0) {
result.push({
host: BITBUCKET_CLOUD_HOST,
apiBaseUrl: BITBUCKET_CLOUD_API_BASE_URL
});
}
return result;
}
export { readBitbucketCloudIntegrationConfig, readBitbucketCloudIntegrationConfigs };
//# sourceMappingURL=config.esm.js.map