@backstage/plugin-catalog-backend-module-github 0.2.0-next.0 → 0.2.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 +65 -0
- package/alpha/package.json +1 -1
- package/dist/index.alpha.d.ts +88 -1
- package/dist/index.beta.d.ts +88 -1
- package/dist/index.cjs.js +162 -134
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +88 -1
- package/package.json +16 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,70 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-backend-module-github
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 67fe5bc9a9: BREAKING: Support authenticated backends by including a server token for catalog requests. The constructor of `GithubLocationAnalyzer` now requires an instance of `TokenManager` to be supplied:
|
|
8
|
+
|
|
9
|
+
```diff
|
|
10
|
+
...
|
|
11
|
+
builder.addLocationAnalyzers(
|
|
12
|
+
new GitHubLocationAnalyzer({
|
|
13
|
+
discovery: env.discovery,
|
|
14
|
+
config: env.config,
|
|
15
|
+
+ tokenManager: env.tokenManager,
|
|
16
|
+
}),
|
|
17
|
+
);
|
|
18
|
+
...
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
- f64d66a45c: Added the ability for the GitHub discovery provider to validate that catalog files exist before emitting them.
|
|
22
|
+
|
|
23
|
+
Users can now set the `validateLocationsExist` property to `true` in their GitHub discovery configuration to opt in to this feature.
|
|
24
|
+
This feature only works with `catalogPath`s that do not contain wildcards.
|
|
25
|
+
|
|
26
|
+
When `validateLocationsExist` is set to `true`, the GitHub discovery provider will retrieve the object from the
|
|
27
|
+
repository at the provided `catalogPath`.
|
|
28
|
+
If this file exists and is non-empty, then it will be emitted as a location for further processing.
|
|
29
|
+
If this file does not exist or is empty, then it will not be emitted.
|
|
30
|
+
Not emitting locations that do not exist allows for far fewer calls to the GitHub API to validate locations that do not exist.
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- 67fe5bc9a9: Properly derive Github credentials when making requests in `GithubLocationAnalyzer` to support Github App authentication
|
|
35
|
+
- bef063dc8d: - Make it possible to inject custom user and team transformers when configuring the `GithubOrgEntityProvider`
|
|
36
|
+
- 4c9f7847e4: Updated dependency `msw` to `^0.48.0` while moving it to be a dev dependency.
|
|
37
|
+
- c1784a4980: Replaces in-code uses of `GitHub` with `Github` and deprecates old versions.
|
|
38
|
+
- Updated dependencies
|
|
39
|
+
- @backstage/backend-common@0.16.0
|
|
40
|
+
- @backstage/plugin-catalog-backend@1.5.1
|
|
41
|
+
- @backstage/integration@1.4.0
|
|
42
|
+
- @backstage/backend-tasks@0.3.7
|
|
43
|
+
- @backstage/catalog-model@1.1.3
|
|
44
|
+
- @backstage/types@1.0.1
|
|
45
|
+
- @backstage/backend-plugin-api@0.1.4
|
|
46
|
+
- @backstage/plugin-catalog-node@1.2.1
|
|
47
|
+
- @backstage/catalog-client@1.1.2
|
|
48
|
+
- @backstage/config@1.0.4
|
|
49
|
+
- @backstage/errors@1.1.3
|
|
50
|
+
|
|
51
|
+
## 0.2.0-next.1
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
- Updated dependencies
|
|
56
|
+
- @backstage/backend-common@0.16.0-next.1
|
|
57
|
+
- @backstage/backend-plugin-api@0.1.4-next.1
|
|
58
|
+
- @backstage/backend-tasks@0.3.7-next.1
|
|
59
|
+
- @backstage/plugin-catalog-backend@1.5.1-next.1
|
|
60
|
+
- @backstage/plugin-catalog-node@1.2.1-next.1
|
|
61
|
+
- @backstage/catalog-client@1.1.2-next.0
|
|
62
|
+
- @backstage/catalog-model@1.1.3-next.0
|
|
63
|
+
- @backstage/config@1.0.4-next.0
|
|
64
|
+
- @backstage/errors@1.1.3-next.0
|
|
65
|
+
- @backstage/integration@1.4.0-next.0
|
|
66
|
+
- @backstage/types@1.0.1-next.0
|
|
67
|
+
|
|
3
68
|
## 0.2.0-next.0
|
|
4
69
|
|
|
5
70
|
### Minor Changes
|
package/alpha/package.json
CHANGED
package/dist/index.alpha.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A Backstage catalog backend module that helps integrate towards
|
|
2
|
+
* A Backstage catalog backend module that helps integrate towards Github
|
|
3
3
|
*
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
@@ -14,6 +14,8 @@ import { EntityProvider } from '@backstage/plugin-catalog-backend';
|
|
|
14
14
|
import { EntityProviderConnection } from '@backstage/plugin-catalog-backend';
|
|
15
15
|
import { GithubCredentialsProvider } from '@backstage/integration';
|
|
16
16
|
import { GithubIntegrationConfig } from '@backstage/integration';
|
|
17
|
+
import { graphql } from '@octokit/graphql';
|
|
18
|
+
import { GroupEntity } from '@backstage/catalog-model';
|
|
17
19
|
import { LocationSpec } from '@backstage/plugin-catalog-backend';
|
|
18
20
|
import { Logger } from 'winston';
|
|
19
21
|
import { PluginEndpointDiscovery } from '@backstage/backend-common';
|
|
@@ -22,6 +24,21 @@ import { ScmIntegrationRegistry } from '@backstage/integration';
|
|
|
22
24
|
import { ScmLocationAnalyzer } from '@backstage/plugin-catalog-backend';
|
|
23
25
|
import { TaskRunner } from '@backstage/backend-tasks';
|
|
24
26
|
import { TokenManager } from '@backstage/backend-common';
|
|
27
|
+
import { UserEntity } from '@backstage/catalog-model';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Default transformer for GitHub Team to GroupEntity
|
|
31
|
+
*
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
export declare const defaultOrganizationTeamTransformer: TeamTransformer;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Default transformer for GitHub users to UserEntity
|
|
38
|
+
*
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
|
+
export declare const defaultUserTransformer: UserTransformer;
|
|
25
42
|
|
|
26
43
|
/**
|
|
27
44
|
* Extracts repositories out of a GitHub org.
|
|
@@ -167,6 +184,7 @@ export declare type GithubMultiOrgConfig = Array<{
|
|
|
167
184
|
* @public
|
|
168
185
|
*/
|
|
169
186
|
export declare class GithubMultiOrgReaderProcessor implements CatalogProcessor {
|
|
187
|
+
private options;
|
|
170
188
|
private readonly integrations;
|
|
171
189
|
private readonly orgs;
|
|
172
190
|
private readonly logger;
|
|
@@ -174,12 +192,16 @@ export declare class GithubMultiOrgReaderProcessor implements CatalogProcessor {
|
|
|
174
192
|
static fromConfig(config: Config, options: {
|
|
175
193
|
logger: Logger;
|
|
176
194
|
githubCredentialsProvider?: GithubCredentialsProvider;
|
|
195
|
+
userTransformer?: UserTransformer;
|
|
196
|
+
teamTransformer?: TeamTransformer;
|
|
177
197
|
}): GithubMultiOrgReaderProcessor;
|
|
178
198
|
constructor(options: {
|
|
179
199
|
integrations: ScmIntegrationRegistry;
|
|
180
200
|
logger: Logger;
|
|
181
201
|
orgs: GithubMultiOrgConfig;
|
|
182
202
|
githubCredentialsProvider?: GithubCredentialsProvider;
|
|
203
|
+
userTransformer?: UserTransformer;
|
|
204
|
+
teamTransformer?: TeamTransformer;
|
|
183
205
|
});
|
|
184
206
|
getProcessorName(): string;
|
|
185
207
|
readLocation(location: LocationSpec, _optional: boolean, emit: CatalogProcessorEmit): Promise<boolean>;
|
|
@@ -211,6 +233,8 @@ export declare class GithubOrgEntityProvider implements EntityProvider {
|
|
|
211
233
|
gitHubConfig: GithubIntegrationConfig;
|
|
212
234
|
logger: Logger;
|
|
213
235
|
githubCredentialsProvider?: GithubCredentialsProvider;
|
|
236
|
+
userTransformer?: UserTransformer;
|
|
237
|
+
teamTransformer?: TeamTransformer;
|
|
214
238
|
});
|
|
215
239
|
/** {@inheritdoc @backstage/plugin-catalog-backend#EntityProvider.getProviderName} */
|
|
216
240
|
getProviderName(): string;
|
|
@@ -272,6 +296,14 @@ export declare interface GithubOrgEntityProviderOptions {
|
|
|
272
296
|
* Optionally supply a custom credentials provider, replacing the default one.
|
|
273
297
|
*/
|
|
274
298
|
githubCredentialsProvider?: GithubCredentialsProvider;
|
|
299
|
+
/**
|
|
300
|
+
* Optionally include a user transformer for transforming from GitHub users to User Entities
|
|
301
|
+
*/
|
|
302
|
+
userTransformer?: UserTransformer;
|
|
303
|
+
/**
|
|
304
|
+
* Optionally include a team transformer for transforming from GitHub teams to Group Entities
|
|
305
|
+
*/
|
|
306
|
+
teamTransformer?: TeamTransformer;
|
|
275
307
|
}
|
|
276
308
|
|
|
277
309
|
/**
|
|
@@ -301,4 +333,59 @@ export declare class GithubOrgReaderProcessor implements CatalogProcessor {
|
|
|
301
333
|
private createClient;
|
|
302
334
|
}
|
|
303
335
|
|
|
336
|
+
/**
|
|
337
|
+
* Github Team
|
|
338
|
+
*
|
|
339
|
+
* @public
|
|
340
|
+
*/
|
|
341
|
+
export declare type GithubTeam = {
|
|
342
|
+
slug: string;
|
|
343
|
+
combinedSlug: string;
|
|
344
|
+
name?: string;
|
|
345
|
+
description?: string;
|
|
346
|
+
avatarUrl?: string;
|
|
347
|
+
editTeamUrl?: string;
|
|
348
|
+
parentTeam?: GithubTeam;
|
|
349
|
+
members: GithubUser[];
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Github User
|
|
354
|
+
*
|
|
355
|
+
* @public
|
|
356
|
+
*/
|
|
357
|
+
export declare type GithubUser = {
|
|
358
|
+
login: string;
|
|
359
|
+
bio?: string;
|
|
360
|
+
avatarUrl?: string;
|
|
361
|
+
email?: string;
|
|
362
|
+
name?: string;
|
|
363
|
+
organizationVerifiedDomainEmails?: string[];
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Transformer for GitHub Team to GroupEntity
|
|
368
|
+
*
|
|
369
|
+
* @public
|
|
370
|
+
*/
|
|
371
|
+
export declare type TeamTransformer = (item: GithubTeam, ctx: TransformerContext) => Promise<GroupEntity | undefined>;
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Context passed to Transformers
|
|
375
|
+
*
|
|
376
|
+
* @public
|
|
377
|
+
*/
|
|
378
|
+
export declare interface TransformerContext {
|
|
379
|
+
client: typeof graphql;
|
|
380
|
+
query: string;
|
|
381
|
+
org: string;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Transformer for GitHub users to UserEntity
|
|
386
|
+
*
|
|
387
|
+
* @public
|
|
388
|
+
*/
|
|
389
|
+
export declare type UserTransformer = (item: GithubUser, ctx: TransformerContext) => Promise<UserEntity | undefined>;
|
|
390
|
+
|
|
304
391
|
export { }
|
package/dist/index.beta.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A Backstage catalog backend module that helps integrate towards
|
|
2
|
+
* A Backstage catalog backend module that helps integrate towards Github
|
|
3
3
|
*
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
@@ -14,6 +14,8 @@ import { EntityProvider } from '@backstage/plugin-catalog-backend';
|
|
|
14
14
|
import { EntityProviderConnection } from '@backstage/plugin-catalog-backend';
|
|
15
15
|
import { GithubCredentialsProvider } from '@backstage/integration';
|
|
16
16
|
import { GithubIntegrationConfig } from '@backstage/integration';
|
|
17
|
+
import { graphql } from '@octokit/graphql';
|
|
18
|
+
import { GroupEntity } from '@backstage/catalog-model';
|
|
17
19
|
import { LocationSpec } from '@backstage/plugin-catalog-backend';
|
|
18
20
|
import { Logger } from 'winston';
|
|
19
21
|
import { PluginEndpointDiscovery } from '@backstage/backend-common';
|
|
@@ -22,6 +24,21 @@ import { ScmIntegrationRegistry } from '@backstage/integration';
|
|
|
22
24
|
import { ScmLocationAnalyzer } from '@backstage/plugin-catalog-backend';
|
|
23
25
|
import { TaskRunner } from '@backstage/backend-tasks';
|
|
24
26
|
import { TokenManager } from '@backstage/backend-common';
|
|
27
|
+
import { UserEntity } from '@backstage/catalog-model';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Default transformer for GitHub Team to GroupEntity
|
|
31
|
+
*
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
export declare const defaultOrganizationTeamTransformer: TeamTransformer;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Default transformer for GitHub users to UserEntity
|
|
38
|
+
*
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
|
+
export declare const defaultUserTransformer: UserTransformer;
|
|
25
42
|
|
|
26
43
|
/**
|
|
27
44
|
* Extracts repositories out of a GitHub org.
|
|
@@ -162,6 +179,7 @@ export declare type GithubMultiOrgConfig = Array<{
|
|
|
162
179
|
* @public
|
|
163
180
|
*/
|
|
164
181
|
export declare class GithubMultiOrgReaderProcessor implements CatalogProcessor {
|
|
182
|
+
private options;
|
|
165
183
|
private readonly integrations;
|
|
166
184
|
private readonly orgs;
|
|
167
185
|
private readonly logger;
|
|
@@ -169,12 +187,16 @@ export declare class GithubMultiOrgReaderProcessor implements CatalogProcessor {
|
|
|
169
187
|
static fromConfig(config: Config, options: {
|
|
170
188
|
logger: Logger;
|
|
171
189
|
githubCredentialsProvider?: GithubCredentialsProvider;
|
|
190
|
+
userTransformer?: UserTransformer;
|
|
191
|
+
teamTransformer?: TeamTransformer;
|
|
172
192
|
}): GithubMultiOrgReaderProcessor;
|
|
173
193
|
constructor(options: {
|
|
174
194
|
integrations: ScmIntegrationRegistry;
|
|
175
195
|
logger: Logger;
|
|
176
196
|
orgs: GithubMultiOrgConfig;
|
|
177
197
|
githubCredentialsProvider?: GithubCredentialsProvider;
|
|
198
|
+
userTransformer?: UserTransformer;
|
|
199
|
+
teamTransformer?: TeamTransformer;
|
|
178
200
|
});
|
|
179
201
|
getProcessorName(): string;
|
|
180
202
|
readLocation(location: LocationSpec, _optional: boolean, emit: CatalogProcessorEmit): Promise<boolean>;
|
|
@@ -206,6 +228,8 @@ export declare class GithubOrgEntityProvider implements EntityProvider {
|
|
|
206
228
|
gitHubConfig: GithubIntegrationConfig;
|
|
207
229
|
logger: Logger;
|
|
208
230
|
githubCredentialsProvider?: GithubCredentialsProvider;
|
|
231
|
+
userTransformer?: UserTransformer;
|
|
232
|
+
teamTransformer?: TeamTransformer;
|
|
209
233
|
});
|
|
210
234
|
/** {@inheritdoc @backstage/plugin-catalog-backend#EntityProvider.getProviderName} */
|
|
211
235
|
getProviderName(): string;
|
|
@@ -267,6 +291,14 @@ export declare interface GithubOrgEntityProviderOptions {
|
|
|
267
291
|
* Optionally supply a custom credentials provider, replacing the default one.
|
|
268
292
|
*/
|
|
269
293
|
githubCredentialsProvider?: GithubCredentialsProvider;
|
|
294
|
+
/**
|
|
295
|
+
* Optionally include a user transformer for transforming from GitHub users to User Entities
|
|
296
|
+
*/
|
|
297
|
+
userTransformer?: UserTransformer;
|
|
298
|
+
/**
|
|
299
|
+
* Optionally include a team transformer for transforming from GitHub teams to Group Entities
|
|
300
|
+
*/
|
|
301
|
+
teamTransformer?: TeamTransformer;
|
|
270
302
|
}
|
|
271
303
|
|
|
272
304
|
/**
|
|
@@ -296,4 +328,59 @@ export declare class GithubOrgReaderProcessor implements CatalogProcessor {
|
|
|
296
328
|
private createClient;
|
|
297
329
|
}
|
|
298
330
|
|
|
331
|
+
/**
|
|
332
|
+
* Github Team
|
|
333
|
+
*
|
|
334
|
+
* @public
|
|
335
|
+
*/
|
|
336
|
+
export declare type GithubTeam = {
|
|
337
|
+
slug: string;
|
|
338
|
+
combinedSlug: string;
|
|
339
|
+
name?: string;
|
|
340
|
+
description?: string;
|
|
341
|
+
avatarUrl?: string;
|
|
342
|
+
editTeamUrl?: string;
|
|
343
|
+
parentTeam?: GithubTeam;
|
|
344
|
+
members: GithubUser[];
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Github User
|
|
349
|
+
*
|
|
350
|
+
* @public
|
|
351
|
+
*/
|
|
352
|
+
export declare type GithubUser = {
|
|
353
|
+
login: string;
|
|
354
|
+
bio?: string;
|
|
355
|
+
avatarUrl?: string;
|
|
356
|
+
email?: string;
|
|
357
|
+
name?: string;
|
|
358
|
+
organizationVerifiedDomainEmails?: string[];
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Transformer for GitHub Team to GroupEntity
|
|
363
|
+
*
|
|
364
|
+
* @public
|
|
365
|
+
*/
|
|
366
|
+
export declare type TeamTransformer = (item: GithubTeam, ctx: TransformerContext) => Promise<GroupEntity | undefined>;
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Context passed to Transformers
|
|
370
|
+
*
|
|
371
|
+
* @public
|
|
372
|
+
*/
|
|
373
|
+
export declare interface TransformerContext {
|
|
374
|
+
client: typeof graphql;
|
|
375
|
+
query: string;
|
|
376
|
+
org: string;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Transformer for GitHub users to UserEntity
|
|
381
|
+
*
|
|
382
|
+
* @public
|
|
383
|
+
*/
|
|
384
|
+
export declare type UserTransformer = (item: GithubUser, ctx: TransformerContext) => Promise<UserEntity | undefined>;
|
|
385
|
+
|
|
299
386
|
export { }
|