Merge branch 'master' of github.com:backstage/backstage into readersprocessorstasks
This commit is contained in:
@@ -1,5 +1,23 @@
|
||||
# @backstage/integration
|
||||
|
||||
## 0.7.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 7d4b4e937c: Create an interface for the GitHub credentials provider in order to support providing implementations.
|
||||
|
||||
We have changed the name of the `GithubCredentialsProvider` to `SingleInstanceGithubCredentialsProvider`.
|
||||
|
||||
`GithubCredentialsProvider` is now an interface that maybe implemented to provide a custom mechanism to retrieve GitHub credentials.
|
||||
|
||||
In a later release we will support configuring URL readers, scaffolder tasks, and processors with customer GitHub credentials providers.
|
||||
|
||||
If you want to uptake this release, you will need to replace all references to `GithubCredentialsProvider.create` with `SingleInstanceGithubCredentialsProvider.create`.
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- cf2e20a792: Added `endpoint` and `s3ForcePathStyle` as optional configuration for AWS S3 integrations.
|
||||
|
||||
## 0.6.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -30,6 +30,8 @@ export class AwsS3Integration implements ScmIntegration {
|
||||
// @public
|
||||
export type AwsS3IntegrationConfig = {
|
||||
host: string;
|
||||
endpoint?: string;
|
||||
s3ForcePathStyle?: boolean;
|
||||
accessKeyId?: string;
|
||||
secretAccessKey?: string;
|
||||
roleArn?: string;
|
||||
@@ -441,9 +443,4 @@ export class SingleInstanceGithubCredentialsProvider
|
||||
static create: (config: GitHubIntegrationConfig) => GithubCredentialsProvider;
|
||||
getCredentials(opts: { url: string }): Promise<GithubCredentials>;
|
||||
}
|
||||
|
||||
// Warnings were encountered during analysis:
|
||||
//
|
||||
// src/gitlab/config.d.ts:29:68 - (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag
|
||||
// src/gitlab/config.d.ts:29:63 - (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"
|
||||
```
|
||||
|
||||
Vendored
+15
-2
@@ -167,10 +167,23 @@ export interface Config {
|
||||
/** Integration configuration for AWS S3 Service */
|
||||
awsS3?: Array<{
|
||||
/**
|
||||
* The host of the target that this matches on, e.g. "amazonaws.com".
|
||||
* AWS Endpoint.
|
||||
* The endpoint URI to send requests to. The default endpoint is built from the configured region.
|
||||
* @see https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#constructor-property
|
||||
*
|
||||
* Supports non-AWS providers, e.g. for LocalStack, endpoint may look like http://localhost:4566
|
||||
* @visibility frontend
|
||||
*/
|
||||
host: string;
|
||||
endpoint?: string;
|
||||
|
||||
/**
|
||||
* Whether to use path style URLs when communicating with S3.
|
||||
* Defaults to false.
|
||||
* This allows providers like LocalStack, Minio and Wasabi (and possibly others) to be used.
|
||||
* @visibility frontend
|
||||
*/
|
||||
s3ForcePathStyle?: boolean;
|
||||
|
||||
/**
|
||||
* Account access key used to authenticate requests.
|
||||
* @visibility backend
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@backstage/integration",
|
||||
"description": "Helpers for managing integrations towards external systems",
|
||||
"version": "0.6.10",
|
||||
"version": "0.7.0",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
"license": "Apache-2.0",
|
||||
@@ -39,9 +39,9 @@
|
||||
"lodash": "^4.17.21"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@backstage/cli": "^0.10.3",
|
||||
"@backstage/config-loader": "^0.9.0",
|
||||
"@backstage/test-utils": "^0.2.0",
|
||||
"@backstage/cli": "^0.10.4",
|
||||
"@backstage/config-loader": "^0.9.1",
|
||||
"@backstage/test-utils": "^0.2.1",
|
||||
"@types/jest": "^26.0.7",
|
||||
"@types/luxon": "^2.0.4",
|
||||
"msw": "^0.35.0"
|
||||
|
||||
@@ -24,7 +24,7 @@ describe('AwsS3Integration', () => {
|
||||
integrations: {
|
||||
awsS3: [
|
||||
{
|
||||
host: 'a.com',
|
||||
endpoint: 'https://a.com',
|
||||
accessKeyId: 'access key',
|
||||
secretAccessKey: 'secret key',
|
||||
},
|
||||
|
||||
@@ -26,16 +26,33 @@ describe('readAwsS3IntegrationConfig', () => {
|
||||
return new ConfigReader(data);
|
||||
}
|
||||
|
||||
it('reads all values', () => {
|
||||
it('reads all values (default)', () => {
|
||||
const output = readAwsS3IntegrationConfig(
|
||||
buildConfig({
|
||||
host: 'amazonaws.com',
|
||||
accessKeyId: 'fake-key',
|
||||
secretAccessKey: 'fake-secret-key',
|
||||
}),
|
||||
);
|
||||
expect(output).toEqual({
|
||||
host: 'amazonaws.com',
|
||||
s3ForcePathStyle: false,
|
||||
accessKeyId: 'fake-key',
|
||||
secretAccessKey: 'fake-secret-key',
|
||||
});
|
||||
});
|
||||
it('reads all values (endpoint)', () => {
|
||||
const output = readAwsS3IntegrationConfig(
|
||||
buildConfig({
|
||||
endpoint: 'http://localhost:4566',
|
||||
s3ForcePathStyle: true,
|
||||
accessKeyId: 'fake-key',
|
||||
secretAccessKey: 'fake-secret-key',
|
||||
}),
|
||||
);
|
||||
expect(output).toEqual({
|
||||
host: 'localhost:4566',
|
||||
endpoint: 'http://localhost:4566',
|
||||
s3ForcePathStyle: true,
|
||||
accessKeyId: 'fake-key',
|
||||
secretAccessKey: 'fake-secret-key',
|
||||
});
|
||||
@@ -59,6 +76,7 @@ describe('readAwsS3IntegrationConfigs', () => {
|
||||
);
|
||||
expect(output).toContainEqual({
|
||||
host: 'amazonaws.com',
|
||||
s3ForcePathStyle: false,
|
||||
accessKeyId: 'key',
|
||||
secretAccessKey: 'secret',
|
||||
});
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
|
||||
import { Config } from '@backstage/config';
|
||||
import { isValidHost } from '../helpers';
|
||||
|
||||
const AMAZON_AWS_HOST = 'amazonaws.com';
|
||||
|
||||
@@ -26,24 +25,38 @@ const AMAZON_AWS_HOST = 'amazonaws.com';
|
||||
*/
|
||||
export type AwsS3IntegrationConfig = {
|
||||
/**
|
||||
* The host of the target that this matches on, e.g. "amazonaws.com"
|
||||
*
|
||||
* Currently only "amazonaws.com" is supported.
|
||||
* Host, derived from endpoint, and defaults to amazonaws.com
|
||||
*/
|
||||
host: string;
|
||||
|
||||
/**
|
||||
* accessKeyId
|
||||
* (Optional) AWS Endpoint.
|
||||
* The endpoint URI to send requests to. The default endpoint is built from the configured region.
|
||||
* @see https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#constructor-property
|
||||
*
|
||||
* Supports non-AWS providers, e.g. for LocalStack, endpoint may look like http://localhost:4566
|
||||
*/
|
||||
endpoint?: string;
|
||||
|
||||
/**
|
||||
* (Optional) Whether to use path style URLs when communicating with S3.
|
||||
* Defaults to false.
|
||||
* This allows providers like LocalStack, Minio and Wasabi (and possibly others) to be used.
|
||||
*/
|
||||
s3ForcePathStyle?: boolean;
|
||||
|
||||
/**
|
||||
* (Optional) User access key id
|
||||
*/
|
||||
accessKeyId?: string;
|
||||
|
||||
/**
|
||||
* secretAccessKey
|
||||
* (Optional) User secret access key
|
||||
*/
|
||||
secretAccessKey?: string;
|
||||
|
||||
/**
|
||||
* roleArn
|
||||
* (Optional) ARN of role to be assumed
|
||||
*/
|
||||
roleArn?: string;
|
||||
};
|
||||
@@ -58,18 +71,42 @@ export type AwsS3IntegrationConfig = {
|
||||
export function readAwsS3IntegrationConfig(
|
||||
config: Config,
|
||||
): AwsS3IntegrationConfig {
|
||||
const host = config.getOptionalString('host') ?? AMAZON_AWS_HOST;
|
||||
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');
|
||||
const roleArn = config.getOptionalString('roleArn');
|
||||
|
||||
if (!isValidHost(host)) {
|
||||
throw new Error(
|
||||
`Invalid awsS3 integration config, '${host}' is not a valid host`,
|
||||
);
|
||||
}
|
||||
|
||||
return { host, accessKeyId, secretAccessKey, roleArn };
|
||||
return {
|
||||
host,
|
||||
endpoint,
|
||||
s3ForcePathStyle,
|
||||
accessKeyId,
|
||||
secretAccessKey,
|
||||
roleArn,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,13 +28,13 @@ const GITLAB_API_BASE_URL = 'https://gitlab.com/api/v4';
|
||||
*/
|
||||
export type GitLabIntegrationConfig = {
|
||||
/**
|
||||
* The host of the target that this matches on, e.g. "gitlab.com".
|
||||
* The host of the target that this matches on, e.g. `gitlab.com`.
|
||||
*/
|
||||
host: string;
|
||||
|
||||
/**
|
||||
* The base URL of the API of this provider, e.g.
|
||||
* "https://gitlab.com/api/v4", with no trailing slash.
|
||||
* `https://gitlab.com/api/v4`, with no trailing slash.
|
||||
*
|
||||
* May be omitted specifically for public GitLab; then it will be deduced.
|
||||
*/
|
||||
@@ -48,10 +48,10 @@ export type GitLabIntegrationConfig = {
|
||||
token?: string;
|
||||
|
||||
/**
|
||||
* The baseUrl of this provider, e.g. "https://gitlab.com", which is passed
|
||||
* The baseUrl of this provider, e.g. `https://gitlab.com`, which is passed
|
||||
* into the GitLab client.
|
||||
*
|
||||
* If no baseUrl is provided, it will default to https://${host}
|
||||
* If no baseUrl is provided, it will default to `https://${host}`
|
||||
*/
|
||||
baseUrl: string;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user