apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: scos-build 
spec:
  params:
  - name: version
    description: The version repo
    type: string
  steps: 
  - name: assemble
    image: quay.io/coreos-assembler/coreos-assembler:latest
    resources:
      requests:
        # Today COSA hardcodes 2048 for launching VMs.  We could
        # probably shrink that in the future.
        memory: "3Gi"
        devices.kubevirt.io/kvm: "1"
      limits:
        memory: "3Gi"
        devices.kubevirt.io/kvm: "1"
    script: |
      #!/usr/bin/env bash
      #
      echo $(params.version) 
      set -euxo pipefail
      mkdir -p scos
      cd scos
      sudo curl -kL -o /etc/pki/ca-trust/source/anchors/Red_Hat_IT_Root_CA.crt https://password.corp.redhat.com/RH-IT-Root-CA.crt
      sudo update-ca-trust
      cosa init https://github.com/openshift/os.git
      ln -snf "manifest-c9s.yaml" "src/config/manifest.yaml"
      ln -snf "extensions-c9s.yaml" "src/config/extensions.yaml"
      ln -snf "image-c9s.yaml" "src/config/image.yaml"
      cp "src/config/repos/c9s.repo" "src/config/c9s.repo"
      echo -e "[rhel-8-server-ose]\nenabled=1\ngpgcheck=0\nbaseurl=http://download.eng.bos.redhat.com/rcm-guest/puddles/RHAOS/plashets/4.12-el8/building/x86_64/os" >> "src/config/c9s.repo"
      # git clone https://gitlab.cee.redhat.com/coreos/redhat-coreos.git
      # cp redhat-coreos/*.repo src/config/
      # cp redhat-coreos/content_sets.yaml src/config/
      
      cosa fetch
      cosa build
      cosa buildextend-metal4k
      cosa buildextend-metal
      cosa buildextend-live
    volumeMounts:
    - name: workdir
      mountPath: /srv
  volumes:
  - name: workdir
    emptyDir: {} 