Review the README to better explain how to integrate gitea in a template. Include parseRepoUrl to get the host name provided by the user. Add a warning to tell to the user that they should define the allowedOwners according to the gitea organisation. Include the new field: repoVisibility

Signed-off-by: cmoulliard <cmoulliard@redhat.com>
This commit is contained in:
cmoulliard
2024-04-19 12:16:25 +02:00
parent 9e59823f9b
commit 6eaba9fb98
@@ -10,6 +10,13 @@ To use this action, you will have to add the package using the following command
yarn --cwd packages/backend add @backstage/plugin-scaffolder-backend-module-gitea
```
Alternatively, if you use the new backend system, then register it like this:
```typescript
// packages/backend/src/index.ts
backend.add(import('@backstage/plugin-scaffolder-backend-module-gitea'));
```
Configure the action (if not yet done):
(you can check the [docs](https://backstage.io/docs/features/software-templates/writing-custom-actions#registering-custom-actions) to see all options):
@@ -27,29 +34,29 @@ integrations:
password: '<GITEA_LOCALHOST_PASSWORD>'
```
**Important**: As backstage will issue HTTPS/TLS requests to the gitea instance, it is needed to configure `gitea` with a valid certificate or at least with a
self-signed certificate `gitea cert --host localhost -ca` trusted by a CA authority. Don't forget to set the env var `NODE_EXTRA_CA_CERTS` to point to the CA file before launching backstage !
**Important**: As backstage will issue `HTTPS/TLS` requests to the gitea instance, it is needed to configure `gitea` with a valid certificate or at least with a
self-signed certificate `gitea cert --host localhost -ca` trusted by a CA authority. Don't forget to set the env var `NODE_EXTRA_CA_CERTS` to point to the CA file before launching backstage or to ignore using the following Node.js parameter: `NODE_TLS_REJECT_UNAUTHORIZED=0` !
When done, you can create a template which:
- Declare the `RepoUrlPicker` within the `spec/parameters` section to select the gitea hosts
- Include a step able to publish by example the newly generated project using the action `action: publish:gitea`
- Declare the `RepoUrlPicker` within the `spec/parameters` section to select the gitea host and to provide the name of the repository
- Add an enum list allowing the user to define the visibility about the repository to be created: `public` or `private`. If this field is omitted, `public` is then used by the action.
- Include in a step the action: `publish:gitea`
**Warning**: The list of the `allowedOwners` of the `repoUrlPicker` must match the list of the `organizations` which are available on the gitea host !
```yaml
apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
name: quarkus-web-template
title: Quarkus Hello world
description: Create a simple microservice using Quarkus
tags:
- java
- quarkus
name: simple-gitea-project
title: Create a gitea repository
description: Create a gitea repository
spec:
owner: quarkus
owner: guests
type: service
parameters:
- title: Git repository Information
- title: Choose a location
required:
- repoUrl
properties:
@@ -58,42 +65,33 @@ spec:
type: string
ui:field: RepoUrlPicker
ui:options:
allowedOwners:
- qteam
- qshift
allowedHosts:
- gitea.<YOUR_DOMAIN>:<PORT>
- localhost:<PORT>
- gitea.localtest.me:3333
repoVisibility:
title: Visibility of the repository
type: string
default: 'public'
enum:
- 'public'
- 'private'
enumNames:
- 'public'
- 'private'
steps:
- id: template
name: Generating component
action: fetch:template
input:
url: ./skeleton
values:
name: ${{ parameters.name }}
...
- id: publish
name: Publishing to a gitea git repository
action: publish:gitea
input:
description: This is ${{ parameters.component_id }}
description: This is ${{ parameters.repoUrl | parseRepoUrl | pick('repo') }}
repoVisibility: ${{ parameters.repoVisibility }}
repoUrl: ${{ parameters.repoUrl }}
defaultBranch: main
- id: register
if: ${{ parameters.dryRun !== true }}
name: Register
action: catalog:register
input:
repoContentsUrl: ${{ steps['publish'].output.repoContentsUrl }}
catalogInfoPath: 'main/catalog-info.yaml'
output:
links:
- title: Source Code Repository
url: ${{ steps.publish.output.remoteUrl }}
- title: Open Component in catalog
icon: catalog
entityRef: ${{ steps.register.output.entityRef }}
```
Access the newly gitea repository created using the `repoContentsUrl` ;-)