apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
  description: Creates a Basic Kubernetes Deployment
  name: argo-workflows-basic
  title: Basic Argo Workflow with a Spark Job
spec:
  owner: guests
  type: service
  parameters:
    - title: Configuration Options
      required:
        - name
      properties:
        name:
          type: string
          description: name of this application
        mainApplicationFile:
          type: string
          default: 'local:///opt/spark/examples/jars/spark-examples_2.12-3.1.3.jar'
          description: Path to the main application file
        
  steps:
    - id: template
      name: Generating component
      action: fetch:template
      input:
        url: ./skeleton
        values:
          name: ${{parameters.name}}

    - id: publish
      name: Publishing to a gitea git repository
      action: publish:gitea
      input:
        description: This is an example app
        # Hard coded value for this demo purposes only.
        repoUrl: gitea.factory.c-one-infra.de:443/?repo=${{parameters.name}}
        defaultBranch: main
    - id: create-argocd-app
      name: Create ArgoCD App
      action: cnoe:create-argocd-app
      input:
        appName: ${{parameters.name}}
        appNamespace: ${{parameters.name}}
        argoInstance: in-cluster
        projectName: default
        # necessary until we generate our own cert
        repoUrl: https://gitea.factory.c-one-infra.de:443/giteaAdmin/${{parameters.name}}
        path: "manifests"
    - id: register
      name: Register
      action: catalog:register
      input:
        repoContentsUrl: ${{ steps['publish'].output.repoContentsUrl }}
        catalogInfoPath: 'catalog-info.yaml'

  output:
    links:
      - title: Open in catalog
        icon: catalog
        entityRef: ${{ steps['register'].output.entityRef }}
