@backstage/plugin-catalog-backend-module-github 0.1.7-next.3 → 0.1.8-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 +38 -0
- package/alpha/package.json +1 -1
- package/dist/index.cjs.js +0 -1
- package/dist/index.cjs.js.map +1 -1
- package/package.json +14 -15
- package/LICENSE +0 -201
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-backend-module-github
|
|
2
2
|
|
|
3
|
+
## 0.1.8-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/catalog-model@1.1.2-next.0
|
|
9
|
+
- @backstage/backend-plugin-api@0.1.3-next.0
|
|
10
|
+
- @backstage/plugin-catalog-backend@1.4.1-next.0
|
|
11
|
+
- @backstage/plugin-catalog-node@1.1.1-next.0
|
|
12
|
+
- @backstage/backend-common@0.15.2-next.0
|
|
13
|
+
- @backstage/backend-tasks@0.3.6-next.0
|
|
14
|
+
- @backstage/config@1.0.3-next.0
|
|
15
|
+
- @backstage/errors@1.1.2-next.0
|
|
16
|
+
- @backstage/integration@1.3.2-next.0
|
|
17
|
+
- @backstage/types@1.0.0
|
|
18
|
+
|
|
19
|
+
## 0.1.7
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- 3c4a388537: New experimental alpha exports for use with the upcoming backend system.
|
|
24
|
+
- 667d917488: Updated dependency `msw` to `^0.47.0`.
|
|
25
|
+
- 87ec2ba4d6: Updated dependency `msw` to `^0.46.0`.
|
|
26
|
+
- bf5e9030eb: Updated dependency `msw` to `^0.45.0`.
|
|
27
|
+
- 3a62594a11: Add support for including (or excluding) Github repositories by topic
|
|
28
|
+
- 287a64bf97: Added the ability to configure the host for the `GitHubEntityProvider` to use against GitHub Enterprise
|
|
29
|
+
- 91e2abbd46: Remove the duplicated `scheduleFn` initialization in `GitHubEntityProvider`.
|
|
30
|
+
- Updated dependencies
|
|
31
|
+
- @backstage/backend-plugin-api@0.1.2
|
|
32
|
+
- @backstage/backend-common@0.15.1
|
|
33
|
+
- @backstage/plugin-catalog-node@1.1.0
|
|
34
|
+
- @backstage/integration@1.3.1
|
|
35
|
+
- @backstage/plugin-catalog-backend@1.4.0
|
|
36
|
+
- @backstage/backend-tasks@0.3.5
|
|
37
|
+
- @backstage/catalog-model@1.1.1
|
|
38
|
+
- @backstage/config@1.0.2
|
|
39
|
+
- @backstage/errors@1.1.1
|
|
40
|
+
|
|
3
41
|
## 0.1.7-next.3
|
|
4
42
|
|
|
5
43
|
### Patch Changes
|
package/alpha/package.json
CHANGED
package/dist/index.cjs.js
CHANGED
|
@@ -703,7 +703,6 @@ class GitHubEntityProvider {
|
|
|
703
703
|
});
|
|
704
704
|
this.scheduleFn = this.createScheduleFn(schedule);
|
|
705
705
|
this.githubCredentialsProvider = integration.SingleInstanceGithubCredentialsProvider.create(integration$1.config);
|
|
706
|
-
this.scheduleFn = this.createScheduleFn(schedule);
|
|
707
706
|
}
|
|
708
707
|
getProviderName() {
|
|
709
708
|
return `github-provider:${this.config.id}`;
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -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","../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 repositoryTopics: RepositoryTopics;\n defaultBranchRef: {\n name: string;\n } | null;\n};\n\ntype RepositoryTopics = {\n nodes: TopicNodes[];\n};\n\ntype TopicNodes = {\n topic: {\n name: string;\n };\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 repositoryTopics(first: 100) {\n nodes {\n ... on RepositoryTopic {\n topic {\n name\n }\n }\n }\n }\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\nimport { GithubTopicFilters } from '../providers/GitHubEntityProviderConfig';\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\nexport function satisfiesTopicFilter(\n topics: string[],\n topicFilter: GithubTopicFilters | undefined,\n): Boolean {\n // We don't want to do anything if a filter is not configured (or configured but empty)\n if (!topicFilter) return true;\n if (!topicFilter.include && !topicFilter.exclude) return true;\n if (!topicFilter.include?.length && !topicFilter.exclude?.length) return true;\n // If topic.include is in use, a topic MUST be set that matches the inclusion\n // filter in order for a repository to be ingested\n if (topicFilter.include?.length && !topicFilter.exclude) {\n for (const topic of topics) {\n if (topicFilter.include.includes(topic)) return true;\n }\n return false;\n }\n // If topic.exclude is in use, all topics are included by default\n // with anything matching the filter being discarded. It is technically\n // possible for the filter to be explicitly empty meaning all repositories\n // are ingested although doing so would be pointless.\n if (!topicFilter.include && topicFilter.exclude?.length) {\n if (!topics.length) return true;\n for (const topic of topics) {\n if (topicFilter.exclude.includes(topic)) return false;\n }\n return true;\n }\n // Now the tricky part is where we have both include and exclude configured.\n // In this case, exclude wins out so we take everything matching the initial\n // inclusion filter and from that group, we further discard anything matching\n // the exclusion filter. If an item were to have a topic set in both filters,\n // we expect it to be discarded in the end. The use case here is that is that\n // you may want to retrieve all repos with the topic of team-a while excluding\n // matching repos that are marked as experiments.\n if (topicFilter.include && topicFilter.exclude) {\n const matchesInclude = satisfiesTopicFilter(topics, {\n include: topicFilter.include,\n });\n const matchesExclude = !satisfiesTopicFilter(topics, {\n exclude: topicFilter.exclude,\n });\n if (matchesExclude) return false;\n return matchesInclude;\n }\n\n // If the topic filter is somehow ever in a state that is not covered here, we\n // will fail \"open\" so that Backstage is still usable as if the filter was\n // not configured at all.\n return true;\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 host: string;\n filters?: {\n repository?: RegExp;\n branch?: string;\n topic?: GithubTopicFilters;\n };\n};\n\nexport type GithubTopicFilters = {\n exclude?: string[];\n include?: string[];\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 host = config.getOptionalString('host') ?? 'github.com';\n const repositoryPattern = config.getOptionalString('filters.repository');\n const branchPattern = config.getOptionalString('filters.branch');\n const topicFilterInclude = config?.getOptionalStringArray(\n 'filters.topic.include',\n );\n const topicFilterExclude = config?.getOptionalStringArray(\n 'filters.topic.exclude',\n );\n\n return {\n id,\n catalogPath,\n organization,\n host,\n filters: {\n repository: repositoryPattern\n ? compileRegExp(repositoryPattern)\n : undefined,\n branch: branchPattern || undefined,\n topic: {\n include: topicFilterInclude,\n exclude: topicFilterExclude,\n },\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';\nimport { satisfiesTopicFilter } from '../lib/util';\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\n return readProviderConfigs(config).map(providerConfig => {\n const integrationHost = providerConfig.host;\n const integration = integrations.github.byHost(integrationHost);\n\n if (!integration) {\n throw new Error(\n `There is no GitHub config that matches host ${integrationHost}. Please add a configuration entry for it under integrations.github`,\n );\n }\n\n return 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 const topicFilters = this.config.filters?.topic;\n\n const matchingRepositories = repositories.filter(r => {\n const repoTopics: string[] = r.repositoryTopics.nodes.map(\n node => node.topic.name,\n );\n return (\n !r.isArchived &&\n (!repositoryFilter || repositoryFilter.test(r.name)) &&\n satisfiesTopicFilter(repoTopics, topicFilters) &&\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":["_a","ScmIntegrations","DefaultGithubCredentialsProvider","graphql","processingResult","GithubAppCredentialsMux","integration","SingleInstanceGithubCredentialsProvider","uuid","locationSpecToLocationEntity","merge","ANNOTATION_LOCATION","ANNOTATION_ORIGIN_LOCATION","createBackendModule","configServi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ACT,MAAQ,EAAAC,iCAAA;AAAA,QACR,SAAW,EAAAC,oCAAA;AAAA,OACb;AAAA,MACA,MAAM,IAAK,CAAA,EAAE,QAAQ,OAAS,EAAA,MAAA,EAAQ,WAAa,EAAA;AApDzD,QAAA,IAAA,EAAA,CAAA;AAqDQ,QAAM,MAAA,WAAA,GAAA,CAAc,EAAS,GAAA,OAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,OAAA,CAAA,QAAA,KAAT,IAAqB,GAAA,EAAA,GAAA;AAAA,UACvC,SAAA,EAAW,EAAE,OAAA,EAAS,GAAI,EAAA;AAAA,UAC1B,OAAA,EAAS,EAAE,OAAA,EAAS,GAAI,EAAA;AAAA,UACxB,YAAA,EAAc,EAAE,OAAA,EAAS,CAAE,EAAA;AAAA,SAC7B,CAAA;AAEA,QAAQ,OAAA,CAAA,iBAAA;AAAA,UACN,oBAAA,CAAqB,WAAW,MAAQ,EAAA;AAAA,YACtC,MAAA,EAAQC,uCAAsB,MAAM,CAAA;AAAA,YACpC,QAAA,EAAU,SAAU,CAAA,yBAAA,CAA0B,WAAW,CAAA;AAAA,WAC1D,CAAA;AAAA,SACH,CAAA;AAAA,OACF;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;;;;;;"}
|
|
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 repositoryTopics: RepositoryTopics;\n defaultBranchRef: {\n name: string;\n } | null;\n};\n\ntype RepositoryTopics = {\n nodes: TopicNodes[];\n};\n\ntype TopicNodes = {\n topic: {\n name: string;\n };\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 repositoryTopics(first: 100) {\n nodes {\n ... on RepositoryTopic {\n topic {\n name\n }\n }\n }\n }\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\nimport { GithubTopicFilters } from '../providers/GitHubEntityProviderConfig';\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\nexport function satisfiesTopicFilter(\n topics: string[],\n topicFilter: GithubTopicFilters | undefined,\n): Boolean {\n // We don't want to do anything if a filter is not configured (or configured but empty)\n if (!topicFilter) return true;\n if (!topicFilter.include && !topicFilter.exclude) return true;\n if (!topicFilter.include?.length && !topicFilter.exclude?.length) return true;\n // If topic.include is in use, a topic MUST be set that matches the inclusion\n // filter in order for a repository to be ingested\n if (topicFilter.include?.length && !topicFilter.exclude) {\n for (const topic of topics) {\n if (topicFilter.include.includes(topic)) return true;\n }\n return false;\n }\n // If topic.exclude is in use, all topics are included by default\n // with anything matching the filter being discarded. It is technically\n // possible for the filter to be explicitly empty meaning all repositories\n // are ingested although doing so would be pointless.\n if (!topicFilter.include && topicFilter.exclude?.length) {\n if (!topics.length) return true;\n for (const topic of topics) {\n if (topicFilter.exclude.includes(topic)) return false;\n }\n return true;\n }\n // Now the tricky part is where we have both include and exclude configured.\n // In this case, exclude wins out so we take everything matching the initial\n // inclusion filter and from that group, we further discard anything matching\n // the exclusion filter. If an item were to have a topic set in both filters,\n // we expect it to be discarded in the end. The use case here is that is that\n // you may want to retrieve all repos with the topic of team-a while excluding\n // matching repos that are marked as experiments.\n if (topicFilter.include && topicFilter.exclude) {\n const matchesInclude = satisfiesTopicFilter(topics, {\n include: topicFilter.include,\n });\n const matchesExclude = !satisfiesTopicFilter(topics, {\n exclude: topicFilter.exclude,\n });\n if (matchesExclude) return false;\n return matchesInclude;\n }\n\n // If the topic filter is somehow ever in a state that is not covered here, we\n // will fail \"open\" so that Backstage is still usable as if the filter was\n // not configured at all.\n return true;\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 host: string;\n filters?: {\n repository?: RegExp;\n branch?: string;\n topic?: GithubTopicFilters;\n };\n};\n\nexport type GithubTopicFilters = {\n exclude?: string[];\n include?: string[];\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 host = config.getOptionalString('host') ?? 'github.com';\n const repositoryPattern = config.getOptionalString('filters.repository');\n const branchPattern = config.getOptionalString('filters.branch');\n const topicFilterInclude = config?.getOptionalStringArray(\n 'filters.topic.include',\n );\n const topicFilterExclude = config?.getOptionalStringArray(\n 'filters.topic.exclude',\n );\n\n return {\n id,\n catalogPath,\n organization,\n host,\n filters: {\n repository: repositoryPattern\n ? compileRegExp(repositoryPattern)\n : undefined,\n branch: branchPattern || undefined,\n topic: {\n include: topicFilterInclude,\n exclude: topicFilterExclude,\n },\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';\nimport { satisfiesTopicFilter } from '../lib/util';\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\n return readProviderConfigs(config).map(providerConfig => {\n const integrationHost = providerConfig.host;\n const integration = integrations.github.byHost(integrationHost);\n\n if (!integration) {\n throw new Error(\n `There is no GitHub config that matches host ${integrationHost}. Please add a configuration entry for it under integrations.github`,\n );\n }\n\n return 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 }\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 const topicFilters = this.config.filters?.topic;\n\n const matchingRepositories = repositories.filter(r => {\n const repoTopics: string[] = r.repositoryTopics.nodes.map(\n node => node.topic.name,\n );\n return (\n !r.isArchived &&\n (!repositoryFilter || repositoryFilter.test(r.name)) &&\n satisfiesTopicFilter(repoTopics, topicFilters) &&\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":["_a","ScmIntegrations","DefaultGithubCredentialsProvider","graphql","processingResult","GithubAppCredentialsMux","integration","SingleInstanceGithubCredentialsProvider","uuid","locationSpecToLocationEntity","merge","ANNOTATION_LOCATION","ANNOTATION_ORIGIN_LOCATION","createBackendModule","configServiceRef","catalogProcessingExtensionPoint","loggerServiceRef","schedulerServiceRef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,EAAQ,WAAa,EAAA;AApDzD,QAAA,IAAA,EAAA,CAAA;AAqDQ,QAAM,MAAA,WAAA,GAAA,CAAc,EAAS,GAAA,OAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,OAAA,CAAA,QAAA,KAAT,IAAqB,GAAA,EAAA,GAAA;AAAA,UACvC,SAAA,EAAW,EAAE,OAAA,EAAS,GAAI,EAAA;AAAA,UAC1B,OAAA,EAAS,EAAE,OAAA,EAAS,GAAI,EAAA;AAAA,UACxB,YAAA,EAAc,EAAE,OAAA,EAAS,CAAE,EAAA;AAAA,SAC7B,CAAA;AAEA,QAAQ,OAAA,CAAA,iBAAA;AAAA,UACN,oBAAA,CAAqB,WAAW,MAAQ,EAAA;AAAA,YACtC,MAAA,EAAQC,uCAAsB,MAAM,CAAA;AAAA,YACpC,QAAA,EAAU,SAAU,CAAA,yBAAA,CAA0B,WAAW,CAAA;AAAA,WAC1D,CAAA;AAAA,SACH,CAAA;AAAA,OACF;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;;;;;;"}
|
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.
|
|
4
|
+
"version": "0.1.8-next.0",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -33,15 +33,15 @@
|
|
|
33
33
|
"start": "backstage-cli package start"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@backstage/backend-common": "^0.15.
|
|
37
|
-
"@backstage/backend-plugin-api": "^0.1.
|
|
38
|
-
"@backstage/backend-tasks": "^0.3.
|
|
39
|
-
"@backstage/catalog-model": "^1.1.
|
|
40
|
-
"@backstage/config": "^1.0.
|
|
41
|
-
"@backstage/errors": "^1.1.
|
|
42
|
-
"@backstage/integration": "^1.3.
|
|
43
|
-
"@backstage/plugin-catalog-backend": "^1.4.
|
|
44
|
-
"@backstage/plugin-catalog-node": "^1.1.
|
|
36
|
+
"@backstage/backend-common": "^0.15.2-next.0",
|
|
37
|
+
"@backstage/backend-plugin-api": "^0.1.3-next.0",
|
|
38
|
+
"@backstage/backend-tasks": "^0.3.6-next.0",
|
|
39
|
+
"@backstage/catalog-model": "^1.1.2-next.0",
|
|
40
|
+
"@backstage/config": "^1.0.3-next.0",
|
|
41
|
+
"@backstage/errors": "^1.1.2-next.0",
|
|
42
|
+
"@backstage/integration": "^1.3.2-next.0",
|
|
43
|
+
"@backstage/plugin-catalog-backend": "^1.4.1-next.0",
|
|
44
|
+
"@backstage/plugin-catalog-node": "^1.1.1-next.0",
|
|
45
45
|
"@backstage/types": "^1.0.0",
|
|
46
46
|
"@octokit/graphql": "^5.0.0",
|
|
47
47
|
"lodash": "^4.17.21",
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"winston": "^3.2.1"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@backstage/backend-test-utils": "^0.1.
|
|
55
|
-
"@backstage/cli": "^0.
|
|
54
|
+
"@backstage/backend-test-utils": "^0.1.29-next.0",
|
|
55
|
+
"@backstage/cli": "^0.20.0-next.0",
|
|
56
56
|
"@types/lodash": "^4.14.151"
|
|
57
57
|
},
|
|
58
58
|
"files": [
|
|
@@ -60,6 +60,5 @@
|
|
|
60
60
|
"alpha",
|
|
61
61
|
"config.d.ts"
|
|
62
62
|
],
|
|
63
|
-
"configSchema": "config.d.ts"
|
|
64
|
-
|
|
65
|
-
}
|
|
63
|
+
"configSchema": "config.d.ts"
|
|
64
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
Apache License
|
|
2
|
-
Version 2.0, January 2004
|
|
3
|
-
http://www.apache.org/licenses/
|
|
4
|
-
|
|
5
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
-
|
|
7
|
-
1. Definitions.
|
|
8
|
-
|
|
9
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
-
|
|
12
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
-
the copyright owner that is granting the License.
|
|
14
|
-
|
|
15
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
-
other entities that control, are controlled by, or are under common
|
|
17
|
-
control with that entity. For the purposes of this definition,
|
|
18
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
-
direction or management of such entity, whether by contract or
|
|
20
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
-
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
-
(an example is provided in the Appendix below).
|
|
39
|
-
|
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
-
the Work and Derivative Works thereof.
|
|
47
|
-
|
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
|
49
|
-
the original version of the Work and any modifications or additions
|
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or
|
|
95
|
-
Derivative Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
|
111
|
-
of the following places: within a NOTICE text file distributed
|
|
112
|
-
as part of the Derivative Works; within the Source form or
|
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
|
114
|
-
within a display generated by the Derivative Works, if and
|
|
115
|
-
wherever such third-party notices normally appear. The contents
|
|
116
|
-
of the NOTICE file are for informational purposes only and
|
|
117
|
-
do not modify the License. You may add Your own attribution
|
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
-
that such additional attribution notices cannot be construed
|
|
121
|
-
as modifying the License.
|
|
122
|
-
|
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
|
124
|
-
may provide additional or different license terms and conditions
|
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
-
the conditions stated in this License.
|
|
129
|
-
|
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
-
this License, without any additional terms or conditions.
|
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
-
the terms of any separate license agreement you may have executed
|
|
136
|
-
with Licensor regarding such Contributions.
|
|
137
|
-
|
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for reasonable and customary use in describing the
|
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
-
|
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
|
152
|
-
|
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
|
158
|
-
incidental, or consequential damages of any character arising as a
|
|
159
|
-
result of this License or out of the use or inability to use the
|
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
-
other commercial damages or losses), even if such Contributor
|
|
163
|
-
has been advised of the possibility of such damages.
|
|
164
|
-
|
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
-
or other liability obligations and/or rights consistent with this
|
|
169
|
-
License. However, in accepting such obligations, You may act only
|
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
-
of your accepting any such warranty or additional liability.
|
|
175
|
-
|
|
176
|
-
END OF TERMS AND CONDITIONS
|
|
177
|
-
|
|
178
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
-
|
|
180
|
-
To apply the Apache License to your work, attach the following
|
|
181
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
-
replaced with your own identifying information. (Don't include
|
|
183
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
-
comment syntax for the file format. We also recommend that a
|
|
185
|
-
file or class name and description of purpose be included on the
|
|
186
|
-
same "printed page" as the copyright notice for easier
|
|
187
|
-
identification within third-party archives.
|
|
188
|
-
|
|
189
|
-
Copyright 2020 The Backstage Authors
|
|
190
|
-
|
|
191
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
-
you may not use this file except in compliance with the License.
|
|
193
|
-
You may obtain a copy of the License at
|
|
194
|
-
|
|
195
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
-
|
|
197
|
-
Unless required by applicable law or agreed to in writing, software
|
|
198
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
-
See the License for the specific language governing permissions and
|
|
201
|
-
limitations under the License.
|