Skip to content

Commit

Permalink
DO NOT MERGE BEFORE REMOVE THIS COMMIT. TESTING PURPOSES
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Riobo <[email protected]>
  • Loading branch information
adrianriobo committed Oct 24, 2024
1 parent 8b9d808 commit 4bef5e7
Showing 1 changed file with 141 additions and 0 deletions.
141 changes: 141 additions & 0 deletions crc-support/tkn/task.yaml
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 4bef5e7

Please sign in to comment.