In my scaffolder template.yaml, I have a case wherein I want to modify an input parameter in a certain way and want to use it in multiple steps. For eg.
# nonk8s
apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
name: my-template
spec:
owner: user:sayak
parameters:
- title: Enter Basic Information
required:
- name
- owner
properties:
name:
title: Name
type: string
description: Unique name of the component. Should be in the form of 'Component Name'.
ui:autofocus: true
description:
title: Description
type: string
description: Description of the component
owner:
title: Owner
type: string
description: Owner of the component
ui:field: OwnerPicker
ui:options:
catalogFilter:
kind:
- Group
- User
steps:
- id: template
name: Fetch Skeleton
action: fetch:template
input:
url: ./skeleton
values:
name: ${{ parameters.name }}
projectName: ${{ parameters.name| replace(' ', '') }}${{ parameters.description | replace(' ', '') }}${{ parameters.name | replace(' ', '') }}
- id: move-classes-to-package
name: Move Classes to Correct Package
action: fs:rename
input:
files:
- from: somefile
to: ${{ parameters.name| replace(' ', '') }}${{ parameters.description | replace(' ', '') }}${{ parameters.name | replace(' ', '') }}
overwrite: true
As you can see in the above, I am making the exact same modifications to the name and description parameters in the 2 steps. I want to keep my template DRY. Is there any possibility to define a single parameter from the name and description parameters and use that values in the 2 steps instead?
EDIT: I am aware that I could create a custom filter. But this seems like an overkill if I need a particular logic in only a single template.
EDIT2: I looked through the source and there doesn't seem to be any way for this to be achieved. I have created an issue for the same https://github.com/backstage/backstage/issues/18396. I think I might attempt a crack at a PR too.