@backstage/plugin-catalog-backend-module-github 0.1.6 → 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 CHANGED
@@ -1,5 +1,19 @@
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
+
3
17
  ## 0.1.6
4
18
 
5
19
  ### Patch Changes
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "@backstage/plugin-catalog-backend-module-github",
3
+ "version": "0.1.7-next.0",
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 { }
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;
@@ -859,9 +861,39 @@ function withLocations(baseUrl, org, entity) {
859
861
  );
860
862
  }
861
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
+
862
893
  exports.GitHubEntityProvider = GitHubEntityProvider;
863
894
  exports.GitHubOrgEntityProvider = GitHubOrgEntityProvider;
864
895
  exports.GithubDiscoveryProcessor = GithubDiscoveryProcessor;
865
896
  exports.GithubMultiOrgReaderProcessor = GithubMultiOrgReaderProcessor;
866
897
  exports.GithubOrgReaderProcessor = GithubOrgReaderProcessor;
898
+ exports.githubEntityProviderCatalogModule = githubEntityProviderCatalogModule;
867
899
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/lib/config.ts","../src/lib/github.ts","../src/lib/org.ts","../src/lib/util.ts","../src/processors/GithubDiscoveryProcessor.ts","../src/processors/GithubMultiOrgReaderProcessor.ts","../src/processors/GithubOrgReaderProcessor.ts","../src/providers/GitHubEntityProviderConfig.ts","../src/providers/GitHubEntityProvider.ts","../src/providers/GitHubOrgEntityProvider.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\n\n/**\n * The configuration parameters for a multi-org GitHub processor.\n * @public\n */\nexport type GithubMultiOrgConfig = Array<{\n /**\n * The name of the GitHub org to process.\n */\n name: string;\n /**\n * The namespace of the group created for this org.\n */\n groupNamespace: string;\n /**\n * The namespace of the users created for this org. If not specified defaults to undefined.\n */\n userNamespace: string | undefined;\n}>;\n\nexport function readGithubMultiOrgConfig(config: Config): GithubMultiOrgConfig {\n const orgConfigs = config.getOptionalConfigArray('orgs') ?? [];\n return orgConfigs.map(c => ({\n name: c.getString('name'),\n groupNamespace: (\n c.getOptionalString('groupNamespace') ?? c.getString('name')\n ).toLowerCase(),\n userNamespace: c.getOptionalString('userNamespace') ?? undefined,\n }));\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { GroupEntity, UserEntity } from '@backstage/catalog-model';\nimport { GithubCredentialType } from '@backstage/integration';\nimport { graphql } from '@octokit/graphql';\n\n// Graphql types\n\nexport type QueryResponse = {\n organization?: Organization;\n repositoryOwner?: Organization | User;\n};\n\nexport type Organization = {\n membersWithRole?: Connection<User>;\n team?: Team;\n teams?: Connection<Team>;\n repositories?: Connection<Repository>;\n};\n\nexport type PageInfo = {\n hasNextPage: boolean;\n endCursor?: string;\n};\n\nexport type User = {\n login: string;\n bio?: string;\n avatarUrl?: string;\n email?: string;\n name?: string;\n repositories?: Connection<Repository>;\n};\n\nexport type Team = {\n slug: string;\n combinedSlug: string;\n name?: string;\n description?: string;\n avatarUrl?: string;\n editTeamUrl?: string;\n parentTeam?: Team;\n members: Connection<User>;\n};\n\nexport type Repository = {\n name: string;\n url: string;\n isArchived: boolean;\n defaultBranchRef: {\n name: string;\n } | null;\n};\n\nexport type Connection<T> = {\n pageInfo: PageInfo;\n nodes: T[];\n};\n\n/**\n * Gets all the users out of a GitHub organization.\n *\n * Note that the users will not have their memberships filled in.\n *\n * @param client - An octokit graphql client\n * @param org - The slug of the org to read\n */\nexport async function getOrganizationUsers(\n client: typeof graphql,\n org: string,\n tokenType: GithubCredentialType,\n userNamespace?: string,\n): Promise<{ users: UserEntity[] }> {\n const query = `\n query users($org: String!, $email: Boolean!, $cursor: String) {\n organization(login: $org) {\n membersWithRole(first: 100, after: $cursor) {\n pageInfo { hasNextPage, endCursor }\n nodes {\n avatarUrl,\n bio,\n email @include(if: $email),\n login,\n name\n }\n }\n }\n }`;\n\n // There is no user -> teams edge, so we leave the memberships empty for\n // now and let the team iteration handle it instead\n const mapper = (user: User) => {\n const entity: UserEntity = {\n apiVersion: 'backstage.io/v1alpha1',\n kind: 'User',\n metadata: {\n name: user.login,\n annotations: {\n 'github.com/user-login': user.login,\n },\n },\n spec: {\n profile: {},\n memberOf: [],\n },\n };\n\n if (userNamespace) entity.metadata.namespace = userNamespace;\n if (user.bio) entity.metadata.description = user.bio;\n if (user.name) entity.spec.profile!.displayName = user.name;\n if (user.email) entity.spec.profile!.email = user.email;\n if (user.avatarUrl) entity.spec.profile!.picture = user.avatarUrl;\n\n return entity;\n };\n\n const users = await queryWithPaging(\n client,\n query,\n r => r.organization?.membersWithRole,\n mapper,\n { org, email: tokenType === 'token' },\n );\n\n return { users };\n}\n\n/**\n * Gets all the teams out of a GitHub organization.\n *\n * Note that the teams will not have any relations apart from parent filled in.\n *\n * @param client - An octokit graphql client\n * @param org - The slug of the org to read\n */\nexport async function getOrganizationTeams(\n client: typeof graphql,\n org: string,\n orgNamespace?: string,\n): Promise<{\n groups: GroupEntity[];\n groupMemberUsers: Map<string, string[]>;\n}> {\n const query = `\n query teams($org: String!, $cursor: String) {\n organization(login: $org) {\n teams(first: 100, after: $cursor) {\n pageInfo { hasNextPage, endCursor }\n nodes {\n slug\n combinedSlug\n name\n description\n avatarUrl\n editTeamUrl\n parentTeam { slug }\n members(first: 100, membership: IMMEDIATE) {\n pageInfo { hasNextPage }\n nodes { login }\n }\n }\n }\n }\n }`;\n\n // Gets populated inside the mapper below\n const groupMemberUsers = new Map<string, string[]>();\n\n const mapper = async (team: Team) => {\n const annotations: { [annotationName: string]: string } = {\n 'github.com/team-slug': team.combinedSlug,\n };\n\n if (team.editTeamUrl) {\n annotations['backstage.io/edit-url'] = team.editTeamUrl;\n }\n\n const entity: GroupEntity = {\n apiVersion: 'backstage.io/v1alpha1',\n kind: 'Group',\n metadata: {\n name: team.slug,\n annotations,\n },\n spec: {\n type: 'team',\n profile: {},\n children: [],\n },\n };\n\n if (orgNamespace) {\n entity.metadata.namespace = orgNamespace;\n }\n\n if (team.description) {\n entity.metadata.description = team.description;\n }\n if (team.name) {\n entity.spec.profile!.displayName = team.name;\n }\n if (team.avatarUrl) {\n entity.spec.profile!.picture = team.avatarUrl;\n }\n if (team.parentTeam) {\n entity.spec.parent = team.parentTeam.slug;\n }\n\n const memberNames: string[] = [];\n const groupKey = orgNamespace ? `${orgNamespace}/${team.slug}` : team.slug;\n groupMemberUsers.set(groupKey, memberNames);\n\n if (!team.members.pageInfo.hasNextPage) {\n // We got all the members in one go, run the fast path\n for (const user of team.members.nodes) {\n memberNames.push(user.login);\n }\n } else {\n // There were more than a hundred immediate members - run the slow\n // path of fetching them explicitly\n const { members } = await getTeamMembers(client, org, team.slug);\n for (const userLogin of members) {\n memberNames.push(userLogin);\n }\n }\n\n return entity;\n };\n\n const groups = await queryWithPaging(\n client,\n query,\n r => r.organization?.teams,\n mapper,\n { org },\n );\n\n return { groups, groupMemberUsers };\n}\n\nexport async function getOrganizationRepositories(\n client: typeof graphql,\n org: string,\n): Promise<{ repositories: Repository[] }> {\n const query = `\n query repositories($org: String!, $cursor: String) {\n repositoryOwner(login: $org) {\n login\n repositories(first: 100, after: $cursor) {\n nodes {\n name\n url\n isArchived\n defaultBranchRef {\n name\n }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n }`;\n\n const repositories = await queryWithPaging(\n client,\n query,\n r => r.repositoryOwner?.repositories,\n x => x,\n { org },\n );\n\n return { repositories };\n}\n\n/**\n * Gets all the users out of a GitHub organization.\n *\n * Note that the users will not have their memberships filled in.\n *\n * @param client - An octokit graphql client\n * @param org - The slug of the org to read\n * @param teamSlug - The slug of the team to read\n */\nexport async function getTeamMembers(\n client: typeof graphql,\n org: string,\n teamSlug: string,\n): Promise<{ members: string[] }> {\n const query = `\n query members($org: String!, $teamSlug: String!, $cursor: String) {\n organization(login: $org) {\n team(slug: $teamSlug) {\n members(first: 100, after: $cursor, membership: IMMEDIATE) {\n pageInfo { hasNextPage, endCursor }\n nodes { login }\n }\n }\n }\n }`;\n\n const members = await queryWithPaging(\n client,\n query,\n r => r.organization?.team?.members,\n user => user.login,\n { org, teamSlug },\n );\n\n return { members };\n}\n\n//\n// Helpers\n//\n\n/**\n * Assists in repeatedly executing a query with a paged response.\n *\n * Requires that the query accepts a $cursor variable.\n *\n * @param client - The octokit client\n * @param query - The query to execute\n * @param connection - A function that, given the response, picks out the actual\n * Connection object that's being iterated\n * @param mapper - A function that, given one of the nodes in the Connection,\n * returns the model mapped form of it\n * @param variables - The variable values that the query needs, minus the cursor\n */\nexport async function queryWithPaging<\n GraphqlType,\n OutputType,\n Variables extends {},\n Response = QueryResponse,\n>(\n client: typeof graphql,\n query: string,\n connection: (response: Response) => Connection<GraphqlType> | undefined,\n mapper: (item: GraphqlType) => Promise<OutputType> | OutputType,\n variables: Variables,\n): Promise<OutputType[]> {\n const result: OutputType[] = [];\n\n let cursor: string | undefined = undefined;\n for (let j = 0; j < 1000 /* just for sanity */; ++j) {\n const response: Response = await client(query, {\n ...variables,\n cursor,\n });\n\n const conn = connection(response);\n if (!conn) {\n throw new Error(`Found no match for ${JSON.stringify(variables)}`);\n }\n\n for (const node of conn.nodes) {\n result.push(await mapper(node));\n }\n\n if (!conn.pageInfo.hasNextPage) {\n break;\n } else {\n cursor = conn.pageInfo.endCursor;\n }\n }\n\n return result;\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { GroupEntity, UserEntity } from '@backstage/catalog-model';\n\nexport function buildOrgHierarchy(groups: GroupEntity[]) {\n const groupsByName = new Map(groups.map(g => [g.metadata.name, g]));\n\n //\n // Make sure that g.parent.children contain g\n //\n\n for (const group of groups) {\n const selfName = group.metadata.name;\n const parentName = group.spec.parent;\n if (parentName) {\n const parent = groupsByName.get(parentName);\n if (parent && !parent.spec.children.includes(selfName)) {\n parent.spec.children.push(selfName);\n }\n }\n }\n\n //\n // Make sure that g.children.parent is g\n //\n\n for (const group of groups) {\n const selfName = group.metadata.name;\n for (const childName of group.spec.children) {\n const child = groupsByName.get(childName);\n if (child && !child.spec.parent) {\n child.spec.parent = selfName;\n }\n }\n }\n}\n\n// Ensure that users have their direct group memberships.\nexport function assignGroupsToUsers(\n users: UserEntity[],\n groupMemberUsers: Map<string, string[]>,\n) {\n const usersByName = new Map(users.map(u => [u.metadata.name, u]));\n for (const [groupName, userNames] of groupMemberUsers.entries()) {\n for (const userName of userNames) {\n const user = usersByName.get(userName);\n if (user && !user.spec.memberOf?.includes(groupName)) {\n if (!user.spec.memberOf) {\n user.spec.memberOf = [];\n }\n user.spec.memberOf.push(groupName);\n }\n }\n }\n}\n\n// Ensure that users have their transitive group memberships. Requires that\n// the groups were previously processed with buildOrgHierarchy()\nexport function buildMemberOf(groups: GroupEntity[], users: UserEntity[]) {\n const groupsByName = new Map(groups.map(g => [g.metadata.name, g]));\n\n users.forEach(user => {\n const transitiveMemberOf = new Set<string>();\n\n const todo = [\n ...(user.spec.memberOf ?? []),\n ...groups\n .filter(g => g.spec.members?.includes(user.metadata.name))\n .map(g => g.metadata.name),\n ];\n\n for (;;) {\n const current = todo.pop();\n if (!current) {\n break;\n }\n\n if (!transitiveMemberOf.has(current)) {\n transitiveMemberOf.add(current);\n const group = groupsByName.get(current);\n if (group?.spec.parent) {\n todo.push(group.spec.parent);\n }\n }\n }\n\n user.spec.memberOf = [...transitiveMemberOf];\n });\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport function parseGitHubOrgUrl(urlString: string): { org: string } {\n const path = new URL(urlString).pathname.substr(1).split('/');\n\n // /backstage\n if (path.length === 1 && path[0].length) {\n return { org: decodeURIComponent(path[0]) };\n }\n\n throw new Error(`Expected a URL pointing to /<org>`);\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport {\n DefaultGithubCredentialsProvider,\n GithubCredentialsProvider,\n ScmIntegrationRegistry,\n ScmIntegrations,\n} from '@backstage/integration';\nimport {\n CatalogProcessor,\n CatalogProcessorEmit,\n LocationSpec,\n processingResult,\n} from '@backstage/plugin-catalog-backend';\nimport { graphql } from '@octokit/graphql';\nimport { Logger } from 'winston';\nimport { getOrganizationRepositories } from '../lib';\n\n/**\n * Extracts repositories out of a GitHub org.\n *\n * The following will create locations for all projects which have a catalog-info.yaml\n * on the default branch. The first is shorthand for the second.\n *\n * target: \"https://github.com/backstage\"\n * or\n * target: https://github.com/backstage/*\\/blob/-/catalog-info.yaml\n *\n * You may also explicitly specify the source branch:\n *\n * target: https://github.com/backstage/*\\/blob/main/catalog-info.yaml\n *\n * @public\n **/\nexport class GithubDiscoveryProcessor implements CatalogProcessor {\n private readonly integrations: ScmIntegrationRegistry;\n private readonly logger: Logger;\n private readonly githubCredentialsProvider: GithubCredentialsProvider;\n\n static fromConfig(\n config: Config,\n options: {\n logger: Logger;\n githubCredentialsProvider?: GithubCredentialsProvider;\n },\n ) {\n const integrations = ScmIntegrations.fromConfig(config);\n\n return new GithubDiscoveryProcessor({\n ...options,\n integrations,\n });\n }\n\n constructor(options: {\n integrations: ScmIntegrationRegistry;\n logger: Logger;\n githubCredentialsProvider?: GithubCredentialsProvider;\n }) {\n this.integrations = options.integrations;\n this.logger = options.logger;\n this.githubCredentialsProvider =\n options.githubCredentialsProvider ||\n DefaultGithubCredentialsProvider.fromIntegrations(this.integrations);\n }\n getProcessorName(): string {\n return 'GithubDiscoveryProcessor';\n }\n\n async readLocation(\n location: LocationSpec,\n _optional: boolean,\n emit: CatalogProcessorEmit,\n ): Promise<boolean> {\n if (location.type !== 'github-discovery') {\n return false;\n }\n\n const gitHubConfig = this.integrations.github.byUrl(\n location.target,\n )?.config;\n if (!gitHubConfig) {\n throw new Error(\n `There is no GitHub integration that matches ${location.target}. Please add a configuration entry for it under integrations.github`,\n );\n }\n\n const { org, repoSearchPath, catalogPath, branch, host } = parseUrl(\n location.target,\n );\n\n // Building the org url here so that the github creds provider doesn't need to know\n // about how to handle the wild card which is special for this processor.\n const orgUrl = `https://${host}/${org}`;\n\n const { headers } = await this.githubCredentialsProvider.getCredentials({\n url: orgUrl,\n });\n\n const client = graphql.defaults({\n baseUrl: gitHubConfig.apiBaseUrl,\n headers,\n });\n\n // Read out all of the raw data\n const startTimestamp = Date.now();\n this.logger.info(`Reading GitHub repositories from ${location.target}`);\n\n const { repositories } = await getOrganizationRepositories(client, org);\n const matching = repositories.filter(\n r => !r.isArchived && repoSearchPath.test(r.name),\n );\n\n const duration = ((Date.now() - startTimestamp) / 1000).toFixed(1);\n this.logger.debug(\n `Read ${repositories.length} GitHub repositories (${matching.length} matching the pattern) in ${duration} seconds`,\n );\n\n for (const repository of matching) {\n const branchName =\n branch === '-' ? repository.defaultBranchRef?.name : branch;\n\n if (!branchName) {\n this.logger.info(\n `the repository ${repository.url} does not have a default branch, skipping`,\n );\n continue;\n }\n\n const path = `/blob/${branchName}${catalogPath}`;\n\n emit(\n processingResult.location({\n type: 'url',\n target: `${repository.url}${path}`,\n // Not all locations may actually exist, since the user defined them as a wildcard pattern.\n // Thus, we emit them as optional and let the downstream processor find them while not outputting\n // an error if it couldn't.\n presence: 'optional',\n }),\n );\n }\n\n return true;\n }\n}\n\n/*\n * Helpers\n */\n\nexport function parseUrl(urlString: string): {\n org: string;\n repoSearchPath: RegExp;\n catalogPath: string;\n branch: string;\n host: string;\n} {\n const url = new URL(urlString);\n const path = url.pathname.substr(1).split('/');\n\n // /backstage/techdocs-*/blob/master/catalog-info.yaml\n // can also be\n // /backstage\n if (path.length > 2 && path[0].length && path[1].length) {\n return {\n org: decodeURIComponent(path[0]),\n repoSearchPath: escapeRegExp(decodeURIComponent(path[1])),\n branch: decodeURIComponent(path[3]),\n catalogPath: `/${decodeURIComponent(path.slice(4).join('/'))}`,\n host: url.host,\n };\n } else if (path.length === 1 && path[0].length) {\n return {\n org: decodeURIComponent(path[0]),\n host: url.host,\n repoSearchPath: escapeRegExp('*'),\n catalogPath: '/catalog-info.yaml',\n branch: '-',\n };\n }\n\n throw new Error(`Failed to parse ${urlString}`);\n}\n\nexport function escapeRegExp(str: string): RegExp {\n return new RegExp(`^${str.replace(/\\*/g, '.*')}$`);\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport {\n DefaultGithubCredentialsProvider,\n GithubAppCredentialsMux,\n GithubCredentialsProvider,\n GitHubIntegrationConfig,\n ScmIntegrationRegistry,\n ScmIntegrations,\n} from '@backstage/integration';\nimport {\n CatalogProcessor,\n CatalogProcessorEmit,\n LocationSpec,\n processingResult,\n} from '@backstage/plugin-catalog-backend';\nimport { graphql } from '@octokit/graphql';\nimport { Logger } from 'winston';\nimport {\n buildOrgHierarchy,\n getOrganizationTeams,\n getOrganizationUsers,\n GithubMultiOrgConfig,\n readGithubMultiOrgConfig,\n} from '../lib';\n\n/**\n * Extracts teams and users out of a multiple GitHub orgs namespaced per org.\n *\n * Be aware that this processor may not be compatible with future org structures in the catalog.\n *\n * @public\n */\nexport class GithubMultiOrgReaderProcessor implements CatalogProcessor {\n private readonly integrations: ScmIntegrationRegistry;\n private readonly orgs: GithubMultiOrgConfig;\n private readonly logger: Logger;\n private readonly githubCredentialsProvider: GithubCredentialsProvider;\n\n static fromConfig(\n config: Config,\n options: {\n logger: Logger;\n githubCredentialsProvider?: GithubCredentialsProvider;\n },\n ) {\n const c = config.getOptionalConfig('catalog.processors.githubMultiOrg');\n const integrations = ScmIntegrations.fromConfig(config);\n\n return new GithubMultiOrgReaderProcessor({\n ...options,\n integrations,\n orgs: c ? readGithubMultiOrgConfig(c) : [],\n });\n }\n\n constructor(options: {\n integrations: ScmIntegrationRegistry;\n logger: Logger;\n orgs: GithubMultiOrgConfig;\n githubCredentialsProvider?: GithubCredentialsProvider;\n }) {\n this.integrations = options.integrations;\n this.logger = options.logger;\n this.orgs = options.orgs;\n this.githubCredentialsProvider =\n options.githubCredentialsProvider ||\n DefaultGithubCredentialsProvider.fromIntegrations(this.integrations);\n }\n getProcessorName(): string {\n return 'GithubMultiOrgReaderProcessor';\n }\n\n async readLocation(\n location: LocationSpec,\n _optional: boolean,\n emit: CatalogProcessorEmit,\n ): Promise<boolean> {\n if (location.type !== 'github-multi-org') {\n return false;\n }\n\n const gitHubConfig = this.integrations.github.byUrl(\n location.target,\n )?.config;\n if (!gitHubConfig) {\n throw new Error(\n `There is no GitHub integration that matches ${location.target}. Please add a configuration entry for it under integrations.github`,\n );\n }\n\n const allUsersMap = new Map();\n const baseUrl = new URL(location.target).origin;\n\n const orgsToProcess = this.orgs.length\n ? this.orgs\n : await this.getAllOrgs(gitHubConfig);\n\n for (const orgConfig of orgsToProcess) {\n try {\n const { headers, type: tokenType } =\n await this.githubCredentialsProvider.getCredentials({\n url: `${baseUrl}/${orgConfig.name}`,\n });\n const client = graphql.defaults({\n baseUrl: gitHubConfig.apiBaseUrl,\n headers,\n });\n\n const startTimestamp = Date.now();\n this.logger.info(\n `Reading GitHub users and teams for org: ${orgConfig.name}`,\n );\n const { users } = await getOrganizationUsers(\n client,\n orgConfig.name,\n tokenType,\n orgConfig.userNamespace,\n );\n const { groups, groupMemberUsers } = await getOrganizationTeams(\n client,\n orgConfig.name,\n orgConfig.groupNamespace,\n );\n\n const duration = ((Date.now() - startTimestamp) / 1000).toFixed(1);\n this.logger.debug(\n `Read ${users.length} GitHub users and ${groups.length} GitHub teams from ${orgConfig.name} in ${duration} seconds`,\n );\n\n let prefix: string = orgConfig.userNamespace ?? '';\n if (prefix.length > 0) prefix += '/';\n\n users.forEach(u => {\n if (!allUsersMap.has(prefix + u.metadata.name)) {\n allUsersMap.set(prefix + u.metadata.name, u);\n }\n });\n\n for (const [groupName, userNames] of groupMemberUsers.entries()) {\n for (const userName of userNames) {\n const user = allUsersMap.get(prefix + userName);\n if (user && !user.spec.memberOf.includes(groupName)) {\n user.spec.memberOf.push(groupName);\n }\n }\n }\n buildOrgHierarchy(groups);\n\n for (const group of groups) {\n emit(processingResult.entity(location, group));\n }\n } catch (e) {\n this.logger.error(\n `Failed to read GitHub org data for ${orgConfig.name}: ${e}`,\n );\n }\n }\n\n const allUsers = Array.from(allUsersMap.values());\n for (const user of allUsers) {\n emit(processingResult.entity(location, user));\n }\n\n return true;\n }\n\n // Note: Does not support usage of PATs\n private async getAllOrgs(\n gitHubConfig: GitHubIntegrationConfig,\n ): Promise<GithubMultiOrgConfig> {\n const githubAppMux = new GithubAppCredentialsMux(gitHubConfig);\n const installs = await githubAppMux.getAllInstallations();\n\n return installs\n .map(install =>\n install.target_type === 'Organization' &&\n install.account &&\n install.account.login\n ? {\n name: install.account.login,\n groupNamespace: install.account.login.toLowerCase(),\n }\n : undefined,\n )\n .filter(Boolean) as GithubMultiOrgConfig;\n }\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport {\n DefaultGithubCredentialsProvider,\n GithubCredentialsProvider,\n GithubCredentialType,\n ScmIntegrationRegistry,\n ScmIntegrations,\n} from '@backstage/integration';\nimport {\n CatalogProcessor,\n CatalogProcessorEmit,\n LocationSpec,\n processingResult,\n} from '@backstage/plugin-catalog-backend';\nimport { graphql } from '@octokit/graphql';\nimport { Logger } from 'winston';\nimport {\n assignGroupsToUsers,\n buildOrgHierarchy,\n getOrganizationTeams,\n getOrganizationUsers,\n parseGitHubOrgUrl,\n} from '../lib';\n\ntype GraphQL = typeof graphql;\n\n/**\n * Extracts teams and users out of a GitHub org.\n *\n * @remarks\n *\n * Consider using {@link GitHubOrgEntityProvider} instead.\n *\n * @public\n */\nexport class GithubOrgReaderProcessor implements CatalogProcessor {\n private readonly integrations: ScmIntegrationRegistry;\n private readonly logger: Logger;\n private readonly githubCredentialsProvider: GithubCredentialsProvider;\n\n static fromConfig(\n config: Config,\n options: {\n logger: Logger;\n githubCredentialsProvider?: GithubCredentialsProvider;\n },\n ) {\n const integrations = ScmIntegrations.fromConfig(config);\n\n return new GithubOrgReaderProcessor({\n ...options,\n integrations,\n });\n }\n\n constructor(options: {\n integrations: ScmIntegrationRegistry;\n logger: Logger;\n githubCredentialsProvider?: GithubCredentialsProvider;\n }) {\n this.integrations = options.integrations;\n this.githubCredentialsProvider =\n options.githubCredentialsProvider ||\n DefaultGithubCredentialsProvider.fromIntegrations(this.integrations);\n this.logger = options.logger;\n }\n getProcessorName(): string {\n return 'GithubOrgReaderProcessor';\n }\n\n async readLocation(\n location: LocationSpec,\n _optional: boolean,\n emit: CatalogProcessorEmit,\n ): Promise<boolean> {\n if (location.type !== 'github-org') {\n return false;\n }\n\n const { client, tokenType } = await this.createClient(location.target);\n const { org } = parseGitHubOrgUrl(location.target);\n\n // Read out all of the raw data\n const startTimestamp = Date.now();\n this.logger.info('Reading GitHub users and groups');\n\n const { users } = await getOrganizationUsers(client, org, tokenType);\n const { groups, groupMemberUsers } = await getOrganizationTeams(\n client,\n org,\n );\n\n const duration = ((Date.now() - startTimestamp) / 1000).toFixed(1);\n this.logger.debug(\n `Read ${users.length} GitHub users and ${groups.length} GitHub groups in ${duration} seconds`,\n );\n\n assignGroupsToUsers(users, groupMemberUsers);\n buildOrgHierarchy(groups);\n\n // Done!\n for (const group of groups) {\n emit(processingResult.entity(location, group));\n }\n for (const user of users) {\n emit(processingResult.entity(location, user));\n }\n\n return true;\n }\n\n private async createClient(\n orgUrl: string,\n ): Promise<{ client: GraphQL; tokenType: GithubCredentialType }> {\n const gitHubConfig = this.integrations.github.byUrl(orgUrl)?.config;\n\n if (!gitHubConfig) {\n throw new Error(\n `There is no GitHub Org provider that matches ${orgUrl}. Please add a configuration for an integration.`,\n );\n }\n\n const { headers, type: tokenType } =\n await this.githubCredentialsProvider.getCredentials({\n url: orgUrl,\n });\n\n const client = graphql.defaults({\n baseUrl: gitHubConfig.apiBaseUrl,\n headers,\n });\n\n return { client, tokenType };\n }\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\n\nconst DEFAULT_CATALOG_PATH = '/catalog-info.yaml';\nconst DEFAULT_PROVIDER_ID = 'default';\n\nexport type GitHubEntityProviderConfig = {\n id: string;\n catalogPath: string;\n organization: string;\n filters?: {\n repository?: RegExp;\n branch?: string;\n };\n};\n\nexport function readProviderConfigs(\n config: Config,\n): GitHubEntityProviderConfig[] {\n const providersConfig = config.getOptionalConfig('catalog.providers.github');\n if (!providersConfig) {\n return [];\n }\n\n if (providersConfig.has('organization')) {\n // simple/single config variant\n return [readProviderConfig(DEFAULT_PROVIDER_ID, providersConfig)];\n }\n\n return providersConfig.keys().map(id => {\n const providerConfig = providersConfig.getConfig(id);\n\n return readProviderConfig(id, providerConfig);\n });\n}\n\nfunction readProviderConfig(\n id: string,\n config: Config,\n): GitHubEntityProviderConfig {\n const organization = config.getString('organization');\n const catalogPath =\n config.getOptionalString('catalogPath') ?? DEFAULT_CATALOG_PATH;\n const repositoryPattern = config.getOptionalString('filters.repository');\n const branchPattern = config.getOptionalString('filters.branch');\n\n return {\n id,\n catalogPath,\n organization,\n filters: {\n repository: repositoryPattern\n ? compileRegExp(repositoryPattern)\n : undefined,\n branch: branchPattern || undefined,\n },\n };\n}\n/**\n * Compiles a RegExp while enforcing the pattern to contain\n * the start-of-line and end-of-line anchors.\n *\n * @param pattern\n */\nfunction compileRegExp(pattern: string): RegExp {\n let fullLinePattern = pattern;\n if (!fullLinePattern.startsWith('^')) {\n fullLinePattern = `^${fullLinePattern}`;\n }\n if (!fullLinePattern.endsWith('$')) {\n fullLinePattern = `${fullLinePattern}$`;\n }\n\n return new RegExp(fullLinePattern);\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { TaskRunner } from '@backstage/backend-tasks';\nimport { Config } from '@backstage/config';\nimport {\n GithubCredentialsProvider,\n ScmIntegrations,\n GitHubIntegrationConfig,\n GitHubIntegration,\n SingleInstanceGithubCredentialsProvider,\n} from '@backstage/integration';\nimport {\n EntityProvider,\n EntityProviderConnection,\n LocationSpec,\n locationSpecToLocationEntity,\n} from '@backstage/plugin-catalog-backend';\n\nimport { graphql } from '@octokit/graphql';\nimport * as uuid from 'uuid';\nimport { Logger } from 'winston';\nimport {\n readProviderConfigs,\n GitHubEntityProviderConfig,\n} from './GitHubEntityProviderConfig';\nimport { getOrganizationRepositories, Repository } from '../lib/github';\n\n/**\n * Discovers catalog files located in [GitHub](https://github.com).\n * The provider will search your GitHub account and register catalog files matching the configured path\n * as Location entity and via following processing steps add all contained catalog entities.\n * This can be useful as an alternative to static locations or manually adding things to the catalog.\n *\n * @public\n */\nexport class GitHubEntityProvider implements EntityProvider {\n private readonly config: GitHubEntityProviderConfig;\n private readonly logger: Logger;\n private readonly integration: GitHubIntegrationConfig;\n private readonly scheduleFn: () => Promise<void>;\n private connection?: EntityProviderConnection;\n private readonly githubCredentialsProvider: GithubCredentialsProvider;\n\n static fromConfig(\n config: Config,\n options: {\n logger: Logger;\n schedule: TaskRunner;\n },\n ): GitHubEntityProvider[] {\n const integrations = ScmIntegrations.fromConfig(config);\n const integration = integrations.github.byHost('github.com');\n\n if (!integration) {\n throw new Error(\n `There is no GitHub config that matches github. Please add a configuration entry for it under integrations.github`,\n );\n }\n\n return readProviderConfigs(config).map(\n providerConfig =>\n new GitHubEntityProvider(\n providerConfig,\n integration,\n options.logger,\n options.schedule,\n ),\n );\n }\n\n private constructor(\n config: GitHubEntityProviderConfig,\n integration: GitHubIntegration,\n logger: Logger,\n schedule: TaskRunner,\n ) {\n this.config = config;\n this.integration = integration.config;\n this.logger = logger.child({\n target: this.getProviderName(),\n });\n this.scheduleFn = this.createScheduleFn(schedule);\n this.githubCredentialsProvider =\n SingleInstanceGithubCredentialsProvider.create(integration.config);\n this.scheduleFn = this.createScheduleFn(schedule);\n }\n\n /** {@inheritdoc @backstage/plugin-catalog-backend#EntityProvider.getProviderName} */\n getProviderName(): string {\n return `github-provider:${this.config.id}`;\n }\n\n /** {@inheritdoc @backstage/plugin-catalog-backend#EntityProvider.connect} */\n async connect(connection: EntityProviderConnection): Promise<void> {\n this.connection = connection;\n return await this.scheduleFn();\n }\n\n private createScheduleFn(schedule: TaskRunner): () => Promise<void> {\n return async () => {\n const taskId = `${this.getProviderName()}:refresh`;\n return schedule.run({\n id: taskId,\n fn: async () => {\n const logger = this.logger.child({\n class: GitHubEntityProvider.prototype.constructor.name,\n taskId,\n taskInstanceId: uuid.v4(),\n });\n try {\n await this.refresh(logger);\n } catch (error) {\n logger.error(error);\n }\n },\n });\n };\n }\n\n async refresh(logger: Logger) {\n if (!this.connection) {\n throw new Error('Not initialized');\n }\n\n const targets = await this.findCatalogFiles();\n const matchingTargets = this.matchesFilters(targets);\n const entities = matchingTargets\n .map(repository => this.createLocationUrl(repository))\n .map(GitHubEntityProvider.toLocationSpec)\n .map(location => {\n return {\n locationKey: this.getProviderName(),\n entity: locationSpecToLocationEntity({ location }),\n };\n });\n\n await this.connection.applyMutation({\n type: 'full',\n entities,\n });\n\n logger.info(\n `Read ${targets.length} GitHub repositories (${entities.length} matching the pattern)`,\n );\n }\n\n // go to the server and get all of the repositories\n private async findCatalogFiles(): Promise<Repository[]> {\n const organization = this.config.organization;\n const host = this.integration.host;\n const orgUrl = `https://${host}/${organization}`;\n\n const { headers } = await this.githubCredentialsProvider.getCredentials({\n url: orgUrl,\n });\n\n const client = graphql.defaults({\n baseUrl: this.integration.apiBaseUrl,\n headers,\n });\n\n const { repositories } = await getOrganizationRepositories(\n client,\n organization,\n );\n\n return repositories;\n }\n\n private matchesFilters(repositories: Repository[]) {\n const repositoryFilter = this.config.filters?.repository;\n\n const matchingRepositories = repositories.filter(r => {\n return (\n !r.isArchived &&\n (!repositoryFilter || repositoryFilter.test(r.name)) &&\n r.defaultBranchRef?.name\n );\n });\n return matchingRepositories;\n }\n\n private createLocationUrl(repository: Repository): string {\n const branch =\n this.config.filters?.branch || repository.defaultBranchRef?.name || '-';\n const catalogFile = this.config.catalogPath.startsWith('/')\n ? this.config.catalogPath.substring(1)\n : this.config.catalogPath;\n return `${repository.url}/blob/${branch}/${catalogFile}`;\n }\n\n private static toLocationSpec(target: string): LocationSpec {\n return {\n type: 'url',\n target: target,\n presence: 'optional',\n };\n }\n}\n\n/*\n * Helpers\n */\n\nexport function parseUrl(urlString: string): {\n org: string;\n repoSearchPath: RegExp;\n catalogPath: string;\n branch: string;\n host: string;\n} {\n const url = new URL(urlString);\n const path = url.pathname.substr(1).split('/');\n\n // /backstage/techdocs-*/blob/master/catalog-info.yaml\n // can also be\n // /backstage\n if (path.length > 2 && path[0].length && path[1].length) {\n return {\n org: decodeURIComponent(path[0]),\n repoSearchPath: escapeRegExp(decodeURIComponent(path[1])),\n catalogPath: `/${decodeURIComponent(path.slice(4).join('/'))}`,\n branch: decodeURIComponent(path[3]),\n host: url.host,\n };\n } else if (path.length === 1 && path[0].length) {\n return {\n org: decodeURIComponent(path[0]),\n repoSearchPath: escapeRegExp('*'),\n catalogPath: '/catalog-info.yaml',\n branch: '-',\n host: url.host,\n };\n }\n\n throw new Error(`Failed to parse ${urlString}`);\n}\n\nexport function escapeRegExp(str: string): RegExp {\n return new RegExp(`^${str.replace(/\\*/g, '.*')}$`);\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { TaskRunner } from '@backstage/backend-tasks';\nimport {\n ANNOTATION_LOCATION,\n ANNOTATION_ORIGIN_LOCATION,\n Entity,\n} from '@backstage/catalog-model';\nimport { Config } from '@backstage/config';\nimport {\n DefaultGithubCredentialsProvider,\n GithubCredentialsProvider,\n GitHubIntegrationConfig,\n ScmIntegrations,\n SingleInstanceGithubCredentialsProvider,\n} from '@backstage/integration';\nimport {\n EntityProvider,\n EntityProviderConnection,\n} from '@backstage/plugin-catalog-backend';\nimport { graphql } from '@octokit/graphql';\nimport { merge } from 'lodash';\nimport * as uuid from 'uuid';\nimport { Logger } from 'winston';\nimport {\n assignGroupsToUsers,\n buildOrgHierarchy,\n getOrganizationTeams,\n getOrganizationUsers,\n parseGitHubOrgUrl,\n} from '../lib';\n\n/**\n * Options for {@link GitHubOrgEntityProvider}.\n *\n * @public\n */\nexport interface GitHubOrgEntityProviderOptions {\n /**\n * A unique, stable identifier for this provider.\n *\n * @example \"production\"\n */\n id: string;\n\n /**\n * The target that this provider should consume.\n *\n * @example \"https://github.com/backstage\"\n */\n orgUrl: string;\n\n /**\n * The refresh schedule to use.\n *\n * @defaultValue \"manual\"\n * @remarks\n *\n * If you pass in 'manual', you are responsible for calling the `read` method\n * manually at some interval.\n *\n * But more commonly you will pass in the result of\n * {@link @backstage/backend-tasks#PluginTaskScheduler.createScheduledTaskRunner}\n * to enable automatic scheduling of tasks.\n */\n schedule?: 'manual' | TaskRunner;\n\n /**\n * The logger to use.\n */\n logger: Logger;\n\n /**\n * Optionally supply a custom credentials provider, replacing the default one.\n */\n githubCredentialsProvider?: GithubCredentialsProvider;\n}\n\n// TODO: Consider supporting an (optional) webhook that reacts on org changes\n/**\n * Ingests org data (users and groups) from GitHub.\n *\n * @public\n */\nexport class GitHubOrgEntityProvider implements EntityProvider {\n private readonly credentialsProvider: GithubCredentialsProvider;\n private connection?: EntityProviderConnection;\n private scheduleFn?: () => Promise<void>;\n\n static fromConfig(config: Config, options: GitHubOrgEntityProviderOptions) {\n const integrations = ScmIntegrations.fromConfig(config);\n const gitHubConfig = integrations.github.byUrl(options.orgUrl)?.config;\n\n if (!gitHubConfig) {\n throw new Error(\n `There is no GitHub Org provider that matches ${options.orgUrl}. Please add a configuration for an integration.`,\n );\n }\n\n const logger = options.logger.child({\n target: options.orgUrl,\n });\n\n const provider = new GitHubOrgEntityProvider({\n id: options.id,\n orgUrl: options.orgUrl,\n logger,\n gitHubConfig,\n githubCredentialsProvider:\n options.githubCredentialsProvider ||\n DefaultGithubCredentialsProvider.fromIntegrations(integrations),\n });\n\n provider.schedule(options.schedule);\n\n return provider;\n }\n\n constructor(\n private options: {\n id: string;\n orgUrl: string;\n gitHubConfig: GitHubIntegrationConfig;\n logger: Logger;\n githubCredentialsProvider?: GithubCredentialsProvider;\n },\n ) {\n this.credentialsProvider =\n options.githubCredentialsProvider ||\n SingleInstanceGithubCredentialsProvider.create(this.options.gitHubConfig);\n }\n\n /** {@inheritdoc @backstage/plugin-catalog-backend#EntityProvider.getProviderName} */\n getProviderName() {\n return `GitHubOrgEntityProvider:${this.options.id}`;\n }\n\n /** {@inheritdoc @backstage/plugin-catalog-backend#EntityProvider.connect} */\n async connect(connection: EntityProviderConnection) {\n this.connection = connection;\n await this.scheduleFn?.();\n }\n\n /**\n * Runs one single complete ingestion. This is only necessary if you use\n * manual scheduling.\n */\n async read(options?: { logger?: Logger }) {\n if (!this.connection) {\n throw new Error('Not initialized');\n }\n\n const logger = options?.logger ?? this.options.logger;\n const { markReadComplete } = trackProgress(logger);\n\n const { headers, type: tokenType } =\n await this.credentialsProvider.getCredentials({\n url: this.options.orgUrl,\n });\n const client = graphql.defaults({\n baseUrl: this.options.gitHubConfig.apiBaseUrl,\n headers,\n });\n\n const { org } = parseGitHubOrgUrl(this.options.orgUrl);\n const { users } = await getOrganizationUsers(client, org, tokenType);\n const { groups, groupMemberUsers } = await getOrganizationTeams(\n client,\n org,\n );\n assignGroupsToUsers(users, groupMemberUsers);\n buildOrgHierarchy(groups);\n\n const { markCommitComplete } = markReadComplete({ users, groups });\n\n await this.connection.applyMutation({\n type: 'full',\n entities: [...users, ...groups].map(entity => ({\n locationKey: `github-org-provider:${this.options.id}`,\n entity: withLocations(\n `https://${this.options.gitHubConfig.host}`,\n org,\n entity,\n ),\n })),\n });\n\n markCommitComplete();\n }\n\n private schedule(schedule: GitHubOrgEntityProviderOptions['schedule']) {\n if (!schedule || schedule === 'manual') {\n return;\n }\n\n this.scheduleFn = async () => {\n const id = `${this.getProviderName()}:refresh`;\n await schedule.run({\n id,\n fn: async () => {\n const logger = this.options.logger.child({\n class: GitHubOrgEntityProvider.prototype.constructor.name,\n taskId: id,\n taskInstanceId: uuid.v4(),\n });\n\n try {\n await this.read({ logger });\n } catch (error) {\n logger.error(error);\n }\n },\n });\n };\n }\n}\n\n// Helps wrap the timing and logging behaviors\nfunction trackProgress(logger: Logger) {\n let timestamp = Date.now();\n let summary: string;\n\n logger.info('Reading GitHub users and groups');\n\n function markReadComplete(read: { users: unknown[]; groups: unknown[] }) {\n summary = `${read.users.length} GitHub users and ${read.groups.length} GitHub groups`;\n const readDuration = ((Date.now() - timestamp) / 1000).toFixed(1);\n timestamp = Date.now();\n logger.info(`Read ${summary} in ${readDuration} seconds. Committing...`);\n return { markCommitComplete };\n }\n\n function markCommitComplete() {\n const commitDuration = ((Date.now() - timestamp) / 1000).toFixed(1);\n logger.info(`Committed ${summary} in ${commitDuration} seconds.`);\n }\n\n return { markReadComplete };\n}\n\n// Makes sure that emitted entities have a proper location\nexport function withLocations(\n baseUrl: string,\n org: string,\n entity: Entity,\n): Entity {\n const location =\n entity.kind === 'Group'\n ? `url:${baseUrl}/orgs/${org}/teams/${entity.metadata.name}`\n : `url:${baseUrl}/${entity.metadata.name}`;\n return merge(\n {\n metadata: {\n annotations: {\n [ANNOTATION_LOCATION]: location,\n [ANNOTATION_ORIGIN_LOCATION]: location,\n },\n },\n },\n entity,\n ) as Entity;\n}\n"],"names":["ScmIntegrations","DefaultGithubCredentialsProvider","graphql","processingResult","GithubAppCredentialsMux","integration","SingleInstanceGithubCredentialsProvider","uuid","locationSpecToLocationEntity","merge","ANNOTATION_LOCATION","ANNOTATION_ORIGIN_LOCATION"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,SAAS,wBAAwB,CAAC,MAAM,EAAE;AACjD,EAAE,IAAI,EAAE,CAAC;AACT,EAAE,MAAM,UAAU,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,sBAAsB,CAAC,MAAM,CAAC,KAAK,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC;AACpF,EAAE,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK;AAC/B,IAAI,IAAI,GAAG,EAAE,EAAE,CAAC;AAChB,IAAI,OAAO;AACX,MAAM,IAAI,EAAE,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC;AAC/B,MAAM,cAAc,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,KAAK,IAAI,GAAG,GAAG,GAAG,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE;AACvH,MAAM,aAAa,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,iBAAiB,CAAC,eAAe,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,UAAU,EAAE,OAAO,CAAC,IAAI,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC;AACtE,GAAG;AACH,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAC9B,CAAC;AACM,SAAS,aAAa,CAAC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE;AACpD,EAAE,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,KAAK,OAAO,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;AACnJ,EAAE,OAAOE,YAAK;AACd,IAAI;AACJ,MAAM,QAAQ,EAAE;AAChB,QAAQ,WAAW,EAAE;AACrB,UAAU,CAACC,gCAAmB,GAAG,QAAQ;AACzC,UAAU,CAACC,uCAA0B,GAAG,QAAQ;AAChD,SAAS;AACT,OAAO;AACP,KAAK;AACL,IAAI,MAAM;AACV,GAAG,CAAC;AACJ;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/lib/config.ts","../src/lib/github.ts","../src/lib/org.ts","../src/lib/util.ts","../src/processors/GithubDiscoveryProcessor.ts","../src/processors/GithubMultiOrgReaderProcessor.ts","../src/processors/GithubOrgReaderProcessor.ts","../src/providers/GitHubEntityProviderConfig.ts","../src/providers/GitHubEntityProvider.ts","../src/providers/GitHubOrgEntityProvider.ts","../src/module.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\n\n/**\n * The configuration parameters for a multi-org GitHub processor.\n * @public\n */\nexport type GithubMultiOrgConfig = Array<{\n /**\n * The name of the GitHub org to process.\n */\n name: string;\n /**\n * The namespace of the group created for this org.\n */\n groupNamespace: string;\n /**\n * The namespace of the users created for this org. If not specified defaults to undefined.\n */\n userNamespace: string | undefined;\n}>;\n\nexport function readGithubMultiOrgConfig(config: Config): GithubMultiOrgConfig {\n const orgConfigs = config.getOptionalConfigArray('orgs') ?? [];\n return orgConfigs.map(c => ({\n name: c.getString('name'),\n groupNamespace: (\n c.getOptionalString('groupNamespace') ?? c.getString('name')\n ).toLowerCase(),\n userNamespace: c.getOptionalString('userNamespace') ?? undefined,\n }));\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { GroupEntity, UserEntity } from '@backstage/catalog-model';\nimport { GithubCredentialType } from '@backstage/integration';\nimport { graphql } from '@octokit/graphql';\n\n// Graphql types\n\nexport type QueryResponse = {\n organization?: Organization;\n repositoryOwner?: Organization | User;\n};\n\nexport type Organization = {\n membersWithRole?: Connection<User>;\n team?: Team;\n teams?: Connection<Team>;\n repositories?: Connection<Repository>;\n};\n\nexport type PageInfo = {\n hasNextPage: boolean;\n endCursor?: string;\n};\n\nexport type User = {\n login: string;\n bio?: string;\n avatarUrl?: string;\n email?: string;\n name?: string;\n repositories?: Connection<Repository>;\n};\n\nexport type Team = {\n slug: string;\n combinedSlug: string;\n name?: string;\n description?: string;\n avatarUrl?: string;\n editTeamUrl?: string;\n parentTeam?: Team;\n members: Connection<User>;\n};\n\nexport type Repository = {\n name: string;\n url: string;\n isArchived: boolean;\n defaultBranchRef: {\n name: string;\n } | null;\n};\n\nexport type Connection<T> = {\n pageInfo: PageInfo;\n nodes: T[];\n};\n\n/**\n * Gets all the users out of a GitHub organization.\n *\n * Note that the users will not have their memberships filled in.\n *\n * @param client - An octokit graphql client\n * @param org - The slug of the org to read\n */\nexport async function getOrganizationUsers(\n client: typeof graphql,\n org: string,\n tokenType: GithubCredentialType,\n userNamespace?: string,\n): Promise<{ users: UserEntity[] }> {\n const query = `\n query users($org: String!, $email: Boolean!, $cursor: String) {\n organization(login: $org) {\n membersWithRole(first: 100, after: $cursor) {\n pageInfo { hasNextPage, endCursor }\n nodes {\n avatarUrl,\n bio,\n email @include(if: $email),\n login,\n name\n }\n }\n }\n }`;\n\n // There is no user -> teams edge, so we leave the memberships empty for\n // now and let the team iteration handle it instead\n const mapper = (user: User) => {\n const entity: UserEntity = {\n apiVersion: 'backstage.io/v1alpha1',\n kind: 'User',\n metadata: {\n name: user.login,\n annotations: {\n 'github.com/user-login': user.login,\n },\n },\n spec: {\n profile: {},\n memberOf: [],\n },\n };\n\n if (userNamespace) entity.metadata.namespace = userNamespace;\n if (user.bio) entity.metadata.description = user.bio;\n if (user.name) entity.spec.profile!.displayName = user.name;\n if (user.email) entity.spec.profile!.email = user.email;\n if (user.avatarUrl) entity.spec.profile!.picture = user.avatarUrl;\n\n return entity;\n };\n\n const users = await queryWithPaging(\n client,\n query,\n r => r.organization?.membersWithRole,\n mapper,\n { org, email: tokenType === 'token' },\n );\n\n return { users };\n}\n\n/**\n * Gets all the teams out of a GitHub organization.\n *\n * Note that the teams will not have any relations apart from parent filled in.\n *\n * @param client - An octokit graphql client\n * @param org - The slug of the org to read\n */\nexport async function getOrganizationTeams(\n client: typeof graphql,\n org: string,\n orgNamespace?: string,\n): Promise<{\n groups: GroupEntity[];\n groupMemberUsers: Map<string, string[]>;\n}> {\n const query = `\n query teams($org: String!, $cursor: String) {\n organization(login: $org) {\n teams(first: 100, after: $cursor) {\n pageInfo { hasNextPage, endCursor }\n nodes {\n slug\n combinedSlug\n name\n description\n avatarUrl\n editTeamUrl\n parentTeam { slug }\n members(first: 100, membership: IMMEDIATE) {\n pageInfo { hasNextPage }\n nodes { login }\n }\n }\n }\n }\n }`;\n\n // Gets populated inside the mapper below\n const groupMemberUsers = new Map<string, string[]>();\n\n const mapper = async (team: Team) => {\n const annotations: { [annotationName: string]: string } = {\n 'github.com/team-slug': team.combinedSlug,\n };\n\n if (team.editTeamUrl) {\n annotations['backstage.io/edit-url'] = team.editTeamUrl;\n }\n\n const entity: GroupEntity = {\n apiVersion: 'backstage.io/v1alpha1',\n kind: 'Group',\n metadata: {\n name: team.slug,\n annotations,\n },\n spec: {\n type: 'team',\n profile: {},\n children: [],\n },\n };\n\n if (orgNamespace) {\n entity.metadata.namespace = orgNamespace;\n }\n\n if (team.description) {\n entity.metadata.description = team.description;\n }\n if (team.name) {\n entity.spec.profile!.displayName = team.name;\n }\n if (team.avatarUrl) {\n entity.spec.profile!.picture = team.avatarUrl;\n }\n if (team.parentTeam) {\n entity.spec.parent = team.parentTeam.slug;\n }\n\n const memberNames: string[] = [];\n const groupKey = orgNamespace ? `${orgNamespace}/${team.slug}` : team.slug;\n groupMemberUsers.set(groupKey, memberNames);\n\n if (!team.members.pageInfo.hasNextPage) {\n // We got all the members in one go, run the fast path\n for (const user of team.members.nodes) {\n memberNames.push(user.login);\n }\n } else {\n // There were more than a hundred immediate members - run the slow\n // path of fetching them explicitly\n const { members } = await getTeamMembers(client, org, team.slug);\n for (const userLogin of members) {\n memberNames.push(userLogin);\n }\n }\n\n return entity;\n };\n\n const groups = await queryWithPaging(\n client,\n query,\n r => r.organization?.teams,\n mapper,\n { org },\n );\n\n return { groups, groupMemberUsers };\n}\n\nexport async function getOrganizationRepositories(\n client: typeof graphql,\n org: string,\n): Promise<{ repositories: Repository[] }> {\n const query = `\n query repositories($org: String!, $cursor: String) {\n repositoryOwner(login: $org) {\n login\n repositories(first: 100, after: $cursor) {\n nodes {\n name\n url\n isArchived\n defaultBranchRef {\n name\n }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n }`;\n\n const repositories = await queryWithPaging(\n client,\n query,\n r => r.repositoryOwner?.repositories,\n x => x,\n { org },\n );\n\n return { repositories };\n}\n\n/**\n * Gets all the users out of a GitHub organization.\n *\n * Note that the users will not have their memberships filled in.\n *\n * @param client - An octokit graphql client\n * @param org - The slug of the org to read\n * @param teamSlug - The slug of the team to read\n */\nexport async function getTeamMembers(\n client: typeof graphql,\n org: string,\n teamSlug: string,\n): Promise<{ members: string[] }> {\n const query = `\n query members($org: String!, $teamSlug: String!, $cursor: String) {\n organization(login: $org) {\n team(slug: $teamSlug) {\n members(first: 100, after: $cursor, membership: IMMEDIATE) {\n pageInfo { hasNextPage, endCursor }\n nodes { login }\n }\n }\n }\n }`;\n\n const members = await queryWithPaging(\n client,\n query,\n r => r.organization?.team?.members,\n user => user.login,\n { org, teamSlug },\n );\n\n return { members };\n}\n\n//\n// Helpers\n//\n\n/**\n * Assists in repeatedly executing a query with a paged response.\n *\n * Requires that the query accepts a $cursor variable.\n *\n * @param client - The octokit client\n * @param query - The query to execute\n * @param connection - A function that, given the response, picks out the actual\n * Connection object that's being iterated\n * @param mapper - A function that, given one of the nodes in the Connection,\n * returns the model mapped form of it\n * @param variables - The variable values that the query needs, minus the cursor\n */\nexport async function queryWithPaging<\n GraphqlType,\n OutputType,\n Variables extends {},\n Response = QueryResponse,\n>(\n client: typeof graphql,\n query: string,\n connection: (response: Response) => Connection<GraphqlType> | undefined,\n mapper: (item: GraphqlType) => Promise<OutputType> | OutputType,\n variables: Variables,\n): Promise<OutputType[]> {\n const result: OutputType[] = [];\n\n let cursor: string | undefined = undefined;\n for (let j = 0; j < 1000 /* just for sanity */; ++j) {\n const response: Response = await client(query, {\n ...variables,\n cursor,\n });\n\n const conn = connection(response);\n if (!conn) {\n throw new Error(`Found no match for ${JSON.stringify(variables)}`);\n }\n\n for (const node of conn.nodes) {\n result.push(await mapper(node));\n }\n\n if (!conn.pageInfo.hasNextPage) {\n break;\n } else {\n cursor = conn.pageInfo.endCursor;\n }\n }\n\n return result;\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { GroupEntity, UserEntity } from '@backstage/catalog-model';\n\nexport function buildOrgHierarchy(groups: GroupEntity[]) {\n const groupsByName = new Map(groups.map(g => [g.metadata.name, g]));\n\n //\n // Make sure that g.parent.children contain g\n //\n\n for (const group of groups) {\n const selfName = group.metadata.name;\n const parentName = group.spec.parent;\n if (parentName) {\n const parent = groupsByName.get(parentName);\n if (parent && !parent.spec.children.includes(selfName)) {\n parent.spec.children.push(selfName);\n }\n }\n }\n\n //\n // Make sure that g.children.parent is g\n //\n\n for (const group of groups) {\n const selfName = group.metadata.name;\n for (const childName of group.spec.children) {\n const child = groupsByName.get(childName);\n if (child && !child.spec.parent) {\n child.spec.parent = selfName;\n }\n }\n }\n}\n\n// Ensure that users have their direct group memberships.\nexport function assignGroupsToUsers(\n users: UserEntity[],\n groupMemberUsers: Map<string, string[]>,\n) {\n const usersByName = new Map(users.map(u => [u.metadata.name, u]));\n for (const [groupName, userNames] of groupMemberUsers.entries()) {\n for (const userName of userNames) {\n const user = usersByName.get(userName);\n if (user && !user.spec.memberOf?.includes(groupName)) {\n if (!user.spec.memberOf) {\n user.spec.memberOf = [];\n }\n user.spec.memberOf.push(groupName);\n }\n }\n }\n}\n\n// Ensure that users have their transitive group memberships. Requires that\n// the groups were previously processed with buildOrgHierarchy()\nexport function buildMemberOf(groups: GroupEntity[], users: UserEntity[]) {\n const groupsByName = new Map(groups.map(g => [g.metadata.name, g]));\n\n users.forEach(user => {\n const transitiveMemberOf = new Set<string>();\n\n const todo = [\n ...(user.spec.memberOf ?? []),\n ...groups\n .filter(g => g.spec.members?.includes(user.metadata.name))\n .map(g => g.metadata.name),\n ];\n\n for (;;) {\n const current = todo.pop();\n if (!current) {\n break;\n }\n\n if (!transitiveMemberOf.has(current)) {\n transitiveMemberOf.add(current);\n const group = groupsByName.get(current);\n if (group?.spec.parent) {\n todo.push(group.spec.parent);\n }\n }\n }\n\n user.spec.memberOf = [...transitiveMemberOf];\n });\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport function parseGitHubOrgUrl(urlString: string): { org: string } {\n const path = new URL(urlString).pathname.substr(1).split('/');\n\n // /backstage\n if (path.length === 1 && path[0].length) {\n return { org: decodeURIComponent(path[0]) };\n }\n\n throw new Error(`Expected a URL pointing to /<org>`);\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport {\n DefaultGithubCredentialsProvider,\n GithubCredentialsProvider,\n ScmIntegrationRegistry,\n ScmIntegrations,\n} from '@backstage/integration';\nimport {\n CatalogProcessor,\n CatalogProcessorEmit,\n LocationSpec,\n processingResult,\n} from '@backstage/plugin-catalog-backend';\nimport { graphql } from '@octokit/graphql';\nimport { Logger } from 'winston';\nimport { getOrganizationRepositories } from '../lib';\n\n/**\n * Extracts repositories out of a GitHub org.\n *\n * The following will create locations for all projects which have a catalog-info.yaml\n * on the default branch. The first is shorthand for the second.\n *\n * target: \"https://github.com/backstage\"\n * or\n * target: https://github.com/backstage/*\\/blob/-/catalog-info.yaml\n *\n * You may also explicitly specify the source branch:\n *\n * target: https://github.com/backstage/*\\/blob/main/catalog-info.yaml\n *\n * @public\n **/\nexport class GithubDiscoveryProcessor implements CatalogProcessor {\n private readonly integrations: ScmIntegrationRegistry;\n private readonly logger: Logger;\n private readonly githubCredentialsProvider: GithubCredentialsProvider;\n\n static fromConfig(\n config: Config,\n options: {\n logger: Logger;\n githubCredentialsProvider?: GithubCredentialsProvider;\n },\n ) {\n const integrations = ScmIntegrations.fromConfig(config);\n\n return new GithubDiscoveryProcessor({\n ...options,\n integrations,\n });\n }\n\n constructor(options: {\n integrations: ScmIntegrationRegistry;\n logger: Logger;\n githubCredentialsProvider?: GithubCredentialsProvider;\n }) {\n this.integrations = options.integrations;\n this.logger = options.logger;\n this.githubCredentialsProvider =\n options.githubCredentialsProvider ||\n DefaultGithubCredentialsProvider.fromIntegrations(this.integrations);\n }\n getProcessorName(): string {\n return 'GithubDiscoveryProcessor';\n }\n\n async readLocation(\n location: LocationSpec,\n _optional: boolean,\n emit: CatalogProcessorEmit,\n ): Promise<boolean> {\n if (location.type !== 'github-discovery') {\n return false;\n }\n\n const gitHubConfig = this.integrations.github.byUrl(\n location.target,\n )?.config;\n if (!gitHubConfig) {\n throw new Error(\n `There is no GitHub integration that matches ${location.target}. Please add a configuration entry for it under integrations.github`,\n );\n }\n\n const { org, repoSearchPath, catalogPath, branch, host } = parseUrl(\n location.target,\n );\n\n // Building the org url here so that the github creds provider doesn't need to know\n // about how to handle the wild card which is special for this processor.\n const orgUrl = `https://${host}/${org}`;\n\n const { headers } = await this.githubCredentialsProvider.getCredentials({\n url: orgUrl,\n });\n\n const client = graphql.defaults({\n baseUrl: gitHubConfig.apiBaseUrl,\n headers,\n });\n\n // Read out all of the raw data\n const startTimestamp = Date.now();\n this.logger.info(`Reading GitHub repositories from ${location.target}`);\n\n const { repositories } = await getOrganizationRepositories(client, org);\n const matching = repositories.filter(\n r => !r.isArchived && repoSearchPath.test(r.name),\n );\n\n const duration = ((Date.now() - startTimestamp) / 1000).toFixed(1);\n this.logger.debug(\n `Read ${repositories.length} GitHub repositories (${matching.length} matching the pattern) in ${duration} seconds`,\n );\n\n for (const repository of matching) {\n const branchName =\n branch === '-' ? repository.defaultBranchRef?.name : branch;\n\n if (!branchName) {\n this.logger.info(\n `the repository ${repository.url} does not have a default branch, skipping`,\n );\n continue;\n }\n\n const path = `/blob/${branchName}${catalogPath}`;\n\n emit(\n processingResult.location({\n type: 'url',\n target: `${repository.url}${path}`,\n // Not all locations may actually exist, since the user defined them as a wildcard pattern.\n // Thus, we emit them as optional and let the downstream processor find them while not outputting\n // an error if it couldn't.\n presence: 'optional',\n }),\n );\n }\n\n return true;\n }\n}\n\n/*\n * Helpers\n */\n\nexport function parseUrl(urlString: string): {\n org: string;\n repoSearchPath: RegExp;\n catalogPath: string;\n branch: string;\n host: string;\n} {\n const url = new URL(urlString);\n const path = url.pathname.substr(1).split('/');\n\n // /backstage/techdocs-*/blob/master/catalog-info.yaml\n // can also be\n // /backstage\n if (path.length > 2 && path[0].length && path[1].length) {\n return {\n org: decodeURIComponent(path[0]),\n repoSearchPath: escapeRegExp(decodeURIComponent(path[1])),\n branch: decodeURIComponent(path[3]),\n catalogPath: `/${decodeURIComponent(path.slice(4).join('/'))}`,\n host: url.host,\n };\n } else if (path.length === 1 && path[0].length) {\n return {\n org: decodeURIComponent(path[0]),\n host: url.host,\n repoSearchPath: escapeRegExp('*'),\n catalogPath: '/catalog-info.yaml',\n branch: '-',\n };\n }\n\n throw new Error(`Failed to parse ${urlString}`);\n}\n\nexport function escapeRegExp(str: string): RegExp {\n return new RegExp(`^${str.replace(/\\*/g, '.*')}$`);\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport {\n DefaultGithubCredentialsProvider,\n GithubAppCredentialsMux,\n GithubCredentialsProvider,\n GitHubIntegrationConfig,\n ScmIntegrationRegistry,\n ScmIntegrations,\n} from '@backstage/integration';\nimport {\n CatalogProcessor,\n CatalogProcessorEmit,\n LocationSpec,\n processingResult,\n} from '@backstage/plugin-catalog-backend';\nimport { graphql } from '@octokit/graphql';\nimport { Logger } from 'winston';\nimport {\n buildOrgHierarchy,\n getOrganizationTeams,\n getOrganizationUsers,\n GithubMultiOrgConfig,\n readGithubMultiOrgConfig,\n} from '../lib';\n\n/**\n * Extracts teams and users out of a multiple GitHub orgs namespaced per org.\n *\n * Be aware that this processor may not be compatible with future org structures in the catalog.\n *\n * @public\n */\nexport class GithubMultiOrgReaderProcessor implements CatalogProcessor {\n private readonly integrations: ScmIntegrationRegistry;\n private readonly orgs: GithubMultiOrgConfig;\n private readonly logger: Logger;\n private readonly githubCredentialsProvider: GithubCredentialsProvider;\n\n static fromConfig(\n config: Config,\n options: {\n logger: Logger;\n githubCredentialsProvider?: GithubCredentialsProvider;\n },\n ) {\n const c = config.getOptionalConfig('catalog.processors.githubMultiOrg');\n const integrations = ScmIntegrations.fromConfig(config);\n\n return new GithubMultiOrgReaderProcessor({\n ...options,\n integrations,\n orgs: c ? readGithubMultiOrgConfig(c) : [],\n });\n }\n\n constructor(options: {\n integrations: ScmIntegrationRegistry;\n logger: Logger;\n orgs: GithubMultiOrgConfig;\n githubCredentialsProvider?: GithubCredentialsProvider;\n }) {\n this.integrations = options.integrations;\n this.logger = options.logger;\n this.orgs = options.orgs;\n this.githubCredentialsProvider =\n options.githubCredentialsProvider ||\n DefaultGithubCredentialsProvider.fromIntegrations(this.integrations);\n }\n getProcessorName(): string {\n return 'GithubMultiOrgReaderProcessor';\n }\n\n async readLocation(\n location: LocationSpec,\n _optional: boolean,\n emit: CatalogProcessorEmit,\n ): Promise<boolean> {\n if (location.type !== 'github-multi-org') {\n return false;\n }\n\n const gitHubConfig = this.integrations.github.byUrl(\n location.target,\n )?.config;\n if (!gitHubConfig) {\n throw new Error(\n `There is no GitHub integration that matches ${location.target}. Please add a configuration entry for it under integrations.github`,\n );\n }\n\n const allUsersMap = new Map();\n const baseUrl = new URL(location.target).origin;\n\n const orgsToProcess = this.orgs.length\n ? this.orgs\n : await this.getAllOrgs(gitHubConfig);\n\n for (const orgConfig of orgsToProcess) {\n try {\n const { headers, type: tokenType } =\n await this.githubCredentialsProvider.getCredentials({\n url: `${baseUrl}/${orgConfig.name}`,\n });\n const client = graphql.defaults({\n baseUrl: gitHubConfig.apiBaseUrl,\n headers,\n });\n\n const startTimestamp = Date.now();\n this.logger.info(\n `Reading GitHub users and teams for org: ${orgConfig.name}`,\n );\n const { users } = await getOrganizationUsers(\n client,\n orgConfig.name,\n tokenType,\n orgConfig.userNamespace,\n );\n const { groups, groupMemberUsers } = await getOrganizationTeams(\n client,\n orgConfig.name,\n orgConfig.groupNamespace,\n );\n\n const duration = ((Date.now() - startTimestamp) / 1000).toFixed(1);\n this.logger.debug(\n `Read ${users.length} GitHub users and ${groups.length} GitHub teams from ${orgConfig.name} in ${duration} seconds`,\n );\n\n let prefix: string = orgConfig.userNamespace ?? '';\n if (prefix.length > 0) prefix += '/';\n\n users.forEach(u => {\n if (!allUsersMap.has(prefix + u.metadata.name)) {\n allUsersMap.set(prefix + u.metadata.name, u);\n }\n });\n\n for (const [groupName, userNames] of groupMemberUsers.entries()) {\n for (const userName of userNames) {\n const user = allUsersMap.get(prefix + userName);\n if (user && !user.spec.memberOf.includes(groupName)) {\n user.spec.memberOf.push(groupName);\n }\n }\n }\n buildOrgHierarchy(groups);\n\n for (const group of groups) {\n emit(processingResult.entity(location, group));\n }\n } catch (e) {\n this.logger.error(\n `Failed to read GitHub org data for ${orgConfig.name}: ${e}`,\n );\n }\n }\n\n const allUsers = Array.from(allUsersMap.values());\n for (const user of allUsers) {\n emit(processingResult.entity(location, user));\n }\n\n return true;\n }\n\n // Note: Does not support usage of PATs\n private async getAllOrgs(\n gitHubConfig: GitHubIntegrationConfig,\n ): Promise<GithubMultiOrgConfig> {\n const githubAppMux = new GithubAppCredentialsMux(gitHubConfig);\n const installs = await githubAppMux.getAllInstallations();\n\n return installs\n .map(install =>\n install.target_type === 'Organization' &&\n install.account &&\n install.account.login\n ? {\n name: install.account.login,\n groupNamespace: install.account.login.toLowerCase(),\n }\n : undefined,\n )\n .filter(Boolean) as GithubMultiOrgConfig;\n }\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport {\n DefaultGithubCredentialsProvider,\n GithubCredentialsProvider,\n GithubCredentialType,\n ScmIntegrationRegistry,\n ScmIntegrations,\n} from '@backstage/integration';\nimport {\n CatalogProcessor,\n CatalogProcessorEmit,\n LocationSpec,\n processingResult,\n} from '@backstage/plugin-catalog-backend';\nimport { graphql } from '@octokit/graphql';\nimport { Logger } from 'winston';\nimport {\n assignGroupsToUsers,\n buildOrgHierarchy,\n getOrganizationTeams,\n getOrganizationUsers,\n parseGitHubOrgUrl,\n} from '../lib';\n\ntype GraphQL = typeof graphql;\n\n/**\n * Extracts teams and users out of a GitHub org.\n *\n * @remarks\n *\n * Consider using {@link GitHubOrgEntityProvider} instead.\n *\n * @public\n */\nexport class GithubOrgReaderProcessor implements CatalogProcessor {\n private readonly integrations: ScmIntegrationRegistry;\n private readonly logger: Logger;\n private readonly githubCredentialsProvider: GithubCredentialsProvider;\n\n static fromConfig(\n config: Config,\n options: {\n logger: Logger;\n githubCredentialsProvider?: GithubCredentialsProvider;\n },\n ) {\n const integrations = ScmIntegrations.fromConfig(config);\n\n return new GithubOrgReaderProcessor({\n ...options,\n integrations,\n });\n }\n\n constructor(options: {\n integrations: ScmIntegrationRegistry;\n logger: Logger;\n githubCredentialsProvider?: GithubCredentialsProvider;\n }) {\n this.integrations = options.integrations;\n this.githubCredentialsProvider =\n options.githubCredentialsProvider ||\n DefaultGithubCredentialsProvider.fromIntegrations(this.integrations);\n this.logger = options.logger;\n }\n getProcessorName(): string {\n return 'GithubOrgReaderProcessor';\n }\n\n async readLocation(\n location: LocationSpec,\n _optional: boolean,\n emit: CatalogProcessorEmit,\n ): Promise<boolean> {\n if (location.type !== 'github-org') {\n return false;\n }\n\n const { client, tokenType } = await this.createClient(location.target);\n const { org } = parseGitHubOrgUrl(location.target);\n\n // Read out all of the raw data\n const startTimestamp = Date.now();\n this.logger.info('Reading GitHub users and groups');\n\n const { users } = await getOrganizationUsers(client, org, tokenType);\n const { groups, groupMemberUsers } = await getOrganizationTeams(\n client,\n org,\n );\n\n const duration = ((Date.now() - startTimestamp) / 1000).toFixed(1);\n this.logger.debug(\n `Read ${users.length} GitHub users and ${groups.length} GitHub groups in ${duration} seconds`,\n );\n\n assignGroupsToUsers(users, groupMemberUsers);\n buildOrgHierarchy(groups);\n\n // Done!\n for (const group of groups) {\n emit(processingResult.entity(location, group));\n }\n for (const user of users) {\n emit(processingResult.entity(location, user));\n }\n\n return true;\n }\n\n private async createClient(\n orgUrl: string,\n ): Promise<{ client: GraphQL; tokenType: GithubCredentialType }> {\n const gitHubConfig = this.integrations.github.byUrl(orgUrl)?.config;\n\n if (!gitHubConfig) {\n throw new Error(\n `There is no GitHub Org provider that matches ${orgUrl}. Please add a configuration for an integration.`,\n );\n }\n\n const { headers, type: tokenType } =\n await this.githubCredentialsProvider.getCredentials({\n url: orgUrl,\n });\n\n const client = graphql.defaults({\n baseUrl: gitHubConfig.apiBaseUrl,\n headers,\n });\n\n return { client, tokenType };\n }\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\n\nconst DEFAULT_CATALOG_PATH = '/catalog-info.yaml';\nconst DEFAULT_PROVIDER_ID = 'default';\n\nexport type GitHubEntityProviderConfig = {\n id: string;\n catalogPath: string;\n organization: string;\n filters?: {\n repository?: RegExp;\n branch?: string;\n };\n};\n\nexport function readProviderConfigs(\n config: Config,\n): GitHubEntityProviderConfig[] {\n const providersConfig = config.getOptionalConfig('catalog.providers.github');\n if (!providersConfig) {\n return [];\n }\n\n if (providersConfig.has('organization')) {\n // simple/single config variant\n return [readProviderConfig(DEFAULT_PROVIDER_ID, providersConfig)];\n }\n\n return providersConfig.keys().map(id => {\n const providerConfig = providersConfig.getConfig(id);\n\n return readProviderConfig(id, providerConfig);\n });\n}\n\nfunction readProviderConfig(\n id: string,\n config: Config,\n): GitHubEntityProviderConfig {\n const organization = config.getString('organization');\n const catalogPath =\n config.getOptionalString('catalogPath') ?? DEFAULT_CATALOG_PATH;\n const repositoryPattern = config.getOptionalString('filters.repository');\n const branchPattern = config.getOptionalString('filters.branch');\n\n return {\n id,\n catalogPath,\n organization,\n filters: {\n repository: repositoryPattern\n ? compileRegExp(repositoryPattern)\n : undefined,\n branch: branchPattern || undefined,\n },\n };\n}\n/**\n * Compiles a RegExp while enforcing the pattern to contain\n * the start-of-line and end-of-line anchors.\n *\n * @param pattern\n */\nfunction compileRegExp(pattern: string): RegExp {\n let fullLinePattern = pattern;\n if (!fullLinePattern.startsWith('^')) {\n fullLinePattern = `^${fullLinePattern}`;\n }\n if (!fullLinePattern.endsWith('$')) {\n fullLinePattern = `${fullLinePattern}$`;\n }\n\n return new RegExp(fullLinePattern);\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { TaskRunner } from '@backstage/backend-tasks';\nimport { Config } from '@backstage/config';\nimport {\n GithubCredentialsProvider,\n ScmIntegrations,\n GitHubIntegrationConfig,\n GitHubIntegration,\n SingleInstanceGithubCredentialsProvider,\n} from '@backstage/integration';\nimport {\n EntityProvider,\n EntityProviderConnection,\n LocationSpec,\n locationSpecToLocationEntity,\n} from '@backstage/plugin-catalog-backend';\n\nimport { graphql } from '@octokit/graphql';\nimport * as uuid from 'uuid';\nimport { Logger } from 'winston';\nimport {\n readProviderConfigs,\n GitHubEntityProviderConfig,\n} from './GitHubEntityProviderConfig';\nimport { getOrganizationRepositories, Repository } from '../lib/github';\n\n/**\n * Discovers catalog files located in [GitHub](https://github.com).\n * The provider will search your GitHub account and register catalog files matching the configured path\n * as Location entity and via following processing steps add all contained catalog entities.\n * This can be useful as an alternative to static locations or manually adding things to the catalog.\n *\n * @public\n */\nexport class GitHubEntityProvider implements EntityProvider {\n private readonly config: GitHubEntityProviderConfig;\n private readonly logger: Logger;\n private readonly integration: GitHubIntegrationConfig;\n private readonly scheduleFn: () => Promise<void>;\n private connection?: EntityProviderConnection;\n private readonly githubCredentialsProvider: GithubCredentialsProvider;\n\n static fromConfig(\n config: Config,\n options: {\n logger: Logger;\n schedule: TaskRunner;\n },\n ): GitHubEntityProvider[] {\n const integrations = ScmIntegrations.fromConfig(config);\n const integration = integrations.github.byHost('github.com');\n\n if (!integration) {\n throw new Error(\n `There is no GitHub config that matches github. Please add a configuration entry for it under integrations.github`,\n );\n }\n\n return readProviderConfigs(config).map(\n providerConfig =>\n new GitHubEntityProvider(\n providerConfig,\n integration,\n options.logger,\n options.schedule,\n ),\n );\n }\n\n private constructor(\n config: GitHubEntityProviderConfig,\n integration: GitHubIntegration,\n logger: Logger,\n schedule: TaskRunner,\n ) {\n this.config = config;\n this.integration = integration.config;\n this.logger = logger.child({\n target: this.getProviderName(),\n });\n this.scheduleFn = this.createScheduleFn(schedule);\n this.githubCredentialsProvider =\n SingleInstanceGithubCredentialsProvider.create(integration.config);\n this.scheduleFn = this.createScheduleFn(schedule);\n }\n\n /** {@inheritdoc @backstage/plugin-catalog-backend#EntityProvider.getProviderName} */\n getProviderName(): string {\n return `github-provider:${this.config.id}`;\n }\n\n /** {@inheritdoc @backstage/plugin-catalog-backend#EntityProvider.connect} */\n async connect(connection: EntityProviderConnection): Promise<void> {\n this.connection = connection;\n return await this.scheduleFn();\n }\n\n private createScheduleFn(schedule: TaskRunner): () => Promise<void> {\n return async () => {\n const taskId = `${this.getProviderName()}:refresh`;\n return schedule.run({\n id: taskId,\n fn: async () => {\n const logger = this.logger.child({\n class: GitHubEntityProvider.prototype.constructor.name,\n taskId,\n taskInstanceId: uuid.v4(),\n });\n try {\n await this.refresh(logger);\n } catch (error) {\n logger.error(error);\n }\n },\n });\n };\n }\n\n async refresh(logger: Logger) {\n if (!this.connection) {\n throw new Error('Not initialized');\n }\n\n const targets = await this.findCatalogFiles();\n const matchingTargets = this.matchesFilters(targets);\n const entities = matchingTargets\n .map(repository => this.createLocationUrl(repository))\n .map(GitHubEntityProvider.toLocationSpec)\n .map(location => {\n return {\n locationKey: this.getProviderName(),\n entity: locationSpecToLocationEntity({ location }),\n };\n });\n\n await this.connection.applyMutation({\n type: 'full',\n entities,\n });\n\n logger.info(\n `Read ${targets.length} GitHub repositories (${entities.length} matching the pattern)`,\n );\n }\n\n // go to the server and get all of the repositories\n private async findCatalogFiles(): Promise<Repository[]> {\n const organization = this.config.organization;\n const host = this.integration.host;\n const orgUrl = `https://${host}/${organization}`;\n\n const { headers } = await this.githubCredentialsProvider.getCredentials({\n url: orgUrl,\n });\n\n const client = graphql.defaults({\n baseUrl: this.integration.apiBaseUrl,\n headers,\n });\n\n const { repositories } = await getOrganizationRepositories(\n client,\n organization,\n );\n\n return repositories;\n }\n\n private matchesFilters(repositories: Repository[]) {\n const repositoryFilter = this.config.filters?.repository;\n\n const matchingRepositories = repositories.filter(r => {\n return (\n !r.isArchived &&\n (!repositoryFilter || repositoryFilter.test(r.name)) &&\n r.defaultBranchRef?.name\n );\n });\n return matchingRepositories;\n }\n\n private createLocationUrl(repository: Repository): string {\n const branch =\n this.config.filters?.branch || repository.defaultBranchRef?.name || '-';\n const catalogFile = this.config.catalogPath.startsWith('/')\n ? this.config.catalogPath.substring(1)\n : this.config.catalogPath;\n return `${repository.url}/blob/${branch}/${catalogFile}`;\n }\n\n private static toLocationSpec(target: string): LocationSpec {\n return {\n type: 'url',\n target: target,\n presence: 'optional',\n };\n }\n}\n\n/*\n * Helpers\n */\n\nexport function parseUrl(urlString: string): {\n org: string;\n repoSearchPath: RegExp;\n catalogPath: string;\n branch: string;\n host: string;\n} {\n const url = new URL(urlString);\n const path = url.pathname.substr(1).split('/');\n\n // /backstage/techdocs-*/blob/master/catalog-info.yaml\n // can also be\n // /backstage\n if (path.length > 2 && path[0].length && path[1].length) {\n return {\n org: decodeURIComponent(path[0]),\n repoSearchPath: escapeRegExp(decodeURIComponent(path[1])),\n catalogPath: `/${decodeURIComponent(path.slice(4).join('/'))}`,\n branch: decodeURIComponent(path[3]),\n host: url.host,\n };\n } else if (path.length === 1 && path[0].length) {\n return {\n org: decodeURIComponent(path[0]),\n repoSearchPath: escapeRegExp('*'),\n catalogPath: '/catalog-info.yaml',\n branch: '-',\n host: url.host,\n };\n }\n\n throw new Error(`Failed to parse ${urlString}`);\n}\n\nexport function escapeRegExp(str: string): RegExp {\n return new RegExp(`^${str.replace(/\\*/g, '.*')}$`);\n}\n","/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { TaskRunner } from '@backstage/backend-tasks';\nimport {\n ANNOTATION_LOCATION,\n ANNOTATION_ORIGIN_LOCATION,\n Entity,\n} from '@backstage/catalog-model';\nimport { Config } from '@backstage/config';\nimport {\n DefaultGithubCredentialsProvider,\n GithubCredentialsProvider,\n GitHubIntegrationConfig,\n ScmIntegrations,\n SingleInstanceGithubCredentialsProvider,\n} from '@backstage/integration';\nimport {\n EntityProvider,\n EntityProviderConnection,\n} from '@backstage/plugin-catalog-backend';\nimport { graphql } from '@octokit/graphql';\nimport { merge } from 'lodash';\nimport * as uuid from 'uuid';\nimport { Logger } from 'winston';\nimport {\n assignGroupsToUsers,\n buildOrgHierarchy,\n getOrganizationTeams,\n getOrganizationUsers,\n parseGitHubOrgUrl,\n} from '../lib';\n\n/**\n * Options for {@link GitHubOrgEntityProvider}.\n *\n * @public\n */\nexport interface GitHubOrgEntityProviderOptions {\n /**\n * A unique, stable identifier for this provider.\n *\n * @example \"production\"\n */\n id: string;\n\n /**\n * The target that this provider should consume.\n *\n * @example \"https://github.com/backstage\"\n */\n orgUrl: string;\n\n /**\n * The refresh schedule to use.\n *\n * @defaultValue \"manual\"\n * @remarks\n *\n * If you pass in 'manual', you are responsible for calling the `read` method\n * manually at some interval.\n *\n * But more commonly you will pass in the result of\n * {@link @backstage/backend-tasks#PluginTaskScheduler.createScheduledTaskRunner}\n * to enable automatic scheduling of tasks.\n */\n schedule?: 'manual' | TaskRunner;\n\n /**\n * The logger to use.\n */\n logger: Logger;\n\n /**\n * Optionally supply a custom credentials provider, replacing the default one.\n */\n githubCredentialsProvider?: GithubCredentialsProvider;\n}\n\n// TODO: Consider supporting an (optional) webhook that reacts on org changes\n/**\n * Ingests org data (users and groups) from GitHub.\n *\n * @public\n */\nexport class GitHubOrgEntityProvider implements EntityProvider {\n private readonly credentialsProvider: GithubCredentialsProvider;\n private connection?: EntityProviderConnection;\n private scheduleFn?: () => Promise<void>;\n\n static fromConfig(config: Config, options: GitHubOrgEntityProviderOptions) {\n const integrations = ScmIntegrations.fromConfig(config);\n const gitHubConfig = integrations.github.byUrl(options.orgUrl)?.config;\n\n if (!gitHubConfig) {\n throw new Error(\n `There is no GitHub Org provider that matches ${options.orgUrl}. Please add a configuration for an integration.`,\n );\n }\n\n const logger = options.logger.child({\n target: options.orgUrl,\n });\n\n const provider = new GitHubOrgEntityProvider({\n id: options.id,\n orgUrl: options.orgUrl,\n logger,\n gitHubConfig,\n githubCredentialsProvider:\n options.githubCredentialsProvider ||\n DefaultGithubCredentialsProvider.fromIntegrations(integrations),\n });\n\n provider.schedule(options.schedule);\n\n return provider;\n }\n\n constructor(\n private options: {\n id: string;\n orgUrl: string;\n gitHubConfig: GitHubIntegrationConfig;\n logger: Logger;\n githubCredentialsProvider?: GithubCredentialsProvider;\n },\n ) {\n this.credentialsProvider =\n options.githubCredentialsProvider ||\n SingleInstanceGithubCredentialsProvider.create(this.options.gitHubConfig);\n }\n\n /** {@inheritdoc @backstage/plugin-catalog-backend#EntityProvider.getProviderName} */\n getProviderName() {\n return `GitHubOrgEntityProvider:${this.options.id}`;\n }\n\n /** {@inheritdoc @backstage/plugin-catalog-backend#EntityProvider.connect} */\n async connect(connection: EntityProviderConnection) {\n this.connection = connection;\n await this.scheduleFn?.();\n }\n\n /**\n * Runs one single complete ingestion. This is only necessary if you use\n * manual scheduling.\n */\n async read(options?: { logger?: Logger }) {\n if (!this.connection) {\n throw new Error('Not initialized');\n }\n\n const logger = options?.logger ?? this.options.logger;\n const { markReadComplete } = trackProgress(logger);\n\n const { headers, type: tokenType } =\n await this.credentialsProvider.getCredentials({\n url: this.options.orgUrl,\n });\n const client = graphql.defaults({\n baseUrl: this.options.gitHubConfig.apiBaseUrl,\n headers,\n });\n\n const { org } = parseGitHubOrgUrl(this.options.orgUrl);\n const { users } = await getOrganizationUsers(client, org, tokenType);\n const { groups, groupMemberUsers } = await getOrganizationTeams(\n client,\n org,\n );\n assignGroupsToUsers(users, groupMemberUsers);\n buildOrgHierarchy(groups);\n\n const { markCommitComplete } = markReadComplete({ users, groups });\n\n await this.connection.applyMutation({\n type: 'full',\n entities: [...users, ...groups].map(entity => ({\n locationKey: `github-org-provider:${this.options.id}`,\n entity: withLocations(\n `https://${this.options.gitHubConfig.host}`,\n org,\n entity,\n ),\n })),\n });\n\n markCommitComplete();\n }\n\n private schedule(schedule: GitHubOrgEntityProviderOptions['schedule']) {\n if (!schedule || schedule === 'manual') {\n return;\n }\n\n this.scheduleFn = async () => {\n const id = `${this.getProviderName()}:refresh`;\n await schedule.run({\n id,\n fn: async () => {\n const logger = this.options.logger.child({\n class: GitHubOrgEntityProvider.prototype.constructor.name,\n taskId: id,\n taskInstanceId: uuid.v4(),\n });\n\n try {\n await this.read({ logger });\n } catch (error) {\n logger.error(error);\n }\n },\n });\n };\n }\n}\n\n// Helps wrap the timing and logging behaviors\nfunction trackProgress(logger: Logger) {\n let timestamp = Date.now();\n let summary: string;\n\n logger.info('Reading GitHub users and groups');\n\n function markReadComplete(read: { users: unknown[]; groups: unknown[] }) {\n summary = `${read.users.length} GitHub users and ${read.groups.length} GitHub groups`;\n const readDuration = ((Date.now() - timestamp) / 1000).toFixed(1);\n timestamp = Date.now();\n logger.info(`Read ${summary} in ${readDuration} seconds. Committing...`);\n return { markCommitComplete };\n }\n\n function markCommitComplete() {\n const commitDuration = ((Date.now() - timestamp) / 1000).toFixed(1);\n logger.info(`Committed ${summary} in ${commitDuration} seconds.`);\n }\n\n return { markReadComplete };\n}\n\n// Makes sure that emitted entities have a proper location\nexport function withLocations(\n baseUrl: string,\n org: string,\n entity: Entity,\n): Entity {\n const location =\n entity.kind === 'Group'\n ? `url:${baseUrl}/orgs/${org}/teams/${entity.metadata.name}`\n : `url:${baseUrl}/${entity.metadata.name}`;\n return merge(\n {\n metadata: {\n annotations: {\n [ANNOTATION_LOCATION]: location,\n [ANNOTATION_ORIGIN_LOCATION]: location,\n },\n },\n },\n entity,\n ) as Entity;\n}\n","/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n createBackendModule,\n loggerToWinstonLogger,\n configServiceRef,\n loggerServiceRef,\n schedulerServiceRef,\n} from '@backstage/backend-plugin-api';\nimport { TaskScheduleDefinition } from '@backstage/backend-tasks';\nimport { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node';\nimport { GitHubEntityProvider } from './providers/GitHubEntityProvider';\n\n/**\n * Options for {@link githubEntityProviderCatalogModule}.\n *\n * @alpha\n */\nexport type GithubEntityProviderCatalogModuleOptions = {\n schedule?: TaskScheduleDefinition;\n};\n\n/**\n * Registers the GitHubEntityProvider with the catalog processing extension point.\n *\n * @alpha\n */\nexport const githubEntityProviderCatalogModule = createBackendModule({\n pluginId: 'catalog',\n moduleId: 'github-entity-provider',\n register(env, options?: GithubEntityProviderCatalogModuleOptions) {\n env.registerInit({\n deps: {\n config: configServiceRef,\n catalog: catalogProcessingExtensionPoint,\n logger: loggerServiceRef,\n scheduler: schedulerServiceRef,\n },\n async init({ config, catalog, logger, scheduler }) {\n const scheduleDef = options?.schedule ?? {\n frequency: { seconds: 600 },\n timeout: { seconds: 900 },\n initialDelay: { seconds: 3 },\n };\n\n catalog.addEntityProvider(\n GitHubEntityProvider.fromConfig(config, {\n logger: loggerToWinstonLogger(logger),\n schedule: scheduler.createScheduledTaskRunner(scheduleDef),\n }),\n );\n },\n });\n },\n});\n"],"names":["ScmIntegrations","DefaultGithubCredentialsProvider","graphql","processingResult","GithubAppCredentialsMux","integration","SingleInstanceGithubCredentialsProvider","uuid","locationSpecToLocationEntity","merge","ANNOTATION_LOCATION","ANNOTATION_ORIGIN_LOCATION","createBackendModule","configServiceRef","catalogProcessingExtensionPoint","loggerServiceRef","schedulerServiceRef","loggerToWinstonLogger"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,SAAS,wBAAwB,CAAC,MAAM,EAAE;AACjD,EAAE,IAAI,EAAE,CAAC;AACT,EAAE,MAAM,UAAU,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,sBAAsB,CAAC,MAAM,CAAC,KAAK,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC;AACpF,EAAE,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK;AAC/B,IAAI,IAAI,GAAG,EAAE,EAAE,CAAC;AAChB,IAAI,OAAO;AACX,MAAM,IAAI,EAAE,CAAC,CAAC,SAAS,CAAC,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AChC,QAAQ,OAAO,EAAEC,iDAA+B;AAChD,QAAQ,MAAM,EAAEC,iCAAgB;AAChC,QAAQ,SAAS,EAAEC,oCAAmB;AACtC,OAAO;AACP,MAAM,MAAM,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE;AACzD,QAAQ,IAAI,EAAE,CAAC;AACf,QAAQ,MAAM,WAAW,GAAG,CAAC,EAAE,GAAG,OAAO,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,OAAO,CAAC,QAAQ,KAAK,IAAI,GAAG,EAAE,GAAG;AAC9F,UAAU,SAAS,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE;AACrC,UAAU,OAAO,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE;AACnC,UAAU,YAAY,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE;AACtC,SAAS,CAAC;AACV,QAAQ,OAAO,CAAC,iBAAiB;AACjC,UAAU,oBAAoB,CAAC,UAAU,CAAC,MAAM,EAAE;AAClD,YAAY,MAAM,EAAEC,sCAAqB,CAAC,MAAM,CAAC;AACjD,YAAY,QAAQ,EAAE,SAAS,CAAC,yBAAyB,CAAC,WAAW,CAAC;AACtE,WAAW,CAAC;AACZ,SAAS,CAAC;AACV,OAAO;AACP,KAAK,CAAC,CAAC;AACP,GAAG;AACH,CAAC;;;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,8 +1,22 @@
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';
1
10
  import { Config } from '@backstage/config';
2
- import { GithubCredentialsProvider, ScmIntegrationRegistry, GitHubIntegrationConfig } from '@backstage/integration';
3
- import { CatalogProcessor, LocationSpec, CatalogProcessorEmit, EntityProvider, EntityProviderConnection } from '@backstage/plugin-catalog-backend';
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';
4
16
  import { Logger } from 'winston';
17
+ import { ScmIntegrationRegistry } from '@backstage/integration';
5
18
  import { TaskRunner } from '@backstage/backend-tasks';
19
+ import { TaskScheduleDefinition } from '@backstage/backend-tasks';
6
20
 
7
21
  /**
8
22
  * Extracts repositories out of a GitHub org.
@@ -20,7 +34,7 @@ import { TaskRunner } from '@backstage/backend-tasks';
20
34
  *
21
35
  * @public
22
36
  **/
23
- declare class GithubDiscoveryProcessor implements CatalogProcessor {
37
+ export declare class GithubDiscoveryProcessor implements CatalogProcessor {
24
38
  private readonly integrations;
25
39
  private readonly logger;
26
40
  private readonly githubCredentialsProvider;
@@ -37,11 +51,47 @@ declare class GithubDiscoveryProcessor implements CatalogProcessor {
37
51
  readLocation(location: LocationSpec, _optional: boolean, emit: CatalogProcessorEmit): Promise<boolean>;
38
52
  }
39
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
+
40
90
  /**
41
91
  * The configuration parameters for a multi-org GitHub processor.
42
92
  * @public
43
93
  */
44
- declare type GithubMultiOrgConfig = Array<{
94
+ export declare type GithubMultiOrgConfig = Array<{
45
95
  /**
46
96
  * The name of the GitHub org to process.
47
97
  */
@@ -63,7 +113,7 @@ declare type GithubMultiOrgConfig = Array<{
63
113
  *
64
114
  * @public
65
115
  */
66
- declare class GithubMultiOrgReaderProcessor implements CatalogProcessor {
116
+ export declare class GithubMultiOrgReaderProcessor implements CatalogProcessor {
67
117
  private readonly integrations;
68
118
  private readonly orgs;
69
119
  private readonly logger;
@@ -84,62 +134,35 @@ declare class GithubMultiOrgReaderProcessor implements CatalogProcessor {
84
134
  }
85
135
 
86
136
  /**
87
- * Extracts teams and users out of a GitHub org.
88
- *
89
- * @remarks
90
- *
91
- * Consider using {@link GitHubOrgEntityProvider} instead.
137
+ * Ingests org data (users and groups) from GitHub.
92
138
  *
93
139
  * @public
94
140
  */
95
- declare class GithubOrgReaderProcessor implements CatalogProcessor {
96
- private readonly integrations;
97
- private readonly logger;
98
- private readonly githubCredentialsProvider;
99
- static fromConfig(config: Config, options: {
100
- logger: Logger;
101
- githubCredentialsProvider?: GithubCredentialsProvider;
102
- }): GithubOrgReaderProcessor;
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;
103
147
  constructor(options: {
104
- integrations: ScmIntegrationRegistry;
148
+ id: string;
149
+ orgUrl: string;
150
+ gitHubConfig: GitHubIntegrationConfig;
105
151
  logger: Logger;
106
152
  githubCredentialsProvider?: GithubCredentialsProvider;
107
153
  });
108
- getProcessorName(): string;
109
- readLocation(location: LocationSpec, _optional: boolean, emit: CatalogProcessorEmit): Promise<boolean>;
110
- private createClient;
111
- }
112
-
113
- /**
114
- * Discovers catalog files located in [GitHub](https://github.com).
115
- * The provider will search your GitHub account and register catalog files matching the configured path
116
- * as Location entity and via following processing steps add all contained catalog entities.
117
- * This can be useful as an alternative to static locations or manually adding things to the catalog.
118
- *
119
- * @public
120
- */
121
- declare class GitHubEntityProvider implements EntityProvider {
122
- private readonly config;
123
- private readonly logger;
124
- private readonly integration;
125
- private readonly scheduleFn;
126
- private connection?;
127
- private readonly githubCredentialsProvider;
128
- static fromConfig(config: Config, options: {
129
- logger: Logger;
130
- schedule: TaskRunner;
131
- }): GitHubEntityProvider[];
132
- private constructor();
133
154
  /** {@inheritdoc @backstage/plugin-catalog-backend#EntityProvider.getProviderName} */
134
155
  getProviderName(): string;
135
156
  /** {@inheritdoc @backstage/plugin-catalog-backend#EntityProvider.connect} */
136
157
  connect(connection: EntityProviderConnection): Promise<void>;
137
- private createScheduleFn;
138
- refresh(logger: Logger): Promise<void>;
139
- private findCatalogFiles;
140
- private matchesFilters;
141
- private createLocationUrl;
142
- private static toLocationSpec;
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;
143
166
  }
144
167
 
145
168
  /**
@@ -147,7 +170,7 @@ declare class GitHubEntityProvider implements EntityProvider {
147
170
  *
148
171
  * @public
149
172
  */
150
- interface GitHubOrgEntityProviderOptions {
173
+ export declare interface GitHubOrgEntityProviderOptions {
151
174
  /**
152
175
  * A unique, stable identifier for this provider.
153
176
  *
@@ -183,36 +206,32 @@ interface GitHubOrgEntityProviderOptions {
183
206
  */
184
207
  githubCredentialsProvider?: GithubCredentialsProvider;
185
208
  }
209
+
186
210
  /**
187
- * Ingests org data (users and groups) from GitHub.
211
+ * Extracts teams and users out of a GitHub org.
212
+ *
213
+ * @remarks
214
+ *
215
+ * Consider using {@link GitHubOrgEntityProvider} instead.
188
216
  *
189
217
  * @public
190
218
  */
191
- declare class GitHubOrgEntityProvider implements EntityProvider {
192
- private options;
193
- private readonly credentialsProvider;
194
- private connection?;
195
- private scheduleFn?;
196
- static fromConfig(config: Config, options: GitHubOrgEntityProviderOptions): GitHubOrgEntityProvider;
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;
197
227
  constructor(options: {
198
- id: string;
199
- orgUrl: string;
200
- gitHubConfig: GitHubIntegrationConfig;
228
+ integrations: ScmIntegrationRegistry;
201
229
  logger: Logger;
202
230
  githubCredentialsProvider?: GithubCredentialsProvider;
203
231
  });
204
- /** {@inheritdoc @backstage/plugin-catalog-backend#EntityProvider.getProviderName} */
205
- getProviderName(): string;
206
- /** {@inheritdoc @backstage/plugin-catalog-backend#EntityProvider.connect} */
207
- connect(connection: EntityProviderConnection): Promise<void>;
208
- /**
209
- * Runs one single complete ingestion. This is only necessary if you use
210
- * manual scheduling.
211
- */
212
- read(options?: {
213
- logger?: Logger;
214
- }): Promise<void>;
215
- private schedule;
232
+ getProcessorName(): string;
233
+ readLocation(location: LocationSpec, _optional: boolean, emit: CatalogProcessorEmit): Promise<boolean>;
234
+ private createClient;
216
235
  }
217
236
 
218
- export { GitHubEntityProvider, GitHubOrgEntityProvider, GitHubOrgEntityProviderOptions, GithubDiscoveryProcessor, GithubMultiOrgConfig, GithubMultiOrgReaderProcessor, GithubOrgReaderProcessor };
237
+ export { }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@backstage/plugin-catalog-backend-module-github",
3
3
  "description": "A Backstage catalog backend module that helps integrate towards GitHub",
4
- "version": "0.1.6",
4
+ "version": "0.1.7-next.0",
5
5
  "main": "dist/index.cjs.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "Apache-2.0",
@@ -9,7 +9,8 @@
9
9
  "publishConfig": {
10
10
  "access": "public",
11
11
  "main": "dist/index.cjs.js",
12
- "types": "dist/index.d.ts"
12
+ "types": "dist/index.d.ts",
13
+ "alphaTypes": "dist/index.alpha.d.ts"
13
14
  },
14
15
  "backstage": {
15
16
  "role": "backend-plugin-module"
@@ -24,7 +25,7 @@
24
25
  "backstage"
25
26
  ],
26
27
  "scripts": {
27
- "build": "backstage-cli package build",
28
+ "build": "backstage-cli package build --experimental-type-build",
28
29
  "lint": "backstage-cli package lint",
29
30
  "test": "backstage-cli package test",
30
31
  "prepack": "backstage-cli package prepack",
@@ -33,30 +34,33 @@
33
34
  "start": "backstage-cli package start"
34
35
  },
35
36
  "dependencies": {
36
- "@backstage/backend-common": "^0.15.0",
37
- "@backstage/backend-tasks": "^0.3.4",
37
+ "@backstage/backend-common": "^0.15.1-next.0",
38
+ "@backstage/backend-plugin-api": "^0.1.2-next.0",
39
+ "@backstage/backend-tasks": "^0.3.5-next.0",
38
40
  "@backstage/catalog-model": "^1.1.0",
39
41
  "@backstage/config": "^1.0.1",
40
42
  "@backstage/errors": "^1.1.0",
41
- "@backstage/integration": "^1.3.0",
42
- "@backstage/plugin-catalog-backend": "^1.3.1",
43
+ "@backstage/integration": "^1.3.1-next.0",
44
+ "@backstage/plugin-catalog-backend": "^1.3.2-next.0",
45
+ "@backstage/plugin-catalog-node": "^1.0.2-next.0",
43
46
  "@backstage/types": "^1.0.0",
44
47
  "@octokit/graphql": "^5.0.0",
45
48
  "lodash": "^4.17.21",
46
- "msw": "^0.44.0",
49
+ "msw": "^0.45.0",
47
50
  "node-fetch": "^2.6.7",
48
51
  "uuid": "^8.0.0",
49
52
  "winston": "^3.2.1"
50
53
  },
51
54
  "devDependencies": {
52
- "@backstage/backend-test-utils": "^0.1.27",
53
- "@backstage/cli": "^0.18.1",
55
+ "@backstage/backend-test-utils": "^0.1.28-next.0",
56
+ "@backstage/cli": "^0.18.2-next.0",
54
57
  "@types/lodash": "^4.14.151"
55
58
  },
56
59
  "files": [
57
60
  "dist",
61
+ "alpha",
58
62
  "config.d.ts"
59
63
  ],
60
64
  "configSchema": "config.d.ts",
61
- "gitHead": "a12f6269e3bf224aa7f52475be9152bc52addeed"
65
+ "gitHead": "c6c0b1978a7ab4d29d813996c56beb7e6b48a268"
62
66
  }