Skip to content

Commit

Permalink
fix(RELEASE-1093): linting issues in update-infra-deployments task (#582
Browse files Browse the repository at this point in the history
)

Signed-off-by: Johnny Bieren <[email protected]>
  • Loading branch information
johnbieren authored Oct 1, 2024
1 parent ef8a91d commit 262f3ee
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 41 deletions.
3 changes: 3 additions & 0 deletions tasks/update-infra-deployments/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
| defaultGithubAppID | ID of Github app used for updating PR | true | 305606 |
| defaultGithubAppInstallationID | Installation ID of Github app in the organization | true | 35269675 |

## Changes in 1.2.1
* Fix shellcheck/checkton linting issues in the task

## Changes in 1.2.0
* Updated the base image used in this task

Expand Down
32 changes: 0 additions & 32 deletions tasks/update-infra-deployments/tests/run.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
name: test-update-infra-deployments-fail-no-data-file
annotations:
test/assert-task-failure: "run-task"
spec:
description: |
Run the update-infra-deployments task with the no data file present. The task should fail.
workspaces:
- name: tests-workspace
tasks:
- name: setup
workspaces:
- name: data
workspace: tests-workspace
taskSpec:
workspaces:
- name: data
steps:
- name: setup-values
image: quay.io/konflux-ci/release-service-utils:e633d51cd41d73e4b3310face21bb980af7a662f
script: |
#!/usr/bin/env sh
set -eux
cat > "$(workspaces.data.path)"/snapshot.json << EOF
{
"application": "myapp",
"components": [
{
"name": "comp",
"containerImage": "registry.io/image:tag",
"repository": "prod-registry.io/prod-location",
"tags": [
"tag"
]
}
]
}
EOF
- name: run-task
taskRef:
name: update-infra-deployments
params:
- name: snapshotPath
value: snapshot.json
- name: dataJsonPath
value: data.json
- name: originRepo
value: repo
- name: revision
value: production
workspaces:
- name: data
workspace: tests-workspace
runAfter:
- setup
19 changes: 10 additions & 9 deletions tasks/update-infra-deployments/update-infra-deployments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: tekton.dev/v1
kind: Task
metadata:
labels:
app.kubernetes.io/version: "1.2.0"
app.kubernetes.io/version: "1.2.1"
annotations:
tekton.dev/pipelines.minVersion: "0.12.1"
tekton.dev/tags: "release"
Expand Down Expand Up @@ -55,7 +55,7 @@ spec:
mountPath: /shared
workingDir: /shared
script: |
TARGET_GH_REPO=$(cat "$(params.dataJsonPath)" | jq -r '.targetGHRepo // "$(params.defaultTargetGHRepo)"')
TARGET_GH_REPO="$(jq -r '.targetGHRepo // "$(params.defaultTargetGHRepo)"' "$(params.dataJsonPath)")"
echo "Cloning $TARGET_GH_REPO"
git clone "https://github.com/${TARGET_GH_REPO}.git" cloned
- name: run-update-script
Expand All @@ -65,25 +65,26 @@ spec:
mountPath: /shared
workingDir: /shared
script: |
set -x
#!/usr/bin/env bash
set -ex
cd cloned
echo "snapshot:"
cat "$(params.snapshotPath)"
echo ""
# We assume we only have one component in the service.
revision=$(cat "$(params.snapshotPath)" | jq -r .components[0].source.git.revision)
revision="$(jq -r .components[0].source.git.revision "$(params.snapshotPath)")"
echo "revision: $revision"
echo $revision > ../revision.txt
echo "$revision" > ../revision.txt
originRepo=$(cat "$(params.snapshotPath)" | jq -r .components[0].source.git.url)
originRepo="$(jq -r .components[0].source.git.url "$(params.snapshotPath)")"
echo "origin repo: $originRepo"
echo $originRepo > ../originRepo.txt
echo "$originRepo" > ../originRepo.txt
# Get SCRIPT from Data
echo "data: $(params.dataJsonPath)"
SCRIPT=$(cat "$(params.dataJsonPath)" | jq -r '."infra-deployment-update-script" // empty')
SCRIPT="$(jq -r '."infra-deployment-update-script" // empty' "$(params.dataJsonPath)")"
if [ "${SCRIPT}" == "" ] ; then
echo "No script provided via 'infra-deployment-update-script' key in data"
Expand All @@ -92,7 +93,7 @@ spec:
echo "original script:"
echo "$SCRIPT"
PATCHED_SCRIPT=$(echo "$SCRIPT" | sed "s/{{ revision }}/$revision/g")
PATCHED_SCRIPT="${SCRIPT//\{\{ revision \}\}/$revision}"
echo "patched script:"
echo "$PATCHED_SCRIPT"
echo "$PATCHED_SCRIPT" | sh
Expand Down

0 comments on commit 262f3ee

Please sign in to comment.