From: mesaj Date: Tue, 24 Jun 2025 11:24:56 +0000 (+0200) Subject: Fix render of PATCH_CONTENT in full_json_patch krm function X-Git-Tag: v18.0.0~40 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F52%2F15252%2F2;p=osm%2Fdevops.git Fix render of PATCH_CONTENT in full_json_patch krm function This will fix Helm inline values patch rendering When using inline values such as: ``` inline_values: service: ports: http: "8080" https: "8443" ``` The current `full_json_patch()` function was failing with error: `Error: bad expression, please check expression syntax`. This is because yq seems like doesn't properly handle literal new-lines inside a double-quoted string. This change replace current implementation to a safer approach using HEREDOCS template to render the patch. Change-Id: If7e78a6509ca0e6731f3125eeb535cedf394b06b Signed-off-by: mesaj Signed-off-by: garciadeblas --- diff --git a/docker/osm-krm-functions/scripts/library/helper-functions.rc b/docker/osm-krm-functions/scripts/library/helper-functions.rc index be3601a2..d012b804 100644 --- a/docker/osm-krm-functions/scripts/library/helper-functions.rc +++ b/docker/osm-krm-functions/scripts/library/helper-functions.rc @@ -423,9 +423,10 @@ function full_json_patch() { done # Wrap a full patch around, adding target specification + export PATCH_CONTENT local PATCH_FULL=$( yq --null-input ".target.kind = \"${TARGET_KIND}\", .target.name = \"${TARGET_NAME}\"" | \ - yq ".patch = \"${PATCH_CONTENT}\"" | \ + yq ".patch = env(PATCH_CONTENT)" | \ yq "[ . ]" )