Skip to content

Commit dcca5c6

Browse files
committed
RHIDP-1925 bulk import from GitHub
Signed-off-by: Fabrice Flore-Thébault <[email protected]>
1 parent cf87cda commit dcca5c6

6 files changed

+181
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
= Bulk Import GitHub repositories
2+
3+
Bulk Import is a {company-name} *Tech Preview* feature.
4+
5+
It allows you to automate GitHub repositories onboarding and track their import status.
6+
7+
include::modules/importing-repositories/procedure-enabling-the-bulk-import-from-github-feature.adoc[leveloffset=+1]
8+
9+
include::modules/importing-repositories/procedure-importing-multiple-repositories-from-github.adoc[leveloffset=+1]
10+
11+
include::modules/importing-repositories/procedure-managing-the-imported-repository-list.adoc[leveloffset=+1]
12+
13+
include::modules/importing-repositories/procedure-understanding-bulk-import-audit-logs.adoc[leveloffset=+1]
14+
15+
include::modules/importing-repositories/procedure-understanding-bulk-import-limitations.adoc[leveloffset=+1]
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[id="enabling-ang-giving-access-to-the-bulk-import-feature"]
2+
= Enabling and giving access to the Bulk Import feature
3+
4+
.Procedure
5+
. To give {product-short} access to GitHub, link:{linkgettingstartedguide}#configuring-github-integration[configure GitHub integration].
6+
7+
. The Bulk Import plugin is installed but disabled by default.
8+
Enable the `./dynamic-plugins/dist/janus-idp-backstage-plugin-bulk-import-backend-dynamic` and `./dynamic-plugins/dist/janus-idp-backstage-plugin-bulk-import` preinstalled plugins.
9+
See link:{plugins-configure-book-url}[{plugins-configure-book-title}].
10+
11+
. Only {product-short} administrators or users with the `bulk.import` permission can use the Bulk Import feature.
12+
Configure the required `bulk.import` RBAC permission for the users that are not administrators.
13+
See link:{authorization-book-url}#ref-rbac-permission-policies_title-authorization[Permission policies in Red Hat Developer Hub].
14+
15+
16+
.Verification
17+
* The sidebar displays a *Bulk Import* line.
18+
* The *Bulk Import* page shows a list of *Added Repositories*.
19+
20+
.Troubleshooting
21+
* If clicking on the *Bulk Import* option displays the following error message: _To view the added repositories, contact your administrator to give you the `bulk.import` permission_, it means that your user does not have the necessary permission to use the Bulk Import feature.
22+
Refer back to link:{authorization-book-url}#ref-rbac-permission-policies_title-authorization[Permission policies in Red Hat Developer Hub] for more information on how an administrator can add that permission to your user.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
= Importing multiple repositories
2+
3+
The Bulk Import feature allows you to view all the GitHub repositories and organizations accessible from the configured GitHub Integrations.
4+
From there, you can pick any number of repositories and onboard them.
5+
6+
.Prerequisites
7+
* xref:enabling-ang-giving-access-to-the-bulk-import-feature[You enabled the Bulk Import feature].
8+
* xref:enabling-ang-giving-access-to-the-bulk-import-feature[Your {product-short} user has access to the Bulk Import feature].
9+
10+
.Procedure
11+
. Click on *Bulk Import* in the left sidebar.
12+
. Click on the *Add* button in the top-right corner to see the list of all repositories accessible from the configured GitHub integrations.
13+
.. From the *Repositories* view, you can select any repository, or search for any accessible repositories.
14+
For each repository selected, a `catalog-info.yaml` will be generated.
15+
.. From the *Organizations* view, you can select any organization by clicking on *Select* in the third column.
16+
This will allow you to pick one or more repositories that are part of the selected organization.
17+
. Click on *Preview file* to view or edit the details of the pull request for each repository.
18+
The pull request details form will be preloaded with some data, and you can also preview the content of the `catalog-info.yaml`.
19+
If the repository already has a `.github/CODEOWNERS` file, you can select the *Use CODEOWNERS file as Entity Owner* checkbox to use it, rather than having the `content-info.yaml` contain a specific entity owner.
20+
. Click on *Save*.
21+
. Click on *Create pull requests*.
22+
At this point, a set of dry-run checks will be run against the selected repositories to make sure they meet the requirements to be imported, that is:
23+
.. Checking that there is no entity in the Developer Hub catalog with the name specified in the repository `catalog-info.yaml`
24+
.. Checking that the repository is not empty
25+
.. Checking that the repository already has a `.github/CODEOWNERS` file if the *Use CODEOWNERS file as Entity Owner* checkbox was selected for that repository.
26+
27+
** If there are any errors, the pull requests will not be created, but you will see a _Failed to create PR_ error message indicating the failures.
28+
Clicking on *Edit* will show more details about the reasons.
29+
30+
** If there are no errors, the pull requests will be created, and you will be redirected to the list of Added repositories.
31+
32+
. Review and merge each pull request that creates a `catalog-info.yml` file.
33+
34+
.Verification
35+
* The *Added repositories* list displays the repositories you just imported, each with an appropriate status: either _Waiting for approval_ or _Added_.
36+
* For each _Waiting for approval_ Import job listed, there is a corresponding pull request adding the `catalog-info.yaml` file in the corresponding repository
37+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
= Managing the list of Added repositories
2+
3+
.Procedure
4+
. Click on *Bulk Import* in the left sidebar to display all the current repositories that are being tracked as Import jobs, along with their status.
5+
6+
Added:: The repository has been added to the Developer Hub catalog.
7+
This can be the case after the import PR has been merged, or if the repository already had a `catalog-info.yaml` when it was bulk-imported.
8+
Please note that it might take a few minutes until the entities are available in the catalog.
9+
10+
Waiting for approval:: There is an open pull request adding a `catalog-info.yaml`.
11+
You can:
12+
* Click on the *pencil icon* on the right to see details about this pull request or edit the pull request content right from {product-short}.
13+
* Delete the Import job, in which case the import PR will be closed as well.
14+
* To transition the Import job to the _Added_ state, merge the import pull request from the Git repository.
15+
16+
Empty:: {product-short} was not able to determine the Import job status.
17+
This can be the case if the repository was imported from other sources but does not have any `catalog-info.yaml` file and does not have any import PR adding it.
18+
19+
[NOTE]
20+
====
21+
* After an import pull request is merged, the Import status will be _Added_ in the list of Added Repositories, but it might take a few seconds until the corresponding entities show up in the Developer Hub Catalog.
22+
* A Location added through other sources (like statically in an `app-config.yaml` file, dynamically when link:{linkgettingstartedguide}#enabling-github-discovery-in-red-hat-developer-hub[enabling GitHub discovery], or registered manually via the "Register an existing component" page) may show up in the Bulk Import list of Added Repositories if both conditions are met:
23+
** The target repository is accessible from the configured GitHub integrations.
24+
** The Location URL points to a `catalog-info.yaml` file at the root of the repository default branch.
25+
====
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
= Bulk Import Audit Logs
2+
3+
The Bulk Import Backend plugin adds the events below to the Developer Hub audit logs.
4+
See link:{linkgettingstartedguide}#assembly-audit-log[Audit Logs in {product}] for more information on how to configure and view such audit logs.
5+
6+
*Bulk Import Events*:
7+
8+
`BulkImportUnknownEndpoint`::
9+
Tracks requests to unknown endpoints.
10+
11+
`BulkImportPing`::
12+
Tracks `GET` requests to the `/ping` endpoint, which allows us to make sure the bulk import backend is up and running.
13+
14+
`BulkImportFindAllOrganizations`::
15+
Tracks `GET` requests to the /organizations endpoint, which returns the list of organizations accessible from all configured GitHub Integrations.
16+
17+
`BulkImportFindRepositoriesByOrganization`::
18+
Tracks `GET` requests to the `/organizations/:orgName/repositories` endpoint, which returns the list of repositories for the specified organization (accessible from any of the configured GitHub Integrations).
19+
20+
`BulkImportFindAllRepositories`::
21+
Tracks GET requests to the `/repositories` endpoint, which returns the list of repositories accessible from all configured GitHub Integrations.
22+
23+
`BulkImportFindAllImports`::
24+
Tracks `GET` requests to the `/imports` endpoint, which returns the list of existing import jobs along with their statuses.
25+
26+
`BulkImportCreateImportJobs`::
27+
Tracks `POST` requests to the `/imports` endpoint, which allows to submit requests to bulk-import one or many repositories into the Developer Hub Catalog, by eventually creating import Pull Requests in the target repositories.
28+
29+
`BulkImportFindImportStatusByRepo`::
30+
Tracks `GET` requests to the `/import/by-repo` endpoint, which fetches details about the import job for the specified repository.
31+
32+
`BulkImportDeleteImportByRepo`::
33+
Tracks `DELETE` requests to the `/import/by-repo` endpoint, which deletes any existing import job for the specified repository, by closing any open import Pull Request that could have been created.
34+
35+
.Example
36+
[code,json]
37+
----
38+
{
39+
"actor": {
40+
"actorId": "user:default/myuser",
41+
"hostname": "localhost",
42+
"ip": "::1",
43+
"userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36"
44+
},
45+
"eventName": "BulkImportFindAllOrganizations",
46+
"isAuditLog": true,
47+
"level": "info",
48+
"message": "'get /organizations' endpoint hit by user:default/myuser",
49+
"meta": {},
50+
"plugin": "bulk-import",
51+
"request": {
52+
"body": {},
53+
"method": "GET",
54+
"params": {},
55+
"query": {
56+
"pagePerIntegration": "1",
57+
"sizePerIntegration": "5"
58+
},
59+
"url": "/api/bulk-import/organizations?pagePerIntegration=1&sizePerIntegration=5"
60+
},
61+
"response": {
62+
"status": 200
63+
},
64+
"service": "backstage",
65+
"stage": "completion",
66+
"status": "succeeded",
67+
"timestamp": "2024-08-26 16:41:02"
68+
}
69+
----
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
= Bulk Import limitations
2+
3+
* Only the first 20 repositories (in alphabetical order) can be displayed at most on the Added Repositories page.
4+
Also, the count of Added Repositories displayed might be wrong.
5+
In future releases, we plan to address this with proper pagination.
6+
Meanwhile, as a workaround, searching would still work against all Added Repositories.
7+
So you can still search any Added Repository and get it listed on the table.
8+
See https://issues.redhat.com/browse/RHIDP-4067[RHIDP-4067].
9+
10+
* Repositories might be added to {product-short} from various sources (like statically in an app-config file or dynamically when link:{linkgettingstartedguide}#enabling-github-discovery-in-red-hat-developer-hub[enabling GitHub discovery]).
11+
By design, the bulk import plugin will only track repositories that are accessible from the configured GitHub integrations.
12+
However, deleting a repository from the Bulk Imports listing page may not work if the repository was discovered by the GitHub discovery plugin.
13+
See https://issues.redhat.com/browse/RHIDP-3931[RHIDP-3931].

0 commit comments

Comments
 (0)