community-plugins icon indicating copy to clipboard operation
community-plugins copied to clipboard

feat(annotator): add scaffolder action for version templates and entities

Open PatAKnight opened this issue 7 months ago • 1 comments

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

  • [x] A changeset describing the change and affected packages. (more info)
  • [x] Added or updated documentation
  • [x] Tests for new functionality and regression tests for bug fixes
  • [ ] Screenshots attached (for UI changes)
  • [x] All your commits have a Signed-off-by line in the message. (more info)

PatAKnight avatar May 20 '25 12:05 PatAKnight

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

backstage-goalie[bot] avatar May 20 '25 12:05 backstage-goalie[bot]

@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.

PatAKnight avatar May 20 '25 13:05 PatAKnight

Awesome, that would address https://github.com/backstage/community-plugins/issues/3892 as well then 🙏

awanlin avatar May 20 '25 13:05 awanlin

@awanlin, examples have been added: https://github.com/backstage/community-plugins/pull/4022/commits/b572328d109918faec4e82d24a0df5b567e8cc0c

PatAKnight avatar May 20 '25 15:05 PatAKnight

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.

dzemanov avatar May 26 '25 14:05 dzemanov

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 avatar May 26 '25 15:05 dzemanov

@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?

PatAKnight avatar Jun 02 '25 13:06 PatAKnight

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!

github-actions[bot] avatar Jun 17 '25 18:06 github-actions[bot]

@BethGriggs @debsmita1, do either one of you mind taking a look at this when you get a chance?

PatAKnight avatar Jun 18 '25 13:06 PatAKnight