Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Create gitlab register component template #174

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7cc6a46
Merge branch 'main' of https://github.com/janus-idp/software-templates
Zaperex Aug 31, 2023
e57430e
Merge branch 'main' of https://github.com/janus-idp/software-templates
Zaperex Sep 11, 2023
41988dc
chore: update github register existing component GPT
Zaperex Sep 12, 2023
7ba7451
chore: add initial gitlab register existing component GPT
Zaperex Sep 12, 2023
8eeb6bf
chore: change register component GPT names
Zaperex Sep 12, 2023
84d4795
chore: add input validation for entity names
Zaperex Sep 12, 2023
c2230ba
chore: update gitlab register component GPT required parameters
Zaperex Sep 12, 2023
adbe3b0
chore: update gitlab register component with correct action
Zaperex Sep 12, 2023
258345b
chore: remove old register github component GPT
Zaperex Sep 15, 2023
85b82cb
chore: update register gitlab component documentation and fix template
Zaperex Sep 18, 2023
85d4b4b
chore: update existing component GPTs validator regex
Zaperex Sep 20, 2023
14ef2dc
chore: update titles to match gitlab terminology
Zaperex Sep 22, 2023
7952a85
chore: fix path to the skeleton catalog-info.yaml file
Zaperex Sep 22, 2023
7d2d7d4
docs: add register existing gitlab component GPT documentation
Zaperex Sep 22, 2023
d77d8b8
docs: add documentation for register existing github component GPT
Zaperex Sep 22, 2023
0d6446a
chore: move github GPT image into images folder
Zaperex Sep 22, 2023
9459846
docs: add additional prereqs for github register existing component GPT
Zaperex Sep 22, 2023
e416e17
docs: update github and gitlab register existing component GPT
Zaperex Sep 22, 2023
127c85c
docs: update image link in gitlab register component docs
Zaperex Oct 4, 2023
63f4ec8
docs: update register existing component GPT docs
Zaperex Oct 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
name: register-component
title: Register existing component to Software Catalog
name: register-github-component
title: Register existing component to Software Catalog from Github
description: Registers existing component (GitHub repository) to Software Catalog
tags:
- import
Expand Down Expand Up @@ -41,7 +41,10 @@ spec:
componentName:
title: Component Name
type: string
description: Name of the created component. If leaved empty the name of the repository will be used.
description: Name of the created component. If left empty the name of the repository will be used.
# Refer to https://github.com/backstage/backstage/blob/master/docs/architecture-decisions/adr002-default-catalog-file-format.md#name
maxLength: 63
pattern: ^([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]$
componentOwner:
title: Owner
description: Select an owner from the list or enter a reference to a Group or a User
Expand All @@ -55,12 +58,12 @@ spec:
componentType:
title: Type
type: string
description: 'The type of component. Well-known and common values: service, website, library.'
description: "The type of component. Well-known and common values: service, website, library."
default: other
componentLifecycle:
title: Lifecycle
type: string
description: 'The lifecycle state of the component. Well-known and common values: experimental, production, deprecated.'
description: "The lifecycle state of the component. Well-known and common values: experimental, production, deprecated."
default: unknown

steps:
Expand Down Expand Up @@ -108,5 +111,5 @@ spec:

output:
links:
- title: 'Open PR #${{ steps.publishPR.output.pullRequestNumber }}'
- title: "Open PR #${{ steps.publishPR.output.pullRequestNumber }}"
url: ${{ steps.publishPR.output.remoteUrl }}
18 changes: 18 additions & 0 deletions templates/gitlab/register-gitlab-component/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Register existing component to Service Catalog

This template is intended to be used as a starting point for registering an existing repository to the Service Catalog.

Currently, it only supports repositories hosted on Gitlab (both `gitlab.com` and Gitlab for Enterprise are supported).

## Required Gitlab permissions

- The Gitlab access token needs to have `api` read & write scopes and added to your gitlab integration
- If using a private Gitlab instance, please make sure the `apiBaseUrl` is set correctly:

```yaml
integrations:
gitlab:
- host: gitlab.mycompany.com
token: my-gitlab-token
apiBaseUrl: https://gitlab.mycompany.com/api/v4
```
109 changes: 109 additions & 0 deletions templates/gitlab/register-gitlab-component/template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
name: register-gitlab-component
title: Register existing component to Software Catalog from Gitlab
description: Registers existing component (Gitlab repository) to Software Catalog
tags:
- import
- catalog
- register
spec:
owner: janus-authors
system: janus-idp
type: service

parameters:
- title: Provide information about the Gitlab location
required:
- gitlabHost
- projectOwner
- projectName
properties:
gitlabHost:
title: Gitlab hostname
Zaperex marked this conversation as resolved.
Show resolved Hide resolved
type: string
description: Use gitlab.com or specify a hostname of your Gitlab Enterprise instance.
default: gitlab.com
projectOwner:
title: Gitlab Repository owner
type: string
description: "Can be a group, subgroup or a user. If using a subgroup, provide full ownership chain, ex: group/subgroup"
projectName:
title: Gitlab project name
type: string

- title: Provide information about the new component
required:
- componentOwner
- componentType
- componentLifecycle
properties:
componentName:
title: Component Name
type: string
description: Name of the created component. If left empty the name of the repository will be used.
# Refer to https://github.com/backstage/backstage/blob/master/docs/architecture-decisions/adr002-default-catalog-file-format.md#name
maxLength: 63
pattern: ^([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]$
componentOwner:
title: Owner
description: Select an owner from the list or enter a reference to a Group or a User
type: string
ui:field: EntityPicker
ui:options:
catalogFilter:
kind:
- Group
- User
componentType:
title: Type
type: string
description: "The type of component. Well-known and common values: service, website, library."
default: other
componentLifecycle:
title: Lifecycle
type: string
description: "The lifecycle state of the component. Well-known and common values: experimental, production, deprecated."
default: unknown

steps:
- id: catalogTemplate
name: Create catalog-info.yaml file
action: fetch:template
input:
url: ./catalog-info/
values:
componentName: ${{ parameters.componentName }}
orgName: ${{ parameters.projectOwner }}
sourceControl: gitlab.com
repoName: ${{ parameters.projectName }}
componentLifecycle: ${{ parameters.componentLifecycle }}
applicationType: ${{ parameters.componentType }}
owner: ${{ parameters.componentOwner }}
- id: publishMergeRequest
name: Open Merge Request with catalog-info.yaml
action: publish:gitlab:merge-request
input:
repoUrl: ${{ parameters.gitlabHost }}?repo=${{ parameters.projectName }}&owner=${{ parameters.projectOwner }}&
branchName: add-catalog-info
title: add catalog-info.yaml
description: |
This pull request adds a **Backstage entity metadata file** to this repository.

After this pull request is merged, the component will become available.

For more information, read an [overview of the Backstage software catalog](https://backstage.io/docs/features/software-catalog/).
removeSourceBranch: true
- id: register
name: Register component
action: catalog:register
input:
repoContentsUrl: https://${{ parameters.gitlabHost }}/${{ parameters.projectOwner }}/${{ parameters.projectName }}/${{ parameters.repositoryName }}-/blob/${{ steps.publishMergeRequest.output.targetBranchName }}/
catalogInfoPath: /catalog-info.yaml
optional: true

output:
links:
- title: "Go to PR"
url: ${{ steps.publishMergeRequest.output.mergeRequestUrl }}