Skip to content

Commit

Permalink
chore: sync crc-builder linux amd64 tekton task contract.
Browse files Browse the repository at this point in the history
Now all tekton tasks for builders use credentials based on worspace.

Signed-off-by: Adrian Riobo <[email protected]>
  • Loading branch information
adrianriobo committed Oct 21, 2024
1 parent 4c77634 commit b95257e
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 71 deletions.
1 change: 0 additions & 1 deletion crc-builder/oci/Containerfile.linux
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ RUN microdnf -y install git make gcc libvirt-devel perl-Digest-SHA xz findutils
&& chmod +x /usr/local/bin/mc \
&& rm /tmp/${GO_VERSION}.tar.gz

COPY lib/common.sh /usr/local/bin
COPY lib/linux/entrypoint.sh /usr/local/bin/entrypoint.sh

ENTRYPOINT entrypoint.sh
22 changes: 10 additions & 12 deletions crc-builder/tkn/tpl/crc-builder-arm64.tpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,15 @@ spec:
# SCM params
- name: crc-scm
default: https://github.com/code-ready/crc.git
- name: crc-scm-pr
default: "''"
- name: crc-scm-ref
default: main
- name: crc-scm-pr
default: "''"


# Target params
- name: s3-folder-path
default: 'crc-binaries'

# Builder params
- name: builder-cpus
Expand Down Expand Up @@ -140,19 +142,15 @@ spec:
}
cmd="podman run --rm --name crc-builder -d "
cmd+="-e DATALAKE_URL=$(cat /opt/s3-credentials/upload-url) "
cmd+="-e DATALAKE_ACCESS_KEY=$(cat /opt/s3-credentials/access-key) "
cmd+="-e DATALAKE_SECRET_KEY=$(cat /opt/s3-credentials/secret-key) "
# Optionals
if [[ $(params.crc-scm) != "" ]]; then
cmd+="-e CRC_SCM=$(params.crc-scm) "
fi
# SCM
cmd+="-e CRC_SCM=$(params.crc-scm) "
cmd+="-e CRC_SCM_REF=$(params.crc-scm-ref) "
if [[ $(params.crc-scm-pr) != "" ]]; then
cmd+="-e CRC_SCM_PR=$(params.crc-scm-pr) "
fi
if [[ $(params.crc-scm-ref) != "" ]]; then
cmd+="-e CRC_SCM_REF=$(params.crc-scm-ref) "
fi
cmd+="-e DATALAKE_URL=$(cat /opt/s3-credentials/upload-url) "
cmd+="-e DATALAKE_ACCESS_KEY=$(cat /opt/s3-credentials/access-key) "
cmd+="-e DATALAKE_SECRET_KEY=$(cat /opt/s3-credentials/secret-key) "
if [[ $(params.s3-folder-path) != "" ]]; then
cmd+="-e UPLOAD_PATH=$(cat /opt/s3-credentials/bucket)/$(params.s3-folder-path) "
fi
Expand Down
3 changes: 3 additions & 0 deletions crc-builder/tkn/tpl/crc-builder-installer.tpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ spec:
default: main
- name: crc-scm-pr
default: "''"
# Target params
- name: s3-folder-path
default: 'crc-binaries'
# Control params
- name: debug
description: debug purposes extend verbosity on cmds executed on the target
Expand Down
129 changes: 71 additions & 58 deletions crc-builder/tkn/tpl/crc-builder.tpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,70 +18,83 @@ spec:
description: >-
This task will build openshift local binary for linux distributions
workspaces:
- name: s3-credentials
description: |
ocp secret holding the s3 credentials. Secret should be accessible to this task.
---
apiVersion: v1
kind: Secret
metadata:
name: XXXX
labels:
app.kubernetes.io/component: XXXX
type: Opaque
data:
download-url: ${download_url}
upload-url: ${upload_url}
bucket: ${bucket_value}
access-key: ${access_key}
secret-key: ${secret_key}
mountPath: /opt/s3-credentials

params:
- name: crc-scm
default: https://github.com/code-ready/crc.git
- name: crc-scm-pr
default: "''"
- name: crc-scm-ref
default: main
- name: s3-url
- name: s3-access-key
- name: s3-secret-key
- name: s3-folder-path
- name: s3-download-url
# SCM params
- name: crc-scm
default: https://github.com/code-ready/crc.git
- name: crc-scm-ref
default: main
- name: crc-scm-pr
default: "''"

# Target params
- name: s3-folder-path
default: 'crc-binaries'

results:
- name: downloadable-base-url
description: base url where the installer and the shasumfile can be downloaded
- name: distributable-name
description: distributable file name for the installer
- name: shasumfile
description: shasumfile name
- name: downloadable-base-url
description: base url where the installer and the shasumfile can be downloaded
- name: distributable-name
description: distributable file name for the installer
- name: shasumfile
description: shasumfile name

steps:
- name: build
# cimage and cversion values should be passed to the template
image: cimage:cversion-linux
imagePullPolicy: Always
script: |
#!/bin/sh
DATALAKE_URL=$(params.s3-url)
DATALAKE_ACCESS_KEY=$(params.s3-access-key)
DATALAKE_SECRET_KEY=$(params.s3-secret-key)
- name: build
# cimage and cversion values should be passed to the template
image: cimage:cversion-linux
imagePullPolicy: Always
script: |
#!/bin/sh
# Optionals
if [[ $(params.crc-scm) != "" ]]; then
# SCM
CRC_SCM=$(params.crc-scm)
fi
if [[ $(params.crc-scm-pr) != "" ]]; then
CRC_SCM_PR=$(params.crc-scm-pr)
fi
if [[ $(params.crc-scm-ref) != "" ]]; then
CRC_SCM_REF=$(params.crc-scm-ref)
fi
if [[ $(params.s3-folder-path) != "" ]]; then
UPLOAD_PATH=$(params.s3-folder-path)
fi
# Build installer
DEBUG=true
. entrypoint.sh
if [[ $? -ne 0 ]]; then
exit 1
fi
if [[ $(params.crc-scm-pr) != "" ]]; then
CRC_SCM_PR=$(params.crc-scm-pr)
fi
DATALAKE_URL=$(cat /opt/s3-credentials/upload-url)
DATALAKE_ACCESS_KEY=$(cat /opt/s3-credentials/access-key)
DATALAKE_SECRET_KEY=$(cat /opt/s3-credentials/secret-key)
UPLOAD_PATH=$(cat /opt/s3-credentials/bucket)/$(params.s3-folder-path)
# Build installer
DEBUG=true
. entrypoint.sh
if [[ $? -ne 0 ]]; then
exit 1
fi
# From entrypoint we can get UPLOAD_PATH env with the target bucket
echo -n "$(params.s3-download-url)/${UPLOAD_PATH}" | tee $(results.downloadable-base-url.path)
# Linux generated files
echo -n "crc-linux-amd64.tar.xz" | tee $(results.distributable-name.path)
echo -n "crc-linux-amd64.tar.xz.sha256sum" | tee $(results.shasumfile.path)
resources:
requests:
memory: 450Mi
cpu: 250m
limits:
memory: 3800Mi
cpu: 1850m
timeout: 900m
# From entrypoint we can get UPLOAD_PATH env with the target bucket
echo -n "$(params.s3-download-url)/${UPLOAD_PATH}" | tee $(results.downloadable-base-url.path)
# Linux generated files
echo -n "crc-linux-amd64.tar.xz" | tee $(results.distributable-name.path)
echo -n "crc-linux-amd64.tar.xz.sha256sum" | tee $(results.shasumfile.path)
resources:
requests:
memory: 450Mi
cpu: 250m
limits:
memory: 3800Mi
cpu: 1850m
timeout: 900m

0 comments on commit b95257e

Please sign in to comment.