Skip to content

Commit 14f6f2f

Browse files
themr0crm3lhmanwani-rhsubhashkhileri
authored
RHIDP-1925 bulk import from GitHub (#616) (#635)
Co-authored-by: Armel Soro <[email protected]> Co-authored-by: Heena Manwani <[email protected]> Co-authored-by: Subhash Khileri <[email protected]>
1 parent b278249 commit 14f6f2f

9 files changed

+216
-6
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[IMPORTANT]
2+
====
3+
These features are for Technology Preview only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs), might not be functionally complete, and Red Hat does not recommend using them for production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.
4+
5+
For more information on Red Hat Technology Preview features, see https://access.redhat.com/support/offerings/techpreview/[Technology Preview Features Scope].
6+
====
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[id="bulk-importing-github-repositories"]
2+
= Bulk importing GitHub repositories
3+
4+
include::{docdir}/artifacts/snip-technology-preview.adoc[]
5+
6+
{product} can automate GitHub repositories onboarding and track their import status.
7+
8+
include::modules/importing-repositories/procedure-enabling-the-bulk-import-from-github-feature.adoc[leveloffset=+1]
9+
10+
include::modules/importing-repositories/procedure-importing-multiple-repositories-from-github.adoc[leveloffset=+1]
11+
12+
include::modules/importing-repositories/procedure-managing-the-imported-repository-list.adoc[leveloffset=+1]
13+
14+
include::modules/importing-repositories/procedure-understanding-bulk-import-audit-logs.adoc[leveloffset=+1]
15+

modules/authorization/ref-rbac-permission-policies.adoc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,22 @@ Catalog permissions::
7878
|Allows user or role to delete locations from the catalog
7979
|===
8080

81+
Bulk import permissions::
82+
83+
[cols="15%,25%,15%,45%", frame="all", options="header"]
84+
|===
85+
|Name
86+
|Resource type
87+
|Policy
88+
|Description
89+
90+
|`bulk.import`
91+
|`bulk-import`
92+
|
93+
|Allows the user to access the bulk import endpoints, such as listing all repositories and organizations accessible by all GitHub integrations and managing the import requests.
94+
95+
|===
96+
8197
Scaffolder permissions::
8298

8399
[cols="15%,25%,15%,45%", frame="all", options="header"]

modules/getting-started/con-servicenow-custom-actions.adoc

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
[id='con-servicenow-custom-actions_{context}']
22
= ServiceNow Custom actions in {product}
33

4-
[IMPORTANT]
5-
====
6-
These features are for Technology Preview only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs), might not be functionally complete, and Red Hat does not recommend using them for production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.
7-
8-
For more information on Red Hat Technology Preview features, see https://access.redhat.com/support/offerings/techpreview/[Technology Preview Features Scope].
9-
====
4+
include::{docdir}/artifacts/snip-technology-preview.adoc[]
105

116
In {product}, you can access ServiceNow custom actions (custom actions) for fetching and registering resources in the catalog.
127

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
[id="enabling-and-giving-access-to-the-bulk-import-feature"]
2+
= Enabling and giving access to the Bulk Import feature
3+
You can enable the Bulk Import feature for users and give them the necessary permissions to access it.
4+
5+
.Prerequisites
6+
* You have link:{authentication-book-url}#enabling-authentication-with-github[configured GitHub authentication and integration].
7+
8+
.Procedure
9+
10+
. The Bulk Import plugins are installed but disabled by default.
11+
To enable the `./dynamic-plugins/dist/janus-idp-backstage-plugin-bulk-import-backend-dynamic` and `./dynamic-plugins/dist/janus-idp-backstage-plugin-bulk-import` plugins,
12+
edit your `dynamic-plugins.yaml` with the following content:
13+
+
14+
.`dynamic-plugins.yaml` fragment
15+
[source,yaml]
16+
----
17+
plugins:
18+
- package: ./dynamic-plugins/dist/janus-idp-backstage-plugin-bulk-import-backend-dynamic
19+
disabled: false
20+
- package: ./dynamic-plugins/dist/janus-idp-backstage-plugin-bulk-import
21+
disabled: false
22+
----
23+
+
24+
See link:{installing-and-viewing-dynamic-plugins-url}[{installing-and-viewing-dynamic-plugins-title}].
25+
26+
. Configure the required `bulk.import` RBAC permission for the users who are not administrators as follows:
27+
+
28+
.`rbac-policy.csv` fragment
29+
[source,csv,subs="+quotes"]
30+
----
31+
p, role:default/bulk-import, bulk.import, use, allow
32+
g, user:default/__<your_user>__, role:default/bulk-import
33+
----
34+
+
35+
Note that only {product-short} administrators or users with the `bulk.import` permission can use the Bulk Import feature. See link:{authorization-book-url}#ref-rbac-permission-policies_title-authorization[Permission policies in Red Hat Developer Hub].
36+
37+
.Verification
38+
* The sidebar displays a *Bulk Import* option.
39+
* The *Bulk Import* page shows a list of *Added Repositories*.
40+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[id="importing-multiple-github-repositories]
2+
= Importing multiple GitHub repositories
3+
4+
In {product}, you can select your GitHub repositories and automate their onboarding to the {product-short} catalog.
5+
6+
.Prerequisites
7+
* You have link:{authentication-book-url}#enabling-authentication-with-github[configured GitHub authentication and integration].
8+
* You have xref:enabling-and-giving-access-to-the-bulk-import-feature[enabled the Bulk Import feature and gave access to it].
9+
10+
.Procedure
11+
. Click *Bulk Import* in the left sidebar.
12+
. Click 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` is generated.
15+
.. From the *Organizations* view, you can select any organization by clicking *Select* in the third column.
16+
This option allows you to select one or more repositories from the selected organization.
17+
. Click *Preview file* to view or edit the details of the pull request for each repository.
18+
.. Review the pull request description and the `catalog-info.yaml` file content.
19+
.. Optional: when the repository 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 *Save*.
21+
. Click *Create pull requests*.
22+
At this point, a set of dry-run checks runs against the selected repositories to ensure they meet the requirements for import, such as:
23+
.. Verifying that there is no entity in the {product-short} catalog with the name specified in the repository `catalog-info.yaml`
24+
.. Verifying that the repository is not empty
25+
.. Verifying that the repository contains a `.github/CODEOWNERS` file if the *Use CODEOWNERS file as Entity Owner* checkbox is selected for that repository
26+
27+
** If any errors occur, the pull requests are not created, and you see a _Failed to create PR_ error message detailing the issues.
28+
To view more details about the reasons, click *Edit*.
29+
30+
** If there are no errors, the pull requests are created, and you are 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 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: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[id="managing-the-added-repositories]
2+
= Managing the added repositories
3+
You can oversee and manage the repositories that are imported to the {product-short}.
4+
5+
.Prerequisites
6+
* You have xref:importing-multiple-github-repositories[imported GitHub repositories].
7+
8+
9+
.Procedure
10+
. Click *Bulk Import* in the left sidebar to display all the current repositories that are being tracked as Import jobs, along with their status.
11+
12+
Added:: The repository is added to the {product-short} catalog after the import pull request is merged or if the repository already contained a `catalog-info.yaml` file during the bulk import.
13+
Note that it may take a few minutes for the entities to be available in the catalog.
14+
15+
Waiting for approval:: There is an open pull request adding a `catalog-info.yaml` file to the repository.
16+
You can:
17+
* Click the *pencil icon* on the right to see details about the pull request or edit the pull request content right from {product-short}.
18+
* Delete the Import job, this action closes the import PR as well.
19+
* To transition the Import job to the _Added_ state, merge the import pull request from the Git repository.
20+
21+
Empty:: {product-short} is unable to determine the import job status because the repository is imported from other sources but does not have a `catalog-info.yaml` file and lacks any import pull request adding it.
22+
23+
[NOTE]
24+
====
25+
* After an import pull request is merged, the import status is marked as _Added_ in the list of Added Repositories, but it might take a few seconds for the corresponding entities to appear in the {product-short} Catalog.
26+
* 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 using the "Register an existing component" page) might show up in the Bulk Import list of Added Repositories if the following conditions are met:
27+
** The target repository is accessible from the configured GitHub integrations.
28+
** The location URL points to a `catalog-info.yaml` file at the root of the repository default branch.
29+
====
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
[id="understanding-bulk-import-audit-logs"]
2+
= Understanding the Bulk Import audit Logs
3+
4+
The Bulk Import backend plugin adds the following events to the {product-short} audit logs.
5+
See link:{linkgettingstartedguide}#assembly-audit-log[Audit Logs in {product}] for more information on how to configure and view audit logs.
6+
7+
*Bulk Import Events*:
8+
9+
`BulkImportUnknownEndpoint`::
10+
Tracks requests to unknown endpoints.
11+
12+
`BulkImportPing`::
13+
Tracks `GET` requests to the `/ping` endpoint, which allows us to make sure the bulk import backend is up and running.
14+
15+
`BulkImportFindAllOrganizations`::
16+
Tracks `GET` requests to the `/organizations` endpoint, which returns the list of organizations accessible from all configured GitHub Integrations.
17+
18+
`BulkImportFindRepositoriesByOrganization`::
19+
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).
20+
21+
`BulkImportFindAllRepositories`::
22+
Tracks GET requests to the `/repositories` endpoint, which returns the list of repositories accessible from all configured GitHub Integrations.
23+
24+
`BulkImportFindAllImports`::
25+
Tracks `GET` requests to the `/imports` endpoint, which returns the list of existing import jobs along with their statuses.
26+
27+
`BulkImportCreateImportJobs`::
28+
Tracks `POST` requests to the `/imports` endpoint, which allows to submit requests to bulk-import one or many repositories into the {product-short} catalog, by eventually creating import pull requests in the target repositories.
29+
30+
`BulkImportFindImportStatusByRepo`::
31+
Tracks `GET` requests to the `/import/by-repo` endpoint, which fetches details about the import job for the specified repository.
32+
33+
`BulkImportDeleteImportByRepo`::
34+
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.
35+
36+
.Example bulk import audit logs
37+
[code,json]
38+
----
39+
{
40+
"actor": {
41+
"actorId": "user:default/myuser",
42+
"hostname": "localhost",
43+
"ip": "::1",
44+
"userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36"
45+
},
46+
"eventName": "BulkImportFindAllOrganizations",
47+
"isAuditLog": true,
48+
"level": "info",
49+
"message": "'get /organizations' endpoint hit by user:default/myuser",
50+
"meta": {},
51+
"plugin": "bulk-import",
52+
"request": {
53+
"body": {},
54+
"method": "GET",
55+
"params": {},
56+
"query": {
57+
"pagePerIntegration": "1",
58+
"sizePerIntegration": "5"
59+
},
60+
"url": "/api/bulk-import/organizations?pagePerIntegration=1&sizePerIntegration=5"
61+
},
62+
"response": {
63+
"status": 200
64+
},
65+
"service": "backstage",
66+
"stage": "completion",
67+
"status": "succeeded",
68+
"timestamp": "2024-08-26 16:41:02"
69+
}
70+
----

titles/getting-started-rhdh/title-getting-started.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ include::modules/getting-started/ref-rhdh-sizing.adoc[leveloffset=+1]
2020
include::modules/getting-started/ref-rhdh-supported-configs.adoc[leveloffset=+1]
2121
include::assemblies/assembly-add-custom-app-file-openshift.adoc[leveloffset=+2]
2222

23+
include::assemblies/assembly-bulk-importing-from-github.adoc[leveloffset=+1]
24+
2325
include::modules/getting-started/proc-customize-rhdh-homepage.adoc[leveloffset=+1]
2426
include::modules/getting-started/proc-customize-rhdh-tech-radar-page.adoc[leveloffset=+1]
2527
include::modules/getting-started/proc-customize-rhdh-learning-paths.adoc[leveloffset=+1]

0 commit comments

Comments
 (0)