Skip to content

Commit d68fec5

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

6 files changed

+139
-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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
= Enabling and giving access to the Bulk Import feature
2+
3+
.Procedure
4+
5+
. Set up at least one GitHub integration.
6+
For more information, see link:{}#configuring-github-integration[Configuring GitHub integration].
7+
. Enable the **`./dynamic-plugins/dist/janus-idp-backstage-plugin-bulk-import-backend-dynamic`</strong> and *`./dynamic-plugins/dist/janus-idp-backstage-plugin-bulk-import`* preinstalled plugins. For more information, see https://docs.redhat.com/en/documentation/red_hat_developer_hub/1.2/html-single/configuring_plugins_in_red_hat_developer_hub/index[Configuring Plugins in Red Hat Developer Hub].
8+
. Configure the required `bulk.import` RBAC permission. See https://docs.redhat.com/en/documentation/red_hat_developer_hub/1.2/html-single/authorization/index#ref-rbac-permission-policies_title-authorization[Permission policies in Red Hat Developer Hub]. Only Developer Hub administrators or users with the `bulk.import` permission will be able to use the Bulk Import feature.
9+
10+
.Verification
11+
12+
* The sidebar displays a *Bulk Import* option and clicking on it shows a list of *Added Repositories*.
13+
14+
==== Troubleshooting
15+
16+
* 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. Refer back to https://docs.redhat.com/en/documentation/red_hat_developer_hub/1.2/html-single/authorization/index#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: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
* You enabled the Bulk Import feature.
8+
* Your RHDH 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.
13+
You will see a list of all repositories accessible from the configured GitHub integrations.
14+
. From the *Repositories* view, you can select any repository, or search for any accessible repositories.
15+
For each repository selected, a `catalog-info.yaml` will be generated.
16+
. From the *Organizations* view, you can select any organization by clicking on *Select* in the third column.
17+
This will allow you to pick one or more repositories that are part of the selected organization.
18+
. Click on *Preview file* to view or edit the details of the pull request for each repository.
19+
The pull request details form will be preloaded with some data, and you can also preview the content of the `catalog-info.yaml`.
20+
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.
21+
. Click on *Save*.
22+
. Click on *Create pull requests*.
23+
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:
24+
. Checking that there is no entity in the Developer Hub catalog with the name specified in the repository `catalog-info.yaml`
25+
. Checking that the repository is not empty
26+
. Checking that the repository already has a `.github/CODEOWNERS` file if the *Use CODEOWNERS file as Entity Owner* checkbox was selected for that repository.
27+
28+
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. 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 list of Added repositories 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 PR adding the `catalog-info.yaml` file in the corresponding repository
37+
38+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
= Managing the list of Added repositories
2+
3+
.Procedure
4+
5+
. Click on *Bulk Import* in the left sidebar. It will display all the current repositories that are being tracked as Import jobs, along with their status.
6+
. If an Import is in the "**`Added`</strong>" state, it means that the repository has been added to the Developer Hub catalog. 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. Please note that it might take a few minutes until the entities are available in the catalog.
7+
. If an Import is in the "*`Waiting for approval`*" state, it means that there is an open Pull Request adding a `catalog-info.yaml`. You can click on the *pencil icon* on the right to see details about this PR or edit the PR content right from Developer Hub. You can also delete the Import job, in which case the import PR will be closed as well. For the Import job to transition to the "*Added*" state, you (or someone with the appropriate write permissions on the repository) will need to merge the import PR from the Git repository.
8+
. If an Import does not have any state, it might mean that Developer Hub was not able to determine its status. 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.
9+
10+
*NOTES*
11+
12+
. After an import PR 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.
13+
. A Location added through other sources (like statically in an app-config file, dynamically when https://docs.redhat.com/en/documentation/red_hat_developer_hub/1.2/html/getting_started_with_red_hat_developer_hub/ref-rhdh-supported-configs_rhdh-getting-started#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:
14+
. the target repository is accessible from the configured GitHub integrations, and
15+
. the Location URL points to a catalog-info.yaml file at the root of the repository default branch
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
= Bulk Import Audit Logs
2+
3+
The Bulk Import Backend plugin adds the events below to the Developer Hub audit logs. See https://docs.redhat.com/en/documentation/red_hat_developer_hub/1.2/html/getting_started_with_red_hat_developer_hub/assembly-audit-log[Audit Logs in Red Hat Developer Hub] for more information on how to configure and view such audit logs.
4+
5+
*Bulk Import Events*:
6+
7+
* **`BulkImportUnknownEndpoint`</strong>: tracks requests to unknown endpoints.
8+
* *`BulkImportPing`*: tracks `GET` requests to the `/ping` endpoint, which allows us to make sure the bulk import backend is up and running.
9+
* *`BulkImportFindAllOrganizations`*: tracks `GET` requests to the /organizations endpoint, which returns the list of organizations accessible from all configured GitHub Integrations.
10+
* *`BulkImportFindRepositoriesByOrganization`*: 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).
11+
* *`BulkImportFindAllRepositories`*: tracks GET requests to the `/repositories` endpoint, which returns the list of repositories accessible from all configured GitHub Integrations.
12+
* *`BulkImportFindAllImports`*: tracks `GET` requests to the `/imports` endpoint, which returns the list of existing import jobs along with their statuses.
13+
* *`BulkImportCreateImportJobs`*: 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.
14+
* *`BulkImportFindImportStatusByRepo`*: tracks `GET` requests to the `/import/by-repo` endpoint, which fetches details about the import job for the specified repository.
15+
* *`BulkImportDeleteImportByRepo`*: 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.
16+
17+
.Example
18+
[code,javascript]
19+
----
20+
{
21+
"actor": {
22+
"actorId": "user:default/myuser",
23+
"hostname": "localhost",
24+
"ip": "::1",
25+
"userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36"
26+
},
27+
"eventName": "BulkImportFindAllOrganizations",
28+
"isAuditLog": true,
29+
"level": "info",
30+
"message": "'get /organizations' endpoint hit by user:default/myuser",
31+
"meta": {},
32+
"plugin": "bulk-import",
33+
"request": {
34+
"body": {},
35+
"method": "GET",
36+
"params": {},
37+
"query": {
38+
"pagePerIntegration": "1",
39+
"sizePerIntegration": "5"
40+
},
41+
"url": "/api/bulk-import/organizations?pagePerIntegration=1&sizePerIntegration=5"
42+
},
43+
"response": {
44+
"status": 200
45+
},
46+
"service": "backstage",
47+
"stage": "completion",
48+
"status": "succeeded",
49+
"timestamp": "2024-08-26 16:41:02"
50+
}
51+
----
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
= Bulk Import limitations
2+
3+
* Only the first 20 repositories (in alphabetical order) can be displayed at most on the Added Repositories page. Also, the count of Added Repositories displayed might be wrong. In future releases, we plan to address this with proper pagination. Meanwhile, as a workaround, searching would still work against all Added Repositories. So you can still search any Added Repository and get it listed on the table. See https://issues.redhat.com/browse/RHIDP-4067[RHIDP-4067].
4+
* Repositories might be added to Developer Hub from various sources (like statically in an app-config file or dynamically when https://docs.redhat.com/en/documentation/red_hat_developer_hub/1.2/html/getting_started_with_red_hat_developer_hub/ref-rhdh-supported-configs_rhdh-getting-started#enabling-github-discovery-in-red-hat-developer-hub[enabling GitHub discovery]). By design, the bulk import plugin will only track repositories that are accessible from the configured GitHub integrations. However, deleting a repository from the Bulk Imports listing page may not work if the repository was discovered by the GitHub discovery plugin. See https://issues.redhat.com/browse/RHIDP-3931[RHIDP-3931].

0 commit comments

Comments
 (0)