diff --git a/environment-provisioner/workflow-template.yaml b/environment-provisioner/workflow-template.yaml index cfac1fc..5df7ac4 100644 --- a/environment-provisioner/workflow-template.yaml +++ b/environment-provisioner/workflow-template.yaml @@ -438,25 +438,47 @@ spec: # Insert inline values block after valueFiles if user provided edited content if [ "$INCLUDE_INLINE_VALUES" = "yes" ]; then echo " Inserting edited values into Application manifest..." - # Write the values block to a temp file (preserves newlines properly) - VALUES_TMP="/tmp/values_block_$$.txt" - { - echo " values: |" - echo "$EDITED_CONTENT" | sed 's/^/ /' - } > "$VALUES_TMP" - # Use awk with getline to read from temp file (preserves multi-line content) - awk ' - /valueFiles:/ { - print - getline - print - while ((getline line < "'"$VALUES_TMP"'") > 0) print line - next - } - { print } - ' "manifests/$APP_NAME-application.yaml" > "manifests/$APP_NAME-application.yaml.tmp" - mv "manifests/$APP_NAME-application.yaml.tmp" "manifests/$APP_NAME-application.yaml" - rm -f "$VALUES_TMP" + + # Debug: show what we're inserting + echo " DEBUG: EDITED_CONTENT length: ${#EDITED_CONTENT}" + echo " DEBUG: EDITED_CONTENT first 200 chars:" + echo "$EDITED_CONTENT" | head -c 200 + echo "" + + # Only insert if we have actual content + if [ -n "$EDITED_CONTENT" ]; then + # Write the values block to a temp file (preserves newlines properly) + VALUES_TMP="/tmp/values_block_$$.txt" + { + echo " values: |" + echo "$EDITED_CONTENT" | sed 's/^/ /' + } > "$VALUES_TMP" + + # Debug: show temp file content + echo " DEBUG: Temp file content:" + cat "$VALUES_TMP" + echo " DEBUG: End of temp file" + + # Use awk with getline to read from temp file (preserves multi-line content) + awk ' + /valueFiles:/ { + print + getline + print + while ((getline line < "'"$VALUES_TMP"'") > 0) print line + next + } + { print } + ' "manifests/$APP_NAME-application.yaml" > "manifests/$APP_NAME-application.yaml.tmp" + mv "manifests/$APP_NAME-application.yaml.tmp" "manifests/$APP_NAME-application.yaml" + rm -f "$VALUES_TMP" + + # Debug: show generated manifest + echo " DEBUG: Generated manifest helm section:" + grep -A 30 "helm:" "manifests/$APP_NAME-application.yaml" || true + else + echo " WARNING: EDITED_CONTENT is empty, skipping inline values insertion" + fi fi echo " HTTPRoute URL: https://$HTTPROUTE_HOST"