Skip to content

Commit

Permalink
chore: sync crc-builder linux amd64 tekton task contract. Fix #37.
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Riobo <[email protected]>
  • Loading branch information
adrianriobo committed Oct 23, 2024
1 parent 717d6e2 commit 7cb9077
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 74 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
12 changes: 10 additions & 2 deletions crc-builder/oci/lib/darwin/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
crcSCM="https://github.com/code-ready/crc.git"
crcSCMPR=''
crcSCMRef='main'
targetFolder="crc-builder"
uploadPath='crc-binaries'
datalakeURL=''
datalakeAcessKey=''
Expand All @@ -27,6 +28,11 @@ while [[ $# -gt 0 ]]; do
shift
shift
;;
-targetFolder)
targetFolder="$2"
shift
shift
;;
-uploadPath)
uploadPath="$2"
shift
Expand Down Expand Up @@ -82,13 +88,15 @@ s3_upload() {
####### MAIN ########
#####################

cd $targetFolder

# Custom setup for git
git config --global http.version "HTTP/1.1"
git config --global http.lowSpeedLimit 0
git config --global http.lowSpeedTime 999999

# Get crc code
git clone ${CRC_SCM}
git clone $crcSCM

# Fetch according to parameters provided
CRC_VERSION_PARTIAL=$(date +'%y.%m.%d')
Expand All @@ -111,7 +119,7 @@ make -C admin-helper macos-universal VERSION=$admin_version

# Build vfkit
git clone https://github.com/code-ready/vfkit.git
sudo make -C vfkit all
make -C vfkit all

# Build pkg
pushd crc
Expand Down
4 changes: 4 additions & 0 deletions crc-builder/oci/lib/windows/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ param(
$crcSCMPR,
[Parameter(HelpMessage='crc scm ref')]
$crcSCMRef="main",
[Parameter(HelpMessage='folder on the remote target to move all assets to run the builder')]
$targetFolder="crc-builder",
[Parameter(HelpMessage='upload path on remote storage where upload the artifacts')]
$uploadPath,
[Parameter(Mandatory,HelpMessage='url for remote s3 compatible storage where build bits will be stored')]
Expand Down Expand Up @@ -53,6 +55,8 @@ function Get-UploadPath($crcVersion, $crcSCMPR, $crcSCMRef) {
####### MAIN ##########
#######################

cd $targetFolder

# Custom setup for git
git config --global http.version "HTTP/1.1"
git config --global http.lowSpeedLimit 0
Expand Down
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
6 changes: 5 additions & 1 deletion 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 Expand Up @@ -112,6 +115,7 @@ spec:
if [[ $(params.crc-scm-pr) != "" ]]; then
cmd+="-crcSCMPR $(params.crc-scm-pr) "
fi
cmd+="-targetFolder ${TARGET_FOLDER} "
cmd+="-uploadPath $(cat /opt/s3-credentials/bucket)/$(params.s3-folder-path) "
cmd+="-datalakeURL $(cat /opt/s3-credentials/upload-url) "
cmd+="-datalakeAcessKey $(cat /opt/s3-credentials/access-key) "
Expand All @@ -123,7 +127,7 @@ spec:
exit 1
fi
echo -n "$(params.s3-download-url)" \
echo -n "$(cat /opt/s3-credentials/download-url)/$(params.s3-folder-path)" \
| tee $(results.downloadable-base-url.path)
case "$(params.os)" in
macos|darwin)
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 "$(cat /opt/s3-credentials/download-url)/$(params.s3-folder-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 7cb9077

Please sign in to comment.