@backstage/plugin-catalog-backend-module-github 0.1.6-next.1 → 0.1.7-next.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 +40 -0
- package/alpha/package.json +6 -0
- package/dist/index.alpha.d.ts +249 -0
- package/dist/index.beta.d.ts +237 -0
- package/dist/index.cjs.js +34 -4
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +93 -74
- package/package.json +15 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,45 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-backend-module-github
|
|
2
2
|
|
|
3
|
+
## 0.1.7-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 3c4a388537: New experimental alpha exports for use with the upcoming backend system.
|
|
8
|
+
- bf5e9030eb: Updated dependency `msw` to `^0.45.0`.
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
- @backstage/backend-common@0.15.1-next.0
|
|
11
|
+
- @backstage/backend-tasks@0.3.5-next.0
|
|
12
|
+
- @backstage/plugin-catalog-backend@1.3.2-next.0
|
|
13
|
+
- @backstage/backend-plugin-api@0.1.2-next.0
|
|
14
|
+
- @backstage/integration@1.3.1-next.0
|
|
15
|
+
- @backstage/plugin-catalog-node@1.0.2-next.0
|
|
16
|
+
|
|
17
|
+
## 0.1.6
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- f48950e34b: Github Entity Provider functionality for adding entities to the catalog.
|
|
22
|
+
|
|
23
|
+
This provider replaces the GithubDiscoveryProcessor functionality as providers offer more flexibility with scheduling ingestion, removing and preventing orphaned entities.
|
|
24
|
+
|
|
25
|
+
More information can be found on the [GitHub Discovery](https://backstage.io/docs/integrations/github/discovery) page.
|
|
26
|
+
|
|
27
|
+
- c59d1ce487: Fixed bug where repository filter was including all archived repositories
|
|
28
|
+
- 97f0a37378: Improved support for wildcards in `catalogPath`
|
|
29
|
+
- Updated dependencies
|
|
30
|
+
- @backstage/backend-common@0.15.0
|
|
31
|
+
- @backstage/integration@1.3.0
|
|
32
|
+
- @backstage/backend-tasks@0.3.4
|
|
33
|
+
- @backstage/plugin-catalog-backend@1.3.1
|
|
34
|
+
|
|
35
|
+
## 0.1.6-next.2
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- 97f0a37378: Improved support for wildcards in `catalogPath`
|
|
40
|
+
- Updated dependencies
|
|
41
|
+
- @backstage/plugin-catalog-backend@1.3.1-next.2
|
|
42
|
+
|
|
3
43
|
## 0.1.6-next.1
|
|
4
44
|
|
|
5
45
|
### Patch Changes
|
|
@@ -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 { }
|
package/dist/index.cjs.js
CHANGED
|
@@ -8,6 +8,8 @@ var graphql = require('@octokit/graphql');
|
|
|
8
8
|
var uuid = require('uuid');
|
|
9
9
|
var catalogModel = require('@backstage/catalog-model');
|
|
10
10
|
var lodash = require('lodash');
|
|
11
|
+
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
12
|
+
var pluginCatalogNode = require('@backstage/plugin-catalog-node');
|
|
11
13
|
|
|
12
14
|
function _interopNamespace(e) {
|
|
13
15
|
if (e && e.__esModule) return e;
|
|
@@ -713,16 +715,14 @@ class GitHubEntityProvider {
|
|
|
713
715
|
const repositoryFilter = (_a = this.config.filters) == null ? void 0 : _a.repository;
|
|
714
716
|
const matchingRepositories = repositories.filter((r) => {
|
|
715
717
|
var _a2;
|
|
716
|
-
return !r.isArchived && repositoryFilter
|
|
718
|
+
return !r.isArchived && (!repositoryFilter || repositoryFilter.test(r.name)) && ((_a2 = r.defaultBranchRef) == null ? void 0 : _a2.name);
|
|
717
719
|
});
|
|
718
720
|
return matchingRepositories;
|
|
719
721
|
}
|
|
720
722
|
createLocationUrl(repository) {
|
|
721
723
|
var _a, _b;
|
|
722
724
|
const branch = ((_a = this.config.filters) == null ? void 0 : _a.branch) || ((_b = repository.defaultBranchRef) == null ? void 0 : _b.name) || "-";
|
|
723
|
-
const catalogFile = this.config.catalogPath.substring(
|
|
724
|
-
this.config.catalogPath.lastIndexOf("/") + 1
|
|
725
|
-
);
|
|
725
|
+
const catalogFile = this.config.catalogPath.startsWith("/") ? this.config.catalogPath.substring(1) : this.config.catalogPath;
|
|
726
726
|
return `${repository.url}/blob/${branch}/${catalogFile}`;
|
|
727
727
|
}
|
|
728
728
|
static toLocationSpec(target) {
|
|
@@ -861,9 +861,39 @@ function withLocations(baseUrl, org, entity) {
|
|
|
861
861
|
);
|
|
862
862
|
}
|
|
863
863
|
|
|
864
|
+
const githubEntityProviderCatalogModule = backendPluginApi.createBackendModule({
|
|
865
|
+
pluginId: "catalog",
|
|
866
|
+
moduleId: "github-entity-provider",
|
|
867
|
+
register(env, options) {
|
|
868
|
+
env.registerInit({
|
|
869
|
+
deps: {
|
|
870
|
+
config: backendPluginApi.configServiceRef,
|
|
871
|
+
catalog: pluginCatalogNode.catalogProcessingExtensionPoint,
|
|
872
|
+
logger: backendPluginApi.loggerServiceRef,
|
|
873
|
+
scheduler: backendPluginApi.schedulerServiceRef
|
|
874
|
+
},
|
|
875
|
+
async init({ config, catalog, logger, scheduler }) {
|
|
876
|
+
var _a;
|
|
877
|
+
const scheduleDef = (_a = options == null ? void 0 : options.schedule) != null ? _a : {
|
|
878
|
+
frequency: { seconds: 600 },
|
|
879
|
+
timeout: { seconds: 900 },
|
|
880
|
+
initialDelay: { seconds: 3 }
|
|
881
|
+
};
|
|
882
|
+
catalog.addEntityProvider(
|
|
883
|
+
GitHubEntityProvider.fromConfig(config, {
|
|
884
|
+
logger: backendPluginApi.loggerToWinstonLogger(logger),
|
|
885
|
+
schedule: scheduler.createScheduledTaskRunner(scheduleDef)
|
|
886
|
+
})
|
|
887
|
+
);
|
|
888
|
+
}
|
|
889
|
+
});
|
|
890
|
+
}
|
|
891
|
+
});
|
|
892
|
+
|
|
864
893
|
exports.GitHubEntityProvider = GitHubEntityProvider;
|
|
865
894
|
exports.GitHubOrgEntityProvider = GitHubOrgEntityProvider;
|
|
866
895
|
exports.GithubDiscoveryProcessor = GithubDiscoveryProcessor;
|
|
867
896
|
exports.GithubMultiOrgReaderProcessor = GithubMultiOrgReaderProcessor;
|
|
868
897
|
exports.GithubOrgReaderProcessor = GithubOrgReaderProcessor;
|
|
898
|
+
exports.githubEntityProviderCatalogModule = githubEntityProviderCatalogModule;
|
|
869
899
|
//# sourceMappingURL=index.cjs.js.map
|