@backstage/plugin-catalog-backend-module-github 0.1.6 → 0.1.7-next.2

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 CHANGED
@@ -1,5 +1,42 @@
1
1
  # @backstage/plugin-catalog-backend-module-github
2
2
 
3
+ ## 0.1.7-next.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 667d917488: Updated dependency `msw` to `^0.47.0`.
8
+ - 87ec2ba4d6: Updated dependency `msw` to `^0.46.0`.
9
+ - 3a62594a11: Add support for including (or excluding) Github repositories by topic
10
+ - Updated dependencies
11
+ - @backstage/backend-plugin-api@0.1.2-next.1
12
+ - @backstage/plugin-catalog-node@1.0.2-next.1
13
+ - @backstage/backend-common@0.15.1-next.2
14
+ - @backstage/integration@1.3.1-next.1
15
+ - @backstage/plugin-catalog-backend@1.4.0-next.2
16
+
17
+ ## 0.1.7-next.1
18
+
19
+ ### Patch Changes
20
+
21
+ - 287a64bf97: Added the ability to configure the host for the `GitHubEntityProvider` to use against GitHub Enterprise
22
+ - Updated dependencies
23
+ - @backstage/backend-common@0.15.1-next.1
24
+ - @backstage/plugin-catalog-backend@1.4.0-next.1
25
+
26
+ ## 0.1.7-next.0
27
+
28
+ ### Patch Changes
29
+
30
+ - 3c4a388537: New experimental alpha exports for use with the upcoming backend system.
31
+ - bf5e9030eb: Updated dependency `msw` to `^0.45.0`.
32
+ - Updated dependencies
33
+ - @backstage/backend-common@0.15.1-next.0
34
+ - @backstage/backend-tasks@0.3.5-next.0
35
+ - @backstage/plugin-catalog-backend@1.3.2-next.0
36
+ - @backstage/backend-plugin-api@0.1.2-next.0
37
+ - @backstage/integration@1.3.1-next.0
38
+ - @backstage/plugin-catalog-node@1.0.2-next.0
39
+
3
40
  ## 0.1.6
4
41
 
5
42
  ### Patch Changes
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "@backstage/plugin-catalog-backend-module-github",
3
+ "version": "0.1.7-next.2",
4
+ "main": "../dist/index.cjs.js",
5
+ "types": "../dist/index.alpha.d.ts"
6
+ }
@@ -0,0 +1,249 @@
1
+ /**
2
+ * A Backstage catalog backend module that helps integrate towards GitHub
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+
7
+ import { BackendFeature } from '@backstage/backend-plugin-api';
8
+ import { CatalogProcessor } from '@backstage/plugin-catalog-backend';
9
+ import { CatalogProcessorEmit } from '@backstage/plugin-catalog-backend';
10
+ import { Config } from '@backstage/config';
11
+ import { EntityProvider } from '@backstage/plugin-catalog-backend';
12
+ import { EntityProviderConnection } from '@backstage/plugin-catalog-backend';
13
+ import { GithubCredentialsProvider } from '@backstage/integration';
14
+ import { GitHubIntegrationConfig } from '@backstage/integration';
15
+ import { LocationSpec } from '@backstage/plugin-catalog-backend';
16
+ import { Logger } from 'winston';
17
+ import { ScmIntegrationRegistry } from '@backstage/integration';
18
+ import { TaskRunner } from '@backstage/backend-tasks';
19
+ import { TaskScheduleDefinition } from '@backstage/backend-tasks';
20
+
21
+ /**
22
+ * Extracts repositories out of a GitHub org.
23
+ *
24
+ * The following will create locations for all projects which have a catalog-info.yaml
25
+ * on the default branch. The first is shorthand for the second.
26
+ *
27
+ * target: "https://github.com/backstage"
28
+ * or
29
+ * target: https://github.com/backstage/*\/blob/-/catalog-info.yaml
30
+ *
31
+ * You may also explicitly specify the source branch:
32
+ *
33
+ * target: https://github.com/backstage/*\/blob/main/catalog-info.yaml
34
+ *
35
+ * @public
36
+ **/
37
+ export declare class GithubDiscoveryProcessor implements CatalogProcessor {
38
+ private readonly integrations;
39
+ private readonly logger;
40
+ private readonly githubCredentialsProvider;
41
+ static fromConfig(config: Config, options: {
42
+ logger: Logger;
43
+ githubCredentialsProvider?: GithubCredentialsProvider;
44
+ }): GithubDiscoveryProcessor;
45
+ constructor(options: {
46
+ integrations: ScmIntegrationRegistry;
47
+ logger: Logger;
48
+ githubCredentialsProvider?: GithubCredentialsProvider;
49
+ });
50
+ getProcessorName(): string;
51
+ readLocation(location: LocationSpec, _optional: boolean, emit: CatalogProcessorEmit): Promise<boolean>;
52
+ }
53
+
54
+ /**
55
+ * Discovers catalog files located in [GitHub](https://github.com).
56
+ * The provider will search your GitHub account and register catalog files matching the configured path
57
+ * as Location entity and via following processing steps add all contained catalog entities.
58
+ * This can be useful as an alternative to static locations or manually adding things to the catalog.
59
+ *
60
+ * @public
61
+ */
62
+ export declare class GitHubEntityProvider implements EntityProvider {
63
+ private readonly config;
64
+ private readonly logger;
65
+ private readonly integration;
66
+ private readonly scheduleFn;
67
+ private connection?;
68
+ private readonly githubCredentialsProvider;
69
+ static fromConfig(config: Config, options: {
70
+ logger: Logger;
71
+ schedule: TaskRunner;
72
+ }): GitHubEntityProvider[];
73
+ private constructor();
74
+ /** {@inheritdoc @backstage/plugin-catalog-backend#EntityProvider.getProviderName} */
75
+ getProviderName(): string;
76
+ /** {@inheritdoc @backstage/plugin-catalog-backend#EntityProvider.connect} */
77
+ connect(connection: EntityProviderConnection): Promise<void>;
78
+ private createScheduleFn;
79
+ refresh(logger: Logger): Promise<void>;
80
+ private findCatalogFiles;
81
+ private matchesFilters;
82
+ private createLocationUrl;
83
+ private static toLocationSpec;
84
+ }
85
+
86
+ /**
87
+ * Registers the GitHubEntityProvider with the catalog processing extension point.
88
+ *
89
+ * @alpha
90
+ */
91
+ export declare const githubEntityProviderCatalogModule: (options?: GithubEntityProviderCatalogModuleOptions | undefined) => BackendFeature;
92
+
93
+ /**
94
+ * Options for {@link githubEntityProviderCatalogModule}.
95
+ *
96
+ * @alpha
97
+ */
98
+ export declare type GithubEntityProviderCatalogModuleOptions = {
99
+ schedule?: TaskScheduleDefinition;
100
+ };
101
+
102
+ /**
103
+ * The configuration parameters for a multi-org GitHub processor.
104
+ * @public
105
+ */
106
+ export declare type GithubMultiOrgConfig = Array<{
107
+ /**
108
+ * The name of the GitHub org to process.
109
+ */
110
+ name: string;
111
+ /**
112
+ * The namespace of the group created for this org.
113
+ */
114
+ groupNamespace: string;
115
+ /**
116
+ * The namespace of the users created for this org. If not specified defaults to undefined.
117
+ */
118
+ userNamespace: string | undefined;
119
+ }>;
120
+
121
+ /**
122
+ * Extracts teams and users out of a multiple GitHub orgs namespaced per org.
123
+ *
124
+ * Be aware that this processor may not be compatible with future org structures in the catalog.
125
+ *
126
+ * @public
127
+ */
128
+ export declare class GithubMultiOrgReaderProcessor implements CatalogProcessor {
129
+ private readonly integrations;
130
+ private readonly orgs;
131
+ private readonly logger;
132
+ private readonly githubCredentialsProvider;
133
+ static fromConfig(config: Config, options: {
134
+ logger: Logger;
135
+ githubCredentialsProvider?: GithubCredentialsProvider;
136
+ }): GithubMultiOrgReaderProcessor;
137
+ constructor(options: {
138
+ integrations: ScmIntegrationRegistry;
139
+ logger: Logger;
140
+ orgs: GithubMultiOrgConfig;
141
+ githubCredentialsProvider?: GithubCredentialsProvider;
142
+ });
143
+ getProcessorName(): string;
144
+ readLocation(location: LocationSpec, _optional: boolean, emit: CatalogProcessorEmit): Promise<boolean>;
145
+ private getAllOrgs;
146
+ }
147
+
148
+ /**
149
+ * Ingests org data (users and groups) from GitHub.
150
+ *
151
+ * @public
152
+ */
153
+ export declare class GitHubOrgEntityProvider implements EntityProvider {
154
+ private options;
155
+ private readonly credentialsProvider;
156
+ private connection?;
157
+ private scheduleFn?;
158
+ static fromConfig(config: Config, options: GitHubOrgEntityProviderOptions): GitHubOrgEntityProvider;
159
+ constructor(options: {
160
+ id: string;
161
+ orgUrl: string;
162
+ gitHubConfig: GitHubIntegrationConfig;
163
+ logger: Logger;
164
+ githubCredentialsProvider?: GithubCredentialsProvider;
165
+ });
166
+ /** {@inheritdoc @backstage/plugin-catalog-backend#EntityProvider.getProviderName} */
167
+ getProviderName(): string;
168
+ /** {@inheritdoc @backstage/plugin-catalog-backend#EntityProvider.connect} */
169
+ connect(connection: EntityProviderConnection): Promise<void>;
170
+ /**
171
+ * Runs one single complete ingestion. This is only necessary if you use
172
+ * manual scheduling.
173
+ */
174
+ read(options?: {
175
+ logger?: Logger;
176
+ }): Promise<void>;
177
+ private schedule;
178
+ }
179
+
180
+ /**
181
+ * Options for {@link GitHubOrgEntityProvider}.
182
+ *
183
+ * @public
184
+ */
185
+ export declare interface GitHubOrgEntityProviderOptions {
186
+ /**
187
+ * A unique, stable identifier for this provider.
188
+ *
189
+ * @example "production"
190
+ */
191
+ id: string;
192
+ /**
193
+ * The target that this provider should consume.
194
+ *
195
+ * @example "https://github.com/backstage"
196
+ */
197
+ orgUrl: string;
198
+ /**
199
+ * The refresh schedule to use.
200
+ *
201
+ * @defaultValue "manual"
202
+ * @remarks
203
+ *
204
+ * If you pass in 'manual', you are responsible for calling the `read` method
205
+ * manually at some interval.
206
+ *
207
+ * But more commonly you will pass in the result of
208
+ * {@link @backstage/backend-tasks#PluginTaskScheduler.createScheduledTaskRunner}
209
+ * to enable automatic scheduling of tasks.
210
+ */
211
+ schedule?: 'manual' | TaskRunner;
212
+ /**
213
+ * The logger to use.
214
+ */
215
+ logger: Logger;
216
+ /**
217
+ * Optionally supply a custom credentials provider, replacing the default one.
218
+ */
219
+ githubCredentialsProvider?: GithubCredentialsProvider;
220
+ }
221
+
222
+ /**
223
+ * Extracts teams and users out of a GitHub org.
224
+ *
225
+ * @remarks
226
+ *
227
+ * Consider using {@link GitHubOrgEntityProvider} instead.
228
+ *
229
+ * @public
230
+ */
231
+ export declare class GithubOrgReaderProcessor implements CatalogProcessor {
232
+ private readonly integrations;
233
+ private readonly logger;
234
+ private readonly githubCredentialsProvider;
235
+ static fromConfig(config: Config, options: {
236
+ logger: Logger;
237
+ githubCredentialsProvider?: GithubCredentialsProvider;
238
+ }): GithubOrgReaderProcessor;
239
+ constructor(options: {
240
+ integrations: ScmIntegrationRegistry;
241
+ logger: Logger;
242
+ githubCredentialsProvider?: GithubCredentialsProvider;
243
+ });
244
+ getProcessorName(): string;
245
+ readLocation(location: LocationSpec, _optional: boolean, emit: CatalogProcessorEmit): Promise<boolean>;
246
+ private createClient;
247
+ }
248
+
249
+ export { }
@@ -0,0 +1,237 @@
1
+ /**
2
+ * A Backstage catalog backend module that helps integrate towards GitHub
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+
7
+ import { BackendFeature } from '@backstage/backend-plugin-api';
8
+ import { CatalogProcessor } from '@backstage/plugin-catalog-backend';
9
+ import { CatalogProcessorEmit } from '@backstage/plugin-catalog-backend';
10
+ import { Config } from '@backstage/config';
11
+ import { EntityProvider } from '@backstage/plugin-catalog-backend';
12
+ import { EntityProviderConnection } from '@backstage/plugin-catalog-backend';
13
+ import { GithubCredentialsProvider } from '@backstage/integration';
14
+ import { GitHubIntegrationConfig } from '@backstage/integration';
15
+ import { LocationSpec } from '@backstage/plugin-catalog-backend';
16
+ import { Logger } from 'winston';
17
+ import { ScmIntegrationRegistry } from '@backstage/integration';
18
+ import { TaskRunner } from '@backstage/backend-tasks';
19
+ import { TaskScheduleDefinition } from '@backstage/backend-tasks';
20
+
21
+ /**
22
+ * Extracts repositories out of a GitHub org.
23
+ *
24
+ * The following will create locations for all projects which have a catalog-info.yaml
25
+ * on the default branch. The first is shorthand for the second.
26
+ *
27
+ * target: "https://github.com/backstage"
28
+ * or
29
+ * target: https://github.com/backstage/*\/blob/-/catalog-info.yaml
30
+ *
31
+ * You may also explicitly specify the source branch:
32
+ *
33
+ * target: https://github.com/backstage/*\/blob/main/catalog-info.yaml
34
+ *
35
+ * @public
36
+ **/
37
+ export declare class GithubDiscoveryProcessor implements CatalogProcessor {
38
+ private readonly integrations;
39
+ private readonly logger;
40
+ private readonly githubCredentialsProvider;
41
+ static fromConfig(config: Config, options: {
42
+ logger: Logger;
43
+ githubCredentialsProvider?: GithubCredentialsProvider;
44
+ }): GithubDiscoveryProcessor;
45
+ constructor(options: {
46
+ integrations: ScmIntegrationRegistry;
47
+ logger: Logger;
48
+ githubCredentialsProvider?: GithubCredentialsProvider;
49
+ });
50
+ getProcessorName(): string;
51
+ readLocation(location: LocationSpec, _optional: boolean, emit: CatalogProcessorEmit): Promise<boolean>;
52
+ }
53
+
54
+ /**
55
+ * Discovers catalog files located in [GitHub](https://github.com).
56
+ * The provider will search your GitHub account and register catalog files matching the configured path
57
+ * as Location entity and via following processing steps add all contained catalog entities.
58
+ * This can be useful as an alternative to static locations or manually adding things to the catalog.
59
+ *
60
+ * @public
61
+ */
62
+ export declare class GitHubEntityProvider implements EntityProvider {
63
+ private readonly config;
64
+ private readonly logger;
65
+ private readonly integration;
66
+ private readonly scheduleFn;
67
+ private connection?;
68
+ private readonly githubCredentialsProvider;
69
+ static fromConfig(config: Config, options: {
70
+ logger: Logger;
71
+ schedule: TaskRunner;
72
+ }): GitHubEntityProvider[];
73
+ private constructor();
74
+ /** {@inheritdoc @backstage/plugin-catalog-backend#EntityProvider.getProviderName} */
75
+ getProviderName(): string;
76
+ /** {@inheritdoc @backstage/plugin-catalog-backend#EntityProvider.connect} */
77
+ connect(connection: EntityProviderConnection): Promise<void>;
78
+ private createScheduleFn;
79
+ refresh(logger: Logger): Promise<void>;
80
+ private findCatalogFiles;
81
+ private matchesFilters;
82
+ private createLocationUrl;
83
+ private static toLocationSpec;
84
+ }
85
+
86
+ /* Excluded from this release type: githubEntityProviderCatalogModule */
87
+
88
+ /* Excluded from this release type: GithubEntityProviderCatalogModuleOptions */
89
+
90
+ /**
91
+ * The configuration parameters for a multi-org GitHub processor.
92
+ * @public
93
+ */
94
+ export declare type GithubMultiOrgConfig = Array<{
95
+ /**
96
+ * The name of the GitHub org to process.
97
+ */
98
+ name: string;
99
+ /**
100
+ * The namespace of the group created for this org.
101
+ */
102
+ groupNamespace: string;
103
+ /**
104
+ * The namespace of the users created for this org. If not specified defaults to undefined.
105
+ */
106
+ userNamespace: string | undefined;
107
+ }>;
108
+
109
+ /**
110
+ * Extracts teams and users out of a multiple GitHub orgs namespaced per org.
111
+ *
112
+ * Be aware that this processor may not be compatible with future org structures in the catalog.
113
+ *
114
+ * @public
115
+ */
116
+ export declare class GithubMultiOrgReaderProcessor implements CatalogProcessor {
117
+ private readonly integrations;
118
+ private readonly orgs;
119
+ private readonly logger;
120
+ private readonly githubCredentialsProvider;
121
+ static fromConfig(config: Config, options: {
122
+ logger: Logger;
123
+ githubCredentialsProvider?: GithubCredentialsProvider;
124
+ }): GithubMultiOrgReaderProcessor;
125
+ constructor(options: {
126
+ integrations: ScmIntegrationRegistry;
127
+ logger: Logger;
128
+ orgs: GithubMultiOrgConfig;
129
+ githubCredentialsProvider?: GithubCredentialsProvider;
130
+ });
131
+ getProcessorName(): string;
132
+ readLocation(location: LocationSpec, _optional: boolean, emit: CatalogProcessorEmit): Promise<boolean>;
133
+ private getAllOrgs;
134
+ }
135
+
136
+ /**
137
+ * Ingests org data (users and groups) from GitHub.
138
+ *
139
+ * @public
140
+ */
141
+ export declare class GitHubOrgEntityProvider implements EntityProvider {
142
+ private options;
143
+ private readonly credentialsProvider;
144
+ private connection?;
145
+ private scheduleFn?;
146
+ static fromConfig(config: Config, options: GitHubOrgEntityProviderOptions): GitHubOrgEntityProvider;
147
+ constructor(options: {
148
+ id: string;
149
+ orgUrl: string;
150
+ gitHubConfig: GitHubIntegrationConfig;
151
+ logger: Logger;
152
+ githubCredentialsProvider?: GithubCredentialsProvider;
153
+ });
154
+ /** {@inheritdoc @backstage/plugin-catalog-backend#EntityProvider.getProviderName} */
155
+ getProviderName(): string;
156
+ /** {@inheritdoc @backstage/plugin-catalog-backend#EntityProvider.connect} */
157
+ connect(connection: EntityProviderConnection): Promise<void>;
158
+ /**
159
+ * Runs one single complete ingestion. This is only necessary if you use
160
+ * manual scheduling.
161
+ */
162
+ read(options?: {
163
+ logger?: Logger;
164
+ }): Promise<void>;
165
+ private schedule;
166
+ }
167
+
168
+ /**
169
+ * Options for {@link GitHubOrgEntityProvider}.
170
+ *
171
+ * @public
172
+ */
173
+ export declare interface GitHubOrgEntityProviderOptions {
174
+ /**
175
+ * A unique, stable identifier for this provider.
176
+ *
177
+ * @example "production"
178
+ */
179
+ id: string;
180
+ /**
181
+ * The target that this provider should consume.
182
+ *
183
+ * @example "https://github.com/backstage"
184
+ */
185
+ orgUrl: string;
186
+ /**
187
+ * The refresh schedule to use.
188
+ *
189
+ * @defaultValue "manual"
190
+ * @remarks
191
+ *
192
+ * If you pass in 'manual', you are responsible for calling the `read` method
193
+ * manually at some interval.
194
+ *
195
+ * But more commonly you will pass in the result of
196
+ * {@link @backstage/backend-tasks#PluginTaskScheduler.createScheduledTaskRunner}
197
+ * to enable automatic scheduling of tasks.
198
+ */
199
+ schedule?: 'manual' | TaskRunner;
200
+ /**
201
+ * The logger to use.
202
+ */
203
+ logger: Logger;
204
+ /**
205
+ * Optionally supply a custom credentials provider, replacing the default one.
206
+ */
207
+ githubCredentialsProvider?: GithubCredentialsProvider;
208
+ }
209
+
210
+ /**
211
+ * Extracts teams and users out of a GitHub org.
212
+ *
213
+ * @remarks
214
+ *
215
+ * Consider using {@link GitHubOrgEntityProvider} instead.
216
+ *
217
+ * @public
218
+ */
219
+ export declare class GithubOrgReaderProcessor implements CatalogProcessor {
220
+ private readonly integrations;
221
+ private readonly logger;
222
+ private readonly githubCredentialsProvider;
223
+ static fromConfig(config: Config, options: {
224
+ logger: Logger;
225
+ githubCredentialsProvider?: GithubCredentialsProvider;
226
+ }): GithubOrgReaderProcessor;
227
+ constructor(options: {
228
+ integrations: ScmIntegrationRegistry;
229
+ logger: Logger;
230
+ githubCredentialsProvider?: GithubCredentialsProvider;
231
+ });
232
+ getProcessorName(): string;
233
+ readLocation(location: LocationSpec, _optional: boolean, emit: CatalogProcessorEmit): Promise<boolean>;
234
+ private createClient;
235
+ }
236
+
237
+ export { }