UNPKG

@backstage/integration

Version:

Helpers for managing integrations towards external systems

51 lines (49 loc) 1.45 kB
const AMAZON_AWS_HOST = "amazonaws.com"; function readAwsS3IntegrationConfig(config) { const endpoint = config.getOptionalString("endpoint"); const s3ForcePathStyle = config.getOptionalBoolean("s3ForcePathStyle") ?? false; let host; let pathname; if (endpoint) { try { const url = new URL(endpoint); host = url.host; pathname = url.pathname; } catch { throw new Error( `invalid awsS3 integration config, endpoint '${endpoint}' is not a valid URL` ); } if (pathname !== "/") { throw new Error( `invalid awsS3 integration config, endpoints cannot contain path, got '${endpoint}'` ); } } else { host = AMAZON_AWS_HOST; } const accessKeyId = config.getOptionalString("accessKeyId"); const secretAccessKey = config.getOptionalString("secretAccessKey")?.trim(); const roleArn = config.getOptionalString("roleArn"); const externalId = config.getOptionalString("externalId"); return { host, endpoint, s3ForcePathStyle, accessKeyId, secretAccessKey, roleArn, externalId }; } function readAwsS3IntegrationConfigs(configs) { const result = configs.map(readAwsS3IntegrationConfig); if (!result.some((c) => c.host === AMAZON_AWS_HOST)) { result.push({ host: AMAZON_AWS_HOST }); } return result; } export { readAwsS3IntegrationConfig, readAwsS3IntegrationConfigs }; //# sourceMappingURL=config.esm.js.map