feat(annotator): add scaffolder action for version templates and entities
Hey, I just made a Pull Request!
Adds a new scaffolder action to the scaffolder-backend-module-annotator that can be used to add the annotation backstage.io/template-version to the entities that the template creates. This action, alongside the catalog:scaffolded-from action can be used to track the version of your scaffolder templates as well as the versions of the entities created from it.
:heavy_check_mark: Checklist
Changed Packages
| Package Name | Package Path | Changeset Bump | Current Version |
|---|---|---|---|
| @backstage-community/plugin-scaffolder-backend-module-annotator | workspaces/scaffolder-backend-module-annotator/plugins/scaffolder-backend-module-annotator | minor | v2.7.0 |
@awanlin Of course, will be adding them in shortly. I'll also go ahead and add the missing examples for the other actions under this plugin as well.
Awesome, that would address https://github.com/backstage/community-plugins/issues/3892 as well then 🙏
@awanlin, examples have been added: https://github.com/backstage/community-plugins/pull/4022/commits/b572328d109918faec4e82d24a0df5b567e8cc0c
I have updated the action id to test the PR out in the meantime.
I am getting this error on the Register step when running 02-scaffolder-template.yaml without specifying template version:
{
"error": {
"name": "InputError",
"message": "InputError: Policy check failed for component:default/test-version1; caused by Error: Malformed envelope, /metadata/annotations/backstage.io~1template-version must be string",
"stack": "InputError: InputError: Policy check failed for component:default/test-version1; caused by Error: Malformed envelope, /metadata/annotations/backstage.io~1template-version must be string\n at DefaultLocationService.processEntities (/Users/dzemanov/Documents/Projects/community-plugins/workspaces/scaffolder-backend-module-annotator/node_modules/@backstage/plugin-catalog-backend/src/service/DefaultLocationService.ts:110:15)\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n at async DefaultLocationService.dryRunCreateLocation (/Users/dzemanov/Documents/Projects/community-plugins/workspaces/scaffolder-backend-module-annotator/node_modules/@backstage/plugin-catalog-backend/src/service/DefaultLocationService.ts:148:32)\n at async <anonymous> (/Users/dzemanov/Documents/Projects/community-plugins/workspaces/scaffolder-backend-module-annotator/node_modules/@backstage/plugin-catalog-backend/src/service/createRouter.ts:549:26)"
},
"request": {
"method": "POST",
"url": "/locations?dryRun=true"
},
"response": {
"statusCode": 400
}
}
It created the entity with annotation: backstage.io/template-version: []
Ach, I originally thought without specifying, template automatically uses latest default version. I wonder if it should tell me this prop is required? The template says version-0 * so it looks like this is required, but I was able to run the template without specifying it.
For when I select some version when running 02-scaffolder-template.yaml, it creates the entity with annotation:
backstage.io/template-version:
- 0.0.1
And fails on register step with the same problem: template-version must be string
@dzemanov, I believe that the problem was occurring because of the example that I included. I had it set as an array of strings instead of a single string. The example should be fixed, do you mind retesting and seeing if you still run into the same problem?
This PR has been automatically marked as stale because it has not had recent activity from the author. It will be closed if no further activity occurs. If the PR was closed and you want it re-opened, let us know and we'll re-open the PR so that you can continue the contribution!
@BethGriggs @debsmita1, do either one of you mind taking a look at this when you get a chance?