File tree Expand file tree Collapse file tree 2 files changed +18
-16
lines changed
providers/provider-btp/v1.0.3/setup Expand file tree Collapse file tree 2 files changed +18
-16
lines changed Original file line number Diff line number Diff line change @@ -34,15 +34,17 @@ process_file() {
3434 if [[ -n " $env_value " ]]; then
3535 # Special handling for CIS_CREDENTIAL or similar JSON structures
3636 if [[ " $var_name " == " CIS_CREDENTIAL" ]] || [[ " $var_name " == " CIS_CENTRAL_BINDING" ]]; then
37- # Validate and format CIS credential JSON
38- if ! echo " $env_value " | jq empty 2> /dev/null; then
37+ # First escape any literal newlines and other control characters for proper JSON parsing
38+ escaped_json=$( printf ' %s' " $env_value " | sed ' :a;N;$!ba;s/\n/\\n/g' | sed ' s/\r/\\r/g' | sed ' s/\t/\\t/g' )
39+
40+ # Validate the escaped JSON
41+ if ! echo " $escaped_json " | jq empty 2> /dev/null; then
3942 echo " Error: $var_name contains invalid JSON"
40- exit 1
43+ exit 1‚
4144 fi
4245
43- # Clean JSON and properly escape for parsing
44- # NOTE: Because the certificate contains \n characters, which are escaped by jq, we need to remove \\n manually from the string
45- clean_value=$( echo " $env_value " | jq . | sed ' s/\\\\n//g' )
46+ # Process with jq and then clean up the escaped newlines
47+ clean_value=$( echo " $escaped_json " | jq -c . | sed ' s/\\n//g' )
4648 line=" ${line// INJECT_ENV.${var_name} / ${clean_value} } "
4749 else
4850 # For non-JSON variables, use direct substitution
Original file line number Diff line number Diff line change @@ -12,16 +12,6 @@ stringData:
1212 "password": "INJECT_ENV.TECHNICAL_USER_PASSWORD"
1313 }
1414 ---
15- apiVersion : v1
16- kind : Secret
17- metadata :
18- namespace : default
19- name : cis-provider-secret
20- type : Opaque
21- stringData :
22- data : |
23- INJECT_ENV.CIS_CENTRAL_BINDING
24- ---
2515apiVersion : btp.sap.crossplane.io/v1alpha1
2616kind : ProviderConfig
2717metadata :
4131 name : sa-provider-secret
4232 namespace : default
4333 source : Secret
34+ ---
35+ apiVersion : v1
36+ kind : Secret
37+ metadata :
38+ namespace : default
39+ name : cis-provider-secret
40+ type : Opaque
41+ stringData :
42+ data : |
43+ INJECT_ENV.CIS_CENTRAL_BINDING
You can’t perform that action at this time.
0 commit comments