You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The annotator module for [@backstage/plugin-scaffolder-backend](https://www.npmjs.com/package/@backstage/plugin-scaffolder-backend).
4
4
5
-
This module enables users to generate custom actions for annotating their entity object(s).
5
+
This module allows users to create custom actions for annotating their entity objects. Additionally, it enables users to utilize existing custom actions provided by the module for annotating entities with timestamps and scaffolder entity references.
### Registering the annotator action plugin with the new backend system
10
24
11
25
To install the module into the [new backend system](https://backstage.io/docs/backend-system/), add the following into the `packages/backend/src/index.ts` file:
12
26
@@ -22,23 +36,17 @@ backend.add(
22
36
backend.start();
23
37
```
24
38
25
-
### Installing on the legacy backend system
39
+
### Registering the annotator action plugin with the legacy backend system
26
40
27
-
1. Install the Annotator custom action plugin using the following command:
3. To annotate the catalog-info.yaml skeleton with the current timestamp, add the **catalog:timestamping** custom action in your template yaml after the `Fetch Skeleton + Template` step:
90
+
2. To annotate the `catalog-info.yaml` skeleton with the current timestamp, add the `catalog:timestamping` custom action in your template's YAML file after the `Fetch Skeleton + Template` step. Refer to the [example templates](./examples/) for examples on how it's used in a template.
83
91
84
92
```yaml title="template.yaml"
85
93
steps:
@@ -95,7 +103,7 @@ steps:
95
103
# highlight-add-end
96
104
```
97
105
98
-
4. To annotate the catalog-info.yaml skeleton with the templateentityRef, add the **catalog:scaffolded-from** custom action in your template yaml after the `Fetch Skeleton + Template` step:
106
+
3. To annotate the `catalog-info.yaml` skeleton with the template's `entityRef`, add the `catalog:scaffolded-from` custom action in your YAML file after the `Fetch Skeleton + Template` step. Refer to the [example templates](./examples/) for examples on how it is used in a template.
99
107
100
108
```yaml "title=template.yaml"
101
109
steps:
@@ -111,40 +119,97 @@ steps:
111
119
112
120
```
113
121
114
-
## Usage
122
+
4. To use the `catalog:annotate` action to annotate your entity object. Refer to the [example templates](./examples/) for examples on how it is used in a template.
115
123
116
-
To use the `createAnnotatorAction` to create a custom action
124
+
```yaml "title=template.yaml"
125
+
steps:
126
+
- id: template
127
+
name: Fetch Skeleton + Template
128
+
action: fetch:template
129
+
...
130
+
# highlight-add-start
131
+
- id: add-fields-to-catalog-info
132
+
name: Add a few fields into `catalog-info.yaml` using the generic action
133
+
action: catalog:annotate
134
+
input:
135
+
labels:
136
+
custom: ${{ parameters.label }}
137
+
other: "test-label"
138
+
annotations:
139
+
custom.io/annotation: ${{ parameters.label }}
140
+
custom.io/other: "value"
141
+
# highlight-add-end
142
+
143
+
```
144
+
145
+
## Creating custom actions for your templates using the annotator module
146
+
147
+
### Create the custom action
148
+
149
+
#### The `createAnnotatorAction` action accepts the following parameters:
150
+
151
+
| Parameter Name | Type | Required | Description |
|`actionId`|`string`| Yes | A unique id for the action. Default: `catalog:annotate`, please provide one or else it may conflict with the generic `catalog:annotate` custom action that is provided by this module. |
154
+
|`actionDescription`|`string`| No | A description of what the action accomplishes. Default: "Creates a new scaffolder action to annotate the entity object with specified label(s), annotation(s) and spec property(ies)." |
155
+
|`loggerInfoMsg`|`string`| No | A message that will be logged upon the execution of the action. Default: "Annotating your object" |
156
+
|`annotateEntityObject.labels`|`object`| No | Key-value pairs to be added to the `metadata.labels` of the entity |
157
+
|`annotateEntityObject.annotations`|`object`| No | Key-value pairs to be added to the `metadata.annotations` of the entity |
158
+
|`annotateEntityObject.spec`|`object`| No | Key-value pairs to be added to the `spec` of the entity. The value for each key can either be a string or an object with the key `readFromContext`, enabling users to specify the path in the context from which the value should be retrieved. |
159
+
160
+
1. Create your [custom action](https://backstage.io/docs/features/software-templates/writing-custom-actions#writing-your-custom-action)
161
+
162
+
2. Add the annotator module package `@janus-idp/backstage-scaffolder-backend-module-annotator` into your module's `package.json`
117
163
118
-
| Parameter Name | Type | Required | Description |
|`actionId`|`string`| Yes | A unique id for the action |
121
-
|`actionDescription`|`string`| Yes | A description of what the action accomplishes |
122
-
|`loggerInfoMsg`|`string`| No | A message that will be logged upon the execution of the action |
123
-
|`annotateEntityObject.labels`|`object`| No | Key-value pairs to be added to the `metadata.labels` of the entity |
124
-
|`annotateEntityObject.annotations`|`object`| No | Key-value pairs to be added to the `metadata.annotations` of the entity |
125
-
|`annotateEntityObject.spec`|`object`| No | Key-value pairs to be added to the `metadata.spec` of the entity. The value for each key can either be a string or an object with the key `readFromContext`, enabling users to specify the path in the context from which the value should be retrieved. |
164
+
3. In the action file, add the following snippet to it:
|`annotatedObject`|`object`| The entity object marked with your specified annotation(s), label(s), and spec property(ies) |
144
202
145
-
Here are the custom actions currently available:
203
+
To annotate the entity file, add your custom action to your template file after `Fetch Skeleton + Template` step. Please note that your custom action needs to be installed into the backstage instance running the software template.
0 commit comments