#Template literal for Templates

1 messages · Page 1 of 1 (latest)

olive gull
#

It can be noob question or confusing but I really did not understand the functionality of ${{values.service}}-config.yaml.
Meanwhile. I am trying to parse entityRef where the default value is component:default/watchtower and I only need watchtower.

So my question, what is the best of passing this value to the ${{values.service}}-config.yaml and use watchtower there something like ${{ value.service }}

Here is the folder structure

.
├── files
│   └── configs
│       └── services
│           └── ${{values.service}}-config.yaml
└── template.yaml

Here is what I have ${{values.service}}-config.yaml.

apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
  name: ${{ values.service }}_config. 
  title: ${{ values.service | capitalize }} Config
  description: ${{ values.service | capitalize }} Config
spec:
  configs:
    - services:
        - ${{ values.service }}
      annotations:
        'backstage.io/techdocs-ref': 'dir:.'
  type: service
  owner: ${{ values.owner }}
  lifecycle: production

Here is my Template

apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
  name: update-service-entity-owner
  title: Update Service Entity Owner
  description: Update the owner of a service entity in the catalog
..
  parameters:
    - title: Update Service Entity Owner
      required:
        - entityRef
        - owner
      properties:
        entityRef:
          type: string
          title: Entity Reference
          description: The entity reference (e.g., `component:default/watchtower`)
          ui:field: EntityPicker
          ui:disabled: true
...
  steps:
    - id: extract-service-name
      name: Extract Service Name
      action: debug:log
      input:
        message: "Extracted service name: ${{ parameters.entityRef.split('component:default/')[1] }}"
      result: ${{ parameters.entityRef.split('component:default/')[1] }}
neon plover
#

To pass the value of the service you will use an action like fetch:template

and you pass a value service on that action

input:
    values:
       service: ${{ parameters.entityRef | parseEntityRef | pick('name') }}