diff --git a/tekton/README.md b/tekton/README.md index 9a8ddd6..b3867af 100644 --- a/tekton/README.md +++ b/tekton/README.md @@ -76,5 +76,11 @@ oc create secret generic flightctl-config --from-file=client.yaml=$HOME/.config/ ## Build the base image ```sh -oc create -f pipelinerun-base.yaml +oc create -f pipelinerun1.yaml +``` + +## Build the other images + +```sh +oc create -f pipelinerun2.yaml ``` diff --git a/tekton/common/task-flightctl-update-digest.yaml b/tekton/common/task-flightctl-update-digest.yaml index b17dbeb..ed339c2 100644 --- a/tekton/common/task-flightctl-update-digest.yaml +++ b/tekton/common/task-flightctl-update-digest.yaml @@ -4,6 +4,8 @@ metadata: name: flightctl-update-digest spec: params: + - name: image-name + type: string - name: new-image-digest type: string - description: The label selector to identify the fleet(s) to update. @@ -22,6 +24,10 @@ spec: value: "false" - name: FLEET_LABEL_SELECTOR value: "$(params.fleet-label-selector)" + - name: IMAGE_NAME + value: "$(params.image-name)" + - name: NEW_IMAGE_DIGEST + value: "$(params.new-image-digest)" script: | #!/bin/bash set -Eeuo pipefail @@ -39,9 +45,6 @@ spec: # Print versions of the program we use echo "=== Environment ===" - echo "---> flightctl" - flightctl version - echo echo "---> bash" bash --version echo @@ -55,28 +58,21 @@ spec: id echo echo "---> flightctl" - flightctl version + flightctl --config-dir $(workspaces.flightctl-config.path) version + echo + echo "---> config file" + ls -lZ $(workspaces.flightctl-config.path) echo # List fleets matching the label selector and update their image to the new digest flightctl --config-dir $(workspaces.flightctl-config.path) get fleets --limit 0 -l "${FLEET_LABEL_SELECTOR}" -o name | while read -r fleet; do - echo "Updating fleet $fleet to image digest $(params.new-image-digest)" + echo "Updating fleet $fleet to image ${IMAGE_NAME}@${NEW_IMAGE_DIGEST}" # Get the current fleet definition flightctl --config-dir $(workspaces.flightctl-config.path) get fleet/$fleet -o yaml > /tmp/fleet.yaml - # Extract the current image from the fleet definition - CURRENT_IMAGE="$(yq eval '.spec.template.spec.os.image' /tmp/fleet.yaml)" - - # Splits the CURRENT_IMAGE on the "@" or ":" character and takes the first part (the image name without tag or digest) - # Using only bash built-in features to avoid dependencies on other tools - IMAGE_NAME="${CURRENT_IMAGE%%[@:]*}" - - # Construct the new image with the new digest - NEW_IMAGE="${IMAGE_NAME}@$(params.new-image-digest)" - # Update the fleet definition with the new image - yq eval -i ".spec.template.spec.os.image = \"$NEW_IMAGE\"" /tmp/fleet.yaml + yq eval -i ".spec.template.spec.os.image = \"${IMAGE_NAME}@${NEW_IMAGE_DIGEST}\"" /tmp/fleet.yaml # Apply the updated fleet definition flightctl --config-dir $(workspaces.flightctl-config.path) apply -f /tmp/fleet.yaml diff --git a/tekton/pipeline.yaml b/tekton/pipeline.yaml index 55b7811..346ac9f 100644 --- a/tekton/pipeline.yaml +++ b/tekton/pipeline.yaml @@ -129,6 +129,8 @@ spec: taskRef: name: flightctl-update-digest params: + - name: image-name + value: $(params.image-name) - name: new-image-digest value: $(tasks.push-image.results.image-digest) - name: fleet-label-selector