Skip to content

Commit 40c174a

Browse files
committed
feat(backstage): scaffold XQueueClaim template with PR automation
- Add Makefile for simplified local Backstage start - Register new template in app-config.yaml - Introduce XQueueClaim scaffolder template with parameters and validations - Automate PR creation with generated claim YAML in target repo
1 parent 1400a39 commit 40c174a

File tree

5 files changed

+117
-0
lines changed

5 files changed

+117
-0
lines changed

backstage/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
start:
2+
@echo "Starting Backstage with --no-node-snapshot..."
3+
NODE_OPTIONS=--no-node-snapshot yarn start

backstage/app-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ catalog:
8888
rules:
8989
- allow: [Template]
9090

91+
# Local example template
92+
- type: file
93+
target: ../../catalog/templates/xqueue-claim/template.yaml
94+
rules:
95+
- allow: [Template]
96+
9197
# Local example organizational data
9298
- type: file
9399
target: ../../examples/org.yaml

backstage/catalog/templates/application/.gitkeep

Whitespace-only changes.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: platform.hooli.tech/v1alpha1
2+
kind: XQueueClaim
3+
metadata:
4+
name: ${{ values.queueName }}
5+
spec:
6+
location: ${{ values.location }}
7+
providerName: ${{ values.providerName }}
8+
visibilityTimeoutSeconds: ${{ values.visibilityTimeoutSeconds }}
9+
maxMessageSize: ${{ values.maxMessageSize }}
10+
{%- if values.tags %}
11+
tags:
12+
{%- for key, val in values.tags %}
13+
${{ key }}: ${{ val }}
14+
{%- endfor %}
15+
{%- endif %}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
apiVersion: scaffolder.backstage.io/v1beta3
2+
kind: Template
3+
metadata:
4+
name: create-xqueue-claim
5+
title: Create XQueue Claim
6+
description: Creates a Crossplane XQueueClaim and opens a PR with the YAML.
7+
spec:
8+
owner: user:guest
9+
type: infrastructure
10+
11+
parameters:
12+
- title: Queue Configuration
13+
required: [queueName, location, providerName]
14+
properties:
15+
queueName:
16+
type: string
17+
title: Queue name
18+
pattern: '^[a-z0-9]+(-[a-z0-9]+)*$'
19+
description: Must be in kebab-case (e.g. "my-queue-name")
20+
errorMessage: Queue name must be in kebab-case, using only lowercase letters, numbers, and hyphens (e.g. "my-queue-name")
21+
location:
22+
type: string
23+
title: Location
24+
enum: [EU, US]
25+
providerName:
26+
type: string
27+
title: Provider Name
28+
description: Select the provider to use for this queue.
29+
enum:
30+
- default
31+
enumNames:
32+
- Localstack
33+
visibilityTimeoutSeconds:
34+
type: integer
35+
title: Visibility Timeout
36+
default: 30
37+
description: The duration (in seconds) that a received message is hidden from subsequent receive requests after being retrieved from the queue.
38+
maxMessageSize:
39+
type: integer
40+
title: Max Message Size (bytes)
41+
default: 262144
42+
description: The limit of how many bytes a message can contain before being rejected. # Valid values: 1024 (1 KiB) to 262144 (256 KiB).
43+
tags:
44+
type: object
45+
title: Tags (optional)
46+
description: Key-value tags to help identify or categorize the queue.
47+
additionalProperties:
48+
type: string
49+
default: {}
50+
51+
steps:
52+
- id: fetch-template
53+
name: Render local XQueueClaim template
54+
action: fetch:template
55+
input:
56+
url: ./skeleton
57+
targetPath: ./output
58+
values:
59+
queueName: ${{ parameters.queueName }}
60+
location: ${{ parameters.location }}
61+
providerName: ${{ parameters.providerName }}
62+
visibilityTimeoutSeconds: ${{ parameters.visibilityTimeoutSeconds }}
63+
maxMessageSize: ${{ parameters.maxMessageSize }}
64+
tags: ${{ parameters.tags }}
65+
66+
- id: publish-pr
67+
name: Publish to GitHub
68+
action: publish:github:pull-request
69+
input:
70+
allowedHosts: ['github.com']
71+
repoUrl: github.com?repo=platform-engineering-backstack&owner=wnqueiroz
72+
branchName: feature/add-xqueue-${{ parameters.queueName }}
73+
title: 'feat(xqueue): add claim for ${{ parameters.queueName }}'
74+
description: |
75+
This PR was automatically created via [Backstage Scaffolder](https://backstage.io/).
76+
77+
A new **XQueueClaim** has been scaffolded with the following configuration:
78+
79+
- **Queue Name**: `${{ parameters.queueName }}`
80+
- **Location**: `${{ parameters.location }}`
81+
- **Provider**: `${{ parameters.providerName }}`
82+
- **Visibility Timeout**: `${{ parameters.visibilityTimeoutSeconds }}s`
83+
- **Max Message Size**: `${{ parameters.maxMessageSize }} bytes`
84+
85+
> Tags and additional configuration can be found in the generated YAML file.
86+
sourcePath: ./output
87+
targetPath: crossplane/claims
88+
89+
output:
90+
links:
91+
- title: View Pull Request
92+
icon: github
93+
url: ${{ steps['publish-pr'].output.remoteUrl }}

0 commit comments

Comments
 (0)