From 4bef5e7a8efe70ea697fced1c1b127db88c0c4be Mon Sep 17 00:00:00 2001 From: Adrian Riobo Date: Thu, 24 Oct 2024 16:01:43 +0200 Subject: [PATCH] DO NOT MERGE BEFORE REMOVE THIS COMMIT. TESTING PURPOSES Signed-off-by: Adrian Riobo --- crc-support/tkn/task.yaml | 141 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 crc-support/tkn/task.yaml diff --git a/crc-support/tkn/task.yaml b/crc-support/tkn/task.yaml new file mode 100644 index 0000000..1f4581d --- /dev/null +++ b/crc-support/tkn/task.yaml @@ -0,0 +1,141 @@ +--- +apiVersion: tekton.dev/v1beta1 +kind: Task +metadata: + name: crc-support + labels: + app.kubernetes.io/version: "v1.0.0-dev" + redhat.com/product: openshift-local + dev.lifecycle.io/phase: testing + annotations: + tekton.dev/pipelines.minVersion: "0.44.x" + tekton.dev/categories: "openshift-local" + tekton.dev/tags: "openshift-local, testing" + tekton.dev/platforms: "linux/amd64" +spec: + description: >- + This task will prepare a target host with valid openshift local related assets + + It will download and install an specific Openshift Local version or can be used to download a specific bundle + + workspaces: + - name: host-info + description: | + ocp secret holding the hsot info credentials. Secret should be accessible to this task. + --- + apiVersion: v1 + kind: Secret + metadata: + name: XXXX + labels: + app.kubernetes.io/component: XXXX + type: Opaque + data: + host: XXXX + user: XXXX + password: XXXX + key: XXXX + platform: XXXX + os-version: XXXX + arch: XXXX + os: XXXX + mountPath: /opt/host/ + + params: + # OS parameter + - name: os + description: type of platform per target host (windows, darwin or linux). Default linux + default: linux + # Assets parameter + - name: asset-base-url + description: base url for the asset to be downloaded + - name: asset-name + description: name for the asset to be downloaded + - name: asset-shasum-name + description: file name for shasum to check asset + default: sha256sum.txt + - name: crc-version + description: Optional parameter to give info about crc version managed as version is not present within the asset name. + # Main stands for version being built from main of the head + default: main + # Control parameters + - name: download + description: controls if preparer will download the element + default: 'true' + - name: install + description: controls if preparer will install. (In case of distriutable) + default: 'true' + - name: force-fresh + description: controls if preparer will remove any previous existing crc version + default: 'true' + - name: debug + description: increase verbosity + default: 'false' + + results: + - name: target-path + description: Path on target host where the item has been dowloaded + + steps: + - name: preparer + image: quay.io/crc-org/ci-crc-support:v1.0.0-dev-$(params.os) + imagePullPolicy: Always + script: | + #!/bin/bash + + if [ "$(params.debug)" = "true" ]; then + set -xuo + fi + + # Prepare ENVs + SECONDS=0 + DEBUG=$(params.debug) + TARGET_HOST=$(cat /opt/host/host) + TARGET_HOST_USERNAME=$(cat /opt/host/user) + cp /opt/host/key id_rsa + chmod 600 id_rsa + TARGET_HOST_KEY_PATH=id_rsa + TARGET_FOLDER=crc-support + TARGET_CLEANUP='true' + + # Create cmd per OS + runner="run.sh" + if [[ $(params.os) == "windows" ]]; then + runner="run.ps1" + fi + # Path for assets on remote target + tPath='/Users/$(params.username)/OpenshiftLocal' + if [[ $(params.os) == 'linux' ]]; then + tPath="/home/$(params.username)/OpenshiftLocal" + fi + if [[ $name == *'.crcbundle' ]]; then + # It is bundle + nameArr=(${name//_/ }) + tPath+='/bundle/${nameArr[2]}' + else + tPath+='/crc/$(params.crc-version) + fi + + cmd="${TARGET_FOLDER}/${runner} -targetPath $tPath " + cmd+="-aBaseURL $(params.asset-base-url) " + cmd+="-aName $(params.asset-name) " + cmd+="-aSHAName $(params.asset-shasum-name) " + cmd+="-freshEnv $(params.force-fresh) " + cmd+="-download $(params.download) " + cmd+="-install $(params.install) " + cmd+="-debug $(params.debug) " + + # Exec + . entrypoint.sh "${cmd}" + + # Results + echo -n "$tPath" | tee $(results.target-path.path) + + resources: + requests: + memory: "100Mi" + cpu: "50m" + limits: + memory: "140Mi" + cpu: "100m" + \ No newline at end of file