Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(plugin-templates): add ability to register to catalog #26

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
@@ -0,0 +1,18 @@
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: ${{ values.plugin_id }}
{%- if values.description %}
description: ${{ values.description }}
{%- endif %}
annotations:
backstage.io/techdocs-ref: dir:.
github.com/project-slug: ${{ values.orgName }}/${{ values.repoName }}
spec:
type: website
{%- if values.lifecycle %}
lifecycle: ${{ values.lifecycle }}
{%- else %}
lifecycle: production
{%- endif %}
owner: ${{ values.owner }}
39 changes: 35 additions & 4 deletions templates/create-backend-plugin/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,28 @@ spec:
- title: Provide some information
required:
- plugin_id
- owner
properties:
plugin_id:
title: Plugin ID
type: string
pattern: "^[a-z0-9-]*[a-z0-9]$"
pattern: '^[a-z0-9-]*[a-z0-9]$'
description: Plugin unique ID.
ui:help: Plugin IDs must be lowercase and contain only letters, digits, and dashes.
ui:autofocus: true
description:
title: Description
type: string
description: Help others understand what this component is for
owner:
title: Owner
type: string
ui:field: EntityPicker
ui:options:
catalogFilter:
kind:
- Group
- User
- title: Choose a location
required:
- repoUrl
Expand Down Expand Up @@ -54,12 +68,12 @@ spec:
title: Branch Name
type: string
description: The name for the branch
default: ""
default: ''
targetBranchName:
title: Target Branch Name
type: string
description: The target branch name of the merge request
default: ""
default: ''
# You can use additional fields of parameters within conditional parameters such as required.
required:
- branchName
Expand All @@ -77,14 +91,18 @@ spec:
values:
plugin_id: ${{ parameters.plugin_id }}
repoUrl: ${{ parameters.repoUrl | parseRepoUrl }}
description: ${{ parameters.description }}
owner: ${{ parameters.owner }}
repoName: ${{ (parameters.repoUrl | parseRepoUrl).repo }}
orgName: ${{ (parameters.repoUrl | parseRepoUrl).owner }}

# This step publishes the contents of the working directory to GitHub if it is a new repository.
- id: publish
name: Publish the backend plugin skeleton in a new repository
if: ${{ parameters.is_existing_repo === false }}
action: publish:github
input:
allowedHosts: ["github.com"]
allowedHosts: ['github.com']
description: This is the ${{ parameters.plugin_id }} backend plugin.
repoUrl: ${{ parameters.repoUrl }}
sourcePath: plugins/${{parameters.plugin_id}}-backend
Expand All @@ -101,10 +119,23 @@ spec:
title: Create backend plugin ${{ parameters.plugin_id }}
description: This pull request creates the skeleton for your backend plugin

# This step registers the component if the contents are being published to a new repository
- id: register
name: Registering the Catalog Info Component
if: ${{ parameters.is_existing_repo === false }}
action: catalog:register
input:
repoContentsUrl: ${{ steps.publish.output.repoContentsUrl }}
catalogInfoPath: /catalog-info.yaml

# Outputs are displayed to the user after a successful execution of the template.
output:
links:
- title: View Plugin
url: ${{ steps.publish.output.remoteUrl }}
- title: View Pull Request
url: ${{ steps.publishGithub.output.remoteUrl }}
- title: Open the Catalog Info Component
if: ${{ parameters.is_existing_repo === false }}
icon: catalog
entityRef: ${{ steps.register.output.entityRef }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: ${{ values.plugin_id }}
{%- if values.description %}
description: ${{ values.description }}
{%- endif %}
annotations:
backstage.io/techdocs-ref: dir:.
github.com/project-slug: ${{ values.orgName }}/${{ values.repoName }}
spec:
type: website
{%- if values.lifecycle %}
lifecycle: ${{ values.lifecycle }}
{%- else %}
lifecycle: production
{%- endif %}
owner: ${{ values.owner }}
39 changes: 35 additions & 4 deletions templates/create-frontend-plugin/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,28 @@ spec:
- title: Provide some information
required:
- plugin_id
- owner
properties:
plugin_id:
title: Plugin ID
type: string
pattern: "^[a-z0-9-]*[a-z0-9]$"
pattern: '^[a-z0-9-]*[a-z0-9]$'
description: Unique ID of the plugin.
ui:help: Plugin IDs must be lowercase and contain only letters, digits, and dashes.
ui:autofocus: true
description:
title: Description
type: string
description: Help others understand what this component is for
owner:
title: Owner
type: string
ui:field: EntityPicker
ui:options:
catalogFilter:
kind:
- Group
- User
- title: Choose a location
required:
- repoUrl
Expand Down Expand Up @@ -60,12 +74,12 @@ spec:
title: Branch Name
type: string
description: The name for the branch
default: ""
default: ''
targetBranchName:
title: Target Branch Name
type: string
description: The target branch name of the merge request
default: ""
default: ''
# You can use additional fields of parameters within conditional parameters such as required.
required:
- branchName
Expand All @@ -83,14 +97,18 @@ spec:
values:
plugin_id: ${{ parameters.plugin_id }}
repoUrl: ${{ parameters.repoUrl | parseRepoUrl }}
description: ${{ parameters.description }}
owner: ${{ parameters.owner }}
repoName: ${{ (parameters.repoUrl | parseRepoUrl).repo }}
orgName: ${{ (parameters.repoUrl | parseRepoUrl).owner }}

# This step publishes the contents of the working directory to GitHub if it is a new repository.
- id: publish
name: Publish the frontend plugin skeleton in a new repository
if: ${{ parameters.pluginLocation === 'Create a new repository within the specified organization' }}
action: publish:github
input:
allowedHosts: ["github.com"]
allowedHosts: ['github.com']
description: This is ${{ parameters.plugin_id }} frontend plugin.
repoUrl: ${{ parameters.repoUrl }}
sourcePath: plugins/${{parameters.plugin_id}}
Expand All @@ -107,10 +125,23 @@ spec:
title: Create frontend plugin ${{ parameters.plugin_id }}
description: This pull request creates the skeleton for your frontend plugin

# This step registers the component if the contents are being published to a new repository
- id: register
name: Registering the Catalog Info Component
if: ${{ parameters.is_existing_repo === false }}
action: catalog:register
input:
repoContentsUrl: ${{ steps.publish.output.repoContentsUrl }}
catalogInfoPath: /catalog-info.yaml

# Outputs are displayed to the user after a successful execution of the template.
output:
links:
- title: View Plugin
url: ${{ steps.publish.output.remoteUrl }}
- title: View Pull Request
url: ${{ steps.publishGithub.output.remoteUrl }}
- title: Open the Catalog Info Component
if: ${{ parameters.is_existing_repo === false }}
icon: catalog
entityRef: ${{ steps.register.output.entityRef }}