Skip to content

Commit 094516a

Browse files
committed
fix: write only tag when field path ends in .tag
When callers use the staffbase-application Helm chart, the image field is split into image.repository and image.tag. Writing the full URI (registry/image:tag) as a scalar to spec.values.workload.container.image replaces the mapping and causes the chart to render 'image: :'. If the field path ends in .tag, write only INPUT_TAG (e.g. dev-abc123) instead of the full IMAGE URI. The repository stays in the base HelmRelease untouched. Backwards compatible: no existing Apperator-style caller uses a field path ending in .tag. All existing callers receive the full URI as before. Callers migrating to staffbase-application chart use: spec.values.workload.container.image.tag instead of: spec.values.workload.container.image Assisted-by: pi:claude-sonnet-4-5
1 parent da1135d commit 094516a

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

scripts/lib/gitops-functions.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ update_file() {
3636
echo "Check if path ${file} ${field} exists and get old current version"
3737
yq -e ."${field}" "${file}"
3838
echo "Run update ${file} ${field} ${image}"
39-
yq -i ."${field}"=\""${image}"\" "${file}"
39+
if [[ "${field}" == *.tag ]]; then
40+
yq -i ."${field}"=\"${INPUT_TAG}\" "${file}"
41+
else
42+
yq -i ."${field}"=\""${image}"\" "${file}"
43+
fi
4044

4145
echo "Writing deployment annotations to ${file}"
4246
yq -i '.metadata.annotations["deploy.staffbase.com/repositoryFullName"] = "'"${GITHUB_REPOSITORY}"'"' "${file}"

tests/lib-gitops-functions.bats

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,22 @@ teardown() {
5151

5252
# --- update_file ---
5353

54+
@test "update_file writes full image URI for non-.tag field paths" {
55+
update_file "deployment.yaml" "spec.template.spec.containers.app.image" "$IMAGE"
56+
grep -q "${IMAGE}" "${TEST_TEMP_DIR}/yq_calls.log"
57+
}
58+
59+
@test "update_file writes only tag portion for field paths ending in .tag" {
60+
update_file "helmrelease.yaml" "spec.values.workload.container.image.tag" "$IMAGE"
61+
grep -q ".spec.values.workload.container.image.tag=\"${INPUT_TAG}\"" "${TEST_TEMP_DIR}/yq_calls.log"
62+
! grep -q "registry.staffbase.com" "${TEST_TEMP_DIR}/yq_calls.log"
63+
}
64+
65+
@test "update_file does not write full URI to .tag field" {
66+
update_file "helmrelease.yaml" "spec.values.workload.container.image.tag" "$IMAGE"
67+
! grep -q "${IMAGE}" "${TEST_TEMP_DIR}/yq_calls.log"
68+
}
69+
5470
@test "update_file calls yq to check and update field" {
5571
update_file "deployment.yaml" "spec.image" "$IMAGE"
5672
assert [ -f "${TEST_TEMP_DIR}/yq_calls.log" ]

0 commit comments

Comments
 (0)