diff --git a/crc-builder/oci/Containerfile.linux b/crc-builder/oci/Containerfile.linux index 4dcc814..fa18b9b 100644 --- a/crc-builder/oci/Containerfile.linux +++ b/crc-builder/oci/Containerfile.linux @@ -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 \ No newline at end of file diff --git a/crc-builder/oci/lib/darwin/run.sh b/crc-builder/oci/lib/darwin/run.sh index e72014a..98380df 100755 --- a/crc-builder/oci/lib/darwin/run.sh +++ b/crc-builder/oci/lib/darwin/run.sh @@ -4,6 +4,7 @@ crcSCM="https://github.com/code-ready/crc.git" crcSCMPR='' crcSCMRef='main' +targetFolder="crc-builder" uploadPath='crc-binaries' datalakeURL='' datalakeAcessKey='' @@ -27,6 +28,11 @@ while [[ $# -gt 0 ]]; do shift shift ;; + -targetFolder) + targetFolder="$2" + shift + shift + ;; -uploadPath) uploadPath="$2" shift @@ -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') @@ -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 diff --git a/crc-builder/oci/lib/windows/run.ps1 b/crc-builder/oci/lib/windows/run.ps1 index dd11e85..fc18020 100644 --- a/crc-builder/oci/lib/windows/run.ps1 +++ b/crc-builder/oci/lib/windows/run.ps1 @@ -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')] @@ -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 diff --git a/crc-builder/tkn/tpl/crc-builder-arm64.tpl.yaml b/crc-builder/tkn/tpl/crc-builder-arm64.tpl.yaml index 47c2d1e..13d26a5 100644 --- a/crc-builder/tkn/tpl/crc-builder-arm64.tpl.yaml +++ b/crc-builder/tkn/tpl/crc-builder-arm64.tpl.yaml @@ -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 @@ -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 diff --git a/crc-builder/tkn/tpl/crc-builder-installer.tpl.yaml b/crc-builder/tkn/tpl/crc-builder-installer.tpl.yaml index 70665ff..98457c2 100644 --- a/crc-builder/tkn/tpl/crc-builder-installer.tpl.yaml +++ b/crc-builder/tkn/tpl/crc-builder-installer.tpl.yaml @@ -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 @@ -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) " @@ -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) diff --git a/crc-builder/tkn/tpl/crc-builder.tpl.yaml b/crc-builder/tkn/tpl/crc-builder.tpl.yaml index 919afe6..ee3ac04 100644 --- a/crc-builder/tkn/tpl/crc-builder.tpl.yaml +++ b/crc-builder/tkn/tpl/crc-builder.tpl.yaml @@ -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 \ No newline at end of file + # 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 \ No newline at end of file