apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
  name: xl-cli-yaml-inline
  title: Provision Digital.ai Release/Deploy by applying inline YAML using the xl CLI
  description: The xl command line tool method for provisioning Digital.ai Release and Deploy servers using YAML file
spec:
  owner: default:user/guest
  type: service
  parameters:
    - title:  Select Product
      required:
        - product
        - yamlContent
        - filePath
      properties:
        product:
          type: string
          enum:
            - xl-release
            - xl-deploy
          default: xl-deploy
        yamlContent:
          title: Text area input
          type: string
          description: Insert your multi line string
          ui:widget: textarea
          ui:options:
            rows: 10
          ui:help: 'Hint: Make it strong!'
          ui:placeholder: |
            apiVersion: backstage.io/v1alpha1
              kind: Component
              metadata:
                name: backstage
              spec:
                type: library
                owner: CNCF
                lifecycle: experimental
        releaseInstance:
          title: Release Instance
          type: string
          description: Release instance to run the command
        filePath:
          title: filePath
          type: string
          description: Path to save the yaml file
  steps:
    - id: debug-log
      name: Log Selected Option
      action: debug:log
      input:
        message: "You selected: ${{ parameters.product }} -  ${{ parameters.filePath }} - ${{ parameters.yamlContent }}"
    - id: write-to-file
      name: Overwrite File Or Create New
      action: roadiehq:utils:fs:write
      input:
        path: ${{ parameters.filePath }}
        content: ${{ parameters.yamlContent }}
    - id: xlcliApply
      name: Apply xl-cli
      action: digitalai:xlcli:apply
      input:
        product: ${{ parameters.product }}
        releaseInstance: ${{ parameters.releaseInstance }}
        filePath: ${{ parameters.filePath }}