Skip to content

Commit fdc7c97

Browse files
committed
add example
1 parent 15e1284 commit fdc7c97

File tree

6 files changed

+146
-0
lines changed

6 files changed

+146
-0
lines changed

examples/entities.yaml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
# https://backstage.io/docs/features/software-catalog/descriptor-format#kind-system
3+
apiVersion: backstage.io/v1alpha1
4+
kind: System
5+
metadata:
6+
name: examples
7+
spec:
8+
owner: guests
9+
---
10+
# https://backstage.io/docs/features/software-catalog/descriptor-format#kind-component
11+
apiVersion: backstage.io/v1alpha1
12+
kind: Component
13+
metadata:
14+
name: example-website
15+
spec:
16+
type: website
17+
lifecycle: experimental
18+
owner: guests
19+
system: examples
20+
providesApis: [example-grpc-api]
21+
---
22+
# https://backstage.io/docs/features/software-catalog/descriptor-format#kind-api
23+
apiVersion: backstage.io/v1alpha1
24+
kind: API
25+
metadata:
26+
name: example-grpc-api
27+
spec:
28+
type: grpc
29+
lifecycle: experimental
30+
owner: guests
31+
system: examples
32+
definition: |
33+
syntax = "proto3";
34+
35+
service Exampler {
36+
rpc Example (ExampleMessage) returns (ExampleMessage) {};
37+
}
38+
39+
message ExampleMessage {
40+
string example = 1;
41+
};

examples/org.yaml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
# https://backstage.io/docs/features/software-catalog/descriptor-format#kind-user
3+
apiVersion: backstage.io/v1alpha1
4+
kind: User
5+
metadata:
6+
name: guest
7+
spec:
8+
memberOf: [guests]
9+
---
10+
# https://backstage.io/docs/features/software-catalog/descriptor-format#kind-group
11+
apiVersion: backstage.io/v1alpha1
12+
kind: Group
13+
metadata:
14+
name: guests
15+
spec:
16+
type: team
17+
children: []
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: backstage.io/v1alpha1
2+
kind: Component
3+
metadata:
4+
name: ${{ values.name | dump }}
5+
spec:
6+
type: service
7+
owner: user:guest
8+
lifecycle: experimental

examples/template/content/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('Hello from ${{ values.name }}!');
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "${{ values.name }}",
3+
"private": true,
4+
"dependencies": {}
5+
}

examples/template/template.yaml

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
apiVersion: scaffolder.backstage.io/v1beta3
2+
# https://backstage.io/docs/features/software-catalog/descriptor-format#kind-template
3+
kind: Template
4+
metadata:
5+
name: example-nodejs-template
6+
title: Example Node.js Template
7+
description: An example template for the scaffolder that creates a simple Node.js service
8+
spec:
9+
owner: user:guest
10+
type: service
11+
12+
# These parameters are used to generate the input form in the frontend, and are
13+
# used to gather input data for the execution of the template.
14+
parameters:
15+
- title: Fill in some steps
16+
required:
17+
- name
18+
properties:
19+
name:
20+
title: Name
21+
type: string
22+
description: Unique name of the component
23+
ui:autofocus: true
24+
ui:options:
25+
rows: 5
26+
- title: Choose a location
27+
required:
28+
- repoUrl
29+
properties:
30+
repoUrl:
31+
title: Repository Location
32+
type: string
33+
ui:field: RepoUrlPicker
34+
ui:options:
35+
allowedHosts:
36+
- github.com
37+
38+
# These steps are executed in the scaffolder backend, using data that we gathered
39+
# via the parameters above.
40+
steps:
41+
# Each step executes an action, in this case one templates files into the working directory.
42+
- id: fetch-base
43+
name: Fetch Base
44+
action: fetch:template
45+
input:
46+
url: ./content
47+
values:
48+
name: ${{ parameters.name }}
49+
50+
# This step publishes the contents of the working directory to GitHub.
51+
- id: publish
52+
name: Publish
53+
action: publish:github
54+
input:
55+
allowedHosts: ['github.com']
56+
description: This is ${{ parameters.name }}
57+
repoUrl: ${{ parameters.repoUrl }}
58+
59+
# The final step is to register our new component in the catalog.
60+
- id: register
61+
name: Register
62+
action: catalog:register
63+
input:
64+
repoContentsUrl: ${{ steps['publish'].output.repoContentsUrl }}
65+
catalogInfoPath: '/catalog-info.yaml'
66+
67+
# Outputs are displayed to the user after a successful execution of the template.
68+
output:
69+
links:
70+
- title: Repository
71+
url: ${{ steps['publish'].output.remoteUrl }}
72+
- title: Open in catalog
73+
icon: catalog
74+
entityRef: ${{ steps['register'].output.entityRef }}

0 commit comments

Comments
 (0)